createAccessPolicy method

Future<CreateAccessPolicyResponse> createAccessPolicy({
  1. required Identity accessPolicyIdentity,
  2. required Permission accessPolicyPermission,
  3. required Resource accessPolicyResource,
  4. String? clientToken,
  5. Map<String, String>? tags,
})
Creates an access policy that grants the specified identity (IAM Identity Center user, IAM Identity Center group, or IAM user) access to the specified IoT SiteWise Monitor portal or project resource.

May throw InternalFailureException. May throw InvalidRequestException. May throw LimitExceededException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter accessPolicyIdentity : The identity for this access policy. Choose an IAM Identity Center user, an IAM Identity Center group, or an IAM user.

Parameter accessPolicyPermission : The permission level for this access policy. Note that a project ADMINISTRATOR is also known as a project owner.

Parameter accessPolicyResource : The IoT SiteWise Monitor resource for this access policy. Choose either a portal or a project.

Parameter clientToken : A unique case-sensitive identifier that you can provide to ensure the idempotency of the request. Don't reuse this client token if a new idempotent request is required.

Parameter tags : A list of key-value pairs that contain metadata for the access policy. For more information, see Tagging your IoT SiteWise resources in the IoT SiteWise User Guide.

Implementation

Future<CreateAccessPolicyResponse> createAccessPolicy({
  required Identity accessPolicyIdentity,
  required Permission accessPolicyPermission,
  required Resource accessPolicyResource,
  String? clientToken,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'accessPolicyIdentity': accessPolicyIdentity,
    'accessPolicyPermission': accessPolicyPermission.value,
    'accessPolicyResource': accessPolicyResource,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/access-policies',
    hostPrefix: 'monitor.',
    exceptionFnMap: _exceptionFns,
  );
  return CreateAccessPolicyResponse.fromJson(response);
}