Importing a user-defined policy into a Catalog

Create a catalog-scoped, user-defined policy that can be used in API assemblies within the catalog where the policy is published.

About this task

Note: In API Connect, this feature is available only with the advanced plan.

A published catalog-scoped policy can only be used with APIs in the same catalog. Complete the following tasks to define, package and publish the catalog-scoped policy.

Procedure

  1. Create a YAML file that describes the new catalog-scoped policy.
    1. Create a file named <policyname>.yaml.
    2. Paste the following content into the new file:
      attach:
      - rest
      - soap
      policy: 1.0.0
      info:
        title: <policyname>
        name: <policyname>
        version: 1.0.0
        description: <description-here>
      properties:
        $schema: 'http://json-schema.org/draft-04/schema#'
        type: object
        properties:
          exampleProperty:
            label: Test Property
            description: Enter any value
            type: string
          exampleProperty2:
            label: Another Test Property
            description: Enter any value
            type: string
        required:
          - exampleProperty2
      gateways:
      - datapower-api-gateway
    3. Modify the content as needed to correctly describe your new catalog-scoped policy.
    4. Save and close the file.
  2. Create a new zip file called <policyname>.zip that contains the new YAML file.
  3. Publish the new policy that uses either the toolkit CLI or the API Manager:
    • API Connect toolkit CLI:

      Use the apic policies:create command to publish the gateway extension (see toolkit CLI reference documentation).

    • API Manager:

      Complete the following steps to publish the new policy:

      1. Log in to API Manager.
      2. Click Manage Catalogs > Select Catalog > Gateways > selected_gateway > Actions icon > View policies and upload your new policy.zip file.
  4. Verify that the new catalog-scoped policy is available in the API Assembler's Policy palette.
    1. In API Manager, select the Catalog where you published the new catalog-scoped policy.
    2. Create an API.
    3. Click Settings icon (next to Save) and for the Target Catalog, select the catalog where you published the new policy.
    4. Save the API.
    5. Open the API Assembler page and view the Policy palette. Verify that your new catalog-scoped policy displays and can be added to the API.