Invoke

The invoke policy sends a request to a backend service and returns its response.

The policy defines how the gateway connects to the target service. It lets you configure the HTTP method, connection and timeout settings, TLS behavior, request and response handling, and caching. It also supports gateway specific extensions such as service registry lookup and gateway level SSL configuration.

In IBM API Studio, this policy is identified by the kind Invoke.

Example of a Invoke policy:

kind: Invoke
apiVersion: apim.ibm.com/v1
metadata:
  name: "invoke"
  version: 1.0
  namespace: sample
spec:
    input : request # optional to set the request for the invoke
    output : response # optional to store response for the invoke
    cache:
      expire:
        static:
            seconds : 60
      scope:
          narrowScope : {} # wideScope
    endpoint:
      http:
        verb: GET
        statusException: 
          - pattern: '500'     
        target:
          tlsClientProfile: tls_profile
          url: 'https://localhost:3000'
          urlType: 'plain' # plain, variables, jsonata     
          version: HTTP/1.0 # HTTP/1.1, HTTP/2
          timeout: 60
          compressRequest: "br" # "gzip", "br", "deflate", "none"
          decompressResponse: false
          followRedirects: false
          chunkedUpload: false
          persistentConnections: true
    extensions:
      webm-gateway:
        apiVersion: api.ibm.com/v1
        spec:
          endpoint:
            http:
              target:
                connectionTimeout: 300
                nativeServiceTimeout: 400
              sslConfig:
                keyStoreAlias: ""
                keyAlias: ""
                trustStoreAlias: ""
              serviceRegistryParameters:
                - name: ""
                  value: ""

To use the Invoke policy, you can specify the following configurations:

Type Description
spec Describes the configuration for the policy.

This section includes:

  • input.Uses the incoming request as input.
  • output. Returns the response as the output
  • cache. Defines caching parameters.
  • endpoint. Defines endpoint settings.
  • extensions. Provides gateway specific settings.
cache Defines caching behavior.

This section includes:

  • expire.static.seconds. Specifies the time after which cached entries expire.
  • scope. Defines how cached entries are grouped.
endpoint Defines the HTTP endpoint configuration.

This section includes:

  • http. Contains HTTP-specific target settings.
  • verb. Sets the HTTP method used for outbound requests.
  • statusException. Defines status codes that are not treated as errors.
    • pattern. Specifies a three digit status code or a wildcard pattern such as 400, 3**, or 50*.
endpoint.http.target Specifies HTTP target properties.

This section includes:

  • timeout. Defines the response timeout.
  • url. Sets the backend URL.
  • urlType. Defines how the URL is interpreted.
  • followRedirects. Controls redirect handling.
  • persistentConnections. Reuses persistent TCP connections.
  • chunkedUpload. Controls chunked upload behavior.
  • decompressResponse. Controls response decompression.
  • compressRequest. Applies compression to outgoing requests. Available options are Gzip, Brotli, Deflate, or None.
  • tlsClientProfile. Sets the TLS client profile.
  • version. Sets the HTTP protocol version.
extensions.webm-gateway Provides gateway specific configuration.

This section includes:

  • apiVersion. Defines the API version for the extension.
  • spec.endpoint. Specifies gateway level endpoint parameters. This section includes:
    • http.target.connectionTimeout. Specifies the time in milliseconds to establish a connection to the target service.
    • http.target.nativeServiceTimeout. Specifies the time in milliseconds to wait for a response from the target service after the connection is established.
  • spec.endpoint.sslConfig. Specifies SSL configuration for gateway initiated calls. This section includes:
    • keyStoreAlias. Sets the keystore alias used for TLS.
    • keyAlias. Sets the private key alias.
    • trustStoreAlias. Sets the truststore alias.
  • spec.endpoint.serviceRegistryParameters. Defines discovery parameters used by the gateway. This section includes:
    • name. Sets the parameter name.
    • value. Sets the parameter value.