Configuring an assembly function

An assembly function augments the assembly actions that the API gateway uses during processing.

About this task

You can implement an assembly function in one of the following ways.
  • Define an assembly function to add custom logic to an assembly. After you define the assembly function, you can add it to a function call assembly action.
  • When you configure the API Connect gateway service as not V5 compatible, use an assembly function to specify a user-defined policy (UDP) that API Connect advertises and makes available in the API Connect assembly editor. A UDP provides custom processing control of APIs in the gateway server.

To configure an assembly function, the only requirement beyond the name is to specify the assembly to apply to calls to the function.

If you configure parameters to pass to the assembly function, the parameter configuration has the following settings.
  • The name of the parameter.
  • The label for the parameter that is advertised to API developers.
  • A description of the parameter that is advertised to API developers.
  • The API schema that is used to verify the parameter type.
  • The default parameter value to pass to the assembly function as a string. The default value is used when no value is passed in the request. You must define the default parameter value when the assembly function is called in a function call assembly action and no parameter value is defined in the action.
    • If the default value is a JSON payload, enter the value as a JSON string.
    • If the default value is an empty string, it is treated as not specified.
    • If the assembly function parameter specifies an API schema, the default parameter value overrides the default value in the schema.
  • The type of the parameter value. The default value is string.
    string
    Indicates that the value is a string. The value is set on the parameter as a JSON string. For example, if the parameter name is foo, the value is set on local.parameter.foo in the API context. This setting is the default value.
    payload
    Indicates that the value is a payload. The payload is set on the body key of the parameter as a binary blob. For example, if the parameter name is foo, the payload is set on local.parameter.foo.body in the API context. If the root of the payload value is a JSON object, it must include a space after the first opening brace, {. For an XML tree or JSON document, the payload must be explicitly parsed.
    message
    Indicates that the value is a message. The message contents are copied and set on the parameter. For example, if the message is foo and the parameter name is bar, then the keys and values of foo are copied and set on local.parameter.bar in the API context. The message must be a JSON object that includes a payload set to the body key. The payload cannot be a stream.
  • The indicator for whether the parameter requires a value in an assembly function call. This setting is relevant only when a value is not specified. When a value is specified, this setting is ignored.

Procedure

  1. In the search field, enter assembly.
  2. From the search results, click Assembly function.
  3. Click Add.
  4. Define the basic properties - Name, administrative state, and comments.
  5. Optional: Enter the title for the assembly function that is advertised to API developers. When the title is not provided, the title to advertise to API Connect is auto-generated.
  6. Optional: Enter the description of the function that is advertised to API developers. When the description is not provided, DataPower® Gateway provides a description to advertise to API Connect.
  7. Optional: Specify the level of availability of the assembly function as a UDP in API Connect. The assembly function can be available at the API assembly level, the catalog level, or both.
  8. Optional: Click the Parameters tab to specify the parameters to apply to the function.
    1. Click Add.
    2. Enter the name of the parameter.
    3. Enter the label to use for the parameter.
    4. Enter a description of the parameter.
    5. Specify the API schema.
    6. Enter the default parameter value as a string.
    7. Specify the type of the parameter value.
    8. Specify whether the parameter requires a value in an assembly function call.
    9. Click Apply.
    10. Optional: Repeat the previous steps to add another parameter.
  9. Specify the assembly to apply to calls to the function. An assembly specifies a rule that defines the assembly actions to run against the call and how to handle processing errors.
  10. Click Apply to save changes to the running configuration.
  11. Click Save to save changes to the persisted configuration.