createWorkspace method

Future<CreateWorkspaceResponse> createWorkspace({
  1. required AccountAccessType accountAccessType,
  2. required List<AuthenticationProviderTypes> authenticationProviders,
  3. required PermissionType permissionType,
  4. String? clientToken,
  5. Object? configuration,
  6. String? grafanaVersion,
  7. IPAddressType? ipAddressType,
  8. String? kmsKeyId,
  9. NetworkAccessConfiguration? networkAccessControl,
  10. String? organizationRoleName,
  11. String? stackSetName,
  12. Map<String, String>? tags,
  13. VpcConfiguration? vpcConfiguration,
  14. List<DataSourceType>? workspaceDataSources,
  15. String? workspaceDescription,
  16. String? workspaceName,
  17. List<NotificationDestinationType>? workspaceNotificationDestinations,
  18. List<String>? workspaceOrganizationalUnits,
  19. String? workspaceRoleArn,
})

Creates a workspace. In a workspace, you can create Grafana dashboards and visualizations to analyze your metrics, logs, and traces. You don't have to build, package, or deploy any hardware to run the Grafana server.

Don't use CreateWorkspace to modify an existing workspace. Instead, use UpdateWorkspace.

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

Parameter accountAccessType : Specifies whether the workspace can access Amazon Web Services resources in this Amazon Web Services account only, or whether it can also access Amazon Web Services resources in other accounts in the same organization. If you specify ORGANIZATION, you must specify which organizational units the workspace can access in the workspaceOrganizationalUnits parameter.

Parameter authenticationProviders : Specifies whether this workspace uses SAML 2.0, IAM Identity Center, or both to authenticate users for using the Grafana console within a workspace. For more information, see User authentication in Amazon Managed Grafana.

Parameter permissionType : When creating a workspace through the Amazon Web Services API, CLI or Amazon Web Services CloudFormation, you must manage IAM roles and provision the permissions that the workspace needs to use Amazon Web Services data sources and notification channels.

You must also specify a workspaceRoleArn for a role that you will manage for the workspace to use when accessing those datasources and notification channels.

The ability for Amazon Managed Grafana to create and update IAM roles on behalf of the user is supported only in the Amazon Managed Grafana console, where this value may be set to SERVICE_MANAGED. For more information, see Amazon Managed Grafana permissions and policies for Amazon Web Services data sources and notification channels.

Parameter clientToken : A unique, case-sensitive, user-provided identifier to ensure the idempotency of the request.

Parameter configuration : The configuration string for the workspace that you create. For more information about the format and configuration options available, see Working in your Grafana workspace.

Parameter grafanaVersion : Specifies the version of Grafana to support in the new workspace. If not specified, defaults to the latest version (for example, 10.4).

To get a list of supported versions, use the ListVersions operation.

Parameter ipAddressType : Specifies whether the workspace supports IPv4 only, or IPv4 and IPv6. Valid values are IPv4 and DualStack. For more information about IP address types, see Network access control.

Parameter kmsKeyId : The ID or ARN of the Key Management Service key to use for encrypting workspace data.

Parameter networkAccessControl : Configuration for network access to your workspace.

When this is configured, only listed IP addresses and VPC endpoints will be able to access your workspace. Standard Grafana authentication and authorization will still be required.

If this is not configured, or is removed, then all IP addresses and VPC endpoints will be allowed. Standard Grafana authentication and authorization will still be required.

Parameter organizationRoleName : The name of an IAM role that already exists to use with Organizations to access Amazon Web Services data sources and notification channels in other accounts in an organization.

Parameter stackSetName : The name of the CloudFormation stack set to use to generate IAM roles to be used for this workspace.

Parameter tags : The list of tags associated with the workspace.

Parameter vpcConfiguration : The configuration settings for an Amazon VPC that contains data sources for your Grafana workspace to connect to.

Parameter workspaceDataSources : This parameter is for internal use only, and should not be used.

Parameter workspaceDescription : A description for the workspace. This is used only to help you identify this workspace.

Pattern: ^[\p{L}\p{Z}\p{N}\p{P}]{0,2048}$

Parameter workspaceName : The name for the workspace. It does not have to be unique.

Parameter workspaceNotificationDestinations : Specify the Amazon Web Services notification channels that you plan to use in this workspace. Specifying these data sources here enables Amazon Managed Grafana to create IAM roles and permissions that allow Amazon Managed Grafana to use these channels.

Parameter workspaceOrganizationalUnits : Specifies the organizational units that this workspace is allowed to use data sources from, if this workspace is in an account that is part of an organization.

Parameter workspaceRoleArn : Specified the IAM role that grants permissions to the Amazon Web Services resources that the workspace will view data from, including both data sources and notification channels. You are responsible for managing the permissions for this role as new data sources or notification channels are added.

Implementation

Future<CreateWorkspaceResponse> createWorkspace({
  required AccountAccessType accountAccessType,
  required List<AuthenticationProviderTypes> authenticationProviders,
  required PermissionType permissionType,
  String? clientToken,
  Object? configuration,
  String? grafanaVersion,
  IPAddressType? ipAddressType,
  String? kmsKeyId,
  NetworkAccessConfiguration? networkAccessControl,
  String? organizationRoleName,
  String? stackSetName,
  Map<String, String>? tags,
  VpcConfiguration? vpcConfiguration,
  List<DataSourceType>? workspaceDataSources,
  String? workspaceDescription,
  String? workspaceName,
  List<NotificationDestinationType>? workspaceNotificationDestinations,
  List<String>? workspaceOrganizationalUnits,
  String? workspaceRoleArn,
}) async {
  final $payload = <String, dynamic>{
    'accountAccessType': accountAccessType.value,
    'authenticationProviders':
        authenticationProviders.map((e) => e.value).toList(),
    'permissionType': permissionType.value,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (configuration != null) 'configuration': jsonEncode(configuration),
    if (grafanaVersion != null) 'grafanaVersion': grafanaVersion,
    if (ipAddressType != null) 'ipAddressType': ipAddressType.value,
    if (kmsKeyId != null) 'kmsKeyId': kmsKeyId,
    if (networkAccessControl != null)
      'networkAccessControl': networkAccessControl,
    if (organizationRoleName != null)
      'organizationRoleName': organizationRoleName,
    if (stackSetName != null) 'stackSetName': stackSetName,
    if (tags != null) 'tags': tags,
    if (vpcConfiguration != null) 'vpcConfiguration': vpcConfiguration,
    if (workspaceDataSources != null)
      'workspaceDataSources':
          workspaceDataSources.map((e) => e.value).toList(),
    if (workspaceDescription != null)
      'workspaceDescription': workspaceDescription,
    if (workspaceName != null) 'workspaceName': workspaceName,
    if (workspaceNotificationDestinations != null)
      'workspaceNotificationDestinations':
          workspaceNotificationDestinations.map((e) => e.value).toList(),
    if (workspaceOrganizationalUnits != null)
      'workspaceOrganizationalUnits': workspaceOrganizationalUnits,
    if (workspaceRoleArn != null) 'workspaceRoleArn': workspaceRoleArn,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/workspaces',
    exceptionFnMap: _exceptionFns,
  );
  return CreateWorkspaceResponse.fromJson(response);
}