diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md
index 679dcac39..fe2ec52dc 100644
--- a/DOCUMENTATION.md
+++ b/DOCUMENTATION.md
@@ -367,6 +367,7 @@ const sdk = fromSharedOptions();
* [.download(options)](#balena.models.os.download) ⇒ Promise
* [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ Promise
* [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ Promise
+ * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ Promise
* [.getSupportedOsUpdateVersions(deviceType, currentVersion, [options])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ Promise
* [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ Boolean
* [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ Promise.<String>
@@ -409,6 +410,7 @@ const sdk = fromSharedOptions();
* [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ Promise
* [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ Promise
* [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ Promise
+ * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ Promise
* [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ Promise
* [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ Promise
* [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo)
@@ -774,6 +776,7 @@ balena.models.device.get(123).catch(function (error) {
* [.download(options)](#balena.models.os.download) ⇒ Promise
* [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ Promise
* [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ Promise
+ * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ Promise
* [.getSupportedOsUpdateVersions(deviceType, currentVersion, [options])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ Promise
* [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ Boolean
* [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ Promise.<String>
@@ -816,6 +819,7 @@ balena.models.device.get(123).catch(function (error) {
* [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ Promise
* [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ Promise
* [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ Promise
+ * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ Promise
* [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ Promise
* [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ Promise
* [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo)
@@ -4957,7 +4961,7 @@ balena.models.organization.membership.getAllByUser(123).then(function(membership
###### ~~membership.create(options) ⇒ Promise
~~
-***Deprecated***
+***use balena.models.organization.invite.create instead***
This method adds a user to an organization by their usename.
WARNING: This method is deprecated, use balena.models.organization.invite.create instead.
@@ -5267,6 +5271,7 @@ balena.models.organization.remove(123);
* [.download(options)](#balena.models.os.download) ⇒ Promise
* [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ Promise
* [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ Promise
+ * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ Promise
* [.getSupportedOsUpdateVersions(deviceType, currentVersion, [options])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ Promise
* [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ Boolean
* [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ Promise.<String>
@@ -5472,6 +5477,36 @@ balena.models.os.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2
console.log(isSupported);
});
```
+
+
+##### os.getOsUpdateType(deviceType, currentVersion, targetVersion) ⇒ Promise
+**Kind**: static method of [os
](#balena.models.os)
+**Summary**: Returns the OS update type based on device type, current and target balenaOS versions
+**Access**: public
+**Fulfil**: String
- Currently available types are:
+ - resinhup11
+ - resinhup12
+ - balenahup
+ - takeover
+
+ Throws error in any of these cases:
+ - Current or target versions are invalid
+ - Current or target versions do not match in dev/prod type
+ - Current and target versions imply a downgrade operation
+ - Action is not supported by device type
+
+| Param | Type | Description |
+| --- | --- | --- |
+| deviceType | String
| device type slug |
+| currentVersion | String
| semver-compatible version for the starting OS version |
+| targetVersion | String
| semver-compatible version for the target OS version |
+
+**Example**
+```js
+balena.models.os.getOsUpdateType('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(osUpdateType) {
+ console.log(osUpdateType);
+});
+```
##### os.getSupportedOsUpdateVersions(deviceType, currentVersion, [options]) ⇒ Promise
@@ -5590,7 +5625,7 @@ balena.models.config.getAll().then(function(config) {
##### ~~config.getDeviceTypes() ⇒ Promise
~~
-***Deprecated***
+***use balena.models.deviceType.getAll***
**Kind**: static method of [config
](#balena.models.config)
**Summary**: Get device types
@@ -5605,7 +5640,7 @@ balena.models.config.getDeviceTypes().then(function(deviceTypes) {
##### ~~config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise
~~
-***Deprecated***
+***use balena.models.deviceType.getBySlugOrName***
**Kind**: static method of [config
](#balena.models.config)
**Summary**: Get a device type manifest by slug
@@ -6349,6 +6384,7 @@ balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(func
* [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ Promise
* [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ Promise
* [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ Promise
+ * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ Promise
* [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ Promise
* [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ Promise
* [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo)
@@ -6410,6 +6446,26 @@ balena.models.billing.getBillingInfo(orgId).then(function(billingInfo) {
console.log(billingInfo);
});
```
+
+
+##### billing.createSetupIntent(setupIntentParams) ⇒ Promise
+**Kind**: static method of [billing
](#balena.models.billing)
+**Summary**: Create a Stripe setup intent required for setting billing information
+**Access**: public
+**Fulfil**: Object
- partial stripe setup intent object
+
+| Param | Type | Description |
+| --- | --- | --- |
+| setupIntentParams | Object
| an object containing the parameters for the setup intent creation |
+| extraParams.organization | String
\| Number
| handle (string) or id (number) of the target organization. |
+| [extraParams.'g-recaptcha-response'] | String
\| undefined
| the captcha response |
+
+**Example**
+```js
+balena.models.billing.createSetupIntent(orgId).then(function(setupIntent) {
+ console.log(setupIntent);
+});
+```
##### billing.updateBillingInfo(organization, billingInfo) ⇒ Promise
@@ -6424,6 +6480,7 @@ balena.models.billing.getBillingInfo(orgId).then(function(billingInfo) {
| billingInfo | Object
| an object containing a billing info token_id |
| billingInfo.token_id | String
| the token id generated for the billing info form |
| [billingInfo.'g-recaptcha-response'] | String
\| undefined
| the captcha response |
+| [billingInfo.token_type] | String
\| undefined
| token type |
**Example**
```js
diff --git a/src/models/os.ts b/src/models/os.ts
index 5e559496d..580f6530b 100644
--- a/src/models/os.ts
+++ b/src/models/os.ts
@@ -862,6 +862,47 @@ const getOsModel = function (
);
};
+ /**
+ * @summary Returns the OS update type based on device type, current and target balenaOS versions
+ * @name getOsUpdateType
+ * @public
+ * @function
+ * @memberof balena.models.os
+ *
+ * @param {String} deviceType - device type slug
+ * @param {String} currentVersion - semver-compatible version for the starting OS version
+ * @param {String} targetVersion - semver-compatible version for the target OS version
+ * @fulfil {String} - Currently available types are:
+ * - resinhup11
+ * - resinhup12
+ * - balenahup
+ * - takeover
+ *
+ * Throws error in any of these cases:
+ * - Current or target versions are invalid
+ * - Current or target versions do not match in dev/prod type
+ * - Current and target versions imply a downgrade operation
+ * - Action is not supported by device type
+ * @returns {Promise}
+ *
+ * @example
+ * balena.models.os.getOsUpdateType('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(osUpdateType) {
+ * console.log(osUpdateType);
+ * });
+ */
+ const getOsUpdateType = async (
+ deviceType: string,
+ currentVersion: string,
+ targetVersion: string,
+ ): Promise => {
+ deviceType = await _getNormalizedDeviceTypeSlug(deviceType);
+ return hupActionHelper().getHUPActionType(
+ deviceType,
+ currentVersion,
+ targetVersion,
+ );
+ };
+
/**
* @summary Returns the supported OS update targets for the provided device type
* @name getSupportedOsUpdateVersions
@@ -1088,6 +1129,7 @@ const getOsModel = function (
download,
getConfig,
isSupportedOsUpdate,
+ getOsUpdateType,
getSupportedOsUpdateVersions,
isArchitectureCompatibleWith,
getSupervisorReleasesForCpuArchitecture,