Use the operation-switch construct when you want to execute alternative policy assemblies, conditional on the operation that is being called.
|DataPower® Gateway (v5 compatible)||1.0.0|
|DataPower API Gateway||2.0.0|
This topic describes how to configure the policy in your OpenAPI source; for details on how to configure the policy in the assembly user interface, see operation-switch.
An operation can be described with a
path pair, or with an
operationIds are strings, or names, that are
defined in the OpenAPI document.
- operation-switch: version: version title: title description: description case: - operations: - verb: operation_verb_1_1 path: operation_path_1_1 - verb: operation_verb_1_2 path: operation_path_1_2 . . . further verb/path combinations . . . execute: policy_assembly_1 ... - operations: - verb: operation_verb_2_1 path: operation_path_2_1 - verb: operation_verb_2_2 path: operation_path_2_2 . . . further verb/path combinations . . . execute: policy_assembly_2 ... . . . - operations: - operationID_3_1 - operationID_3_2 - operationID_3_3 . . . further operationIDs . . . execute: policy_assembly_3 ... . . . further operations sections . . .
operations: section, if the operation that is being called matches any
path combinations or
strings listed in that
operations: section, then the policy assembly that is
defined in the
execute: section is executed. Therefore, each
operations: section defines execution of a policy assembly conditional on the
operation that is being called.
You can have as many
operations: sections as you want, and each
operations: section can have one or more
path combinations or
execute: section can define any policy assembly, including further operation-switch policies.
|Property||Required||Description||Data type||Contained in|
|version||Yes||The policy version number||string||N/A|
|title||No||A title for the policy.||string||N/A|
|description||No||A policy description.||string||N/A|
|case||Yes||An array containing different cases, each entry contains an operations and execute field.||array (object)||N/A|
|operations||Yes||The operations to which a case applies.||object||case|
|verb||No||An operation verb.
|path||No||A relative path to an individual endpoint. For example,
|operationID||No||The operation is defined in OpenAPI. The policy operation refers to the OpenAPI operation.||string||operations|
|execute||Yes||The policy assembly that you want to execute if the operation that is being called matches any one of the verb/path combinations. For more information, see execute.||string||case|
# carry out different redaction actions depending on the operation - operation-switch: version: 1.0.0 title: clear_region_and_set_body case: - operations: - verb: GET path: /account_details execute: - redact: title: remove secret field actions: - action: remove from: all path: /document/user/secret - operations: - verb: GET path: /account_status execute: - redact: title: redact address actions: - action: redact from: response path: //*[@name='secondaryAddress']/*[@name='streetAddress']
# match on operationIDs - operation-switch: title: customer_actions case: - operations: - getCustomerByName - deleteCustomer - addACustomer execute: . . .