Mendix Platform SDK
The Mendix Platform SDK can be used to call Mendix Platform APIs.
It also integrates with the Mendix Model SDK for working on temporary
online working copies of Mendix projects.
At the moment, the Platform SDK implements the following functionality:
- Creating a new app,
- Deleting an app,
- Creating a temporary working copy for editing an app model using the Mendix Model SDK,
- Committing the changes to a temporary working copy back to the Mendix Team Server.
Obtaining a Personal Access Token
To use the Mendix Platform SDK, you need a Personal Access Token with the right scopes.
Go to Warden to create a Personal Access Token.
Warning: Do not put the Personal Access Token inside your source code! Instead, pass it to your script using an environment variable. The Platform SDK automatically tries to get the Personal Access Token from the environment variable MENDIX_TOKEN.
Creating a script
TODO
npm install mendixplatformsdk mendixmodelsdk
.
Using the API
Here is a small example script that shows the main APIs of the Platform SDK.
import { MendixPlatformClient } from "mendixplatformsdk";
async function main() {
const client = new MendixPlatformClient();
const app = await client.createNewApp("My First App");
const workingCopy = await app.createTemporaryWorkingCopy("main");
const model = await workingCopy.openModel();
console.log("All modules in the model:");
for (const module of model.allModules()) {
console.log(` * ${module.name}`);
}
model.allModules()[0].name = "RenamedModule";
await model.flushChanges();
await workingCopy.commitToTeamServer();
await app.delete();
}
main().catch(error => {
console.log("ERROR: An error occurred.", error);
process.exit(1);
})