createWorkloadShare method

Future<CreateWorkloadShareOutput> createWorkloadShare({
  1. required PermissionType permissionType,
  2. required String sharedWith,
  3. required String workloadId,
  4. String? clientRequestToken,
})

Create a workload share.

The owner of a workload can share it with other Amazon Web Services accounts and users in the same Amazon Web Services Region. Shared access to a workload is not removed until the workload invitation is deleted.

If you share a workload with an organization or OU, all accounts in the organization or OU are granted access to the workload.

For more information, see Sharing a workload in the Well-Architected Tool User Guide.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Implementation

Future<CreateWorkloadShareOutput> createWorkloadShare({
  required PermissionType permissionType,
  required String sharedWith,
  required String workloadId,
  String? clientRequestToken,
}) async {
  final $payload = <String, dynamic>{
    'PermissionType': permissionType.value,
    'SharedWith': sharedWith,
    'ClientRequestToken': clientRequestToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/workloads/${Uri.encodeComponent(workloadId)}/shares',
    exceptionFnMap: _exceptionFns,
  );
  return CreateWorkloadShareOutput.fromJson(response);
}