Get in touch: info@samuelfair.com

The operation switch logic policy – Digital Transformation with IBM API Connect-1

The operation switch policy is used to separate the programming logic by the HTTP operation verb (POST, GET, PUT, DELETE, and so on). By splitting it this way, it provides you with the opportunity to supplement each operation with additional policies, such as security or transformations. Before we implement the operational switch, let’s review where the operations are set up by looking at a completed example:

  1. Log in to your API Manager.
  2. Choose the Develop APIs and products title.
  3. Click the Add button and choose the API.
  4. Click on Import Existing OpenAPI and select Evidence-swagger.json.

Your file will be uploaded as follows:

Figure 6.35 – Uploaded Evidence API

5. Now click on Evidence API and navigate to Paths. It is under Paths that you can create a new path and assign HTTP methods:

Figure 6.36 – Paths are where you add HTTP methods

You can see the paths already created in this API. These RESTful paths were created using the FHIR specifications on how you interact with an FHIR server.

6. Locate /Evidence{id} in the Paths menu list, and expand it and Operations to see what operations have been set:

Figure 6.37 – Operations defined for /Evidence{id}

In Figure 6.37, you can see the plus sign (next to Operations) button visible on the right. This is how you will add new operations. Go ahead and click on the button to see how you would accomplish it:

Figure 6.38 – Adding an operation

As you can see, there is a dropdown that has all the operations not currently added. You can choose any of the other operations and provide a description of that operation.

7. Choose patch and click Create:

Figure 6.39 – patch added to the operations

You will now see PATCH added on the left menu under Operations. You are required to add a response for the PATCH operation. Expand PATCH and you will see Responses.

8. Click on the plus sign (next to Responses) to add a response.

This pops up a new page to add details about the operation:

Figure 6.40 – A response code is required for patch

The default is the 200 HTTP response code. You’ll accept this default and click Create. Ensure you enter a descriptive message, such as Success. Click Create to create the response code.

9. Next, you will define the response schema returned with your 200 response code:

Figure 6.41 – Create a new schema for the 200 HTTP code

In the Schema section, click on Create to define a new schema. There are two method tabs to choose from. The first is Definition. When you choose Definition, you create the schema from scratch. You can add a title and a description, but you must select a type. Since the response is a simple text response, you will select string. The other option is Reference. Since our imported API already has existing definitions, we want to choose this. Click on Reference:

Figure 6.42 – Choose an existing schema definition

Leave a Reply

Your email address will not be published. Required fields are marked *