Skip to content

create_api_key async

create_api_key(
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    name: Optional[String] = None,
    description: Optional[String] = None,
    enabled: Optional[Boolean] = None,
    generate_distinct_id: Optional[Boolean] = None,
    value: Optional[String] = None,
    stage_keys: Optional[ListOfStageKeys] = None,
    customer_id: Optional[String] = None,
    tags: Optional[MapOfStringToString] = None,
) -> ApiKey

Create an ApiKey resource.

Parameters:

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

    The name of the ApiKey.

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

    The description of the ApiKey.

  • enabled (Optional[Boolean], default: None ) –

    Specifies whether the ApiKey can be used by callers.

  • generate_distinct_id (Optional[Boolean], default: None ) –

    Specifies whether (true) or not (false) the key identifier is distinct from the created API key value. This parameter is deprecated and should not be used.

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

    Specifies a value of the API key.

  • stage_keys (Optional[ListOfStageKeys], default: None ) –

    DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.

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

    An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.

  • tags (Optional[MapOfStringToString], default: None ) –

    The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with aws:. The tag value can be up to 256 characters.

Raises:

  • BadRequestException –

    The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.

  • ConflictException –

    The request configuration has conflicts. For details, see the accompanying error message.

  • LimitExceededException –

    The request exceeded the rate limit. Retry after the specified time period.

  • NotFoundException –

    The requested resource is not found. Make sure that the request URI is correct.

  • TooManyRequestsException –

    The request has reached its throttling limit. Retry after the specified time period.

  • UnauthorizedException –

    The request is denied because the caller has insufficient permissions.

  • UnknownServiceError –

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

Source code in docs_src/capo_api_gateway/_services/async_api_gateway.py
async def create_api_key(
    self,
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    name: Optional["capo_api_gateway.types.string.String"] = None,
    description: Optional["capo_api_gateway.types.string.String"] = None,
    enabled: Optional["capo_api_gateway.types.boolean.Boolean"] = None,
    generate_distinct_id: Optional["capo_api_gateway.types.boolean.Boolean"] = None,
    value: Optional["capo_api_gateway.types.string.String"] = None,
    stage_keys: Optional[
        "capo_api_gateway.types.list_of_stage_keys.ListOfStageKeys"
    ] = None,
    customer_id: Optional["capo_api_gateway.types.string.String"] = None,
    tags: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
) -> "capo_api_gateway.types.api_key.ApiKey":
    """<p>Create an ApiKey resource. </p>

    Args:
        name: <p>The name of the ApiKey.</p>
        description: <p>The description of the ApiKey.</p>
        enabled: <p>Specifies whether the ApiKey can be used by callers.</p>
        generate_distinct_id: <p>Specifies whether (<code>true</code>) or not (<code>false</code>) the key identifier is distinct from the created API key value. This parameter is deprecated and should not be used.</p>
        value: <p>Specifies a value of the API key.</p>
        stage_keys: <p>DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.</p>
        customer_id: <p>An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.</p>
        tags: <p>The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with <code>aws:</code>. The tag value can be up to 256 characters.</p>

    Raises:
        capo_api_gateway.errors.bad_request_exception.BadRequestException: <p>The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.</p>
        capo_api_gateway.errors.conflict_exception.ConflictException: <p>The request configuration has conflicts. For details, see the accompanying error message.</p>
        capo_api_gateway.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeded the rate limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.not_found_exception.NotFoundException: <p>The requested resource is not found. Make sure that the request URI is correct.</p>
        capo_api_gateway.errors.too_many_requests_exception.TooManyRequestsException: <p>The request has reached its throttling limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.unauthorized_exception.UnauthorizedException: <p>The request is denied because the caller has insufficient permissions.</p>
        capo_api_gateway.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_api_gateway.types.create_api_key_request.CreateApiKeyRequest]",
    ) -> AsyncOperationResponse["capo_api_gateway.types.api_key.ApiKey"]:
        import capo_api_gateway._operations.backplane_control_service.create_api_key

        (
            output,
            http_response,
        ) = await capo_api_gateway._operations.backplane_control_service.create_api_key.async_create_api_key(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateApiKey")
    )
    input_: capo_api_gateway.types.create_api_key_request.CreateApiKeyRequest = {}
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if enabled is not None:
        input_["enabled"] = enabled
    if generate_distinct_id is not None:
        input_["generate_distinct_id"] = generate_distinct_id
    if value is not None:
        input_["value"] = value
    if stage_keys is not None:
        input_["stage_keys"] = stage_keys
    if customer_id is not None:
        input_["customer_id"] = customer_id
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output