patch method

Future<Document> patch(
  1. Document request,
  2. String name, {
  3. bool? currentDocument_exists,
  4. String? currentDocument_updateTime,
  5. List<String>? mask_fieldPaths,
  6. List<String>? updateMask_fieldPaths,
  7. String? $fields,
})

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>);
}