updateDocument method

Future<UpdateDocumentResult> updateDocument({
  1. required String content,
  2. required String name,
  3. List<AttachmentsSource>? attachments,
  4. DocumentFormat? documentFormat,
  5. String? documentVersion,
  6. String? targetType,
  7. String? versionName,
})

Updates one or more values for an SSM document.

May throw MaxDocumentSizeExceeded. May throw DocumentVersionLimitExceeded. May throw InternalServerError. May throw DuplicateDocumentContent. May throw DuplicateDocumentVersionName. May throw InvalidDocumentContent. May throw InvalidDocumentVersion. May throw InvalidDocumentSchemaVersion. May throw InvalidDocument. May throw InvalidDocumentOperation.

Parameter content : A valid JSON or YAML string.

Parameter name : The name of the document that you want to update.

Parameter attachments : A list of key and value pairs that describe attachments to a version of a document.

Parameter documentFormat : Specify the document format for the new document version. Systems Manager supports JSON and YAML documents. JSON is the default format.

Parameter documentVersion : (Required) The latest version of the document that you want to update. The latest document version can be specified using the $LATEST variable or by the version number. Updating a previous version of a document is not supported.

Parameter targetType : Specify a new target type for the document.

Parameter versionName : An optional field specifying the version of the artifact you are updating with the document. For example, "Release 12, Update 6". This value is unique across all versions of a document, and cannot be changed.

Implementation

Future<UpdateDocumentResult> updateDocument({
  required String content,
  required String name,
  List<AttachmentsSource>? attachments,
  DocumentFormat? documentFormat,
  String? documentVersion,
  String? targetType,
  String? versionName,
}) async {
  ArgumentError.checkNotNull(content, 'content');
  _s.validateStringLength(
    'content',
    content,
    1,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'targetType',
    targetType,
    0,
    200,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.UpdateDocument'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Content': content,
      'Name': name,
      if (attachments != null) 'Attachments': attachments,
      if (documentFormat != null) 'DocumentFormat': documentFormat.toValue(),
      if (documentVersion != null) 'DocumentVersion': documentVersion,
      if (targetType != null) 'TargetType': targetType,
      if (versionName != null) 'VersionName': versionName,
    },
  );

  return UpdateDocumentResult.fromJson(jsonResponse.body);
}