setPermission method

Future<void> setPermission({
  1. required String iamUserArn,
  2. required String stackId,
  3. bool? allowSsh,
  4. bool? allowSudo,
  5. String? level,
})

Specifies a user's permissions. For more information, see Security and Permissions.

Required Permissions: To use this action, an IAM user must have a Manage permissions level for the stack, or an attached policy that explicitly grants permissions. For more information on user permissions, see Managing User Permissions.

May throw ValidationException. May throw ResourceNotFoundException.

Parameter iamUserArn : The user's IAM ARN. This can also be a federated user's ARN.

Parameter stackId : The stack ID.

Parameter allowSsh : The user is allowed to use SSH to communicate with the instance.

Parameter allowSudo : The user is allowed to use sudo to elevate privileges.

Parameter level : The user's permission level, which must be set to one of the following strings. You cannot set your own permissions level.

  • deny
  • show
  • deploy
  • manage
  • iam_only
For more information about the permissions associated with these levels, see Managing User Permissions.

Implementation

Future<void> setPermission({
  required String iamUserArn,
  required String stackId,
  bool? allowSsh,
  bool? allowSudo,
  String? level,
}) async {
  ArgumentError.checkNotNull(iamUserArn, 'iamUserArn');
  ArgumentError.checkNotNull(stackId, 'stackId');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'OpsWorks_20130218.SetPermission'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'IamUserArn': iamUserArn,
      'StackId': stackId,
      if (allowSsh != null) 'AllowSsh': allowSsh,
      if (allowSudo != null) 'AllowSudo': allowSudo,
      if (level != null) 'Level': level,
    },
  );
}