NOTE: This is an advanced instruction for manipulating MyST using the REST APIs. Take a backup of the database before performing any direct manipulations using the API.
If you are looking to create or configure any MyST component using REST API, this guide will help you to achieve. In this guide, you would know how to use Development Tools of our Browser to get respective REST APIs MyST studio invokes to its backend service to create components. We will then make use of Jenkins (which in turn uses shell commands) to GET/POST data to MyST studio.
In this example, we explain how to create Stream types using the REST API. At a minimum you will require curl
to be installed on your machine. To make JSON manipulation easier, it is also recommended to install jq
which is downloadable from here.
In order to interact with API, you will first need to retrieve and/or regenerate an API key from MyST Studio. This can be performed as follows:
In order to POST data to MyST studio, we need URL and payload that needs to be posted which will be creating our resources. This can be performed as follows:
In order to reuse the source payload to create Multiple Stream Types, we parameterize the fields which we pass when we create manually. Below steps guide the procedure:
Create a FreeStyle Jenkins Job with Name “Stream Type Creation”
Add two parameters “Name” and “Description”
In the Build section add a Execute shell which will publish Stream Type Data to MyST studio using curl commands as below:
StreamTypeData='{"name":"'${Name}'","description":"'${Description}'"}'
curl -k -X POST -H "Content-type:application/json" -H "Authorization: Bearer ${MYST_STUDIO_API_KEY}" -d "$StreamTypeData" ${MYST_STUDIO_URL}/api/v1/release-management/stream-types"
Save the job.
Click Build with Parameters to build the job and provide “Name” and “Description”. Press Build.
The Job will post the Data to MyST Studio and Stream Type will be created successfully
Verify the resource created in MyST Studio.
For more information on REST APIs used in MyST, please refer MyST Studio REST API