getDocument method

Future<GetDocumentResult> getDocument({
  1. required String name,
  2. DocumentFormat? documentFormat,
  3. String? documentVersion,
  4. String? versionName,
})

Gets the contents of the specified Systems Manager document.

May throw InternalServerError. May throw InvalidDocument. May throw InvalidDocumentVersion.

Parameter name : The name of the Systems Manager document.

Parameter documentFormat : Returns the document in the specified format. The document format can be either JSON or YAML. JSON is the default format.

Parameter documentVersion : The document version for which you want information.

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

Implementation

Future<GetDocumentResult> getDocument({
  required String name,
  DocumentFormat? documentFormat,
  String? documentVersion,
  String? versionName,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.GetDocument'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      if (documentFormat != null) 'DocumentFormat': documentFormat.toValue(),
      if (documentVersion != null) 'DocumentVersion': documentVersion,
      if (versionName != null) 'VersionName': versionName,
    },
  );

  return GetDocumentResult.fromJson(jsonResponse.body);
}