Skip to content

get_function async

get_function(
    name: FunctionName,
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
    stage: Optional[FunctionStage] = None,
) -> GetFunctionResult

Gets the code of a CloudFront function. To get configuration information and metadata about a function, use DescribeFunction.

To get a function's code, you must provide the function's name and stage. To get these values, you can use ListFunctions.

Parameters:

  • name (FunctionName) –

    The name of the function whose code you are getting.

  • stage (Optional[FunctionStage], default: None ) –

    The function's stage, either DEVELOPMENT or LIVE.

Raises:

Source code in docs_src/capo_cloudfront/_services/async_cloud_front.py
async def get_function(
    self,
    name: "capo_cloudfront.types.function_name.FunctionName",
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
    stage: Optional["capo_cloudfront.types.function_stage.FunctionStage"] = None,
) -> "capo_cloudfront.types.get_function_result.GetFunctionResult":
    """<p>Gets the code of a CloudFront function. To get configuration information and metadata about a function, use <code>DescribeFunction</code>.</p> <p>To get a function's code, you must provide the function's name and stage. To get these values, you can use <code>ListFunctions</code>.</p>

    Args:
        name: <p>The name of the function whose code you are getting.</p>
        stage: <p>The function's stage, either <code>DEVELOPMENT</code> or <code>LIVE</code>.</p>

    Raises:
        capo_cloudfront.errors.no_such_function_exists.NoSuchFunctionExists: <p>The function does not exist.</p>
        capo_cloudfront.errors.unsupported_operation.UnsupportedOperation: <p>This operation is not supported in this Amazon Web Services Region.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudfront.types.get_function_request.GetFunctionRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudfront.types.get_function_result.GetFunctionResult"
    ]:
        import capo_cloudfront._operations.cloudfront2020_05_31.get_function

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

    def _redact_output(
        output: "capo_cloudfront.types.get_function_result.GetFunctionResult",
    ) -> dict[str, Any]:
        import capo_cloudfront.types.get_function_result

        return capo_cloudfront.types.get_function_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetFunction", redact_output=_redact_output),
    )
    input_: capo_cloudfront.types.get_function_request.GetFunctionRequest = {
        "name": name
    }
    if stage is not None:
        input_["stage"] = stage

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