deleteOrganization method

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

Deletes an WorkMail organization and all underlying AWS resources managed by WorkMail as part of the organization. You can choose whether to delete the associated directory. For more information, see Removing an organization in the 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.

Parameter deleteIdentityCenterApplication : Deletes IAM Identity Center application for WorkMail. This action does not affect authentication settings for any organization.

Parameter forceDelete : Deletes a WorkMail organization even if the organization has enabled users.

Implementation

Future<DeleteOrganizationResponse> deleteOrganization({
  required bool deleteDirectory,
  required String organizationId,
  String? clientToken,
  bool? deleteIdentityCenterApplication,
  bool? forceDelete,
}) async {
  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(),
      if (deleteIdentityCenterApplication != null)
        'DeleteIdentityCenterApplication': deleteIdentityCenterApplication,
      if (forceDelete != null) 'ForceDelete': forceDelete,
    },
  );

  return DeleteOrganizationResponse.fromJson(jsonResponse.body);
}