Add API to Policy Manager

Learn how to add a simple API to the Policy Manager Management Console, configure associated Policies and Contracts, and send a test request.

Table of Contents

Introduction

Learn how to add a simple API to the Policy Manager Management Console, configure associated Policies and Contracts, and send a test request.

Step 1: Install and Configure Policy Manager

Install and configure Policy Manager.

Refer to the applicable installation instructions; go to Installing the Akana API Platform.

Step 2: Add API to Policy Manager

This example uses the Swagger Petstore API, available at http://petstore.swagger.io/. The JSON for this API is available at http://petstore.swagger.io/v2/swagger.json. To keep it simple, we will just register the Get Pet by ID operation at http://petstore.swagger.io/#/pet/getPetById.

There are three main steps:

Add Organization

  1. Log in to the Policy Manager Management Console.
  2. From the Organization Tree, click Registry.
  3. From the Actions Portlet on the right, click Add Organization.
  4. Indicate where you'd like to place the organization on the Organization Tree. Click Next.
  5. Give your organization a name, as shown below.

    Add Organization in PM

  6. click Finish, and then click Close.

Register API

  1. From the Organization Tree, click on the organization you created.
  2. From the Actions Portlet on the right, click Create Physical Service.
  3. Select the Create Without Using Service Descriptor Document option and click Next.
  4. On the Service Details, specify the following, then click Next.
    • Name—The name of the API.
    • QName and Localpart—in the Advanced Options section. This information is used internally by the system to uniquely route to a service or API. If you don't specify values, they are assigned automatically.
  5. On Schema Import Options, select Use Existing Schemas and click Next.
  6. Click Add Operation. Specify an optional name and description and click Next.
  7. The Operation Details page gives you the opportunity to specify Schema elements/types for your operation. For simplicity's sake, under Schemas, click >> to assign anyType to Input and "Output. Leave Fault blank, and click Next to continue.
  8. On the Configure HTTP Binding Properties page, choose the following and click Next. Add the following values, shown in the illustration below:
    • Method—This example uses the getPetbyId operation.
    • Path—This is the path for your operation. You can also use regular expressions. For more information, refer to the help panel to the left of the page.

    Adding the operation details

  9. Next, choose how you would like to manage the Service (API). Select Manage through a Virtual Service option. This will create a proxy service that is hosted in the container. Click Next.
  10. In Virtual Service Provider Organization, ensure that the correct organization is selected and click Next.
  11. Select the container that you created when registering the Network Director and click Next.
  12. Select the first Access Point in the list. Provide a name and click Next.
  13. In HTTP Details, enter a Location; for example, /posts.
  14. Click Finish, and then click Close.

When you've finished, you'll have two services: a physical service and a virtual service.

Add Access Point to Physical Service

  1. From the Organization Tree, select Organization > Services of the physical API you're registering.
  2. Select the Access Points tab and click Add Access Point.
  3. Leave all defaults for the Service Details and Binding Details.
  4. Add a WSDL Port Name and click Next.
  5. Under the HTTP Details section, enter the API web address for our example: http://demo.akana-dev.net:3005/posts in the Location field and click Finish.

Step 3: Configure Policies

Next you will configure your APIs with the policies you want Akana to enforce.

  1. From the Organization Tree, select the organization you’d like to apply the policies to.
  2. Click Policies. In the Operational section of the Policy Attachments Portlet click Manage. For our example, we will set up an operational policy. The choices are:
    • Compliance checks that the service is compliant with your set of standards.
    • Operations does security and monitoring for the service.
    • QoS (Quality of Service) does things like ensure availability, speed, etc.
  3. From the Manage Operation Attachments window, click Policies > Operational Policies.
  4. Choose DetailedAuditing then click Apply.

You can find all descriptions of the policies in the Organization Tree.

Step 4: Create Contracts

A contract gives someone (typically another application,) authorization to access an API.

  1. From the Organization Tree, select your organization.
  2. Click Offer Contract from the Actions Portlet. The Add Contract Wizard launches.
  3. Enter the contract details.
  4. In the Access Controls, select the anonymous contract option (i.e., second option) and click Next.
  5. Select the Provider Organization and click Finish.

Your contract is now in draft mode. Next you must activate it:

  1. Navigate the Organization Tree to find your Organization. In the Contracts folder find your contract.
  2. Scroll down to the Consumers section. You'll see your contract in Draft state.
  3. Click on the contract. In this example, it shows as Anonymous.
  4. Review the contract, then in the Contracts Actions Portlet click Activate Contract, and then click OK.

Step 5: Send Test Request

To send a test request, you will need the endpoint.

  1. You can find this in the Policy Manager Organization Tree, under {specific Organization} > Services > API.
  2. Select the Access Points tab.
  3. Find the URL, and then copy the URL and paste into a browser window. You should get a successful response.
  4. Verify that the requests are coming through by checking the audit logs. You can see the logs by selecting the organization, then the API. From the API page, click Monitoring > Logs. You'll see request details.

Auditing Use Cases

The following detailed use cases illustrate how to perform basic or detailed auditing of an entire message and view the message metrics in Policy Manager.