patch method

Future<Document> patch (
  1. Document request,
  2. String name,
  3. {bool currentDocument_exists,
  4. List<String> updateMask_fieldPaths,
  5. List<String> mask_fieldPaths,
  6. String currentDocument_updateTime,
  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.

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.

$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.


async.Future<Document> patch(Document request, core.String name,
    {core.bool currentDocument_exists,
    core.List<core.String> updateMask_fieldPaths,
    core.List<core.String> mask_fieldPaths,
    core.String currentDocument_updateTime,
    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 (currentDocument_exists != null) {
    _queryParams["currentDocument.exists"] = ["${currentDocument_exists}"];
  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 ($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));