Adding an API State Change Workflow

This section let's see how to add a simple approval workflow to control the API state changes in WSO2 API Manager. Before you begin, see Workflow Extensions to get more information on the different types of workflow executors, and also to get a better understanding on the API states, see API Lifecycle.

Engaging the Approval Workflow Executor in API Manager

  1. Enable the API state change workflow for the Approval Workflow Executor.

    1. Sign in to the API-M management console (https://<Server Host>:9443/carbon).

    2. Click ResourcesBrowse.

      Resources Browse Menu

    3. Go to the /_system/governance/apimgt/applicationdata/workflow-extensions.xml resource.

    4. Disable the Simple Workflow Executor and enable the Approval Workflow Executor.

      <WorkFlowExtensions>
          ....
      <!--APIStateChange executor="org.wso2.carbon.apimgt.impl.workflow.APIStateChangeSimpleWorkflowExecutor" /-->
      <APIStateChange executor="org.wso2.carbon.apimgt.impl.workflow.APIStateChangeApprovalWorkflowExecutor">
          <Property name="stateList">Created:Publish,Published:Block</Property>
      </APIStateChange>
          ....
      </WorkFlowExtensions>

      You have now engaged the API state change approval Workflow. The default configuration is set to the following state changes.

      • Created to Publish

      • Published to Block

      For information on configuring more state changes, see Advanced Configurations.

  2. Trigger an API state change request.

    1. Sign in to the API Publisher (https://<Server-Host>:9443/publisher) and publish an API.

    For more information, see Create a REST API and Publish an API.

    1. Click Lifecycle.

    A message related to the publish workflow will be displayed because the workflow is enabled for Created to Publish state change.

    Lifecycle change pending

    Info

    Note that the publish button will be disabled in the overview page until the workflow task is completed or deleted. Publish Disabled

    1. Optionally, you can revoke the state change by clicking Delete Task.

      Delete pending task

  3. Approve or reject the API state change pending request.

    1. Sign in to the Admin Portal (https://<Server Host>:9443/admin)

    2. Click TasksAPI State Change.

      The list of API state change tasks awaiting for approval appears.

    3. Click on Approve or Reject to approve or reject the pending API state change request(s).

      API state change pending list

  4. View the outcome of the updated API state change request.

    1. Navigate to the API Publisher (https://<Server-Host>:9443/publisher).

    2. Click Lifecycle.

      Notice that the API state is updated.

      • If the request was approved, it will update the API state to the new state.
      • If the request was rejected, the status will stay unchanged.

      API state change updated list

    Info

    Changes that correspond to the API state can be easily viewed through the Lifecycle page. Lifecycle State

Advanced Configurations

The elements of the above configuration are explained below.

Element Name Mandatory/Optional Description
processDefinitionKey Mandatory Business Process Modeling Notation (BPMN) process definition ID.  BPMN process provided with AM as default has APIStateChangeApprovalProcess as the ID.
stateList Mandatory This is a comma-separated list of the current state and intended action. For example, Created:Publish,Published:Block
serviceEndpoint Optional The URL of the BPMN process engine. This overrides the global <ServerUrl> value from the api-manager.xml file. This can be used to connect a separate workflow engine for a tenant.
username Optional Username for the external BPMN process engine. This overrides the value of the <ServerUser> element that is defined in the api-manager.xml file of the tenant.
password Optional Password for the external BPMN process engine. This overrides the value of the <ServerPassword> element that is defined in the api-manager.xml file of the tenant.
Top