patch method
Updates or inserts a document.
request
- The metadata request object.
Request parameters:
name
- The resource name of the document, for example
projects/{project_id}/databases/{database_id}/documents/{document_path}
.
Value must have pattern
^projects/\[^/\]+/databases/\[^/\]+/documents/\[^/\]+/.*$
.
currentDocument_exists
- When set to true
, the target document must
exist. When set to false
, the target document must not exist.
currentDocument_updateTime
- When set, the target document must exist
and have been last updated at that time. Timestamp must be microsecond
aligned.
mask_fieldPaths
- The list of field paths in the mask. See
Document.fields for a field path syntax reference.
updateMask_fieldPaths
- The list of field paths in the mask. See
Document.fields for a field path syntax reference.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Document.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client
completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<Document> patch(
Document request,
core.String name, {
core.bool? currentDocument_exists,
core.String? currentDocument_updateTime,
core.List<core.String>? mask_fieldPaths,
core.List<core.String>? updateMask_fieldPaths,
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if (currentDocument_exists != null)
'currentDocument.exists': ['${currentDocument_exists}'],
if (currentDocument_updateTime != null)
'currentDocument.updateTime': [currentDocument_updateTime],
if (mask_fieldPaths != null) 'mask.fieldPaths': mask_fieldPaths,
if (updateMask_fieldPaths != null)
'updateMask.fieldPaths': updateMask_fieldPaths,
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name');
final _response = await _requester.request(
_url,
'PATCH',
body: _body,
queryParams: _queryParams,
);
return Document.fromJson(_response as core.Map<core.String, core.dynamic>);
}