deleteOrganization method

Future<DeleteOrganizationResponse> deleteOrganization({
  1. required bool deleteDirectory,
  2. required String organizationId,
  3. String? clientToken,
})

Deletes an Amazon WorkMail organization and all underlying AWS resources managed by Amazon WorkMail as part of the organization. You can choose whether to delete the associated directory. For more information, see Removing an organization in the Amazon WorkMail Administrator Guide.

May throw InvalidParameterException. May throw OrganizationNotFoundException. May throw OrganizationStateException.

Parameter deleteDirectory : If true, deletes the AWS Directory Service directory associated with the organization.

Parameter organizationId : The organization ID.

Parameter clientToken : The idempotency token associated with the request.

Implementation

Future<DeleteOrganizationResponse> deleteOrganization({
  required bool deleteDirectory,
  required String organizationId,
  String? clientToken,
}) async {
  ArgumentError.checkNotNull(deleteDirectory, 'deleteDirectory');
  ArgumentError.checkNotNull(organizationId, 'organizationId');
  _s.validateStringLength(
    'organizationId',
    organizationId,
    34,
    34,
    isRequired: true,
  );
  _s.validateStringLength(
    'clientToken',
    clientToken,
    1,
    128,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'WorkMailService.DeleteOrganization'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DeleteDirectory': deleteDirectory,
      'OrganizationId': organizationId,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    },
  );

  return DeleteOrganizationResponse.fromJson(jsonResponse.body);
}