modifyDocumentPermission method

Future<void> modifyDocumentPermission({
  1. required String name,
  2. required DocumentPermissionType permissionType,
  3. List<String>? accountIdsToAdd,
  4. List<String>? accountIdsToRemove,
  5. String? sharedDocumentVersion,
})

Shares a Systems Manager document publicly or privately. If you share a document privately, you must specify the AWS user account IDs for those people who can use the document. If you share a document publicly, you must specify All as the account ID.

May throw InternalServerError. May throw InvalidDocument. May throw InvalidPermissionType. May throw DocumentPermissionLimit. May throw DocumentLimitExceeded.

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

Parameter permissionType : The permission type for the document. The permission type can be Share.

Parameter accountIdsToAdd : The AWS user accounts that should have access to the document. The account IDs can either be a group of account IDs or All.

Parameter accountIdsToRemove : The AWS user accounts that should no longer have access to the document. The AWS user account can either be a group of account IDs or All. This action has a higher priority than AccountIdsToAdd. If you specify an account ID to add and the same ID to remove, the system removes access to the document.

Parameter sharedDocumentVersion : (Optional) The version of the document to share. If it's not specified, the system choose the Default version to share.

Implementation

Future<void> modifyDocumentPermission({
  required String name,
  required DocumentPermissionType permissionType,
  List<String>? accountIdsToAdd,
  List<String>? accountIdsToRemove,
  String? sharedDocumentVersion,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  ArgumentError.checkNotNull(permissionType, 'permissionType');
  _s.validateStringLength(
    'sharedDocumentVersion',
    sharedDocumentVersion,
    0,
    8,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.ModifyDocumentPermission'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'PermissionType': permissionType.toValue(),
      if (accountIdsToAdd != null) 'AccountIdsToAdd': accountIdsToAdd,
      if (accountIdsToRemove != null)
        'AccountIdsToRemove': accountIdsToRemove,
      if (sharedDocumentVersion != null)
        'SharedDocumentVersion': sharedDocumentVersion,
    },
  );
}