patch method

Future<AddOnAttachment> patch(
  1. AddOnAttachment request,
  2. String courseId,
  3. String postId,
  4. String attachmentId, {
  5. String? itemId,
  6. String? updateMask,
  7. String? $fields,
})

Updates an add-on attachment.

Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * PERMISSION_DENIED for access errors. * INVALID_ARGUMENT if the request is malformed. * NOT_FOUND if one of the identified resources does not exist.

request - The metadata request object.

Request parameters:

courseId - Required. Identifier of the course.

postId - Required. Identifier of the post under which the attachment is attached.

attachmentId - Required. Identifier of the attachment.

itemId - Identifier of the post under which the attachment is attached.

updateMask - Required. Mask that identifies which fields on the attachment to update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the AddOnAttachment object. If a field that does not support empty values is included in the update mask and not set in the AddOnAttachment object, an INVALID_ARGUMENT error is returned. The following fields may be specified by teachers: * title * teacher_view_uri * student_view_uri * student_work_review_uri * due_date * due_time * max_points

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

Completes with a AddOnAttachment.

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<AddOnAttachment> patch(
  AddOnAttachment request,
  core.String courseId,
  core.String postId,
  core.String attachmentId, {
  core.String? itemId,
  core.String? updateMask,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (itemId != null) 'itemId': [itemId],
    if (updateMask != null) 'updateMask': [updateMask],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/courses/' +
      commons.escapeVariable('$courseId') +
      '/posts/' +
      commons.escapeVariable('$postId') +
      '/addOnAttachments/' +
      commons.escapeVariable('$attachmentId');

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