Skip to content

update_api_key

update_api_key(
    api_id: String,
    id: String,
    *,
    config_overrides: Optional[AppSyncClientConfig] = None,
    description: Optional[String] = None,
    expires: Optional[Long] = None,
) -> UpdateApiKeyResponse

Updates an API key. You can update the key as long as it's not deleted.

Parameters:

  • api_id (String) –

    The ID for the GraphQL API.

  • id (String) –

    The API key ID.

  • description (Optional[String], default: None ) –

    A description of the purpose of the API key.

  • expires (Optional[Long], default: None ) –

    From the update time, the time after which the API key expires. The date is represented as seconds since the epoch. For more information, see .

Raises:

  • ApiKeyValidityOutOfBoundsException –

    The API key expiration must be set to a value between 1 and 365 days from creation (for CreateApiKey) or from update (for UpdateApiKey).

  • BadRequestException –

    The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and then try again.

  • InternalFailureException –

    An internal AppSync error occurred. Try your request again.

  • LimitExceededException –

    The request exceeded a limit. Try your request again.

  • NotFoundException –

    The resource specified in the request was not found. Check the resource, and then try again.

  • UnauthorizedException –

    You aren't authorized to perform this operation.

  • UnknownServiceError –

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

Source code in docs_src/capo_appsync/_services/app_sync.py
def update_api_key(
    self,
    api_id: "capo_appsync.types.string.String",
    id: "capo_appsync.types.string.String",
    *,
    config_overrides: Optional[AppSyncClientConfig] = None,
    description: Optional["capo_appsync.types.string.String"] = None,
    expires: Optional["capo_appsync.types.long.Long"] = None,
) -> "capo_appsync.types.update_api_key_response.UpdateApiKeyResponse":
    """<p>Updates an API key. You can update the key as long as it's not deleted.</p>

    Args:
        api_id: <p>The ID for the GraphQL API.</p>
        id: <p>The API key ID.</p>
        description: <p>A description of the purpose of the API key.</p>
        expires: <p>From the update time, the time after which the API key expires. The date is represented as seconds since the epoch. For more information, see .</p>

    Raises:
        capo_appsync.errors.api_key_validity_out_of_bounds_exception.ApiKeyValidityOutOfBoundsException: <p>The API key expiration must be set to a value between 1 and 365 days from creation (for <code>CreateApiKey</code>) or from update (for <code>UpdateApiKey</code>).</p>
        capo_appsync.errors.bad_request_exception.BadRequestException: <p>The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and then try again.</p>
        capo_appsync.errors.internal_failure_exception.InternalFailureException: <p>An internal AppSync error occurred. Try your request again.</p>
        capo_appsync.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeded a limit. Try your request again.</p>
        capo_appsync.errors.not_found_exception.NotFoundException: <p>The resource specified in the request was not found. Check the resource, and then try again.</p>
        capo_appsync.errors.unauthorized_exception.UnauthorizedException: <p>You aren't authorized to perform this operation.</p>
        capo_appsync.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_appsync.types.update_api_key_request.UpdateApiKeyRequest]",
    ) -> OperationResponse[
        "capo_appsync.types.update_api_key_response.UpdateApiKeyResponse"
    ]:
        import capo_appsync._operations.aws_deepdish_control_plane_service.update_api_key

        output, http_response = (
            capo_appsync._operations.aws_deepdish_control_plane_service.update_api_key.update_api_key(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateApiKey")
    )
    input_: capo_appsync.types.update_api_key_request.UpdateApiKeyRequest = {
        "api_id": api_id,
        "id": id,
    }
    if description is not None:
        input_["description"] = description
    if expires is not None:
        input_["expires"] = expires

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