insert method

Future<ParentReference> insert (
  1. ParentReference request,
  2. String fileId,
  3. {bool enforceSingleParent,
  4. bool supportsAllDrives,
  5. bool supportsTeamDrives,
  6. String $fields}
)

Adds a parent folder for a file.

request - The metadata request object.

Request parameters:

fileId - The ID of the file.

enforceSingleParent - Set to true to opt in to API behavior that aims for all items to have exactly one parent. This parameter only takes effect if the item is not in a shared drive. If the child's owner makes the request, the child is removed from all current folders and placed in the requested folder. Any other requests that increase the number of the child's parents fail, except when the canAddMyDriveParent file capability is true and a single parent is being added.

supportsAllDrives - Whether the requesting application supports both My Drives and shared drives.

supportsTeamDrives - Deprecated use supportsAllDrives instead.

$fields - Selector specifying which fields to include in a partial response.

Completes with a ParentReference.

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<ParentReference> insert(
    ParentReference request, core.String fileId,
    {core.bool enforceSingleParent,
    core.bool supportsAllDrives,
    core.bool supportsTeamDrives,
    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_1.json.encode((request).toJson());
  }
  if (fileId == null) {
    throw new core.ArgumentError("Parameter fileId is required.");
  }
  if (enforceSingleParent != null) {
    _queryParams["enforceSingleParent"] = ["${enforceSingleParent}"];
  }
  if (supportsAllDrives != null) {
    _queryParams["supportsAllDrives"] = ["${supportsAllDrives}"];
  }
  if (supportsTeamDrives != null) {
    _queryParams["supportsTeamDrives"] = ["${supportsTeamDrives}"];
  }
  if ($fields != null) {
    _queryParams["fields"] = [$fields];
  }

  _url = 'files/' + commons.Escaper.ecapeVariable('$fileId') + '/parents';

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