This documentation is for WSO2 API Manager 2.6.0. View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Organizations Importing Endpoint CertificatesOrganizations can have multiple environments like Development, Testing, QA, Staging, Production with own instance of API Managers. These environments often have different configurations for APIs.

...

  1. Create a file called api_params.yaml inside your SwaggerPetstore directory. Open this api_params.yaml file in your favourite text editor.

  2. Adding environment-specific parameters for APIs is done via this file. We are going to change backends in the production environment to point for production endpoints

    Code Block
    languageyml
    environments: 
      - name: dev 
        endpoints: 
            production: 
                url: http://dev.wso2.com
            sandbox:
                url: http://dev.sandbox.wso2.com
      - name: prod
        endpoints:
            production:
                url: http://prod.wso2.com
            sandbox:
                url: http://prod.sandbox.wso2.com

    As you can see we have defined prod.wso2.com and prod.sandbox.wso2.com as backend URLs for the production environment.

    Info
    titleSetup Multiple Endpoints
    Setup Load Balancing Endpoints

    To setup load balancing endpoints, you need to specify the field loadBalanceEndpoints instead of the usual endpoints field in the api_params.yaml file. Under the loadBalanceEndpoints, you can specify the following fields.

    • production: An array which consists the multiple production endpoints
    • sandbox: An array which consists the multiple sandbox endpoints
    • sessionManagement: Values can be "none", "transport", "soap", "simpleClientSession" and if not specified the default value would be "transport"
    • sessionTimeout: The number of milliseconds after which the session would time out
    Code Block
    languageyml
    titleExample api_params.yaml for load balancing
    environments:
     - name: dev
       endpoints:
           production:
               url: http://dev.wso2.com
           sandbox:
               url: http://dev.sandbox.wso2.com
     - name: prod
       loadBalanceEndpoints:
           production:
               - url: http://prod.wso2.com
               - url: http://prod.next.wso2.com
               - url: http://prod.later.wso2.com
           sandbox:
               - url: http://prod.sandbox.wso2.com
               - url: http://prod.next.sandbox.wso2.com
    Setup Failover Endpoints

    To setup failover endpoints, you need to specify the field failoverEndpoints instead of the usual endpoints field in the api_params.yaml file. Under the failoverEndpoints, you can specify the following fields.

    • production: The primary production endpoint (not an array)
    • sandbox: The primary sandbox endpoint (not an array)
    • productionFailovers: An array which consists of failover production endpoints
    • sandboxFailovers: An array which consists failover sandbox endpoints
    Code Block
    languageyml
    titleExample api_params.yaml for failover
    environments:
      - name: dev
        endpoints:
            production:
            sandbox:
      - name: prod
        failoverEndpoints:
           production:
               url: http://prod.wso2.com
           productionFailovers:
               - url: http://prod.next.wso2.com
               - url: http://prod.later.wso2.com
           sandbox:
               url: http://prod.sandbox.wso2.com
           sandboxFailovers:
               - url: http://prod.sandbox.next.wso2.com
    Info
    titleAdvanced Endpoint Configurations
    Setting Up Advanced Endpoint Configurations

    You can set up advanced configurations related to endpoints by specifying the field config for the corresponding endpoint URL as shown with the below fields. (Note that, the only supported values for actionSelect is "discard" and "fault")

    Code Block
    languageyml
    titleExample for setting up advanced endpoint configurations in the api_params.yaml
    environments: 
      - name: prod
        endpoints:
            production:
                url: http://prod.wso2.com
                config: 
                    factor: 3
                    retryTimeOut: 13000
                    retryDelay: 23000
                    retryErroCode: 101504
                    actionSelect: discard
                    actionDuration: 75000
                    suspendErrorCode: 101504
                    suspendMaxDuration: 25000
                    suspendDuration: 45000
            sandbox:
                url: http://prod.sandbox.wso2.com
    Info
    titleImport Certificates
    Importing Endpoint Certificates

    You can import endpoint certificates using the api_params.yaml file by specifying the field certs. This field is an array where each item contains the following fields.

    • host: The endpoint URL which the certificate belongs to
    • alias: Alias for the certificate
    • path: File path to locate the certificate file
    Code Block
    languageyml
    titleExample api_params.yaml to import endpoint certificates
    environments:
      - name: dev
        endpoints:
            production:
            sandbox:
      - name: prod
        endpoints:
            production:
                url: http://prod1.wso2.com
            sandbox:
                url: http://prod2.wso2.com
        certs:
            - hostNamehost: https://prod1.wso2.com
              alias: Prod1
              path: ~/.certs/prod1.pem
            - hostNamehost: https://prod2.wso2.com
              alias: Prod2
              path: ~/.certs/prod2.pem 
    Importing Mutual SSL Certificates

    You can import Mutual SSL certificates using the api_params.yaml file by specifying the field mutualSslCerts. This field is an array where each item contains the following fields.

    • tierName: Name of the tier of the certificate
    • alias: Alias for the certificate
    • path: File path to locate the certificate file
    Code Block
    languageyml
    titleExample api_params.yaml to import mutual ssl certificates
    environments:
      - name: dev
        endpoints:
            production:
            sandbox:
      - name: prod
        endpoints:
            production:
                url: http://prod1.wso2.com
            sandbox:
                url: http://prod2.wso2.com
        mutualSslCerts:
            - tierName: Unlimited
              alias: Prod1
              path: ~/.certs/prod1.pem
            - tierName: Gold
              alias: Prod2
              path: ~/.certs/prod2.pem 
    Info
    titleEndpoint Security
    Setting Up Endpoint Security

    You can set up endpoint security by defining the field security. Under the security field, you can specify the following fields. 

    • enabled: If this is set to true you need to specify the below attributes as well. If this is false, then non of the security parameters will be set. If the enabled attribute is not set (blank), then the security parameters in api.yaml file will be considered.
    • type: Endpoint authentication type (can be either only basic or digest)
    • username: Endpoint username
    • password: Endpoint password
    Code Block
    languageyml
    titleExample api_params.yaml to set up endpoint security
    environments:
      - name: prod
        endpoints:
            production:
                url: http://prod1.wso2.com
            sandbox:
                url: http://prod2.wso2.com
        security:
        	enabled: true
            type: basic
            username: admin
            password: admin
    Info
    titleSubscription Policies/Tiers
    Setting Up Subscription Policies for an API

    You can set up subscription policies of an API by defining the field policies which is an array where you can list down the policy names that are needed to be enforced to the API. (Make sure that the policy/policies should be available in the environment. Otherwise, you will get an error.)

    Code Block
    languageyml
    titleExample api_params.yaml to set up subscription policies of an API
    environments:
      - name: prod
        endpoints:
            production:
                url: http://prod1.wso2.com
            sandbox:
                url: http://prod2.wso2.com
        policies:
        	- Gold
            - Silver
  3. Now we can commit this project to a version control system.

...