putFunction method

Future<PutFunctionResponse> putFunction({
  1. required String functionId,
  2. required FunctionType functionType,
  3. CustomOutputConfiguration? customOutputConfiguration,
  4. String? description,
  5. HttpRequestConfiguration? httpRequestConfiguration,
  6. SequentialExecutorConfiguration? sequentialExecutorConfiguration,
  7. Map<String, String>? tags,
})

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.

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

Parameter functionType : 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.

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

Parameter description : A description of the function.

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

Parameter sequentialExecutorConfiguration : 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.

Parameter tags : 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.

Implementation

Future<PutFunctionResponse> putFunction({
  required String functionId,
  required FunctionType functionType,
  CustomOutputConfiguration? customOutputConfiguration,
  String? description,
  HttpRequestConfiguration? httpRequestConfiguration,
  SequentialExecutorConfiguration? sequentialExecutorConfiguration,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'FunctionType': functionType.value,
    if (customOutputConfiguration != null)
      'CustomOutputConfiguration': customOutputConfiguration,
    if (description != null) 'Description': description,
    if (httpRequestConfiguration != null)
      'HttpRequestConfiguration': httpRequestConfiguration,
    if (sequentialExecutorConfiguration != null)
      'SequentialExecutorConfiguration': sequentialExecutorConfiguration,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/function/${Uri.encodeComponent(functionId)}',
    exceptionFnMap: _exceptionFns,
  );
  return PutFunctionResponse.fromJson(response);
}