patch method

Future<Document> patch (Document request, String name, { List<String> updateMask_fieldPaths, List<String> mask_fieldPaths, String currentDocument_updateTime bool currentDocument_exists, 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/^/+/.+$".

updateMask_fieldPaths - The list of field paths in the mask. See Document.fields for a field path syntax reference.

mask_fieldPaths - The list of field paths in the mask. See Document.fields for a field path syntax reference.

currentDocument_updateTime - When set, the target document must exist and have been last updated at that time.

currentDocument_exists - When set to true, the target document must exist. When set to false, the target document must not exist.

$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.List<core.String> updateMask_fieldPaths,
    core.List<core.String> mask_fieldPaths,
    core.String currentDocument_updateTime,
    core.bool currentDocument_exists,
    core.String $fields}) {
  var _url;
  var _queryParams = new core.Map<core.String, core.List<core.String>>();
  var _uploadMedia;
  var _uploadOptions;
  var _downloadOptions = commons.DownloadOptions.Metadata;
  var _body;

  if (request != null) {
    _body = convert.json.encode((request).toJson());
  }
  if (name == null) {
    throw new core.ArgumentError("Parameter name is required.");
  }
  if (updateMask_fieldPaths != null) {
    _queryParams["updateMask.fieldPaths"] = updateMask_fieldPaths;
  }
  if (mask_fieldPaths != null) {
    _queryParams["mask.fieldPaths"] = mask_fieldPaths;
  }
  if (currentDocument_updateTime != null) {
    _queryParams["currentDocument.updateTime"] = [currentDocument_updateTime];
  }
  if (currentDocument_exists != null) {
    _queryParams["currentDocument.exists"] = ["${currentDocument_exists}"];
  }
  if ($fields != null) {
    _queryParams["fields"] = [$fields];
  }

  _url = 'v1/' + commons.Escaper.ecapeVariableReserved('$name');

  var _response = _requester.request(_url, "PATCH",
      body: _body,
      queryParams: _queryParams,
      uploadOptions: _uploadOptions,
      uploadMedia: _uploadMedia,
      downloadOptions: _downloadOptions);
  return _response.then((data) => new Document.fromJson(data));
}