Skip to content

create_workspace_service_account

create_workspace_service_account(
    name: ServiceAccountName,
    grafana_role: Role,
    workspace_id: WorkspaceId,
    *,
    config_overrides: Optional[grafanaClientConfig] = None,
) -> CreateWorkspaceServiceAccountResponse

Creates a service account for the workspace. A service account can be used to call Grafana HTTP APIs, and run automated workloads. After creating the service account with the correct GrafanaRole for your use case, use CreateWorkspaceServiceAccountToken to create a token that can be used to authenticate and authorize Grafana HTTP API calls.

You can only create service accounts for workspaces that are compatible with Grafana version 9 and above.

For more information about service accounts, see Service accounts in the Amazon Managed Grafana User Guide.

For more information about the Grafana HTTP APIs, see Using Grafana HTTP APIs in the Amazon Managed Grafana User Guide.

Parameters:

  • name (ServiceAccountName) –

    A name for the service account. The name must be unique within the workspace, as it determines the ID associated with the service account.

  • grafana_role (Role) –

    The permission level to use for this service account.

    For more information about the roles and the permissions each has, see User roles in the Amazon Managed Grafana User Guide.

  • workspace_id (WorkspaceId) –

    The ID of the workspace within which to create the service account.

Raises:

Source code in docs_src/capo_grafana/_services/grafana.py
def create_workspace_service_account(
    self,
    name: "capo_grafana.types.service_account_name.ServiceAccountName",
    grafana_role: "capo_grafana.types.role.Role",
    workspace_id: "capo_grafana.types.workspace_id.WorkspaceId",
    *,
    config_overrides: Optional[grafanaClientConfig] = None,
) -> "capo_grafana.types.create_workspace_service_account_response.CreateWorkspaceServiceAccountResponse":
    """<p>Creates a service account for the workspace. A service account can be used to call Grafana HTTP APIs, and run automated workloads. After creating the service account with the correct <code>GrafanaRole</code> for your use case, use <code>CreateWorkspaceServiceAccountToken</code> to create a token that can be used to authenticate and authorize Grafana HTTP API calls.</p> <p>You can only create service accounts for workspaces that are compatible with Grafana version 9 and above.</p> <note> <p>For more information about service accounts, see <a href="https://docs.aws.amazon.com/grafana/latest/userguide/service-accounts.html">Service accounts</a> in the <i>Amazon Managed Grafana User Guide</i>.</p> <p>For more information about the Grafana HTTP APIs, see <a href="https://docs.aws.amazon.com/grafana/latest/userguide/Using-Grafana-APIs.html">Using Grafana HTTP APIs</a> in the <i>Amazon Managed Grafana User Guide</i>.</p> </note>

    Args:
        name: <p>A name for the service account. The name must be unique within the workspace, as it determines the ID associated with the service account.</p>
        grafana_role: <p>The permission level to use for this service account.</p> <note> <p>For more information about the roles and the permissions each has, see <a href="https://docs.aws.amazon.com/grafana/latest/userguide/Grafana-user-roles.html">User roles</a> in the <i>Amazon Managed Grafana User Guide</i>.</p> </note>
        workspace_id: <p>The ID of the workspace within which to create the service account.</p>

    Raises:
        capo_grafana.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient permissions to perform this action. </p>
        capo_grafana.errors.conflict_exception.ConflictException: <p>A resource was in an inconsistent state during an update or a deletion.</p>
        capo_grafana.errors.internal_server_exception.InternalServerException: <p>Unexpected error while processing the request. Retry the request.</p>
        capo_grafana.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resource that does not exist.</p>
        capo_grafana.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota to be exceeded.</p>
        capo_grafana.errors.throttling_exception.ThrottlingException: <p>The request was denied because of request throttling. Retry the request.</p>
        capo_grafana.errors.validation_exception.ValidationException: <p>The value of a parameter in the request caused an error.</p>
        capo_grafana.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_grafana.types.create_workspace_service_account_request.CreateWorkspaceServiceAccountRequest]",
    ) -> OperationResponse[
        "capo_grafana.types.create_workspace_service_account_response.CreateWorkspaceServiceAccountResponse"
    ]:
        import capo_grafana._operations.aws_grafana_control_plane.create_workspace_service_account

        output, http_response = (
            capo_grafana._operations.aws_grafana_control_plane.create_workspace_service_account.create_workspace_service_account(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateWorkspaceServiceAccount")
    )
    input_: capo_grafana.types.create_workspace_service_account_request.CreateWorkspaceServiceAccountRequest = {
        "name": name,
        "grafana_role": grafana_role,
        "workspace_id": workspace_id,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output