MAP policy in IBM APIC Assembly
Here in this blog, we will learn about MAP policy in the IBM APIC Assembly.
The Map policy structure
The Map policy relies on a specific structure defined within its OpenAPI definition to outline how the policy operates. This structure serves as a framework for defining inputs, outputs, actions, options, and other parameters that govern the behavior of the policy.
Map Policy contains the following sections:
- Structure
- Input and output definitions
- Actions
- Script
- Fields
- References to inputs and outputs
- Accessing other contexts
- Structure: The Map policy is organized into four main sections: inputs, outputs, actions, and options. These sections define how the policy operates.
- Input and Output Definitions: Inputs are the data the policy works with, while outputs are the results it produces. Each input and output is defined by its name, type, and where it comes from or goes to.
- Actions: Actions are the tasks the policy performs in a specific order. They include setting values, creating new ones, or using data from inputs.
- Options: These are settings that customize the behavior of the Map policy. For example, you can choose whether to include empty elements in the output or how to handle specific data types.
- References to Inputs and Outputs: The policy refers to inputs and outputs by their names or numbers to know which data to use or produce.
- Accessing Other Contexts: The policy can access information from the environment it’s running in, such as details about the API request. This helps it make decisions based on the situation.
- Fields: These are specific parts of actions that define what they do. For example, ‘set’ assigns a value to an output, ‘create’ adds a new entry to an array, and ‘from’ specifies where the input data comes from.
- Script: You can write custom behavior for actions. It’s like writing instructions for the policy to follow.
- References to Inputs and Outputs (repeated): This explains how you refer to inputs and outputs within the actions of the policy, using numbers or names to identify them.
- Accessing Other Contexts (repeated): It’s a reminder that the policy can access information about the API call it’s working with and how you can include variables from other contexts.
Implementation:
Step1: Open the APIC Manager login go to develop and click on developed API
Step2: Now click on Gateway and click on Policies
Step3: In the Filters, we can see the MAP policy drag it and put it in the Assembly
Step4: click on it we can see the options and configure it
In the definitions option we want to create the definitions which is present in API develop option (here below the mapping is done by adding 2 integers the 2 integers are mapped from input to do sum operation which is present at output )
Definitions configuration:
Step5: after configuring we click on the source code, it is a yml file the configuration that we have done we can see there
Step6: we want to test the required Api, so go to explore and click on post give the client ID and client secret, and test it with the required request