Skip to content

create_public_key async

create_public_key(
    public_key_config: PublicKeyConfig,
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
) -> CreatePublicKeyResult

Uploads a public key to CloudFront that you can use with signed URLs and signed cookies, or with field-level encryption.

Parameters:

  • public_key_config (PublicKeyConfig) –

    A CloudFront public key configuration.

Raises:

Source code in docs_src/capo_cloudfront/_services/async_cloud_front.py
async def create_public_key(
    self,
    public_key_config: "capo_cloudfront.types.public_key_config.PublicKeyConfig",
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
) -> "capo_cloudfront.types.create_public_key_result.CreatePublicKeyResult":
    """<p>Uploads a public key to CloudFront that you can use with <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html">signed URLs and signed cookies</a>, or with <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/field-level-encryption.html">field-level encryption</a>.</p>

    Args:
        public_key_config: <p>A CloudFront public key configuration.</p>

    Raises:
        capo_cloudfront.errors.invalid_argument.InvalidArgument: <p>An argument is invalid.</p>
        capo_cloudfront.errors.public_key_already_exists.PublicKeyAlreadyExists: <p>The specified public key already exists.</p>
        capo_cloudfront.errors.too_many_public_keys.TooManyPublicKeys: <p>The maximum number of public keys for field-level encryption have been created. To create a new public key, delete one of the existing keys.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudfront.types.create_public_key_request.CreatePublicKeyRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudfront.types.create_public_key_result.CreatePublicKeyResult"
    ]:
        import capo_cloudfront._operations.cloudfront2020_05_31.create_public_key

        (
            output,
            http_response,
        ) = await capo_cloudfront._operations.cloudfront2020_05_31.create_public_key.async_create_public_key(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePublicKey")
    )
    input_: capo_cloudfront.types.create_public_key_request.CreatePublicKeyRequest = {
        "public_key_config": public_key_config
    }

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