MediaTailor / Client / put_function

put_function

MediaTailor.Client.put_function(**kwargs)

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.

See also: AWS API Documentation

Request Syntax

response = client.put_function(
    FunctionId='string',
    FunctionType='HTTP_REQUEST'|'CUSTOM_OUTPUT'|'SEQUENTIAL_EXECUTOR',
    Description='string',
    HttpRequestConfiguration={
        'Runtime': 'JSONATA',
        'Output': {
            'string': 'string'
        },
        'MethodType': 'GET'|'POST',
        'RequestTimeoutMilliseconds': 123,
        'Url': 'string',
        'Body': 'string',
        'Headers': {
            'string': 'string'
        }
    },
    CustomOutputConfiguration={
        'Runtime': 'JSONATA',
        'Output': {
            'string': 'string'
        }
    },
    SequentialExecutorConfiguration={
        'Runtime': 'JSONATA',
        'Output': {
            'string': 'string'
        },
        'FunctionList': [
            {
                'RunCondition': 'string',
                'FunctionId': 'string'
            },
        ],
        'TimeoutMilliseconds': 123
    },
    Tags={
        'string': 'string'
    }
)
Parameters:
  • FunctionId (string) –

    [REQUIRED]

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

  • FunctionType (string) –

    [REQUIRED]

    The type of the function. The function type 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. SEQUENTIAL_EXECUTOR runs a sequence of child functions in order, passing data between steps through temporary data. For more information, see Function types and composition in the MediaTailor User Guide.

  • Description (string) – A description of the function.

  • HttpRequestConfiguration (dict) –

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

    • Runtime (string) – [REQUIRED]

      The expression language used to evaluate expressions in the function configuration. Set this to JSONata.

    • Output (dict) –

      A map of output bindings. Each key is a namespaced output path (such as player_params.device_type or temp.identity), and each value is an expression that MediaTailor evaluates at runtime. Output expressions in an HTTP_REQUEST function can reference the response object returned by the HTTP call. For more information about expression syntax, see JSONata expression reference in the MediaTailor User Guide.

      • (string) –

        • (string) –

    • MethodType (string) – [REQUIRED]

      The HTTP method for the request. Valid values: GET and POST.

    • RequestTimeoutMilliseconds (integer) – [REQUIRED]

      The maximum time, in milliseconds, that MediaTailor waits for a response from the external service. If the call exceeds this timeout, MediaTailor sets the response status code to null and proceeds with output expression evaluation. Valid values: 100 to 2000.

    • Url (string) – [REQUIRED]

      An expression that evaluates to the request URL. Use {%...%} delimiters for dynamic expressions. The maximum length after evaluation is 2,048 characters.

    • Body (string) –

      An expression that evaluates to the request body. Used with POST requests. The maximum size after evaluation is 64 KB.

    • Headers (dict) –

      A map of HTTP header names to expression values. MediaTailor evaluates each header value expression at runtime and includes the result in the outbound HTTP request. Maximum 50 headers.

      • (string) –

        • (string) –

  • CustomOutputConfiguration (dict) –

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

    • Runtime (string) – [REQUIRED]

      The expression language used to evaluate expressions in the function configuration. Set this to JSONata.

    • Output (dict) –

      A map of output bindings. Each key is a namespaced output path (such as player_params.device_type or temp.variant), and each value is an expression that MediaTailor evaluates at runtime against the current session state. For more information about expression syntax, see JSONata expression reference in the MediaTailor User Guide.

      • (string) –

        • (string) –

  • SequentialExecutorConfiguration (dict) –

    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.

    • Runtime (string) – [REQUIRED]

      The expression language used to evaluate expressions in the function configuration. Set this to JSONata.

    • Output (dict) –

      An optional map of output bindings that controls which bindings the sequence commits to the session state after all steps complete. If omitted, MediaTailor commits all accumulated output bindings from all child steps.

      • (string) –

        • (string) –

    • FunctionList (list) – [REQUIRED]

      An ordered list of 1 to 10 steps. Each step specifies a child function to execute and an optional run condition expression that controls whether the step runs. MediaTailor executes steps in order, passing data between steps through temporary data.

      • (dict) –

        A reference to a child function within a SEQUENTIAL_EXECUTOR function.

        • RunCondition (string) –

          An optional expression that evaluates to a boolean. MediaTailor evaluates this expression immediately before running the step, using the accumulated state at that point in the sequence. If the expression evaluates to false, MediaTailor skips the step and moves to the next one. If omitted, the step always runs.

        • FunctionId (string) –

          The identifier of the child function to execute in this step.

    • TimeoutMilliseconds (integer) – [REQUIRED]

      The maximum time, in milliseconds, for the entire sequence to complete. This timeout covers all steps, including any HTTP calls made by child functions. If the sequence exceeds this timeout, MediaTailor discards all output from the sequence and proceeds with default behavior.

  • Tags (dict) –

    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.

    • (string) –

      • (string) –

Return type:

dict

Returns:

Response Syntax

{
    'FunctionId': 'string',
    'FunctionType': 'HTTP_REQUEST'|'CUSTOM_OUTPUT'|'SEQUENTIAL_EXECUTOR',
    'Description': 'string',
    'HttpRequestConfiguration': {
        'Runtime': 'JSONATA',
        'Output': {
            'string': 'string'
        },
        'MethodType': 'GET'|'POST',
        'RequestTimeoutMilliseconds': 123,
        'Url': 'string',
        'Body': 'string',
        'Headers': {
            'string': 'string'
        }
    },
    'CustomOutputConfiguration': {
        'Runtime': 'JSONATA',
        'Output': {
            'string': 'string'
        }
    },
    'SequentialExecutorConfiguration': {
        'Runtime': 'JSONATA',
        'Output': {
            'string': 'string'
        },
        'FunctionList': [
            {
                'RunCondition': 'string',
                'FunctionId': 'string'
            },
        ],
        'TimeoutMilliseconds': 123
    },
    'Tags': {
        'string': 'string'
    },
    'Arn': 'string'
}

Response Structure

  • (dict) –

    – Define Mixin –

    • FunctionId (string) –

      The identifier of the function.

    • FunctionType (string) –

      The type of the function.

    • Description (string) –

      A description of the function.

    • HttpRequestConfiguration (dict) –

      The configuration for an HTTP_REQUEST function.

      • Runtime (string) –

        The expression language used to evaluate expressions in the function configuration. Set this to JSONata.

      • Output (dict) –

        A map of output bindings. Each key is a namespaced output path (such as player_params.device_type or temp.identity), and each value is an expression that MediaTailor evaluates at runtime. Output expressions in an HTTP_REQUEST function can reference the response object returned by the HTTP call. For more information about expression syntax, see JSONata expression reference in the MediaTailor User Guide.

        • (string) –

          • (string) –

      • MethodType (string) –

        The HTTP method for the request. Valid values: GET and POST.

      • RequestTimeoutMilliseconds (integer) –

        The maximum time, in milliseconds, that MediaTailor waits for a response from the external service. If the call exceeds this timeout, MediaTailor sets the response status code to null and proceeds with output expression evaluation. Valid values: 100 to 2000.

      • Url (string) –

        An expression that evaluates to the request URL. Use {%...%} delimiters for dynamic expressions. The maximum length after evaluation is 2,048 characters.

      • Body (string) –

        An expression that evaluates to the request body. Used with POST requests. The maximum size after evaluation is 64 KB.

      • Headers (dict) –

        A map of HTTP header names to expression values. MediaTailor evaluates each header value expression at runtime and includes the result in the outbound HTTP request. Maximum 50 headers.

        • (string) –

          • (string) –

    • CustomOutputConfiguration (dict) –

      The configuration for a CUSTOM_OUTPUT function.

      • Runtime (string) –

        The expression language used to evaluate expressions in the function configuration. Set this to JSONata.

      • Output (dict) –

        A map of output bindings. Each key is a namespaced output path (such as player_params.device_type or temp.variant), and each value is an expression that MediaTailor evaluates at runtime against the current session state. For more information about expression syntax, see JSONata expression reference in the MediaTailor User Guide.

        • (string) –

          • (string) –

    • SequentialExecutorConfiguration (dict) –

      The configuration for a SEQUENTIAL_EXECUTOR function.

      • Runtime (string) –

        The expression language used to evaluate expressions in the function configuration. Set this to JSONata.

      • Output (dict) –

        An optional map of output bindings that controls which bindings the sequence commits to the session state after all steps complete. If omitted, MediaTailor commits all accumulated output bindings from all child steps.

        • (string) –

          • (string) –

      • FunctionList (list) –

        An ordered list of 1 to 10 steps. Each step specifies a child function to execute and an optional run condition expression that controls whether the step runs. MediaTailor executes steps in order, passing data between steps through temporary data.

        • (dict) –

          A reference to a child function within a SEQUENTIAL_EXECUTOR function.

          • RunCondition (string) –

            An optional expression that evaluates to a boolean. MediaTailor evaluates this expression immediately before running the step, using the accumulated state at that point in the sequence. If the expression evaluates to false, MediaTailor skips the step and moves to the next one. If omitted, the step always runs.

          • FunctionId (string) –

            The identifier of the child function to execute in this step.

      • TimeoutMilliseconds (integer) –

        The maximum time, in milliseconds, for the entire sequence to complete. This timeout covers all steps, including any HTTP calls made by child functions. If the sequence exceeds this timeout, MediaTailor discards all output from the sequence and proceeds with default behavior.

    • Tags (dict) –

      The tags assigned 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.

      • (string) –

        • (string) –

    • Arn (string) –

      The Amazon Resource Name (ARN) of the function.