Skip to content

Commit

Permalink
Merge pull request #1195 from balena-io/add-application-class-paramet…
Browse files Browse the repository at this point in the history
…er-to-create-app

Add applicationClass parameter to application create function for setting is_of__class property
  • Loading branch information
bulldozer-balena[bot] authored Feb 16, 2022
2 parents a4fddc8 + 03572ea commit a946f59
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/models/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ const getApplicationModel = function (
* @param {Object} options - application creation parameters
* @param {String} options.name - application name
* @param {String} [options.applicationType] - application type slug e.g. microservices-starter
* @param {String} [options.applicationClass] - application class: 'app' | 'fleet' | 'block'
* @param {String} options.deviceType - device type slug
* @param {(Number|String)} [options.parent] - parent application name or id
* @param {(String|Number)} options.organization - handle (string) or id (number) of the organization that the application will belong to or null
Expand All @@ -647,6 +648,11 @@ const getApplicationModel = function (
* });
*
* @example
* balena.models.application.create({ name: 'My Block', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) {
* console.log(application);
* });
*
* @example
* balena.models.application.create({ name: 'My App', applicationType: 'microservices', deviceType: 'raspberry-pi', parent: 'ParentApp' }).then(function(application) {
* console.log(application);
* });
Expand All @@ -660,12 +666,14 @@ const getApplicationModel = function (
async create({
name,
applicationType,
applicationClass,
deviceType,
parent,
organization,
}: {
name: string;
applicationType?: string;
applicationClass?: 'app' | 'fleet' | 'block';
deviceType: string;
parent?: number | string;
organization: number | string;
Expand Down Expand Up @@ -773,6 +781,10 @@ const getApplicationModel = function (
body.organization = organizationId;
}

if (applicationClass) {
body.is_of__class = applicationClass;
}

return await pine.post({
resource: 'application',
body,
Expand Down

0 comments on commit a946f59

Please sign in to comment.