Set
Sets or updates context variables used later in the flow.
Use the Set policy to assign or update context variables that can be referenced later in the assembly flow.
For more information on the policy parameter descriptions, see DataPower Nano Gateway documentation.
Example of a Set policy in code view.
apiVersion: api.ibm.com/v1
kind: Set
metadata:
name: set-customer-name-var
namespace: lwgw
spec:
messageHeader:
action: 'add' # 'combine' | 'set' | 'add'
headerName: "organisation"
value: "${request.query.QUERY_NAME}"
messageName: "request" # Name of the message to set. For example: request or response
valueType: 'webm-var-expression' # "webm-var-expression | plain | variables" and webm-var-expression is applicable only for webM
---
apiVersion: api.ibm.com/v1
kind: Set
metadata:
name: set-message-body
namespace: lwgw
spec:
messageBody:
messageName: "request" # Name of the message to set. For example: request or response
value: "example-value" # Value to set on the specified message element. Interpreted based on valueType
valueType: "plain"
---
apiVersion: api.ibm.com/v1
kind: Set
metadata:
name: set-message-header
namespace: lwgw
spec:
messageHeader:
action: 'set'
headerName: "X-Custom-Header"
value: "example-value" # Value to set on the specified message element. Interpreted based on valueType
messageName: "request" # Name of the message to set. For example: request or response
valueType: "plain"
---
apiVersion: api.ibm.com/v1
kind: Set
metadata:
name: set-message-method
namespace: lwgw
spec:
messageMethod:
messageName: "request" # Name of the message to set. For example: request or response
method: "GET"
valueType: 'plain' # plain | variables
---
apiVersion: api.ibm.com/v1
kind: Set
metadata:
name: set-message-uri
namespace: lwgw
version: 1.0
spec:
messageUri:
messageName: "request" # Name of the message to set. For example: request or response
nameType: "plain" # plain | variables | jsonata
path: "/path" # Path value to set on the message URI
queryParams:
- name: "QUERY_NAME"
value: "VALUE"
valueType: 'plain' # plain | variables | jsonata
---
apiVersion: api.ibm.com/v1
kind: Set
metadata:
name: set-message-variable
namespace: lwgw
version: 1.0
spec:
variable:
name: "sample-variable-name"
value: "example-value" # Value to set on the specified message element. Interpreted based on valueType
valueType: 'plain' # plain | variables | jsonata
---
apiVersion: api.ibm.com/v1
kind: Set
metadata:
name: set-distribute-variable
namespace: lwgw
version: 1.0
spec:
distributedVariable:
expire: 0 # integer
name: 'example-name'
setExclusive: false
value: "example-value" # Value to set on the specified message element. Interpreted based on valueType
valueType: 'plain' # plain | variables | jsonata
---
apiVersion: api.ibm.com/v1
kind: Set
metadata:
name: set-telemetry
namespace: lwgw
version: 1.0
spec:
telemetry:
key: "sample-telemetry-key"
# (1/3) rootSpan
span: "rootSpan"
# # (2/3) policySpan
# span:
# policySpan: ""
# # (3/3) httpSpan
# span:
# httpSpan: ""
value: "sample-telemetry-value"
valueType: 'plain' # plain | variables | jsonata