Mendix for Private Cloud Build API
Introduction
The Mendix for Private Cloud Build API allows you to manage deployment packages which can later be used in the environments deployed in your private cloud. You can use the API to do the following:
- Retrieve all deployment packages of an application
- Retrieve a single deployment package based on the package ID
- Upload deployment package in an application
- Create deployment packages based on the branch and revision
- Delete a deployment package
Using the API
To help you work with the Mendix for Private Cloud Build API, the following sections of this document describe how to authenticate for the API, and how to manage asynchronous API calls.
Authentication
Authentication for the API uses a personal access token (PAT).
Generating a PAT
You can generate a PAT in the Developer Settings section of your Mendix Profile. For details, see the Personal Access Tokens section of Mendix Profile.
Select the following as scopes:
mx:privatecloud-build:read
– to performGET
operationsmx:privatecloud-build:write
– to perform all operations (GET
,POST
andDELETE
)mx:modelrepository:write
– underModel Repository
– to perform build package operation
Store the {GENERATED_PAT}
in a safe location, so you can use it to authorize your Mendix for Private Cloud API calls.
Scopes Explanation
Operation | Scopes |
---|---|
Build deployment package | mx:privatecloud-build:write and mx:modelrepository:write |
Upload deployment package | mx:privatecloud-build:write |
Delete deployment package | mx:privatecloud-build:write |
Get deployment package | mx:privatecloud-build:read or mx:privatecloud-build:write |
Get deployment package list | mx:privatecloud-build:read or mx:privatecloud-build:write |
Get Job | mx:privatecloud-build:read or mx:privatecloud-build:write |
Using the PAT
Each request must contain an Authorization
header with the value MxToken {GENERATED_PAT}
.
To authenticate calls when using the Open API specification below, click Authorize and use the value MxToken {GENERATED_PAT}
.
Managing Asynchronous Jobs
All resource manipulation API calls are processed asynchronously. In the response, there is an id
which you can use with the GET /jobs/…
call to get the status of the asynchronous job.
Each asynchronous call will also return a Location
header that references the URL where the result of that job can be found, for example, https://privatecloud.mendixcloud.com/api/v3/jobs/59464c21-0558-47a9-8d3d-ccc7057dc359
. This can be used as an alternative to GET /jobs/…
.
Once GET /jobs/…
or the equivalent HTTP call returns a response with "status": "finished"
, you can verify the manifest for the resource by using a GET {RESOURCE}
API call. For example, when updating a cluster, you can use GET /clusters/{clusterId}
to verify the cluster manifest.
Examples
The following sections of this document contain sample usage scenarios for the API.
Using the API to Build, Download and Delete a Deployment Package
The following steps will create a deployment package, retrieve it, refresh its URL
, download it, delete it and, in the end, list all available deployment packages of an application.
- Set up your authentication PAT.
- Call
GET /apps/{appId}/packages
to retrieve all the deployment packages in the application. - Prepare the JSON request for your deployment package, as seen in the OpenAPI specification file.
- Make the API call
POST /apps/{appId}/packages/build
using the deployment package JSON request to initiate the build of a new deployment package. - Verify that the job is successful using the process described in Managing Asynchronous Jobs.
- Call
GET /apps/{appId}/packages
to retrieve all the packages in the application. - Once the job that you launched in step 4 is successful, you will see a
id
in the response from Step 6. You can then callGET /apps/{appId}/packages/{id}
to get the deployment package details. The sameid
can the be used in step 12 from the DeployAPI documentation. - Call
GET /apps/{appId}/packages
to retrieve all the deployment packages in the application. You should see the previously created deployment package in the list. - If you want to download the deployment package locally, you can use the location URL present in the response from step 7. The URL has a lifetime of 15 minutes, so if more than 15 minutes have passed since the creation of the deployment package, you must request a new URL by calling
GET /apps/{appId}/packages/{id}?url=true
. - Call
DELETE /apps/{appId}/id
, where you can get the package ID value from step 7. - Verify that the job is successful using the process described in Managing Asynchronous Jobs.
- Call
GET /apps/{appId}/packages
to retrieve all the deployment packages in the application. The deployment package should be removed from the list.
Main line
and the build operation fails, try setting the branch to trunk
in the JSON request body for the Build Deployment Package endpoint.
Using the API to Upload a Deployment Package
Follow the steps below to upload a deployment package by using the API.
- Set up your authentication PAT.
- Prepare the
multipart/form-data
request for your deployment package, as seen in the OpenAPI specification file. Thefile
indicates the .mda file of the deployment package that you want to upload, andfileName
represents the name with which the deployment package will be displayed in the Private Cloud Portal. If you do not provide the .mda extension to the filename, it is added automatically. - Make the API call
POST /apps/{appId}/packages
using the request created in the previous step to upload the new deployment package. - Verify that the job is successful using the process described in Managing Asynchronous Jobs.
- Once the previous job is successful, you will see a
id
in the response. You can then callGET /apps/{appId}/packages/{id}
to get the deployment package details and verify the uploaded file. You can use the sameid
when deploying an app through the Mendix for Private Cloud Deploy API.