addResourcePermissions method

Future<AddResourcePermissionsResponse> addResourcePermissions({
  1. required List<SharePrincipal> principals,
  2. required String resourceId,
  3. String? authenticationToken,
  4. NotificationOptions? notificationOptions,
})

Creates a set of permissions for the specified folder or document. The resource permissions are overwritten if the principals already have different permissions.

May throw UnauthorizedOperationException. May throw UnauthorizedResourceAccessException. May throw FailedDependencyException. May throw ServiceUnavailableException.

Parameter principals : The users, groups, or organization being granted permission.

Parameter resourceId : The ID of the resource.

Parameter authenticationToken : Amazon WorkDocs authentication token. Not required when using AWS administrator credentials to access the API.

Parameter notificationOptions : The notification options.

Implementation

Future<AddResourcePermissionsResponse> addResourcePermissions({
  required List<SharePrincipal> principals,
  required String resourceId,
  String? authenticationToken,
  NotificationOptions? notificationOptions,
}) async {
  ArgumentError.checkNotNull(principals, 'principals');
  ArgumentError.checkNotNull(resourceId, 'resourceId');
  _s.validateStringLength(
    'resourceId',
    resourceId,
    1,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'authenticationToken',
    authenticationToken,
    1,
    8199,
  );
  final headers = <String, String>{
    if (authenticationToken != null)
      'Authentication': authenticationToken.toString(),
  };
  final $payload = <String, dynamic>{
    'Principals': principals,
    if (notificationOptions != null)
      'NotificationOptions': notificationOptions,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/api/v1/resources/${Uri.encodeComponent(resourceId)}/permissions',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return AddResourcePermissionsResponse.fromJson(response);
}