create method

Updates a label's permissions.

If a permission for the indicated principal doesn't exist, a label permission is created, otherwise the existing permission is updated. Permissions affect the label resource as a whole, aren't revisioned, and don't require publishing.

request - The metadata request object.

Request parameters:

parent - Required. The parent label resource name on the label permission is created. Format: labels/{label}. Value must have pattern ^labels/\[^/\]+$.

useAdminAccess - Set to true in order to use the user's admin credentials. The server will verify the user is an admin for the label before allowing access.

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

Completes with a GoogleAppsDriveLabelsV2LabelPermission.

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<GoogleAppsDriveLabelsV2LabelPermission> create(
  GoogleAppsDriveLabelsV2LabelPermission request,
  core.String parent, {
  core.bool? useAdminAccess,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (useAdminAccess != null) 'useAdminAccess': ['${useAdminAccess}'],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v2/' + core.Uri.encodeFull('$parent') + '/permissions';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return GoogleAppsDriveLabelsV2LabelPermission.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}