Skip to content

Managing common API Policies

Following actions on common API Policies are allowed by apictl.

  1. List common API Policies in an environment.
  2. Export a common API Policy in an environment.
  3. Import a common API Policy to an environment.
  4. Delete a common API Policy in an environment.

Add common API Policies in an environment

You can add common API Policies via the Publisher Portal. For more information, see Create API Policy via Publisher Portal. However, WSO2 API Controller (apictl) allows you to create API Policies without using the Publisher Portal.

Get common API Policies in an environment

Follow the instructions below to display a list of common API Policies in an environment using apictl:

  1. Make sure that the WSO2 API Manager (WSO2 API-M) is started and that the relevant version of apictl is set up.
    For more information, see Download and Initialize the apictl.
  2. Log in to the WSO2 API-M in the environment by following the instructions in Login to an Environment.
  3. Run the corresponding apictl command below to get (list) common API Policies in an environment.

    • Get API common Policies in an environment.

      • Command

        apictl get policies api -e <environment>
        
        apictl get policies api --environment <environment>
        
        apictl get policies api --environment <environment> --all 
        

        Info

        Flags:

        • Required :
          --environment or -e : Environment to be searched
        • Optional :
          --all: All common API Policies available in the environment
          --limit or -l : Maximum number of common API Policies to return (Default 25)
          --format : pretty-print common API Policies using Go templates

        Note

        When executing the apictl get policies api command, using both the --all and --limit flags at once is not allowed.

        Example

        apictl get policies api -e dev 
        
        apictl get policies api --environment production --limit 15 
        
        apictl get policies api --environment production
        
        apictl get policies api --environment production --all 
        

      • Response

        ID                                     NAME                       DISPLAY NAME                VERSION             CATEGORY            APPLICABLE FLOWS           SUPPORTED GATEWAYS        SUPPORTED API TYPES
        0d254577-566d-4277-8104-8e764d10dbca   ccCallInterceptorService   Call Interceptor Service    v1                  Mediation           [request response]         [ChoreoConnect]           [HTTP]
        4bfdb007-5cf4-461d-8360-d89e3c8765f2   setToHeader                Set To Header               v1                  Mediation           [request]                  [Synapse]                 [HTTP]
        bcc2b759-f78b-4680-bf99-505f921c6e5e   addQueryParam              Add Query Param             v1                  Mediation           [request]                  [Synapse ChoreoConnect]   [HTTP]
        3660df5e-2776-4128-bbf0-34e76436bfdd   CustomLogPolicy            Custom Log Policy           v1                  Mediation           [request]                  [Synapse]                 [HTTP SOAP]
        3a61542f-4acf-41b7-9b63-c50dc37234d6   CustomLogPolicy            Custom Log Policy           v2                  Mediation           [request fault]            [Synapse ChoreoConnect]   [HTTP SOAP SOAPTOREST]
        

        Tip

        When using the get policies api command, --all optional flag can be used to get all available common API Policies.

        Note

        Output of the get policies api command can be formatted with Go Templates. For more information on formatting the get commands, see Formatting the outputs of get commands.

Delete a common API Policy in an environment

Follow the instructions below to delete a common API Policy in an environment using apictl:

  1. Make sure that the WSO2 API-M is started and that the corresponding version of apictl is set up.
    For more information, see Download and Initialize the apictl.
  2. Log in to the WSO2 API-M in the environment by following the instructions in Login to an Environment.
  3. Run the corresponding apictl command below to delete a common API Policy in an environment.

    1. Delete a common API Policy in an environment.

      • Command

        apictl delete policy api -n <common API Policy name> -v <common API Policy version> -e <environment>
        
        apictl delete policy api --name <common API Policy name> --version <common API Policy version> --environment <environment> 
        

        Info

        Flags:

        • Required :
          --environment or -e : Environment from which the common API Policy should be deleted
          --name or -n : Name of the common API Policy to be deleted
          --version or -v : Version of the common API Policy to be deleted

        Example

        apictl delete policy api -n addHeader -v v1 -e dev
        
        apictl delete policy api --name addHeader --version v1 --environment production 
        

      • Response

        addHeader common API Policy with the version v1 deleted successfully!