Skip to content

put_function async

put_function(
    function_id: __string,
    function_type: FunctionType,
    *,
    config_overrides: Optional[AsyncMediaTailorClientConfig] = None,
    description: Optional[__string] = None,
    http_request_configuration: Optional[HttpRequestConfiguration] = None,
    aws_service_request_configuration: Optional[AwsServiceRequestConfiguration] = None,
    custom_output_configuration: Optional[CustomOutputConfiguration] = None,
    concurrent_executor_configuration: Optional[ConcurrentExecutorConfiguration] = None,
    sequential_executor_configuration: Optional[SequentialExecutorConfiguration] = None,
    vast_request_configuration: Optional[VastRequestConfiguration] = None,
    tags: Optional[__mapOf__string] = None,
) -> PutFunctionResponse

Creates or updates a function. A function defines reusable logic that MediaTailor executes at lifecycle hooks during ad insertion. For more information about functions, see Working with functions in the MediaTailor User Guide.

Parameters:

  • function_id (__string) –

    The identifier of the function. The identifier must be unique within your account.

  • function_type (FunctionType) –

    The type of the function, which determines what the function can do at runtime. Valid values:

    • CUSTOM_OUTPUT – Evaluates expressions and produces output bindings with no external calls.

    • HTTP_REQUEST – Makes an HTTP call to an external service and evaluates output expressions that can reference the response.

    • AWS_SERVICE_REQUEST – Makes an authenticated request to a supported AWS service API and evaluates output expressions that can reference the response.

    • VAST_REQUEST – Calls a VAST endpoint, parses the response as VAST, and makes the parsed ads available to output expressions.

    • SEQUENTIAL_EXECUTOR – Runs a sequence of child functions in order, passing data between steps through temporary data.

    • CONCURRENT_EXECUTOR – Runs a set of child functions in parallel, up to a maximum concurrency, and combines their output when all functions complete.

    For more information, see Function types and composition in the MediaTailor User Guide.

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

    A description of the function.

  • http_request_configuration (Optional[HttpRequestConfiguration], default: None ) –

    The configuration for an HTTP_REQUEST function. Specifies the HTTP method, URL, headers, body, timeout, and output expressions. Required when FunctionType is HTTP_REQUEST.

  • aws_service_request_configuration (Optional[AwsServiceRequestConfiguration], default: None ) –

    The configuration for an AWS_SERVICE_REQUEST function. You must specify this parameter when FunctionType is AWS_SERVICE_REQUEST.

  • custom_output_configuration (Optional[CustomOutputConfiguration], default: None ) –

    The configuration for a CUSTOM_OUTPUT function. Specifies the runtime and output expressions. Required when FunctionType is CUSTOM_OUTPUT.

  • concurrent_executor_configuration (Optional[ConcurrentExecutorConfiguration], default: None ) –

    The configuration for a CONCURRENT_EXECUTOR function. Specifies the list of child functions to run in parallel, the maximum concurrency, an optional output block, and a timeout. Required when FunctionType is CONCURRENT_EXECUTOR.

  • sequential_executor_configuration (Optional[SequentialExecutorConfiguration], default: None ) –

    The configuration for a SEQUENTIAL_EXECUTOR function. Specifies the ordered list of child functions to execute, an optional output block, and a timeout. Required when FunctionType is SEQUENTIAL_EXECUTOR.

  • vast_request_configuration (Optional[VastRequestConfiguration], default: None ) –

    The configuration for a VAST_REQUEST function. Specifies the HTTP method, URL, headers, body, timeout, and output expressions. Required when FunctionType is VAST_REQUEST.

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

    The tags to assign to the function. Tags are key-value pairs that you can associate with Amazon resources to help with organization, access control, and cost tracking. For more information, see Tagging AWS Elemental MediaTailor Resources.

Raises:

Source code in docs_src/capo_mediatailor/_services/async_media_tailor.py
async def put_function(
    self,
    function_id: "capo_mediatailor.types.__string.__string",
    function_type: "capo_mediatailor.types.function_type.FunctionType",
    *,
    config_overrides: Optional[AsyncMediaTailorClientConfig] = None,
    description: Optional["capo_mediatailor.types.__string.__string"] = None,
    http_request_configuration: Optional[
        "capo_mediatailor.types.http_request_configuration.HttpRequestConfiguration"
    ] = None,
    aws_service_request_configuration: Optional[
        "capo_mediatailor.types.aws_service_request_configuration.AwsServiceRequestConfiguration"
    ] = None,
    custom_output_configuration: Optional[
        "capo_mediatailor.types.custom_output_configuration.CustomOutputConfiguration"
    ] = None,
    concurrent_executor_configuration: Optional[
        "capo_mediatailor.types.concurrent_executor_configuration.ConcurrentExecutorConfiguration"
    ] = None,
    sequential_executor_configuration: Optional[
        "capo_mediatailor.types.sequential_executor_configuration.SequentialExecutorConfiguration"
    ] = None,
    vast_request_configuration: Optional[
        "capo_mediatailor.types.vast_request_configuration.VastRequestConfiguration"
    ] = None,
    tags: Optional[
        "capo_mediatailor.types.__map_of__string.__mapOf__string"
    ] = None,
) -> "capo_mediatailor.types.put_function_response.PutFunctionResponse":
    """<p>Creates or updates a function. A function defines reusable logic that MediaTailor executes at lifecycle hooks during ad insertion. For more information about functions, see <a href="https://docs.aws.amazon.com/mediatailor/latest/ug/monetization-functions.html">Working with functions</a> in the <i>MediaTailor User Guide</i>.</p>

    Args:
        function_id: <p>The identifier of the function. The identifier must be unique within your account.</p>
        function_type: <p>The type of the function, which determines what the function can do at runtime. Valid values:</p> <ul> <li> <p> <code>CUSTOM_OUTPUT</code> – Evaluates expressions and produces output bindings with no external calls.</p> </li> <li> <p> <code>HTTP_REQUEST</code> – Makes an HTTP call to an external service and evaluates output expressions that can reference the response.</p> </li> <li> <p> <code>AWS_SERVICE_REQUEST</code> – Makes an authenticated request to a supported AWS service API and evaluates output expressions that can reference the response.</p> </li> <li> <p> <code>VAST_REQUEST</code> – Calls a VAST endpoint, parses the response as VAST, and makes the parsed ads available to output expressions.</p> </li> <li> <p> <code>SEQUENTIAL_EXECUTOR</code> – Runs a sequence of child functions in order, passing data between steps through temporary data.</p> </li> <li> <p> <code>CONCURRENT_EXECUTOR</code> – Runs a set of child functions in parallel, up to a maximum concurrency, and combines their output when all functions complete.</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/mediatailor/latest/ug/monetization-functions-types.html">Function types and composition</a> in the <i>MediaTailor User Guide</i>.</p>
        description: <p>A description of the function.</p>
        http_request_configuration: <p>The configuration for an <code>HTTP_REQUEST</code> function. Specifies the HTTP method, URL, headers, body, timeout, and output expressions. Required when <code>FunctionType</code> is <code>HTTP_REQUEST</code>.</p>
        aws_service_request_configuration: <p>The configuration for an <code>AWS_SERVICE_REQUEST</code> function. You must specify this parameter when <code>FunctionType</code> is <code>AWS_SERVICE_REQUEST</code>.</p>
        custom_output_configuration: <p>The configuration for a <code>CUSTOM_OUTPUT</code> function. Specifies the runtime and output expressions. Required when <code>FunctionType</code> is <code>CUSTOM_OUTPUT</code>.</p>
        concurrent_executor_configuration: <p>The configuration for a <code>CONCURRENT_EXECUTOR</code> function. Specifies the list of child functions to run in parallel, the maximum concurrency, an optional output block, and a timeout. Required when <code>FunctionType</code> is <code>CONCURRENT_EXECUTOR</code>.</p>
        sequential_executor_configuration: <p>The configuration for a <code>SEQUENTIAL_EXECUTOR</code> function. Specifies the ordered list of child functions to execute, an optional output block, and a timeout. Required when <code>FunctionType</code> is <code>SEQUENTIAL_EXECUTOR</code>.</p>
        vast_request_configuration: <p>The configuration for a <code>VAST_REQUEST</code> function. Specifies the HTTP method, URL, headers, body, timeout, and output expressions. Required when <code>FunctionType</code> is <code>VAST_REQUEST</code>.</p>
        tags: <p>The tags to assign to the function. Tags are key-value pairs that you can associate with Amazon resources to help with organization, access control, and cost tracking. For more information, see <a href="https://docs.aws.amazon.com/mediatailor/latest/ug/tagging.html">Tagging AWS Elemental MediaTailor Resources</a>.</p>

    Raises:
        capo_mediatailor.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_mediatailor.types.put_function_request.PutFunctionRequest]",
    ) -> AsyncOperationResponse[
        "capo_mediatailor.types.put_function_response.PutFunctionResponse"
    ]:
        import capo_mediatailor._operations.media_tailor.put_function

        (
            output,
            http_response,
        ) = await capo_mediatailor._operations.media_tailor.put_function.async_put_function(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutFunction")
    )
    input_: capo_mediatailor.types.put_function_request.PutFunctionRequest = {
        "function_id": function_id,
        "function_type": function_type,
    }
    if description is not None:
        input_["description"] = description
    if http_request_configuration is not None:
        input_["http_request_configuration"] = http_request_configuration
    if aws_service_request_configuration is not None:
        input_["aws_service_request_configuration"] = (
            aws_service_request_configuration
        )
    if custom_output_configuration is not None:
        input_["custom_output_configuration"] = custom_output_configuration
    if concurrent_executor_configuration is not None:
        input_["concurrent_executor_configuration"] = (
            concurrent_executor_configuration
        )
    if sequential_executor_configuration is not None:
        input_["sequential_executor_configuration"] = (
            sequential_executor_configuration
        )
    if vast_request_configuration is not None:
        input_["vast_request_configuration"] = vast_request_configuration
    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