Skip to content

create_access_token

create_access_token(
    name: AccessTokenName,
    *,
    config_overrides: Optional[CodeCatalystClientConfig] = None,
    expires_time: Optional[Timestamp] = None,
) -> CreateAccessTokenResponse

Creates a personal access token (PAT) for the current user. A personal access token (PAT) is similar to a password. It is associated with your user identity for use across all spaces and projects in Amazon CodeCatalyst. You use PATs to access CodeCatalyst from resources that include integrated development environments (IDEs) and Git-based source repositories. PATs represent you in Amazon CodeCatalyst and you can manage them in your user settings.For more information, see Managing personal access tokens in Amazon CodeCatalyst.

Parameters:

  • name (AccessTokenName) –

    The friendly name of the personal access token.

  • expires_time (Optional[Timestamp], default: None ) –

    The date and time the personal access token expires, in coordinated universal time (UTC) timestamp format as specified in RFC 3339.

Raises:

  • AccessDeniedException –

    The request was denied because you don't have sufficient access to perform this action. Verify that you are a member of a role that allows this action.

  • ConflictException –

    The request was denied because the requested operation would cause a conflict with the current state of a service resource associated with the request. Another user might have updated the resource. Reload, make sure you have the latest data, and then try again.

  • ResourceNotFoundException –

    The request was denied because the specified resource was not found. Verify that the spelling is correct and that you have access to the resource.

  • ServiceQuotaExceededException –

    The request was denied because one or more resources has reached its limits for the tier the space belongs to. Either reduce the number of resources, or change the tier if applicable.

  • ThrottlingException –

    The request was denied due to request throttling.

  • ValidationException –

    The request was denied because an input failed to satisfy the constraints specified by the service. Check the spelling and input requirements, and then try again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_codecatalyst/_services/code_catalyst.py
def create_access_token(
    self,
    name: "capo_codecatalyst.types.access_token_name.AccessTokenName",
    *,
    config_overrides: Optional[CodeCatalystClientConfig] = None,
    expires_time: Optional["capo_codecatalyst.types.timestamp.Timestamp"] = None,
) -> (
    "capo_codecatalyst.types.create_access_token_response.CreateAccessTokenResponse"
):
    """<p>Creates a personal access token (PAT) for the current user. A personal access token (PAT) is similar to a password. It is associated with your user identity for use across all spaces and projects in Amazon CodeCatalyst. You use PATs to access CodeCatalyst from resources that include integrated development environments (IDEs) and Git-based source repositories. PATs represent you in Amazon CodeCatalyst and you can manage them in your user settings.For more information, see <a href="https://docs.aws.amazon.com/codecatalyst/latest/userguide/ipa-tokens-keys.html">Managing personal access tokens in Amazon CodeCatalyst</a>.</p>

    Args:
        name: <p>The friendly name of the personal access token.</p>
        expires_time: <p>The date and time the personal access token expires, in coordinated universal time (UTC) timestamp format as specified in <a href="https://www.rfc-editor.org/rfc/rfc3339#section-5.6">RFC 3339</a>.</p>

    Raises:
        capo_codecatalyst.errors.access_denied_exception.AccessDeniedException: <p>The request was denied because you don't have sufficient access to perform this action. Verify that you are a member of a role that allows this action.</p>
        capo_codecatalyst.errors.conflict_exception.ConflictException: <p>The request was denied because the requested operation would cause a conflict with the current state of a service resource associated with the request. Another user might have updated the resource. Reload, make sure you have the latest data, and then try again.</p>
        capo_codecatalyst.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request was denied because the specified resource was not found. Verify that the spelling is correct and that you have access to the resource.</p>
        capo_codecatalyst.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request was denied because one or more resources has reached its limits for the tier the space belongs to. Either reduce the number of resources, or change the tier if applicable.</p>
        capo_codecatalyst.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_codecatalyst.errors.validation_exception.ValidationException: <p>The request was denied because an input failed to satisfy the constraints specified by the service. Check the spelling and input requirements, and then try again.</p>
        capo_codecatalyst.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_codecatalyst.types.create_access_token_request.CreateAccessTokenRequest]",
    ) -> OperationResponse[
        "capo_codecatalyst.types.create_access_token_response.CreateAccessTokenResponse"
    ]:
        import capo_codecatalyst._operations.code_catalyst.create_access_token

        output, http_response = (
            capo_codecatalyst._operations.code_catalyst.create_access_token.create_access_token(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_codecatalyst.types.create_access_token_response.CreateAccessTokenResponse",
    ) -> dict[str, Any]:
        import capo_codecatalyst.types.create_access_token_response

        return (
            capo_codecatalyst.types.create_access_token_response.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateAccessToken", redact_output=_redact_output),
    )
    input_: capo_codecatalyst.types.create_access_token_request.CreateAccessTokenRequest = {
        "name": name
    }
    if expires_time is not None:
        input_["expires_time"] = expires_time

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