Kony Fabric console User Guide: Kony Fabric Command Line Utility - Continuous Integration > Continuous Integration with MobileFabric APIs

Continuous Integration with Kony Fabric APIs

In the section, you can learn about the Continuous Integration (CI) capabilities by using APIs supported by Kony Fabric. Without using Kony Fabric Console, developers can automate the process of importing an app, exporting an app, and publishing an app by using APIs supported in CI. The details of the APIs are captured in the subsequent sections.

The following are two ways of publishing apps in Kony Fabric:

The following APIs are supported for continuous integration of an app:

  1. Fetch the Auth Token - Get Authentication Token Information via API
  2. Export and App - Export the Kony Fabric App From Console via API
  3. Import an App - Import a Kony Fabric App (.zip file) via API
  4. Publish via API

Fetch the Auth Token

To fetch the claims token, invoke the Auth service login API and extract the “claims_token”.”value” from the response.

The API helps you log in as a management user and get back session token that can be used for invoking management APIs.

A successful response includes a session token.

If a user's credentials are incorrect, the log-in fails, and the system generates an HTTP 401 error.

Signature

 https://accounts.auth.konycloud.com/login

Sample cURL Script

 
token="$(curl -H "Accept: application/json" --data "userid=[abc@kony.com]&password=[pwd]" -X POST "https://accounts.auth.konycloud.com/login" | awk -F 'claims_token.*?value":"' '{print $2}' | awk -F '",' '{print $1}')"

Method

POST

Request Headers

Form post parameters

Sample Response:

 Login Success Response (HTTP Response Code 200 OK):
{
    "profile": {
        "email": "",
        "userid": "",
        "firstname": "",
        "lastname": ""
    },
    "refresh_token": "{refresh_token}", 
    "claims_token": {
        "value": "{session_token}",
        "exp": 1402941484000 /* expiry time of session in seconds since epoch */
    }
}

Sample error response: (HTTP Response Code 401 Unauthorized):
{
    "domain": "AUTH",
    "code": -4,
    "mfcode": "Auth-4",
    "message": "Invalid User Credentials",
    "details": {
        "message": "Invalid User Credentials",
        "errcode": 0,
        "errmsg": "Invalid User Credentials"
    },
    "requestid": "77cf1b1b-3bc5-4d73-84ec-806dcd60cf56",
    "httpstatus": "Unauthorized"
}

Export an App

The Apps Export API helps you export all the services and properties of Kony Fabric custom application from a specified workspace.

When you call the Apps Export API, the system exports the application in Export app structure.

Signature

 https:// {workspaceid}.workspace.konycloud.com/api/v1/ws/{workspaceid}/apps/export?appName={appName}

Sample cURL Script

 
token="$(curl -H "Accept: application/json" --data "userid=[abc@kony.com]&password=[pwd]" -X POST "https://accounts.auth.konycloud.com/login" | awk -F 'claims_token.*?value":"' '{print $2}' | awk -F '",' '{print $1}')"

Method

GET

Request Query Parameters (Mandatory)

Request Headers Parameters (Mandatory)

X-Kony-Authorization : {Auth Service Token}

Response:

Import an App

The App Import API in Workspace service imports the App configuration in the package in a zip file (application zip). An application zip has app configuration, services, and messaging configuration. While importing, if these details are already present in the app, these details will be updated. Otherwise, these details are created.

Signature

 https:// {workspaceid}.workspace.konycloud.com/api/v1/ws/{workspaceid}/apps/import?appName={appName}

Sample cURL Script

 
curl -F "appZip=@C:/Users/KH1895/Desktop/file.zip" -H "X-Kony-Authorization:[auth token]" -X POST " https:// [workspaceid].workspace.konycloud.com/api/v1/ws/[workspaceid]/apps/import"

curl -F "appZip=@C:/Users/KH1895/Desktop/file.zip" -H "X-Kony-Authorization:[auth token]" -X POST " https:// [workspaceid].workspace.konycloud.com/api/v1/ws/[workspaceid]/apps/import?appName=[app name]&suppressWarnings=true"

Method

POST

Request Query Parameters (Mandatory)

Request Query Parameters (Optional)

Request Headers (Mandatory)

X-Kony-Authorization : {Auth Service Token}

Request Body

 Content-Type : multipart/form-data
{
   "appZip" : < Zip file content of the app. The zip file needs to be in this format >
}

Response

Publish via APIs

Publishing a Kony Fabric app is a multi-step workflow. During publishing an app, the next_step object in the response of the publish API decides whether the next step to be executed.

  1. Fetch Environment GUID of an Environment via API
  2. Fetch App ID of the Imported Kony Fabric App via API
  3. Publish a Kony Fabric App via API

  4. Unpublish a Kony Fabric App via API

Fetch Environment Globally Unique Identifier (GUID)

To publish or unpublish an app to or from an environment, the environment must be uniquely identified through a GUID. To retrieve a GUID of an environment, call the following API and extract the “environment_guid” of the relevant one.

The API fetches the details of the environments that a user can access.

The environment_guid value retrieved from the response of the API and will be used for publishing or unpublishing an app.

Signature

 https://manage.kony.com/api/v1_0/environments

Method

GET

Request Headers Parameters (Mandatory)

Response:

Fetch App Globally Unique Identifier (GUID)

This API fetches the list of apps.

Signature

 https://{workspaceid}.workspace.konycloud.com/api/v1/ws/{workspaceid}/apps

Method

GET

Request Query Parameters (Mandatory)

Request Headers Parameters (Mandatory)

Response:

Publish a Kony Fabric App via API

Initiate Publish

The API helps you start publishing the services inside the application to an environment with the environment  id {env_guid}  that you received. For more details on how to get the environment  ID, refer to Fetch Environment GUID.

When you call this API, the system starts publishing the app, and locks the app from publishing by different users until the publish completes or fails.

Signature

 https://api.kony.com/api/v1_0/environments/{env_guid}/publish

Method

POST

Request Headers (Mandatory)

Request Headers (Optional)

Request Body

 Mandatory

app_id : Id of the Application to be published. For details on how to fetch the app id, refer to Fetch App ID
 
Optional

action : release_lock (This action releases the previous locks on the app before attempting publish). If the action parameter is not provided, the value will be set to start by default.

Response

Continue Publish

The API helps you continue publishing the services inside the application to an environment with the id {env_guid}  a user can access. For more details on how to get the id {env_guid}, refer to Fetch Environment GUID.

Signature

 https://api.kony.com/api/v1_0/environments/{env_guid}/publish/{publish_id}

Method

PUT

Request Headers (Mandatory)

Request Headers (Optional)

Request Body

 
Optional

action : cancel | continue ( Default value is “continue” )

Response

Unpublish

Similar to publish, unpublishing of a Kony Fabric app is a multi-step workflow. During unpublishing an app, the next_step object in the response of the unpublish API decides whether the next step to be executed.

Initiate Unpublish

Signature

 https://api.kony.com/api/v1_0/environments/{env_guid}/unpublish

Method

POST

Request Headers (Mandatory)

Request Headers (Optional)

Request Body

 
Mandatory

app_id : Id of the Application to be published. For details on how to fetch the app id, refer to Fetch App ID
 
Optional

action : release_lock (This action releases the previous locks on the app before attempting publish). If the action parameter is not provided, the value will be set to unpublish by default.

Response

Continue Unpublish

The API helps you to continue unpublishing the services inside the application to an environment with the id {env_guid} that the user can access. For more details on how to get the  id {env_guid}, refer to Fetch Environment GUID.

Signature

 https://api.kony.com/api/v1_0/environments/{env_guid}/unpublish/{publish_id}

Method

PUT

Request Headers (Mandatory)

Request Headers (Optional)

Request Body

 
Optional

action : cancel | continue ( Default value is “continue” )

Response

Copyright © 2020 Kony, Inc. All rights reserved.