From e59cbfb65feb880859d47a1e7f37e17bb839ec63 Mon Sep 17 00:00:00 2001 From: Matthew Yarmolinsky Date: Tue, 26 May 2026 11:35:24 -0400 Subject: [PATCH] TEST NODE SDK LINK CLEANUP, DO NOT MERGE Change-type: patch --- .../includes/balena-example-projects.md | 172 +- .../.gitbook/includes/balena-labs-projects.md | 50 +- pages/SUMMARY.md | 116 +- pages/external-docs/sdk/node-sdk/latest.md | 10835 ---------------- .../sdk/node-sdk/latest/README.md | 1 + .../external-docs/sdk/node-sdk/latest/auth.md | 497 + .../sdk/node-sdk/latest/errors.md | 24 + .../sdk/node-sdk/latest/fromSharedOptions.md | 18 + .../sdk/node-sdk/latest/getSdk.md | 22 + .../sdk/node-sdk/latest/interceptors.md | 68 + .../sdk/node-sdk/latest/introduction.md | 59 + .../external-docs/sdk/node-sdk/latest/logs.md | 179 + .../sdk/node-sdk/latest/models/README.md | 1 + .../sdk/node-sdk/latest/models/apiKey.md | 242 + .../sdk/node-sdk/latest/models/application.md | 1956 +++ .../sdk/node-sdk/latest/models/billing.md | 339 + .../sdk/node-sdk/latest/models/config.md | 130 + .../node-sdk/latest/models/creditBundle.md | 74 + .../sdk/node-sdk/latest/models/device.md | 2986 +++++ .../sdk/node-sdk/latest/models/deviceType.md | 309 + .../sdk/node-sdk/latest/models/image.md | 68 + .../sdk/node-sdk/latest/models/key.md | 123 + .../node-sdk/latest/models/organization.md | 521 + .../sdk/node-sdk/latest/models/os.md | 523 + .../sdk/node-sdk/latest/models/release.md | 853 ++ .../sdk/node-sdk/latest/models/service.md | 243 + .../sdk/node-sdk/latest/models/team.md | 313 + .../external-docs/sdk/node-sdk/latest/pine.md | 25 + .../sdk/node-sdk/latest/request.md | 17 + .../sdk/node-sdk/latest/setSharedOptions.md | 68 + .../sdk/node-sdk/latest/settings.md | 52 + .../sdk/node-sdk/latest/utils.md | 18 + pages/external-docs/sdk/node-sdk/v20.9.1.md | 7145 ---------- .../sdk/node-sdk/v20.9.1/README.md | 1 + .../sdk/node-sdk/v20.9.1/auth.md | 497 + .../sdk/node-sdk/v20.9.1/errors.md | 24 + .../sdk/node-sdk/v20.9.1/fromSharedOptions.md | 18 + .../sdk/node-sdk/v20.9.1/getSdk.md | 22 + .../sdk/node-sdk/v20.9.1/interceptors.md | 68 + .../sdk/node-sdk/v20.9.1/introduction.md | 59 + .../sdk/node-sdk/v20.9.1/logs.md | 179 + .../sdk/node-sdk/v20.9.1/models/README.md | 1 + .../sdk/node-sdk/v20.9.1/models/apiKey.md | 242 + .../node-sdk/v20.9.1/models/application.md | 1956 +++ .../sdk/node-sdk/v20.9.1/models/billing.md | 339 + .../sdk/node-sdk/v20.9.1/models/config.md | 130 + .../node-sdk/v20.9.1/models/creditBundle.md | 74 + .../sdk/node-sdk/v20.9.1/models/device.md | 2986 +++++ .../sdk/node-sdk/v20.9.1/models/deviceType.md | 309 + .../sdk/node-sdk/v20.9.1/models/image.md | 68 + .../sdk/node-sdk/v20.9.1/models/key.md | 123 + .../node-sdk/v20.9.1/models/organization.md | 521 + .../sdk/node-sdk/v20.9.1/models/os.md | 523 + .../sdk/node-sdk/v20.9.1/models/release.md | 853 ++ .../sdk/node-sdk/v20.9.1/models/service.md | 243 + .../sdk/node-sdk/v20.9.1/models/team.md | 313 + .../sdk/node-sdk/v20.9.1/pine.md | 25 + .../sdk/node-sdk/v20.9.1/request.md | 17 + .../sdk/node-sdk/v20.9.1/setSharedOptions.md | 68 + .../sdk/node-sdk/v20.9.1/settings.md | 52 + .../sdk/node-sdk/v20.9.1/utils.md | 18 + pages/external-docs/sdk/node-sdk/v21.7.4.md | 7199 ---------- .../sdk/node-sdk/v21.7.4/README.md | 1 + .../sdk/node-sdk/v21.7.4/auth.md | 497 + .../sdk/node-sdk/v21.7.4/errors.md | 24 + .../sdk/node-sdk/v21.7.4/fromSharedOptions.md | 18 + .../sdk/node-sdk/v21.7.4/getSdk.md | 22 + .../sdk/node-sdk/v21.7.4/interceptors.md | 68 + .../sdk/node-sdk/v21.7.4/introduction.md | 59 + .../sdk/node-sdk/v21.7.4/logs.md | 179 + .../sdk/node-sdk/v21.7.4/models/README.md | 1 + .../sdk/node-sdk/v21.7.4/models/apiKey.md | 242 + .../node-sdk/v21.7.4/models/application.md | 1956 +++ .../sdk/node-sdk/v21.7.4/models/billing.md | 339 + .../sdk/node-sdk/v21.7.4/models/config.md | 130 + .../node-sdk/v21.7.4/models/creditBundle.md | 74 + .../sdk/node-sdk/v21.7.4/models/device.md | 2986 +++++ .../sdk/node-sdk/v21.7.4/models/deviceType.md | 309 + .../sdk/node-sdk/v21.7.4/models/image.md | 68 + .../sdk/node-sdk/v21.7.4/models/key.md | 123 + .../node-sdk/v21.7.4/models/organization.md | 521 + .../sdk/node-sdk/v21.7.4/models/os.md | 523 + .../sdk/node-sdk/v21.7.4/models/release.md | 853 ++ .../sdk/node-sdk/v21.7.4/models/service.md | 243 + .../sdk/node-sdk/v21.7.4/models/team.md | 313 + .../sdk/node-sdk/v21.7.4/pine.md | 25 + .../sdk/node-sdk/v21.7.4/request.md | 17 + .../sdk/node-sdk/v21.7.4/setSharedOptions.md | 68 + .../sdk/node-sdk/v21.7.4/settings.md | 52 + .../sdk/node-sdk/v21.7.4/utils.md | 18 + pages/external-docs/sdk/node-sdk/v22.4.9.md | 7431 ----------- .../sdk/node-sdk/v22.4.9/README.md | 1 + .../sdk/node-sdk/v22.4.9/auth.md | 497 + .../sdk/node-sdk/v22.4.9/errors.md | 24 + .../sdk/node-sdk/v22.4.9/fromSharedOptions.md | 18 + .../sdk/node-sdk/v22.4.9/getSdk.md | 22 + .../sdk/node-sdk/v22.4.9/interceptors.md | 68 + .../sdk/node-sdk/v22.4.9/introduction.md | 59 + .../sdk/node-sdk/v22.4.9/logs.md | 179 + .../sdk/node-sdk/v22.4.9/models/README.md | 1 + .../sdk/node-sdk/v22.4.9/models/apiKey.md | 242 + .../node-sdk/v22.4.9/models/application.md | 1956 +++ .../sdk/node-sdk/v22.4.9/models/billing.md | 339 + .../sdk/node-sdk/v22.4.9/models/config.md | 130 + .../node-sdk/v22.4.9/models/creditBundle.md | 74 + .../sdk/node-sdk/v22.4.9/models/device.md | 2986 +++++ .../sdk/node-sdk/v22.4.9/models/deviceType.md | 309 + .../sdk/node-sdk/v22.4.9/models/image.md | 68 + .../sdk/node-sdk/v22.4.9/models/key.md | 123 + .../node-sdk/v22.4.9/models/organization.md | 521 + .../sdk/node-sdk/v22.4.9/models/os.md | 523 + .../sdk/node-sdk/v22.4.9/models/release.md | 853 ++ .../sdk/node-sdk/v22.4.9/models/service.md | 243 + .../sdk/node-sdk/v22.4.9/models/team.md | 313 + .../sdk/node-sdk/v22.4.9/pine.md | 25 + .../sdk/node-sdk/v22.4.9/request.md | 17 + .../sdk/node-sdk/v22.4.9/setSharedOptions.md | 68 + .../sdk/node-sdk/v22.4.9/settings.md | 52 + .../sdk/node-sdk/v22.4.9/utils.md | 18 + tools/sync-external.js | 4 +- 120 files changed, 39137 insertions(+), 32731 deletions(-) delete mode 100644 pages/external-docs/sdk/node-sdk/latest.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/README.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/auth.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/errors.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/fromSharedOptions.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/getSdk.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/interceptors.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/introduction.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/logs.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/README.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/apiKey.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/application.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/billing.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/config.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/creditBundle.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/device.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/deviceType.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/image.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/key.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/organization.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/os.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/release.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/service.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/models/team.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/pine.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/request.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/setSharedOptions.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/settings.md create mode 100644 pages/external-docs/sdk/node-sdk/latest/utils.md delete mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/README.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/auth.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/errors.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/fromSharedOptions.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/getSdk.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/interceptors.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/introduction.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/logs.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/README.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/apiKey.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/application.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/billing.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/config.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/creditBundle.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/device.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/deviceType.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/image.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/key.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/organization.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/os.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/release.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/service.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/models/team.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/pine.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/request.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/setSharedOptions.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/settings.md create mode 100644 pages/external-docs/sdk/node-sdk/v20.9.1/utils.md delete mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/README.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/auth.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/errors.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/fromSharedOptions.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/getSdk.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/interceptors.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/introduction.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/logs.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/README.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/apiKey.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/application.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/billing.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/config.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/creditBundle.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/device.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/deviceType.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/image.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/key.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/organization.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/os.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/release.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/service.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/models/team.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/pine.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/request.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/setSharedOptions.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/settings.md create mode 100644 pages/external-docs/sdk/node-sdk/v21.7.4/utils.md delete mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/README.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/auth.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/errors.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/fromSharedOptions.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/getSdk.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/interceptors.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/introduction.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/logs.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/README.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/apiKey.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/application.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/billing.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/config.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/creditBundle.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/device.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/deviceType.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/image.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/key.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/organization.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/os.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/release.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/service.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/models/team.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/pine.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/request.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/setSharedOptions.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/settings.md create mode 100644 pages/external-docs/sdk/node-sdk/v22.4.9/utils.md diff --git a/pages/.gitbook/includes/balena-example-projects.md b/pages/.gitbook/includes/balena-example-projects.md index 84c3e12fa3..85bae34e38 100644 --- a/pages/.gitbook/includes/balena-example-projects.md +++ b/pages/.gitbook/includes/balena-example-projects.md @@ -1,88 +1,84 @@ ---- -title: balena-example-projects ---- - -| Name | Description | -| -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [balena-nodejs-hello-world](https://github.com/balena-io-examples/balena-nodejs-hello-world) | Example of how to deploy Node code on a balena supported device. | -| [balena-plant-saver](https://github.com/balena-io-examples/balena-plant-saver) | We're building a plant monitor (and saver) - this is the early stage | -| [multicontainer-getting-started](https://github.com/balena-io-examples/multicontainer-getting-started) | Get up and running quickly with a multicontainer setup on balena | -| [internetspeedtest](https://github.com/balena-io-examples/internetspeedtest) | Log your internet download, upload and ping metrics ti influxDB, and Grafana it. Grafana all the things! | -| [balena-python-hello-world](https://github.com/balena-io-examples/balena-python-hello-world) | Example of how to deploy Python code on a balena supported device. | -| [x11-window-manager](https://github.com/balena-io-examples/x11-window-manager) | Example project showing how to run a desktop manager with balenaCloud in order to run GUI applications. | -| [staged-releases](https://github.com/balena-io-examples/staged-releases) | demonstration scripts on how to use the resin.io API to do staged releases to a fleet of devices. | -| [coral-streaming-object-detector](https://github.com/balena-io-examples/coral-streaming-object-detector) | This example will help you deploy a streaming camera feed with realtime people detection using the Coral Edge TPU for on-device ML inferencing. | -| [balena-aws-lambda](https://github.com/balena-io-examples/balena-aws-lambda) | Associate balena devices with AWS IoT when they ping a lambda endpoint | -| [balena-storage](https://github.com/balena-io-examples/balena-storage) | Sample project to showcase storage mounting on balenaOS. | -| [jetson-examples](https://github.com/balena-io-examples/jetson-examples) | Sample container applications for Jetson devices | -| [balena-rust-hello-world](https://github.com/balena-io-examples/balena-rust-hello-world) | Example of how to deploy Rust code on a balena supported device. | -| [wifi-connect-api](https://github.com/balena-io-examples/wifi-connect-api) | Example Python web application that uses WiFi Connect's JSON API | -| [balena-aws-device](https://github.com/balena-io-examples/balena-aws-device) | Device portion of balena/AWS integration | -| [balena-go-hello-world](https://github.com/balena-io-examples/balena-go-hello-world) | Example of how to deploy Go code on a balena supported device. | -| [google-iot](https://github.com/balena-io-examples/google-iot) | Google Cloud IoT integration | -| [proxy-tunnel](https://github.com/balena-io-examples/proxy-tunnel) | Connecting your device(s) to balenaCloud from behind a compatible proxy. | -| [balena-timezone](https://github.com/balena-io-examples/balena-timezone) | Example of how to set the timezone within a container | -| [aws-iot-provision](https://github.com/balena-io-examples/aws-iot-provision) | Lambda function to provision a device with AWS IoT | -| [jetson-nano-sample-app](https://github.com/balena-io-examples/jetson-nano-sample-app) | Sample App with instructions for Jetson Nano | -| [device-cloud-logging](https://github.com/balena-io-examples/device-cloud-logging) | An example of using the journald log streaming endpoint on balena-supervisor | -| [balena-device-node-exporter](https://github.com/balena-io-examples/balena-device-node-exporter) | On-device node\_exporter | -| [balena-multiapp-project](https://github.com/balena-io-examples/balena-multiapp-project) | Sample project to demonstrate how to integrate several existing balena projects in one | -| [balena-electron](https://github.com/balena-io-examples/balena-electron) | A simple example of how to get an Electron application running on Balena | -| [community-cli-action](https://github.com/balena-io-examples/community-cli-action) | A community built GitHub action that allows you to use the balena CLI | -| [device-tags](https://github.com/balena-io-examples/device-tags) | Examples on how to use the balena API & SDK to set device tags from within your app. | -| [baletheus](https://github.com/balena-io-examples/baletheus) | Balena Service Discovery for Prometheus | -| [nginx-reverse-proxy](https://github.com/balena-io-examples/nginx-reverse-proxy) | Access multiple ports over public URL using nginx reverse proxy. | -| [balena-java-hello-world](https://github.com/balena-io-examples/balena-java-hello-world) | Hello Java in balena | -| [balena-datadog](https://github.com/balena-io-examples/balena-datadog) | Balena + Datadog Example Project | -| [balenalib-systemd-example](https://github.com/balena-io-examples/balenalib-systemd-example) | Example project using systemd with balenalib images | -| [balena-aws-iot-mqtt-example](https://github.com/balena-io-examples/balena-aws-iot-mqtt-example) | Sample project showing how to connect your Balena device to a AWS IoT MQTT broker | -| [balena-google-apps-script-sheet-skeleton](https://github.com/balena-io-examples/balena-google-apps-script-sheet-skeleton) | Skeleton template for google sheets projects. | -| [balena-ros2-CUDA-trt-pose-estimation](https://github.com/balena-io-examples/balena-ros2-CUDA-trt-pose-estimation) | An installation of ROS2 Eloquent in a container, with a full desktop environment, CUDA, PyTorch, OpenCV, and TensorRT ready to deploy computer vision ROS applications on balena devices. | -| [cloud-relay](https://github.com/balena-io-examples/cloud-relay) | Relay data to an IoT cloud provider via MQTT | -| [balena-cpp-hello-world](https://github.com/balena-io-examples/balena-cpp-hello-world) | Example of how to deploy C++ code on a balena supported device. | -| [example-build-secrets-and-variables](https://github.com/balena-io-examples/example-build-secrets-and-variables) | Example of build time secrets and variables on balenaCloud | -| [wifi-connect-custom-ui-example](https://github.com/balena-io-examples/wifi-connect-custom-ui-example) | An example on how to customize the captive portal of WiFi Connect | -| [balena-netdata](https://github.com/balena-io-examples/balena-netdata) | Netdata configuration for internal on-device monitoring | -| [balena-ros2-foxy-base](https://github.com/balena-io-examples/balena-ros2-foxy-base) | A basic installation of ROS2 Foxy in a container, ready to deploy on balena devices. | -| [hostapd-enterprise](https://github.com/balena-io-examples/hostapd-enterprise) | Resin multicontainer hostapd-powered access point with WPA-EAP (Enterprise) authentication | -| [nvidia-x86](https://github.com/balena-io-examples/nvidia-x86) | Example of using CUDA on an Nvidia GPU in an x86 device. | -| [balena-updates-lock](https://github.com/balena-io-examples/balena-updates-lock) | Example project of simple updates locking | -| [balena-idling](https://github.com/balena-io-examples/balena-idling) | Likely the most minimalist project to deploy on a balena device | -| [healthcheck-publicurl](https://github.com/balena-io-examples/healthcheck-publicurl) | Demo of Docker healthcheck functionality for a balena service (through public device URL) | -| [balena-aspnet-core](https://github.com/balena-io-examples/balena-aspnet-core) | A simple multi-container-ready project demonstrating the use of the Microsoft ASP.Net Core 2.2 framework | -| [coral-getting-started](https://github.com/balena-io-examples/coral-getting-started) | A getting started example project for Coral.ai on balenaCloud | -| [balena-nginx-hello-world](https://github.com/balena-io-examples/balena-nginx-hello-world) | Simple nginx example on balena | -| [ROS-AutonomousVehicle](https://github.com/balena-io-examples/ROS-AutonomousVehicle) | Sample project to show ROS autonomous vehicle running in a balena container. | -| [balena-ros2-foxy-desktop](https://github.com/balena-io-examples/balena-ros2-foxy-desktop) | An installation of ROS2 Foxy in a container, with a full desktop environment, ready to deploy on balena devices. | -| [balena-avahi](https://github.com/balena-io-examples/balena-avahi) | mDNS/.local resolution with Avahi within a container | -| [system-metrics](https://github.com/balena-io-examples/system-metrics) | Collect metrics on device performance and forward to MQTT | -| [network-metrics-logger](https://github.com/balena-io-examples/network-metrics-logger) | Log metrics on network I/O | -| [setup-balena-action](https://github.com/balena-io-examples/setup-balena-action) | Install the balena CLI in your GitHub Actions workflow | -| [balena-haskell-hello-world](https://github.com/balena-io-examples/balena-haskell-hello-world) | Example of how to deploy haskell code on a balena supported device. | -| [hostapd-minimal](https://github.com/balena-io-examples/hostapd-minimal) | Minimal hostapd access point example for resin.io | -| [meta-exporter](https://github.com/balena-io-examples/meta-exporter) | The People's Exporter | -| [sample-gcr-registry-secrets](https://github.com/balena-io-examples/sample-gcr-registry-secrets) | Sample balena push/deploy with Google Container Registry (GCR) private images | -| [google-coral-dev-sample](https://github.com/balena-io-examples/google-coral-dev-sample) | Sample Application running in container on BalenaOS, for the Google Coral Dev Board | -| [tx2-container-contracts-sample](https://github.com/balena-io-examples/tx2-container-contracts-sample) | Sample TX2 application with optional containers tied to device L4T version | -| [remote-local-logging](https://github.com/balena-io-examples/remote-local-logging) | Receiver of logs | -| [balena-cloudflare-tunnel](https://github.com/balena-io-examples/balena-cloudflare-tunnel) | A simple balenaBlock to route your application through Cloudflare Tunnel | -| [balena-zerotier-gateway](https://github.com/balena-io-examples/balena-zerotier-gateway) | Fully working ZeroTier container with IP forwarding an masquerading to the LAN. | -| [tx2-sample-app](https://github.com/balena-io-examples/tx2-sample-app) | Jetson TX2 Sample Application | -| [balena-c-hello-world](https://github.com/balena-io-examples/balena-c-hello-world) | Getting started with C on balena | -| [ruuvitag](https://github.com/balena-io-examples/ruuvitag) | Collect data from a ruuvitag BLE sensor and chart it in a dashboard | -| [balena-ts-node-hello-world](https://github.com/balena-io-examples/balena-ts-node-hello-world) | A simple TypeScript Node.js Express server | -| [balena-OpenVino](https://github.com/balena-io-examples/balena-OpenVino) | | -| [balena-hello-world-skeleton](https://github.com/balena-io-examples/balena-hello-world-skeleton) | A skeleton to use for your next balena hello world repostiory | -| [cb-gcp-iot-provision](https://github.com/balena-io-examples/cb-gcp-iot-provision) | Cloud function to provision a device with ClearBlade IoT on GCP | -| [test-bluetooth](https://github.com/balena-io-examples/test-bluetooth) | Test case for internal bluetooth on various boards (artik5, artik710 etc.) | -| [rpi3-alsa-test](https://github.com/balena-io-examples/rpi3-alsa-test) | Test case for 3.5 audio jack on the rpi3 | -| [alwaysai-starter-apps](https://github.com/balena-io-examples/alwaysai-starter-apps) | Sample project to showcase how to run alwaysAI starter apps in balenaOS. | -| [balena-poll-publicurl](https://github.com/balena-io-examples/balena-poll-publicurl) | Poll a device publicURL forever. | -| [jetson-nano-x11](https://github.com/balena-io-examples/jetson-nano-x11) | Jetson Nano X11 Example | -| [gcp-iot-provision](https://github.com/balena-io-examples/gcp-iot-provision) | Cloud function to provision a device with Google Cloud IoT | -| [azure-iot-provision](https://github.com/balena-io-examples/azure-iot-provision) | Azure function to provision a device with Azure IoT | -| [cloud-relay-starter](https://github.com/balena-io-examples/cloud-relay-starter) | Create a fleet to experiment with cloud IoT integrations using Cloud Relay block | -| [balena-hyperpixel4-square](https://github.com/balena-io-examples/balena-hyperpixel4-square) | Minimal example of using Hyperpixel4 Square w/touch on balena | -| [balena-multistage-dockerfile-example](https://github.com/balena-io-examples/balena-multistage-dockerfile-example) | How to leverage _multi-stage Dockerfile_ with _docker-compose.dev.yml_ to improve DX with balena. | -| [moby-balena-compare](https://github.com/balena-io-examples/moby-balena-compare) | Finds commits specific to Balena Engine inside Balena Engine repository | -| [release-assets-hello-world](https://github.com/balena-io-examples/release-assets-hello-world) | | +Name|Description +---|--- +[balena-nodejs-hello-world](https://github.com/balena-io-examples/balena-nodejs-hello-world)|Example of how to deploy Node code on a balena supported device. +[balena-plant-saver](https://github.com/balena-io-examples/balena-plant-saver)|We're building a plant monitor (and saver) - this is the early stage +[multicontainer-getting-started](https://github.com/balena-io-examples/multicontainer-getting-started)|Get up and running quickly with a multicontainer setup on balena +[internetspeedtest](https://github.com/balena-io-examples/internetspeedtest)|Log your internet download, upload and ping metrics ti influxDB, and Grafana it. Grafana all the things! +[balena-python-hello-world](https://github.com/balena-io-examples/balena-python-hello-world)|Example of how to deploy Python code on a balena supported device. +[x11-window-manager](https://github.com/balena-io-examples/x11-window-manager)|Example project showing how to run a desktop manager with balenaCloud in order to run GUI applications. +[staged-releases](https://github.com/balena-io-examples/staged-releases)|demonstration scripts on how to use the resin.io API to do staged releases to a fleet of devices. +[coral-streaming-object-detector](https://github.com/balena-io-examples/coral-streaming-object-detector)|This example will help you deploy a streaming camera feed with realtime people detection using the Coral Edge TPU for on-device ML inferencing. +[balena-aws-lambda](https://github.com/balena-io-examples/balena-aws-lambda)|Associate balena devices with AWS IoT when they ping a lambda endpoint +[balena-storage](https://github.com/balena-io-examples/balena-storage)|Sample project to showcase storage mounting on balenaOS. +[jetson-examples](https://github.com/balena-io-examples/jetson-examples)|Sample container applications for Jetson devices +[balena-rust-hello-world](https://github.com/balena-io-examples/balena-rust-hello-world)|Example of how to deploy Rust code on a balena supported device. +[wifi-connect-api](https://github.com/balena-io-examples/wifi-connect-api)|Example Python web application that uses WiFi Connect's JSON API +[balena-aws-device](https://github.com/balena-io-examples/balena-aws-device)|Device portion of balena/AWS integration +[balena-go-hello-world](https://github.com/balena-io-examples/balena-go-hello-world)|Example of how to deploy Go code on a balena supported device. +[google-iot](https://github.com/balena-io-examples/google-iot)|Google Cloud IoT integration +[proxy-tunnel](https://github.com/balena-io-examples/proxy-tunnel)|Connecting your device(s) to balenaCloud from behind a compatible proxy. +[balena-timezone](https://github.com/balena-io-examples/balena-timezone)|Example of how to set the timezone within a container +[aws-iot-provision](https://github.com/balena-io-examples/aws-iot-provision)|Lambda function to provision a device with AWS IoT +[jetson-nano-sample-app](https://github.com/balena-io-examples/jetson-nano-sample-app)|Sample App with instructions for Jetson Nano +[device-cloud-logging](https://github.com/balena-io-examples/device-cloud-logging)|An example of using the journald log streaming endpoint on balena-supervisor +[balena-device-node-exporter](https://github.com/balena-io-examples/balena-device-node-exporter)|On-device node_exporter +[balena-multiapp-project](https://github.com/balena-io-examples/balena-multiapp-project)|Sample project to demonstrate how to integrate several existing balena projects in one +[balena-electron](https://github.com/balena-io-examples/balena-electron)|A simple example of how to get an Electron application running on Balena +[community-cli-action](https://github.com/balena-io-examples/community-cli-action)|A community built GitHub action that allows you to use the balena CLI +[device-tags](https://github.com/balena-io-examples/device-tags)|Examples on how to use the balena API & SDK to set device tags from within your app. +[baletheus](https://github.com/balena-io-examples/baletheus)|Balena Service Discovery for Prometheus +[nginx-reverse-proxy](https://github.com/balena-io-examples/nginx-reverse-proxy)|Access multiple ports over public URL using nginx reverse proxy. +[balena-java-hello-world](https://github.com/balena-io-examples/balena-java-hello-world)|Hello Java in balena +[balena-datadog](https://github.com/balena-io-examples/balena-datadog)|Balena + Datadog Example Project +[balenalib-systemd-example](https://github.com/balena-io-examples/balenalib-systemd-example)|Example project using systemd with balenalib images +[balena-aws-iot-mqtt-example](https://github.com/balena-io-examples/balena-aws-iot-mqtt-example)|Sample project showing how to connect your Balena device to a AWS IoT MQTT broker +[balena-google-apps-script-sheet-skeleton](https://github.com/balena-io-examples/balena-google-apps-script-sheet-skeleton)|Skeleton template for google sheets projects. +[balena-ros2-CUDA-trt-pose-estimation](https://github.com/balena-io-examples/balena-ros2-CUDA-trt-pose-estimation)|An installation of ROS2 Eloquent in a container, with a full desktop environment, CUDA, PyTorch, OpenCV, and TensorRT ready to deploy computer vision ROS applications on balena devices. +[cloud-relay](https://github.com/balena-io-examples/cloud-relay)|Relay data to an IoT cloud provider via MQTT +[balena-cpp-hello-world](https://github.com/balena-io-examples/balena-cpp-hello-world)|Example of how to deploy C++ code on a balena supported device. +[example-build-secrets-and-variables](https://github.com/balena-io-examples/example-build-secrets-and-variables)|Example of build time secrets and variables on balenaCloud +[wifi-connect-custom-ui-example](https://github.com/balena-io-examples/wifi-connect-custom-ui-example)|An example on how to customize the captive portal of WiFi Connect +[balena-netdata](https://github.com/balena-io-examples/balena-netdata)|Netdata configuration for internal on-device monitoring +[balena-ros2-foxy-base](https://github.com/balena-io-examples/balena-ros2-foxy-base)|A basic installation of ROS2 Foxy in a container, ready to deploy on balena devices. +[hostapd-enterprise](https://github.com/balena-io-examples/hostapd-enterprise)|Resin multicontainer hostapd-powered access point with WPA-EAP (Enterprise) authentication +[nvidia-x86](https://github.com/balena-io-examples/nvidia-x86)|Example of using CUDA on an Nvidia GPU in an x86 device. +[balena-updates-lock](https://github.com/balena-io-examples/balena-updates-lock)|Example project of simple updates locking +[balena-idling](https://github.com/balena-io-examples/balena-idling)|Likely the most minimalist project to deploy on a balena device +[healthcheck-publicurl](https://github.com/balena-io-examples/healthcheck-publicurl)|Demo of Docker healthcheck functionality for a balena service (through public device URL) +[balena-aspnet-core](https://github.com/balena-io-examples/balena-aspnet-core)|A simple multi-container-ready project demonstrating the use of the Microsoft ASP.Net Core 2.2 framework +[coral-getting-started](https://github.com/balena-io-examples/coral-getting-started)|A getting started example project for Coral.ai on balenaCloud +[balena-nginx-hello-world](https://github.com/balena-io-examples/balena-nginx-hello-world)|Simple nginx example on balena +[ROS-AutonomousVehicle](https://github.com/balena-io-examples/ROS-AutonomousVehicle)|Sample project to show ROS autonomous vehicle running in a balena container. +[balena-ros2-foxy-desktop](https://github.com/balena-io-examples/balena-ros2-foxy-desktop)|An installation of ROS2 Foxy in a container, with a full desktop environment, ready to deploy on balena devices. +[balena-avahi](https://github.com/balena-io-examples/balena-avahi)|mDNS/.local resolution with Avahi within a container +[system-metrics](https://github.com/balena-io-examples/system-metrics)|Collect metrics on device performance and forward to MQTT +[network-metrics-logger](https://github.com/balena-io-examples/network-metrics-logger)|Log metrics on network I/O +[setup-balena-action](https://github.com/balena-io-examples/setup-balena-action)|Install the balena CLI in your GitHub Actions workflow +[balena-haskell-hello-world](https://github.com/balena-io-examples/balena-haskell-hello-world)|Example of how to deploy haskell code on a balena supported device. +[hostapd-minimal](https://github.com/balena-io-examples/hostapd-minimal)|Minimal hostapd access point example for resin.io +[meta-exporter](https://github.com/balena-io-examples/meta-exporter)|The People's Exporter +[sample-gcr-registry-secrets](https://github.com/balena-io-examples/sample-gcr-registry-secrets)|Sample balena push/deploy with Google Container Registry (GCR) private images +[google-coral-dev-sample](https://github.com/balena-io-examples/google-coral-dev-sample)|Sample Application running in container on BalenaOS, for the Google Coral Dev Board +[tx2-container-contracts-sample](https://github.com/balena-io-examples/tx2-container-contracts-sample)|Sample TX2 application with optional containers tied to device L4T version +[remote-local-logging](https://github.com/balena-io-examples/remote-local-logging)|Receiver of logs +[balena-cloudflare-tunnel](https://github.com/balena-io-examples/balena-cloudflare-tunnel)|A simple balenaBlock to route your application through Cloudflare Tunnel +[balena-zerotier-gateway](https://github.com/balena-io-examples/balena-zerotier-gateway)|Fully working ZeroTier container with IP forwarding an masquerading to the LAN. +[tx2-sample-app](https://github.com/balena-io-examples/tx2-sample-app)|Jetson TX2 Sample Application +[balena-c-hello-world](https://github.com/balena-io-examples/balena-c-hello-world)|Getting started with C on balena +[ruuvitag](https://github.com/balena-io-examples/ruuvitag)|Collect data from a ruuvitag BLE sensor and chart it in a dashboard +[balena-ts-node-hello-world](https://github.com/balena-io-examples/balena-ts-node-hello-world)|A simple TypeScript Node.js Express server +[balena-OpenVino](https://github.com/balena-io-examples/balena-OpenVino)| +[balena-hello-world-skeleton](https://github.com/balena-io-examples/balena-hello-world-skeleton)|A skeleton to use for your next balena hello world repostiory +[cb-gcp-iot-provision](https://github.com/balena-io-examples/cb-gcp-iot-provision)|Cloud function to provision a device with ClearBlade IoT on GCP +[test-bluetooth](https://github.com/balena-io-examples/test-bluetooth)|Test case for internal bluetooth on various boards (artik5, artik710 etc.) +[rpi3-alsa-test](https://github.com/balena-io-examples/rpi3-alsa-test)|Test case for 3.5 audio jack on the rpi3 +[alwaysai-starter-apps](https://github.com/balena-io-examples/alwaysai-starter-apps)|Sample project to showcase how to run alwaysAI starter apps in balenaOS. +[balena-poll-publicurl](https://github.com/balena-io-examples/balena-poll-publicurl)|Poll a device publicURL forever. +[jetson-nano-x11](https://github.com/balena-io-examples/jetson-nano-x11)|Jetson Nano X11 Example +[gcp-iot-provision](https://github.com/balena-io-examples/gcp-iot-provision)|Cloud function to provision a device with Google Cloud IoT +[azure-iot-provision](https://github.com/balena-io-examples/azure-iot-provision)|Azure function to provision a device with Azure IoT +[cloud-relay-starter](https://github.com/balena-io-examples/cloud-relay-starter)|Create a fleet to experiment with cloud IoT integrations using Cloud Relay block +[balena-hyperpixel4-square](https://github.com/balena-io-examples/balena-hyperpixel4-square)|Minimal example of using Hyperpixel4 Square w/touch on balena +[balena-multistage-dockerfile-example](https://github.com/balena-io-examples/balena-multistage-dockerfile-example)|How to leverage _multi-stage Dockerfile_ with _docker-compose.dev.yml_ to improve DX with balena. +[moby-balena-compare](https://github.com/balena-io-examples/moby-balena-compare)|Finds commits specific to Balena Engine inside Balena Engine repository +[release-assets-hello-world](https://github.com/balena-io-examples/release-assets-hello-world)| diff --git a/pages/.gitbook/includes/balena-labs-projects.md b/pages/.gitbook/includes/balena-labs-projects.md index 6320e928be..a99604cf4c 100644 --- a/pages/.gitbook/includes/balena-labs-projects.md +++ b/pages/.gitbook/includes/balena-labs-projects.md @@ -1,27 +1,23 @@ ---- -title: balena-labs-projects ---- - -| Name | Description | -| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | -| [balena-dash](https://github.com/balena-labs-projects/balena-dash) | Build a Raspberry Pi based desktop dashboard for stats, photos, videos and more! | -| [balena-sense](https://github.com/balena-labs-projects/balena-sense) | Take readings from a BME680 or similar sensor on a Raspberry Pi, store with InfluxDB and view with Grafana | -| [wifi-repeater](https://github.com/balena-labs-projects/wifi-repeater) | Easily create a WiFi Access Point or WiFi repeater with balenaOS | -| [balena-cam](https://github.com/balena-labs-projects/balena-cam) | Network Camera with Raspberry Pi and WebRTC. Tutorial: | -| [rosetta-at-home](https://github.com/balena-labs-projects/rosetta-at-home) | | -| [balena-node-red](https://github.com/balena-labs-projects/balena-node-red) | a node-red application with balena-supervisor support, can be managed remotely via balena publicURL | -| [bluetooth](https://github.com/balena-labs-projects/bluetooth) | Optimized bluetooth agent for balenaOS. Based on BlueZ 5.0. | -| [dashboard](https://github.com/balena-labs-projects/dashboard) | Grafana dashboard block with auto-visualization of InfluxDB databases to get your data visualized instantly! | -| [xserver](https://github.com/balena-labs-projects/xserver) | A simple X11 server block | -| [connector](https://github.com/balena-labs-projects/connector) | Auto-configured data connector block based on Telegraf | -| [sensor](https://github.com/balena-labs-projects/sensor) | Auto-detects connected i2c sensors and published data on HTTP or MQTT. | -| [fbcp](https://github.com/balena-labs-projects/fbcp) | fbcp driver for SPI based displays for Raspberry Pis via fbcp-ili9341 | -| [project-template](https://github.com/balena-labs-projects/project-template) | Project template for new Balena projects | -| [multiroom](https://github.com/balena-labs-projects/multiroom) | Set up multiroom audio for your fleet of devices. Uses the Snapcast audio player. | -| [log2screen](https://github.com/balena-labs-projects/log2screen) | | -| [dbus](https://github.com/balena-labs-projects/dbus) | | -| [pulse](https://github.com/balena-labs-projects/pulse) | A block for counting pulses on a Raspberry Pi GPIO pin. | -| [browsercontrol](https://github.com/balena-labs-projects/browsercontrol) | | -| [video-capture](https://github.com/balena-labs-projects/video-capture) | Provide an RTSP stream for a connected video source. | -| [logwatcher](https://github.com/balena-labs-projects/logwatcher) | | -| [lockr-block](https://github.com/balena-labs-projects/lockr-block) | Create or remove application update locks with the return code of any command. | +Name|Description +---|--- +[balena-dash](https://github.com/balena-labs-projects/balena-dash)|Build a Raspberry Pi based desktop dashboard for stats, photos, videos and more! +[balena-sense](https://github.com/balena-labs-projects/balena-sense)|Take readings from a BME680 or similar sensor on a Raspberry Pi, store with InfluxDB and view with Grafana +[wifi-repeater](https://github.com/balena-labs-projects/wifi-repeater)|Easily create a WiFi Access Point or WiFi repeater with balenaOS +[balena-cam](https://github.com/balena-labs-projects/balena-cam)|Network Camera with Raspberry Pi and WebRTC. Tutorial: +[rosetta-at-home](https://github.com/balena-labs-projects/rosetta-at-home)| +[balena-node-red](https://github.com/balena-labs-projects/balena-node-red)|a node-red application with balena-supervisor support, can be managed remotely via balena publicURL +[bluetooth](https://github.com/balena-labs-projects/bluetooth)|Optimized bluetooth agent for balenaOS. Based on BlueZ 5.0. +[dashboard](https://github.com/balena-labs-projects/dashboard)|Grafana dashboard block with auto-visualization of InfluxDB databases to get your data visualized instantly! +[xserver](https://github.com/balena-labs-projects/xserver)|A simple X11 server block +[connector](https://github.com/balena-labs-projects/connector)|Auto-configured data connector block based on Telegraf +[sensor](https://github.com/balena-labs-projects/sensor)|Auto-detects connected i2c sensors and published data on HTTP or MQTT. +[fbcp](https://github.com/balena-labs-projects/fbcp)|fbcp driver for SPI based displays for Raspberry Pis via fbcp-ili9341 +[project-template](https://github.com/balena-labs-projects/project-template)|Project template for new Balena projects +[multiroom](https://github.com/balena-labs-projects/multiroom)|Set up multiroom audio for your fleet of devices. Uses the Snapcast audio player. +[log2screen](https://github.com/balena-labs-projects/log2screen)| +[dbus](https://github.com/balena-labs-projects/dbus)| +[pulse](https://github.com/balena-labs-projects/pulse)|A block for counting pulses on a Raspberry Pi GPIO pin. +[browsercontrol](https://github.com/balena-labs-projects/browsercontrol)| +[video-capture](https://github.com/balena-labs-projects/video-capture)|Provide an RTSP stream for a connected video source. +[logwatcher](https://github.com/balena-labs-projects/logwatcher)| +[lockr-block](https://github.com/balena-labs-projects/lockr-block)|Create or remove application update locks with the return code of any command. diff --git a/pages/SUMMARY.md b/pages/SUMMARY.md index 07d3dea20e..e7cccde4bd 100644 --- a/pages/SUMMARY.md +++ b/pages/SUMMARY.md @@ -343,10 +343,118 @@ * [v22.5.5](external-docs/balena-cli/v22.5.5.md) * [SDK](reference/sdk/README.md) * [Node SDK](reference/sdk/node-sdk/README.md) - * [v23.2.0 (latest)](external-docs/sdk/node-sdk/latest.md) - * [v22.4.9](external-docs/sdk/node-sdk/v22.4.9.md) - * [v21.7.4](external-docs/sdk/node-sdk/v21.7.4.md) - * [v20.9.1 (DEPRECATED)](external-docs/sdk/node-sdk/v20.9.1.md) + * [v23.2.0 (latest)](external-docs/sdk/node-sdk/latest/README.md) + * [Introduction](external-docs/sdk/node-sdk/latest/introduction.md) + * [Auth](external-docs/sdk/node-sdk/latest/auth.md) + * [Errors](external-docs/sdk/node-sdk/latest/errors.md) + * [FromSharedOptions](external-docs/sdk/node-sdk/latest/fromSharedOptions.md) + * [GetSdk](external-docs/sdk/node-sdk/latest/getSdk.md) + * [Interceptors](external-docs/sdk/node-sdk/latest/interceptors.md) + * [Logs](external-docs/sdk/node-sdk/latest/logs.md) + * [Models](external-docs/sdk/node-sdk/latest/models/README.md) + * [ApiKey](external-docs/sdk/node-sdk/latest/models/apiKey.md) + * [Application](external-docs/sdk/node-sdk/latest/models/application.md) + * [Billing](external-docs/sdk/node-sdk/latest/models/billing.md) + * [Config](external-docs/sdk/node-sdk/latest/models/config.md) + * [CreditBundle](external-docs/sdk/node-sdk/latest/models/creditBundle.md) + * [Device](external-docs/sdk/node-sdk/latest/models/device.md) + * [DeviceType](external-docs/sdk/node-sdk/latest/models/deviceType.md) + * [Image](external-docs/sdk/node-sdk/latest/models/image.md) + * [Key](external-docs/sdk/node-sdk/latest/models/key.md) + * [Organization](external-docs/sdk/node-sdk/latest/models/organization.md) + * [Os](external-docs/sdk/node-sdk/latest/models/os.md) + * [Release](external-docs/sdk/node-sdk/latest/models/release.md) + * [Service](external-docs/sdk/node-sdk/latest/models/service.md) + * [Team](external-docs/sdk/node-sdk/latest/models/team.md) + * [Pine](external-docs/sdk/node-sdk/latest/pine.md) + * [Request](external-docs/sdk/node-sdk/latest/request.md) + * [SetSharedOptions](external-docs/sdk/node-sdk/latest/setSharedOptions.md) + * [Settings](external-docs/sdk/node-sdk/latest/settings.md) + * [Utils](external-docs/sdk/node-sdk/latest/utils.md) + * [v22.4.9](external-docs/sdk/node-sdk/v22.4.9/README.md) + * [Introduction](external-docs/sdk/node-sdk/v22.4.9/introduction.md) + * [Auth](external-docs/sdk/node-sdk/v22.4.9/auth.md) + * [Errors](external-docs/sdk/node-sdk/v22.4.9/errors.md) + * [FromSharedOptions](external-docs/sdk/node-sdk/v22.4.9/fromSharedOptions.md) + * [GetSdk](external-docs/sdk/node-sdk/v22.4.9/getSdk.md) + * [Interceptors](external-docs/sdk/node-sdk/v22.4.9/interceptors.md) + * [Logs](external-docs/sdk/node-sdk/v22.4.9/logs.md) + * [Models](external-docs/sdk/node-sdk/v22.4.9/models/README.md) + * [ApiKey](external-docs/sdk/node-sdk/v22.4.9/models/apiKey.md) + * [Application](external-docs/sdk/node-sdk/v22.4.9/models/application.md) + * [Billing](external-docs/sdk/node-sdk/v22.4.9/models/billing.md) + * [Config](external-docs/sdk/node-sdk/v22.4.9/models/config.md) + * [CreditBundle](external-docs/sdk/node-sdk/v22.4.9/models/creditBundle.md) + * [Device](external-docs/sdk/node-sdk/v22.4.9/models/device.md) + * [DeviceType](external-docs/sdk/node-sdk/v22.4.9/models/deviceType.md) + * [Image](external-docs/sdk/node-sdk/v22.4.9/models/image.md) + * [Key](external-docs/sdk/node-sdk/v22.4.9/models/key.md) + * [Organization](external-docs/sdk/node-sdk/v22.4.9/models/organization.md) + * [Os](external-docs/sdk/node-sdk/v22.4.9/models/os.md) + * [Release](external-docs/sdk/node-sdk/v22.4.9/models/release.md) + * [Service](external-docs/sdk/node-sdk/v22.4.9/models/service.md) + * [Team](external-docs/sdk/node-sdk/v22.4.9/models/team.md) + * [Pine](external-docs/sdk/node-sdk/v22.4.9/pine.md) + * [Request](external-docs/sdk/node-sdk/v22.4.9/request.md) + * [SetSharedOptions](external-docs/sdk/node-sdk/v22.4.9/setSharedOptions.md) + * [Settings](external-docs/sdk/node-sdk/v22.4.9/settings.md) + * [Utils](external-docs/sdk/node-sdk/v22.4.9/utils.md) + * [v21.7.4](external-docs/sdk/node-sdk/v21.7.4/README.md) + * [Introduction](external-docs/sdk/node-sdk/v21.7.4/introduction.md) + * [Auth](external-docs/sdk/node-sdk/v21.7.4/auth.md) + * [Errors](external-docs/sdk/node-sdk/v21.7.4/errors.md) + * [FromSharedOptions](external-docs/sdk/node-sdk/v21.7.4/fromSharedOptions.md) + * [GetSdk](external-docs/sdk/node-sdk/v21.7.4/getSdk.md) + * [Interceptors](external-docs/sdk/node-sdk/v21.7.4/interceptors.md) + * [Logs](external-docs/sdk/node-sdk/v21.7.4/logs.md) + * [Models](external-docs/sdk/node-sdk/v21.7.4/models/README.md) + * [ApiKey](external-docs/sdk/node-sdk/v21.7.4/models/apiKey.md) + * [Application](external-docs/sdk/node-sdk/v21.7.4/models/application.md) + * [Billing](external-docs/sdk/node-sdk/v21.7.4/models/billing.md) + * [Config](external-docs/sdk/node-sdk/v21.7.4/models/config.md) + * [CreditBundle](external-docs/sdk/node-sdk/v21.7.4/models/creditBundle.md) + * [Device](external-docs/sdk/node-sdk/v21.7.4/models/device.md) + * [DeviceType](external-docs/sdk/node-sdk/v21.7.4/models/deviceType.md) + * [Image](external-docs/sdk/node-sdk/v21.7.4/models/image.md) + * [Key](external-docs/sdk/node-sdk/v21.7.4/models/key.md) + * [Organization](external-docs/sdk/node-sdk/v21.7.4/models/organization.md) + * [Os](external-docs/sdk/node-sdk/v21.7.4/models/os.md) + * [Release](external-docs/sdk/node-sdk/v21.7.4/models/release.md) + * [Service](external-docs/sdk/node-sdk/v21.7.4/models/service.md) + * [Team](external-docs/sdk/node-sdk/v21.7.4/models/team.md) + * [Pine](external-docs/sdk/node-sdk/v21.7.4/pine.md) + * [Request](external-docs/sdk/node-sdk/v21.7.4/request.md) + * [SetSharedOptions](external-docs/sdk/node-sdk/v21.7.4/setSharedOptions.md) + * [Settings](external-docs/sdk/node-sdk/v21.7.4/settings.md) + * [Utils](external-docs/sdk/node-sdk/v21.7.4/utils.md) + * [v20.9.1 (DEPRECATED)](external-docs/sdk/node-sdk/v20.9.1/README.md) + * [Introduction](external-docs/sdk/node-sdk/v20.9.1/introduction.md) + * [Auth](external-docs/sdk/node-sdk/v20.9.1/auth.md) + * [Errors](external-docs/sdk/node-sdk/v20.9.1/errors.md) + * [FromSharedOptions](external-docs/sdk/node-sdk/v20.9.1/fromSharedOptions.md) + * [GetSdk](external-docs/sdk/node-sdk/v20.9.1/getSdk.md) + * [Interceptors](external-docs/sdk/node-sdk/v20.9.1/interceptors.md) + * [Logs](external-docs/sdk/node-sdk/v20.9.1/logs.md) + * [Models](external-docs/sdk/node-sdk/v20.9.1/models/README.md) + * [ApiKey](external-docs/sdk/node-sdk/v20.9.1/models/apiKey.md) + * [Application](external-docs/sdk/node-sdk/v20.9.1/models/application.md) + * [Billing](external-docs/sdk/node-sdk/v20.9.1/models/billing.md) + * [Config](external-docs/sdk/node-sdk/v20.9.1/models/config.md) + * [CreditBundle](external-docs/sdk/node-sdk/v20.9.1/models/creditBundle.md) + * [Device](external-docs/sdk/node-sdk/v20.9.1/models/device.md) + * [DeviceType](external-docs/sdk/node-sdk/v20.9.1/models/deviceType.md) + * [Image](external-docs/sdk/node-sdk/v20.9.1/models/image.md) + * [Key](external-docs/sdk/node-sdk/v20.9.1/models/key.md) + * [Organization](external-docs/sdk/node-sdk/v20.9.1/models/organization.md) + * [Os](external-docs/sdk/node-sdk/v20.9.1/models/os.md) + * [Release](external-docs/sdk/node-sdk/v20.9.1/models/release.md) + * [Service](external-docs/sdk/node-sdk/v20.9.1/models/service.md) + * [Team](external-docs/sdk/node-sdk/v20.9.1/models/team.md) + * [Pine](external-docs/sdk/node-sdk/v20.9.1/pine.md) + * [Request](external-docs/sdk/node-sdk/v20.9.1/request.md) + * [SetSharedOptions](external-docs/sdk/node-sdk/v20.9.1/setSharedOptions.md) + * [Settings](external-docs/sdk/node-sdk/v20.9.1/settings.md) + * [Utils](external-docs/sdk/node-sdk/v20.9.1/utils.md) * [Python SDK](reference/sdk/python-sdk/README.md) * [v17.1.1 (latest)](external-docs/sdk/python-sdk/latest.md) * [v16.0.0](external-docs/sdk/python-sdk/v16.0.0.md) diff --git a/pages/external-docs/sdk/node-sdk/latest.md b/pages/external-docs/sdk/node-sdk/latest.md deleted file mode 100644 index a0c18d6f60..0000000000 --- a/pages/external-docs/sdk/node-sdk/latest.md +++ /dev/null @@ -1,10835 +0,0 @@ - -## Installation - -Install the balena SDK by running: - -```sh -$ npm install --save balena-sdk -``` - -### Bundling for browsers - -If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. - -If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: - -* fs -* path -* balena-settings-client -* node-localstorage -* fs/promises -* mime - -### Bundling with pkg - -The balena SDK includes builds for various ECMAScript versions that are -dynamically selected at runtime (using -[@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). -For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not -able to automatically detect which assets to include in the output package. The -following sample `pkg` section should be added to your application's -`package.json` file to instruct `pkg` to bundle the required assets: - -```json - "pkg": { - "scripts": [ - "node_modules/balena-sdk/**/*.js" - ], - "assets": [ - "node_modules/pinejs-client-core/**/*" - ] - } -``` - -For more information, please refer to the respective -[documentation from the `pkg` project](https://github.com/vercel/pkg#config). - -## Trying balenaSDK in the browser - -BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. -To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries. - -![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png) - - -If you feel something is missing, not clear or could be improved, please don't hesitate to open an -[issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help. - - -## Modules - -
-
balena-sdk
-
-
- -## Objects - -
-
balena : object
-
-
- -## Functions - -
-
listImagesFromTargetState(targetState)
-
-
- - - -## balena-sdk - -* [balena-sdk](#module_balena-sdk) - * [~fromSharedOptions()](#module_balena-sdk..fromSharedOptions) - * [~getSdk()](#module_balena-sdk..getSdk) - * [~setSharedOptions(options)](#module_balena-sdk..setSharedOptions) - - -* * * - - - -### balena-sdk~fromSharedOptions() -Create an SDK instance using shared default options set using the `setSharedOptions()` method. -If options have not been set using this method, then this method will use the -same defaults as the main SDK factory function. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Create an SDK instance using shared default options -**Access**: public -**Example** -```js -import { fromSharedOptions } from 'balena-sdk'; -const sdk = fromSharedOptions(); -``` - -* * * - - - -### balena-sdk~getSdk() -The module exports a single factory function. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Creates a new SDK instance using the default or the provided options. -**Example** -```js -// with es6 imports -import { getSdk } from 'balena-sdk'; -// or with node require -const { getSdk } = require('balena-sdk'); - -const balena = getSdk({ - apiUrl: "https://api.balena-cloud.com/", - dataDirectory: "/opt/local/balena" -}); -``` - -* * * - - - -### balena-sdk~setSharedOptions(options) -Set options that are used by calls to `fromSharedOptions()`. -The options accepted are the same as those used in the main SDK factory function. -If you use this method, it should be called as soon as possible during app -startup and before any calls to `fromSharedOptions()` are made. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Set shared default options -**Access**: public - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
optionsObject

The shared default options

-
[options.apiUrl]String'https://api.balena-cloud.com/'

the balena API url to use.

-
[options.builderUrl]String'https://builder.balena-cloud.com/'

the balena builder url to use.

-
[options.deviceUrlsBase]String'balena-devices.com'

the base balena device API url to use.

-
[options.requestLimit]Number

the number of requests per requestLimitInterval that the SDK should respect.

-
[options.requestLimitInterval]Number60000

the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute).

-
[options.retryRateLimitedRequests]Boolean | functionfalse

Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header.

-
    -
  • If false, rate-limited requests will not be retried, and the rate limit error will be propagated.
  • -
  • If true, all rate-limited requests will be retried after the duration specified by the Retry-After header.
  • -
  • If a function (retryAfterMs: number) => boolean is provided, it will be called with the retry duration in ms and the request will be retried only when true is returned.
  • -
-
[options.dataDirectory]String | False'$HOME/.balena'

ignored in the browser unless false, the directory where the user settings are stored, normally retrieved like require('balena-settings-client').get('dataDirectory'). Providing false creates an isolated in-memory instance.

-
[options.isBrowser]Boolean

the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global window value.

-
[options.debug]Boolean

when set will print some extra debug information.

-
- -**Example** -```js -import { setSharedOptions } from 'balena-sdk'; -setSharedOptions({ - apiUrl: 'https://api.balena-cloud.com/', - builderUrl: 'https://builder.balena-cloud.com/', - isBrowser: true, -}); -``` - -* * * - - - -## listImagesFromTargetState(targetState) ⇒ -**Kind**: global function -**Returns**: array containing all images for all services for all releases for all apps for the device - - - - - - - - - - -
Param
targetState
- - -* * * - - - -## balena : object -**Kind**: global namespace - -* [balena](#balena) : object - * [.errors](#balena.errors) : Object - * [.interceptors](#balena.interceptors) : Array.<Interceptor> - * [.Interceptor](#balena.interceptors.Interceptor) : object - * [.pine](#balena.pine) : Object - * [.request](#balena.request) : Object - * [.utils](#balena.utils) : Object - * [.auth](#balena.auth) : object - * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ Promise - * [.getActorId()](#balena.auth.getActorId) ⇒ Promise - * [.getToken()](#balena.auth.getToken) ⇒ Promise - * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ Promise - * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ Promise - * [.login(credentials)](#balena.auth.login) ⇒ Promise - * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ Promise - * [.logout()](#balena.auth.logout) ⇒ Promise - * [.register(credentials)](#balena.auth.register) ⇒ Promise - * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ Promise - * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ Promise - * [.whoami()](#balena.auth.whoami) ⇒ Promise - * [.twoFactor](#balena.auth.twoFactor) : object - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.logs](#balena.logs) : object - * [.history(uuidOrId, [options])](#balena.logs.history) ⇒ Promise - * [.subscribe(uuidOrId, [options])](#balena.logs.subscribe) ⇒ Promise.<LogSubscription> - * [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["error"](#balena.logs.LogSubscription.event_error) - * ["line"](#balena.logs.LogSubscription.event_line) - * [.models](#balena.models) : object - * [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.application](#balena.models.application) : object - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.billing](#balena.models.billing) : object - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - * [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ Promise - * [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ Promise - * [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ Promise - * [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo) - * [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ Promise - * [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise - * [.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise - * [.creditBundle](#balena.models.creditBundle) : object - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.device](#balena.models.device) : object - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.pinToOsRelease(uuidOrIdOrArray, osVersionOrId)](#balena.models.device.pinToOsRelease) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.pinToSupervisorRelease) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - * [.key](#balena.models.key) : object - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.organization](#balena.models.organization) : object - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.membership](#balena.models.organization.membership) : object - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.os](#balena.models.os) : object - * [.download(options)](#balena.models.os.download) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getAvailableOsVersions(deviceTypes, [pineOptions], [extraOptions])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ Promise - * [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ Promise.<String> - * [.getSupportedOsUpdateVersions(deviceType, currentVersion, [options])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ Promise - * [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ Boolean - * [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ Promise - * [.release](#balena.models.release) : object - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.asset](#balena.models.release.asset) : object - * [.download(id)](#balena.models.release.asset.download) ⇒ Promise - * [.get(id, [options])](#balena.models.release.asset.get) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.asset.getAllByRelease) ⇒ Promise - * [.remove(id)](#balena.models.release.asset.remove) ⇒ Promise - * [.upload(uploadParams, [options])](#balena.models.release.asset.upload) ⇒ Promise - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.service](#balena.models.service) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.var](#balena.models.service.var) : object - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.team](#balena.models.team) : object - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.settings](#balena.settings) : object - * [.get([key])](#balena.settings.get) ⇒ Promise - * [.getAll()](#balena.settings.getAll) ⇒ Promise - * [.utils](#balena.utils) : object - - -* * * - - - -### balena.errors : Object -The balena-errors module used internally. This is provided primarily for -convenience, and to avoid the necessity for separate balena-errors -dependencies. You'll want to use this if you need to match on the specific -type of error thrown by the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena errors module -**Access**: public -**Example** -```js -balena.models.device.get(123).catch(function (error) { - if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) { - ... - } else if (error.code === balena.errors.BalenaRequestError.prototype.code) { - ... - } -}); -``` - -* * * - - - -### balena.interceptors : Array.<Interceptor> -The current array of interceptors to use. Interceptors intercept requests made -internally and are executed in the order they appear in this array for requests, -and in the reverse order for responses. - -**Kind**: static property of [balena](#balena) -**Summary**: Array of interceptors -**Access**: public -**Example** -```js -balena.interceptors.push({ - responseError: function (error) { - console.log(error); - throw error; - }) -}); -``` - -* * * - - - -#### interceptors.Interceptor : object -An interceptor implements some set of the four interception hook callbacks. -To continue processing, each function should return a value or a promise that -successfully resolves to a value. - -To halt processing, each function should throw an error or return a promise that -rejects with an error. - -**Kind**: static typedef of [interceptors](#balena.interceptors) -**Properties** - - - - - - - - - - - - - - - - - -
NameTypeDescription
[request]function

Callback invoked before requests are made. Called with -the request options, should return (or resolve to) new request options, or throw/reject.

-
[response]function

Callback invoked before responses are returned. Called with -the response, should return (or resolve to) a new response, or throw/reject.

-
[requestError]function

Callback invoked if an error happens before a request. -Called with the error itself, caused by a preceeding request interceptor rejecting/throwing -an error for the request, or a failing in preflight token validation. Should return (or resolve -to) new request options, or throw/reject.

-
[responseError]function

Callback invoked if an error happens in the response. -Called with the error itself, caused by a preceeding response interceptor rejecting/throwing -an error for the request, a network error, or an error response from the server. Should return -(or resolve to) a new response, or throw/reject.

-
- - -* * * - - - -### balena.pine : Object -The pinejs-client instance used internally. This should not be necessary -in normal usage, but can be useful if you want to directly make pine -queries to the api for some resource that isn't directly supported -in the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena pine instance -**Access**: public -**Example** -```js -balena.pine.get({ - resource: 'release', - options: { - $count: { - $filter: { belongs_to__application: applicationId } - } - } -}); -``` - -* * * - - - -### balena.request : Object -The balena-request instance used internally. This should not be necessary -in normal usage, but can be useful if you want to make an API request directly, -using the same token and hooks as the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena request instance -**Access**: public -**Example** -```js -balena.request.send({ url: 'http://api.balena-cloud.com/ping' }); -``` - -* * * - - - -### balena.utils : Object -The utils instance offers some convenient features for clients. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena utils instance -**Access**: public -**Example** -```js -balena.utils.mergePineOptions( - { $expand: { device: { $select: ['id'] } } }, - { $expand: { device: { $select: ['name'] } } }, -); -``` - -* * * - - - -### balena.auth : object -**Kind**: static namespace of [balena](#balena) - -* [.auth](#balena.auth) : object - * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ Promise - * [.getActorId()](#balena.auth.getActorId) ⇒ Promise - * [.getToken()](#balena.auth.getToken) ⇒ Promise - * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ Promise - * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ Promise - * [.login(credentials)](#balena.auth.login) ⇒ Promise - * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ Promise - * [.logout()](#balena.auth.logout) ⇒ Promise - * [.register(credentials)](#balena.auth.register) ⇒ Promise - * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ Promise - * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ Promise - * [.whoami()](#balena.auth.whoami) ⇒ Promise - * [.twoFactor](#balena.auth.twoFactor) : object - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - - -* * * - - - -#### auth.authenticate(credentials) ⇒ Promise -You should use [login](#balena.auth.login) when possible, -as it takes care of saving the token and email as well. - -Notice that if `credentials` contains extra keys, they'll be discarted -by the server automatically. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Authenticate with the server -**Access**: protected -**Fulfil**: String - session token - - - - - - - - - - - - - - -
ParamTypeDescription
credentialsObject

in the form of email, password

-
credentials.emailString

the email

-
credentials.passwordString

the password

-
- -**Example** -```js -balena.auth.authenticate(credentials).then(function(token) { - console.log('My token is:', token); -}); -``` - -* * * - - - -#### auth.getActorId() ⇒ Promise -This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in actor id -**Access**: public -**Fulfil**: Number - actor id -**Example** -```js -balena.auth.getActorId().then(function(actorId) { - console.log(actorId); -}); -``` - -* * * - - - -#### auth.getToken() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in user's raw API key or session token -**Access**: public -**Fulfil**: String - raw API key or session token -**Example** -```js -balena.auth.getToken().then(function(token) { - console.log(token); -}); -``` - -* * * - - - -#### auth.getUserInfo() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in user's info -**Access**: public -**Fulfil**: Object - user info -**Example** -```js -balena.auth.getUserInfo().then(function(userInfo) { - console.log(userInfo); -}); -``` - -* * * - - - -#### auth.isLoggedIn() ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Check if you're logged in -**Access**: public -**Fulfil**: Boolean - is logged in -**Example** -```js -balena.auth.isLoggedIn().then(function(isLoggedIn) { - if (isLoggedIn) { - console.log('I\'m in!'); - } else { - console.log('Too bad!'); - } -}); -``` - -* * * - - - -#### auth.login(credentials) ⇒ Promise -If the login is successful, the token is persisted between sessions. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Login -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
credentialsObject

in the form of email, password

-
credentials.emailString

the email

-
credentials.passwordString

the password

-
- -**Example** -```js -balena.auth.login(credentials); -``` - -* * * - - - -#### auth.loginWithToken(authToken) ⇒ Promise -Login to balena with a session token or api key instead of with credentials. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Login with a token or api key -**Access**: public - - - - - - - - - - -
ParamTypeDescription
authTokenString

the auth token

-
- -**Example** -```js -balena.auth.loginWithToken(authToken); -``` - -* * * - - - -#### auth.logout() ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Logout -**Access**: public -**Example** -```js -balena.auth.logout(); -``` - -* * * - - - -#### auth.register(credentials) ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Register a user account -**Access**: public -**Fulfil**: String - session token - - - - - - - - - - - - - - - - -
ParamTypeDescription
credentialsObject

in the form of username, password and email

-
credentials.emailString

the email

-
credentials.passwordString

the password

-
[credentials.'g-recaptcha-response']String | undefined

the captcha response

-
- -**Example** -```js -balena.auth.register({ - email: 'johndoe@gmail.com', - password: 'secret' -}).then(function(token) { - console.log(token); -}); -``` - -* * * - - - -#### auth.requestVerificationEmail() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Re-send verification email to the user -**Access**: public -**Example** -```js -balena.auth.requestVerificationEmail().then(function() { - console.log('Requesting verification email operation complete!'); -}) -``` - -* * * - - - -#### auth.verifyEmail(verificationPayload) ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Verifies an email -**Access**: public -**Fulfil**: String - session token - - - - - - - - - - - - - - -
ParamTypeDescription
verificationPayloadObject

in the form of email, and token

-
verificationPayload.emailString

the email

-
verificationPayload.tokenString

the verification token

-
- -**Example** -```js -balena.auth.verifyEmail({ - email: 'johndoe@gmail.com', - token: '5bb11d90eefb34a70318f06a43ef063f' -}).then(function(jwt) { - console.log(jwt); -}); -``` - -* * * - - - -#### auth.whoami() ⇒ Promise -This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Return current logged in information -**Access**: public -**Fulfil**: (Object\|undefined) - actor information, if it exists -**Example** -```js -balena.auth.whoami().then(function(result) { - if (!result) { - console.log('I\'m not logged in!'); - } else { - console.log('My result is:', result); - } -}); -``` - -* * * - - - -#### auth.twoFactor : object -**Kind**: static namespace of [auth](#balena.auth) - -* [.twoFactor](#balena.auth.twoFactor) : object - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - - -* * * - - - -##### twoFactor.challenge(code) ⇒ Promise -You should use [login](#balena.auth.login) when possible, -as it takes care of saving the token and email as well. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Challenge two factor authentication and complete login -**Access**: public - - - - - - - - - - -
ParamTypeDescription
codeString

code

-
- -**Example** -```js -balena.auth.twoFactor.challenge('1234'); -``` - -* * * - - - -##### twoFactor.disable(password) ⇒ Promise -Disables two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Disable two factor authentication -**Access**: public -**Fulfil**: String - session token - - - - - - - - - - -
ParamTypeDescription
passwordString

password

-
- -**Example** -```js -const token = balena.auth.twoFactor.disable('1234'); -balena.auth.loginWithToken(token); -``` - -* * * - - - -##### twoFactor.enable(code) ⇒ Promise -Enables two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Enable two factor authentication -**Access**: public -**Fulfil**: String - session token - - - - - - - - - - -
ParamTypeDescription
codeString

code

-
- -**Example** -```js -const token = balena.auth.twoFactor.enable('1234'); -balena.auth.loginWithToken(token); -``` - -* * * - - - -##### twoFactor.getSetupKey() ⇒ Promise -Retrieves a setup key for enabling two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Get two factor authentication setup key -**Access**: public -**Fulfil**: String - setup key -**Example** -```js -const setupKey = balena.auth.twoFactor.getSetupKey(); -console.log(setupKey); -``` - -* * * - - - -##### twoFactor.isEnabled() ⇒ Promise -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Check if two factor authentication is enabled -**Access**: public -**Fulfil**: Boolean - whether 2fa is enabled -**Example** -```js -balena.auth.twoFactor.isEnabled().then(function(isEnabled) { - if (isEnabled) { - console.log('2FA is enabled for this account'); - } -}); -``` - -* * * - - - -##### twoFactor.isPassed() ⇒ Promise -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Check if two factor authentication challenge was passed -**Access**: public -**Fulfil**: Boolean - whether 2fa challenge was passed -**Example** -```js -balena.auth.twoFactor.isPassed().then(function(isPassed) { - if (isPassed) { - console.log('2FA challenge passed'); - } -}); -``` - -* * * - - - -##### twoFactor.verify(code) ⇒ Promise -Verifies two factor authentication. -Note that this method not update the token automatically. -You should use [challenge](#balena.auth.twoFactor.challenge) when possible, -as it takes care of that as well. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Verify two factor authentication -**Access**: public -**Fulfil**: String - session token - - - - - - - - - - -
ParamTypeDescription
codeString

code

-
- -**Example** -```js -const token = balena.auth.twoFactor.verify('1234'); -balena.auth.loginWithToken(token); -``` - -* * * - - - -### balena.logs : object -**Kind**: static namespace of [balena](#balena) - -* [.logs](#balena.logs) : object - * [.history(uuidOrId, [options])](#balena.logs.history) ⇒ Promise - * [.subscribe(uuidOrId, [options])](#balena.logs.subscribe) ⇒ Promise.<LogSubscription> - * [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["error"](#balena.logs.LogSubscription.event_error) - * ["line"](#balena.logs.LogSubscription.event_line) - - -* * * - - - -#### logs.history(uuidOrId, [options]) ⇒ Promise -Get an array of the latest log messages for a given device. - -**Kind**: static method of [logs](#balena.logs) -**Summary**: Get device logs history -**Access**: public -**Fulfil**: Object[] - history lines - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object

options

-
[options.count]Number | 'all'1000

number of log messages to return (or 'all')

-
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages

-
- -**Example** -```js -balena.logs.history('7cf02a69e4d34c9da573914963cf54fd').then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -balena.logs.history(123).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -const oneDayAgoTimestamp = Date.now() - 24*60*60*1000; -balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoTimestamp }).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -const oneDayAgoIsoDateString = new Date(Date.now() - 24*60*60*1000).toISOString(); -balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoIsoDateString }).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` - -* * * - - - -#### logs.subscribe(uuidOrId, [options]) ⇒ Promise.<LogSubscription> -Connects to the stream of devices logs, returning a LogSubscription, which -can be used to listen for logs as they appear, line by line. - -**Kind**: static method of [logs](#balena.logs) -**Summary**: Subscribe to device logs -**Access**: public -**Fulfil**: [LogSubscription](#balena.logs.LogSubscription) - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object

options

-
[options.count]Number | 'all'0

number of historical messages to include (or 'all')

-
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages. When specified, the count parameter needs to also be provided.

-
- -**Example** -```js -balena.logs.subscribe('7cf02a69e4d34c9da573914963cf54fd').then(function(logs) { - logs.on('line', function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -balena.logs.subscribe(123).then(function(logs) { - logs.on('line', function(line) { - console.log(line); - }); -}); -``` - -* * * - - - -#### logs.LogSubscription : EventEmitter -The log subscription emits events as log data arrives. -You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)` - -**Kind**: static typedef of [logs](#balena.logs) - -* [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["error"](#balena.logs.LogSubscription.event_error) - * ["line"](#balena.logs.LogSubscription.event_line) - - -* * * - - - -##### LogSubscription.unsubscribe() -Disconnect from the logs feed and stop receiving any future events on this emitter. - -**Kind**: static method of [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Unsubscribe from device logs -**Access**: public -**Example** -```js -logs.unsubscribe(); -``` - -* * * - - - -##### "error" -**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Event fired when an error has occured reading the device logs -**Example** -```js -logs.on('error', function(error) { - console.error(error); -}); -``` - -* * * - - - -##### "line" -**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Event fired when a new line of log output is available -**Example** -```js -logs.on('line', function(line) { - console.log(line); -}); -``` - -* * * - - - -### balena.models : object -**Kind**: static namespace of [balena](#balena) - -* [.models](#balena.models) : object - * [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.application](#balena.models.application) : object - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.billing](#balena.models.billing) : object - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - * [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ Promise - * [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ Promise - * [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ Promise - * [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo) - * [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ Promise - * [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise - * [.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise - * [.creditBundle](#balena.models.creditBundle) : object - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.device](#balena.models.device) : object - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.pinToOsRelease(uuidOrIdOrArray, osVersionOrId)](#balena.models.device.pinToOsRelease) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.pinToSupervisorRelease) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - * [.key](#balena.models.key) : object - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.organization](#balena.models.organization) : object - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.membership](#balena.models.organization.membership) : object - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.os](#balena.models.os) : object - * [.download(options)](#balena.models.os.download) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getAvailableOsVersions(deviceTypes, [pineOptions], [extraOptions])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ Promise - * [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ Promise.<String> - * [.getSupportedOsUpdateVersions(deviceType, currentVersion, [options])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ Promise - * [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ Boolean - * [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ Promise - * [.release](#balena.models.release) : object - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.asset](#balena.models.release.asset) : object - * [.download(id)](#balena.models.release.asset.download) ⇒ Promise - * [.get(id, [options])](#balena.models.release.asset.get) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.asset.getAllByRelease) ⇒ Promise - * [.remove(id)](#balena.models.release.asset.remove) ⇒ Promise - * [.upload(uploadParams, [options])](#balena.models.release.asset.upload) ⇒ Promise - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.service](#balena.models.service) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.var](#balena.models.service.var) : object - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.team](#balena.models.team) : object - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - - -* * * - - - -#### models.apiKey : object -**Kind**: static namespace of [models](#balena.models) - -* [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - - -* * * - - - -##### apiKey.create(createApiKeyParams) ⇒ Promise -This method registers a new api key for the current user with the name given. - -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Creates a new user API key -**Access**: public -**Fulfil**: String - API key - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
createApiKeyParamsObject

an object containing the parameters for the creation of an API key

-
createApiKeyParams.nameString

the API key name

-
createApiKeyParams.expiryDateString

the API key expiry date

-
[createApiKeyParams.description]String

the API key description

-
- -**Example** -```js -balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12}).then(function(apiKey) { - console.log(apiKey); -}); -``` -**Example** -```js -balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12, description: apiKeyDescription}).then(function(apiKey) { - console.log(apiKey); -}); -``` - -* * * - - - -##### apiKey.getAll([options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all accessible API keys -**Access**: public -**Fulfil**: Object[] - apiKeys - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.apiKey.getAll().then(function(apiKeys) { - console.log(apiKeys); -}); -``` - -* * * - - - -##### apiKey.getAllNamedUserApiKeys([options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all named user API keys of the current user -**Access**: public -**Fulfil**: Object[] - apiKeys - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) { - console.log(apiKeys); -}); -``` - -* * * - - - -##### apiKey.getDeviceApiKeysByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all API keys for a device -**Access**: public -**Fulfil**: Object[] - apiKeys - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device, uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(apiKeys) { - console.log(apiKeys); -}); -``` - -* * * - - - -##### apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all provisioning API keys for an application -**Access**: public -**Fulfil**: Object[] - apiKeys - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) { - console.log(apiKeys); -}); -``` - -* * * - - - -##### apiKey.revoke(id) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Revoke an API key -**Access**: public - - - - - - - - - - -
ParamTypeDescription
idNumber

API key id

-
- -**Example** -```js -balena.models.apiKey.revoke(123); -``` - -* * * - - - -##### apiKey.update(id, apiKeyInfo) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Update the details of an API key -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
idNumber

API key id

-
apiKeyInfoObject

an object with the updated name|description|expiryDate

-
- -**Example** -```js -balena.models.apiKey.update(123, { name: 'updatedName' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { description: 'updated description' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { expiryDate: '2022-04-29' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' }); -``` - -* * * - - - -#### models.application : object -**Kind**: static namespace of [models](#balena.models) - -* [.application](#balena.models.application) : object - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - - -* * * - - - -##### application.create(options) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Create an application -**Access**: public -**Fulfil**: Object - application - - - - - - - - - - - - - - - - - - - - -
ParamTypeDescription
optionsObject

application creation parameters

-
options.nameString

application name

-
options.organizationString | Number

handle (string) or id (number) of the organization that the application will belong to or null

-
[options.uuid]String

application uuid

-
[options.applicationClass]String

application class: 'app' | 'fleet' | 'block'

-
options.deviceTypeString

device type slug

-
- -**Example** -```js -balena.models.application.create({ name: 'My App', organization: 'myorganization', deviceType: 'raspberry-pi' }).then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.create({ name: 'My Block', organization: 'myorganization', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) { - console.log(application); -}); -``` - -* * * - - - -##### application.disableDeviceUrls(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Disable device urls for all devices that belong to an application -**Access**: public - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.disableDeviceUrls('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.disableDeviceUrls(123); -``` - -* * * - - - -##### application.enableDeviceUrls(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Enable device urls for all devices that belong to an application -**Access**: public - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.enableDeviceUrls('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.enableDeviceUrls(123); -``` - -* * * - - - -##### application.generateProvisioningKey(generateProvisioningKeyParams) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Generate a device provisioning key for a specific application -**Access**: public -**Fulfil**: String - device provisioning key - - - - - - - - - - - - - - - - - - -
ParamTypeDescription
generateProvisioningKeyParamsObject

an object containing the parameters for the provisioning key generation

-
generateProvisioningKeyParams.slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
generateProvisioningKeyParams.keyExpiryDateString

Expiry Date for provisioning key

-
[generateProvisioningKeyParams.keyName]String

Provisioning key name

-
[generateProvisioningKeyParams.keyDescription]String

Description for provisioning key

-
- -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 'myorganization/myapp', keyExpiryDate: '2030-10-12'}).then(function(key) { - console.log(key); -}); -``` -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12'}).then(function(key) { - console.log(key); -}); -``` -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12', keyName: 'api key name', keyDescription: 'api key long description'}).then(function(key) { - console.log(key); -}); -``` - -* * * - - - -##### application.get(slugOrUuidOrId, [options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application -**Access**: public -**Fulfil**: Object - application - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
[context]String

extra access filters, undefined or 'directly_accessible'

-
- -**Example** -```js -balena.models.application.get('myorganization/myapp').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.get(123).then(function(application) { - console.log(application); -}); -``` - -* * * - - - -##### application.getAll([options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications -**Access**: public -**Fulfil**: Object[] - applications - - - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
[context]String

extra access filters, undefined or 'directly_accessible'

-
- -**Example** -```js -balena.models.application.getAll().then(function(applications) { - console.log(applications); -}); -``` - -* * * - - - -##### application.getAllByOrganization(orgHandleOrId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications of an organization -**Access**: public -**Fulfil**: Object[] - applications - - - - - - - - - - - - -
ParamTypeDefaultDescription
orgHandleOrIdNumber | String

organization handle (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.getAllByOrganization('myorganization').then(function(applications) { - console.log(applications); -}); -``` -**Example** -```js -const applications = await sdk.models.application.getAllByOrganization('myorganization', { - $select: ['app_name', 'slug'], - $expand: { - owns__device: { - $select: ['uuid', 'overall_status', 'is_connected_to_vpn', 'api_heartbeat_state'], - }, - }, - }); -``` - -* * * - - - -##### application.getAllDirectlyAccessible([options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications directly accessible by the user -**Access**: public -**Fulfil**: Object[] - applications - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.getAllDirectlyAccessible().then(function(applications) { - console.log(applications); -}); -``` - -* * * - - - -##### application.getAppByName(appName, [options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application using the appname and the handle of the owning organization -**Access**: public -**Fulfil**: Object - application - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
appNameString

application name

-
[options]Object{}

extra pine options to use

-
[context]String

extra access filters, undefined or 'directly_accessible'

-
- -**Example** -```js -balena.models.application.getAppByName('MyApp').then(function(application) { - console.log(application); -}); -``` - -* * * - - - -##### application.getDashboardUrl(id) ⇒ String -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get Dashboard URL for a specific application -**Returns**: String - - Dashboard URL for the specific application -**Throws**: - -- Exception if the id is not a finite number - - - - - - - - - - - -
ParamTypeDescription
idNumber

Application id

-
- -**Example** -```js -balena.models.application.get('myorganization/myapp').then(function(application) { - const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); - console.log(dashboardApplicationUrl); -}); -``` - -* * * - - - -##### application.getDirectlyAccessible(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application directly accessible by the user -**Access**: public -**Fulfil**: Object - application - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.getDirectlyAccessible(123).then(function(application) { - console.log(application); -}); -``` - -* * * - - - -##### application.getTargetReleaseHash(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get the hash of the current release for a specific application -**Access**: public -**Fulfil**: String\|undefined - The release hash of the current release - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.application.getTargetReleaseHash(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) { - console.log(release); -}); -``` - -* * * - - - -##### application.getWithDeviceServiceDetails(slugOrUuidOrId, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want more control, or to see the raw model -directly, use `application.get(uuidOrId, options)` instead. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application and its devices, along with each device's -associated services' essential details -**Access**: public -**Fulfil**: Object - application - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.application.getWithDeviceServiceDetails(123).then(function(device) { - console.log(device); -}) -``` - -* * * - - - -##### application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Grant support access to an application until a specified time -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
expiryTimestampNumber

a timestamp in ms for when the support access will expire

-
- -**Example** -```js -balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000); -``` -**Example** -```js -balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000); -``` - -* * * - - - -##### application.has(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Check if an application exists -**Access**: public -**Fulfil**: Boolean - has application - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.has('myorganization/myapp').then(function(hasApp) { - console.log(hasApp); -}); -``` -**Example** -```js -balena.models.application.has(123).then(function(hasApp) { - console.log(hasApp); -}); -``` - -* * * - - - -##### application.hasAny() ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Check if the user has access to any applications -**Access**: public -**Fulfil**: Boolean - has any applications -**Example** -```js -balena.models.application.hasAny().then(function(hasAny) { - console.log('Has any?', hasAny); -}); -``` - -* * * - - - -##### application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates -**Access**: public -**Fulfil**: Boolean - is tracking the latest release - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) { - console.log(isEnabled); -}); -``` -**Example** -```js -balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) { - console.log(isEnabled); -}); -``` - -* * * - - - -##### application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ Promise -Configures the application to run a particular release -and not get updated when the latest release changes. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Set a specific application to run a particular release -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
fullReleaseHashString

the hash of a successful release (string)

-
- -**Example** -```js -balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` - -* * * - - - -##### application.purge(appId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Purge devices by application id -**Access**: public - - - - - - - - - - -
ParamTypeDescription
appIdNumber

application id

-
- -**Example** -```js -balena.models.application.purge(123); -``` - -* * * - - - -##### application.reboot(appId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Reboot devices by application id -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
appIdNumber

application id

-
[options]Object

options

-
[options.force]Booleanfalse

override update lock

-
- -**Example** -```js -balena.models.application.reboot(123); -``` - -* * * - - - -##### application.remove(slugOrUuidOrIdOrIds) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Remove application -**Access**: public - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdOrIdsString | Number | Array.<Number>

application slug (string), uuid (string) or id (number) or array of ids

-
- -**Example** -```js -balena.models.application.remove('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.remove(123); -``` - -* * * - - - -##### application.rename(slugOrUuidOrId, newName) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Rename application -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
newNameString

new application name (string)

-
- -**Example** -```js -balena.models.application.rename('myorganization/myapp', 'MyRenamedApp'); -``` -**Example** -```js -balena.models.application.rename(123, 'MyRenamedApp'); -``` - -* * * - - - -##### application.restart(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Restart application -**Access**: public - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.restart('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.restart(123); -``` - -* * * - - - -##### application.revokeSupportAccess(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Revoke support access to an application -**Access**: public - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.revokeSupportAccess('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.revokeSupportAccess(123); -``` - -* * * - - - -##### application.shutdown(appId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Shutdown devices by application id -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
appIdNumber

application id

-
[options]Object

options

-
[options.force]Booleanfalse

override update lock

-
- -**Example** -```js -balena.models.application.shutdown(123); -``` - -* * * - - - -##### application.trackLatestRelease(slugOrUuidOrId) ⇒ Promise -The application's current release will be updated with each new successfully built release. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Configure a specific application to track the latest finalized available release -**Access**: public - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.trackLatestRelease('myorganization/myapp').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.trackLatestRelease(123).then(function() { - ... -}); -``` - -* * * - - - -##### application.willTrackNewReleases(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get whether the application is configured to receive updates whenever a new release is available -**Access**: public -**Fulfil**: Boolean - is tracking the latest release - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) { - console.log(isEnabled); -}); -``` -**Example** -```js -balena.models.application.willTrackNewReleases(123).then(function(isEnabled) { - console.log(isEnabled); -}); -``` - -* * * - - - -##### application.buildVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.buildVar](#balena.models.application.buildVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - - -* * * - - - -###### buildVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Get the value of a specific build environment variable -**Access**: public -**Fulfil**: String\|undefined - the build environment variable value (or undefined) - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

build environment variable name

-
- -**Example** -```js -balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.buildVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - -* * * - - - -###### buildVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Get all build environment variables for an application -**Access**: public -**Fulfil**: Object[] - application build environment variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### buildVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Clear the value of a specific build environment variable -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

build environment variable name

-
- -**Example** -```js -balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.buildVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - -* * * - - - -###### buildVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Set the value of a specific build environment variable -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

build environment variable name

-
valueString

build environment variable value

-
- -**Example** -```js -balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - -* * * - - - -##### application.configVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.configVar](#balena.models.application.configVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - - -* * * - - - -###### configVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Get the value of a specific config variable -**Access**: public -**Fulfil**: String\|undefined - the config variable value (or undefined) - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

config variable name

-
- -**Example** -```js -balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` - -* * * - - - -###### configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Get all config variables for an application -**Access**: public -**Fulfil**: Object[] - application config variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.configVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### configVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Clear the value of a specific config variable -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

config variable name

-
- -**Example** -```js -balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() { - ... -}); -``` - -* * * - - - -###### configVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Set the value of a specific config variable -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

config variable name

-
valueString

config variable value

-
- -**Example** -```js -balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` - -* * * - - - -##### application.envVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.envVar](#balena.models.application.envVar) : object - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - - -* * * - - - -###### envVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Get the value of a specific environment variable -**Access**: public -**Fulfil**: String\|undefined - the environment variable value (or undefined) - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

environment variable name

-
- -**Example** -```js -balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.envVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - -* * * - - - -###### envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Get all environment variables for an application -**Access**: public -**Fulfil**: Object[] - application environment variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.envVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### envVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Clear the value of a specific environment variable -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

environment variable name

-
- -**Example** -```js -balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.envVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - -* * * - - - -###### envVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Set the value of a specific environment variable -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
keyString

environment variable name

-
valueString

environment variable value

-
- -**Example** -```js -balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - -* * * - - - -##### application.invite : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.invite](#balena.models.application.invite) : object - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - - -* * * - - - -###### invite.accept(invitationToken) ⇒ Promise -This method adds the calling user to the application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Accepts an invite -**Access**: public - - - - - - - - - - -
ParamTypeDescription
invitationTokenString

invite token

-
- -**Example** -```js -balena.models.application.invite.accept("qwerty-invitation-token"); -``` - -* * * - - - -###### invite.create(slugOrUuidOrId, options, [message]) ⇒ Promise -This method invites a user by their email to an application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Creates a new invite for an application -**Access**: public -**Fulfil**: String - application invite - - - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
optionsObject

invite creation parameters

-
options.inviteeString

the email of the invitee

-
[options.roleName]String"developer"

the role name to be granted to the invitee

-
[message]String

the message to send along with the invite

-
- -**Example** -```js -balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) { - console.log(invite); -}); -``` - -* * * - - - -###### invite.getAll([options]) ⇒ Promise -This method returns all invites. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Get all invites -**Access**: public -**Fulfil**: Object[] - invites - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.invite.getAll().then(function(invites) { - console.log(invites); -}); -``` - -* * * - - - -###### invite.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all invites for a specific application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Get all invites by application -**Access**: public -**Fulfil**: Object[] - invites - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) { - console.log(invites); -}); -``` -**Example** -```js -balena.models.application.invite.getAllByApplication(123).then(function(invites) { - console.log(invites); -}); -``` - -* * * - - - -###### invite.revoke(id) ⇒ Promise -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Revoke an invite -**Access**: public - - - - - - - - - - -
ParamTypeDescription
idNumber

application invite id

-
- -**Example** -```js -balena.models.application.invite.revoke(123); -``` - -* * * - - - -##### application.membership : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.membership](#balena.models.application.membership) : object - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - - -* * * - - - -###### membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise -This method changes the role of an application member. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Changes the role of an application member -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be changed

-
roleNameString

the role name to be granted to the membership

-
- -**Example** -```js -balena.models.application.membership.changeRole(123, "member").then(function() { - console.log('OK'); -}); -``` -**Example** -```js -balena.models.application.membership.changeRole({ - user: 123, - is_member_of__application: 125, -}, "member").then(function() { - console.log('OK'); -}); -``` - -* * * - - - -###### membership.create(options) ⇒ Promise -This method adds a user to an application by their username if they are a member of the organization. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Creates a new membership for an application -**Access**: public -**Fulfil**: Object - application membership - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
optionsObject

membership creation parameters

-
options.applicationString | Number

application handle (string), or id (number)

-
options.usernameString

the username of the balena user that will become a member

-
[options.roleName]String"member"

the role name to be granted to the membership

-
- -**Example** -```js -balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { - console.log(membership); -}); -``` - -* * * - - - -###### membership.get(membershipId, [options]) ⇒ Promise -This method returns a single application membership. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get a single application membership -**Access**: public -**Fulfil**: Object - application membership - - - - - - - - - - - - -
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.membership.get(5).then(function(memberships) { - console.log(memberships); -}); -``` - -* * * - - - -###### membership.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all application memberships for a specific application. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get all memberships by application -**Access**: public -**Fulfil**: Object[] - application memberships - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.application.membership.getAllByApplication(123).then(function(memberships) { - console.log(memberships); -}); -``` - -* * * - - - -###### membership.getAllByUser(usernameOrId, [options]) ⇒ Promise -This method returns all application memberships for a specific user. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get all memberships by user -**Access**: public -**Fulfil**: Object[] - application memberships - - - - - - - - - - - - -
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.application.membership.getAllByUser(123).then(function(memberships) { - console.log(memberships); -}); -``` - -* * * - - - -###### membership.remove(idOrUniqueKey) ⇒ Promise -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Remove a membership -**Access**: public - - - - - - - - - - -
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be removed

-
- -**Example** -```js -balena.models.application.membership.remove(123); -``` -**Example** -```js -balena.models.application.membership.remove({ - user: 123, - is_member_of__application: 125, -}); -``` - -* * * - - - -##### application.tags : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - - -* * * - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Get all application tags for an application -**Access**: public -**Fulfil**: Object[] - application tags - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.application.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - -* * * - - - -###### tags.remove(slugOrUuidOrId, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Remove an application tag -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
tagKeyString

tag key

-
- -**Example** -```js -balena.models.application.tags.remove('myorganization/myapp', 'EDITOR'); -``` - -* * * - - - -###### tags.set(slugOrUuidOrId, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Set an application tag -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
tagKeyString

tag key

-
valueString | undefined

tag value

-
- -**Example** -```js -balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.application.tags.set(123, 'EDITOR', 'vim'); -``` - -* * * - - - -#### models.billing : object -**Note!** The billing methods are available on Balena.io exclusively. - -**Kind**: static namespace of [models](#balena.models) - -* [.billing](#balena.models.billing) : object - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - * [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ Promise - * [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ Promise - * [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ Promise - * [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo) - * [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ Promise - - -* * * - - - -##### billing.changePlan(organization, planChangeOptions) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Change the current billing plan -**Access**: public - - - - - - - - - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
planChangeOptionsObject

an object containing the billing plan change options

-
billingInfo.tierString

the code of the target billing plan

-
billingInfo.cycleString

the billing cycle

-
[billingInfo.planChangeReason]String

the reason for changing the current plan

-
- -**Example** -```js -balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() { - console.log('Plan changed!'); -}); -``` - -* * * - - - -##### 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 - - - - - - - - - - - - - - -
ParamTypeDescription
setupIntentParamsObject

an object containing the parameters for the setup intent creation

-
extraParams.organizationString | 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.downloadInvoice(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Download a specific invoice -**Access**: public -**Fulfil**: Blob\|ReadableStream - blob on the browser, download stream on node - - - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
String

an invoice number

-
- -**Example** -```js -# Browser -balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) { - console.log(blob); -}); -# Node -balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) { - stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf')); -}); -``` - -* * * - - - -##### billing.getAccount(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the user's billing account -**Access**: public -**Fulfil**: Object - billing account - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
- -**Example** -```js -balena.models.billing.getAccount(orgId).then(function(billingAccount) { - console.log(billingAccount); -}); -``` - -* * * - - - -##### billing.getBillingInfo(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the current billing information -**Access**: public -**Fulfil**: Object - billing information - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
- -**Example** -```js -balena.models.billing.getBillingInfo(orgId).then(function(billingInfo) { - console.log(billingInfo); -}); -``` - -* * * - - - -##### billing.getInvoices(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the available invoices -**Access**: public -**Fulfil**: Object - invoices - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
- -**Example** -```js -balena.models.billing.getInvoices(orgId).then(function(invoices) { - console.log(invoices); -}); -``` - -* * * - - - -##### billing.getPlan(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the current billing plan -**Access**: public -**Fulfil**: Object - billing plan - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
- -**Example** -```js -balena.models.billing.getPlan(orgId).then(function(billingPlan) { - console.log(billingPlan); -}); -``` - -* * * - - - -##### billing.removeBillingInfo(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Remove an organization's billing information -**Access**: public - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
- -**Example** -```js -balena.models.billing.removeBillingInfo(orgId).then(function() { - console.log("Success"); -}); -``` - -* * * - - - -##### billing.updateAccountInfo(organization, accountInfo) -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Update the current billing account information -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
accountInfoAccountInfo

an object containing billing account info

-
- -**Example** -```js -balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) -``` -**Example** -```js -balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) -``` - -* * * - - - -##### billing.updateBillingInfo(organization, billingInfo) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Update the current billing information -**Access**: public -**Fulfil**: Object - billing information - - - - - - - - - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
billingInfoObject

an object containing a billing info token_id

-
billingInfo.token_idString

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 -balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) { - console.log(billingInfo); -}); -``` - -* * * - - - -#### models.config : object -**Kind**: static namespace of [models](#balena.models) - -* [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise - * [.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise - - -* * * - - - -##### config.getAll() ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get all configuration -**Access**: public -**Fulfil**: Object - configuration -**Example** -```js -balena.models.config.getAll().then(function(config) { - console.log(config); -}); -``` - -* * * - - - -##### config.getConfigVarSchema(deviceType) ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get configuration variables schema for a device type -**Access**: public -**Fulfil**: Object[] - configuration options - - - - - - - - - - -
ParamTypeDescription
deviceTypeString

device type slug

-
- -**Example** -```js -balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) { - console.log(options); -}); -``` - -* * * - - - -##### config.getDeviceOptions(deviceType) ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get configuration/initialization options for a device type -**Access**: public -**Fulfil**: Object[] - configuration options - - - - - - - - - - -
ParamTypeDescription
deviceTypeString

device type slug

-
- -**Example** -```js -balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) { - console.log(options); -}); -``` - -* * * - - - -##### config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise -***use balena.models.deviceType.getBySlugOrName*** - -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get a device type manifest by slug -**Access**: public -**Fulfil**: Object - device type manifest - - - - - - - - - - -
ParamTypeDescription
slugOrNameString

device type slug

-
- -**Example** -```js -balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) { - console.log(manifest); -}); -``` - -* * * - - - -##### config.getDeviceTypes() ⇒ Promise -***use balena.models.deviceType.getAll*** - -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get device types -**Access**: public -**Fulfil**: Object[] - device types -**Example** -```js -balena.models.config.getDeviceTypes().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` - -* * * - - - -#### models.creditBundle : object -**Kind**: static namespace of [models](#balena.models) - -* [.creditBundle](#balena.models.creditBundle) : object - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - - -* * * - - - -##### creditBundle.create(organization, featureId, creditsToPurchase) ⇒ Promise -**Kind**: static method of [creditBundle](#balena.models.creditBundle) -**Summary**: Purchase a credit bundle for the given feature and org of the given quantity -**Access**: public -**Fulfil**: Object[] - credit bundles - - - - - - - - - - - - - - -
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
featureIdNumber

id (number) of the feature for which credits are being purchased.

-
creditsToPurchaseNumber

number of credits being purchased.

-
- -**Example** -```js -balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) { - console.log(creditBundle); -}); -``` - -* * * - - - -##### creditBundle.getAllByOrg(organization, [options]) ⇒ Promise -**Kind**: static method of [creditBundle](#balena.models.creditBundle) -**Summary**: Get all of the credit bundles purchased by the given org -**Access**: public -**Fulfil**: Object[] - credit bundles - - - - - - - - - - - - -
ParamTypeDefaultDescription
organizationString | Number

handle (string) or id (number) of the target organization.

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) { - console.log(creditBundles); -}); -``` - -* * * - - - -#### models.device : object -**Kind**: static namespace of [models](#balena.models) - -* [.device](#balena.models.device) : object - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.pinToOsRelease(uuidOrIdOrArray, osVersionOrId)](#balena.models.device.pinToOsRelease) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.pinToSupervisorRelease) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - - -* * * - - - -##### device.deactivate(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Deactivate device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
- -**Example** -```js -balena.models.device.deactivate('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.deactivate(123); -``` - -* * * - - - -##### device.disableDeviceUrl(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable device url for a device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
- -**Example** -```js -balena.models.device.disableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.disableDeviceUrl(123); -``` - -* * * - - - -##### device.disableLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable local mode -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.disableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.disableLocalMode(123); -``` - -* * * - - - -##### device.disableLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable lock override -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.disableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.disableLockOverride(123); -``` - -* * * - - - -##### device.enableDeviceUrl(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable device url for a device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
- -**Example** -```js -balena.models.device.enableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.enableDeviceUrl(123); -``` - -* * * - - - -##### device.enableLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable local mode -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.enableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.enableLocalMode(123); -``` - -* * * - - - -##### device.enableLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable lock override -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.enableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.enableLockOverride(123); -``` - -* * * - - - -##### device.generateDeviceKey(uuidOrId, [keyName], [keyDescription]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Generate a device key -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[keyName]String

Device key name

-
[keyDescription]String

Description for device key

-
- -**Example** -```js -balena.models.device.generateDeviceKey('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceApiKey) { - console.log(deviceApiKey); -}); -``` -**Example** -```js -balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) { - console.log(deviceApiKey); -}); -``` - -* * * - - - -##### device.generateUniqueKey() ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Generate a random key, useful for both uuid and api key. -**Returns**: String - A generated key -**Access**: public -**Example** -```js -randomKey = balena.models.device.generateUniqueKey(); -// randomKey is a randomly generated key that can be used as either a uuid or an api key -console.log(randomKey); -``` - -* * * - - - -##### device.get(uuidOrId, [options]) ⇒ Promise -This method returns a single device by id or uuid. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a single device -**Access**: public -**Fulfil**: Object - device - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.get(123).then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - -* * * - - - -##### device.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all devices of a specific application. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get all devices by application -**Access**: public -**Fulfil**: Object[] - devices - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByApplication(123).then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - -* * * - - - -##### device.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all devices of a specific application. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get all devices by organization -**Access**: public -**Fulfil**: Object[] - devices - - - - - - - - - - - - -
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.getAllByOrganization('myorganization').then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByOrganization(123).then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - -* * * - - - -##### device.getApplicationName(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get application name -**Access**: public -**Fulfil**: String - application name - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getApplicationName('7cf02a69e4d34c9da573914963cf54fd').then(function(applicationName) { - console.log(applicationName); -}); -``` -**Example** -```js -balena.models.device.getApplicationName(123).then(function(applicationName) { - console.log(applicationName); -}); -``` - -* * * - - - -##### device.getByName(name) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get devices by name -**Access**: public -**Fulfil**: Object[] - devices - - - - - - - - - - -
ParamTypeDescription
nameString

device name

-
- -**Example** -```js -balena.models.device.getByName('MyDevice').then(function(devices) { - console.log(devices); -}); -``` - -* * * - - - -##### device.getDashboardUrl(uuid) ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get Dashboard URL for a specific device -**Returns**: String - - Dashboard URL for the specific device -**Throws**: - -- Exception if the uuid is empty - - - - - - - - - - - -
ParamTypeDescription
uuidString

Device uuid

-
- -**Example** -```js -dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8') -``` - -* * * - - - -##### device.getDeviceUrl(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a device url -**Access**: public -**Fulfil**: String - device url - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(url) { - console.log(url); -}); -``` -**Example** -```js -balena.models.device.getDeviceUrl(123).then(function(url) { - console.log(url); -}); -``` - -* * * - - - -##### device.getLocalIPAddresses(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the local IP addresses of a device -**Access**: public -**Fulfil**: String[] - local ip addresses -**Reject**: Error Will reject if the device is offline - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getLocalIPAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(localIPAddresses) { - localIPAddresses.forEach(function(localIP) { - console.log(localIP); - }); -}); -``` -**Example** -```js -balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) { - localIPAddresses.forEach(function(localIP) { - console.log(localIP); - }); -}); -``` - -* * * - - - -##### device.getLocalModeSupport(device) ⇒ Object -**Kind**: static method of [device](#balena.models.device) -**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported. -**Returns**: Object - Local mode support info ({ supported: true/false, message: "..." }) -**Access**: public - - - - - - - - - - -
ParamTypeDescription
deviceObject

A device object

-
- -**Example** -```js -balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { - balena.models.device.getLocalModeSupport(device); -}) -``` - -* * * - - - -##### device.getMACAddresses(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the MAC addresses of a device -**Access**: public -**Fulfil**: String[] - mac addresses - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getMACAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(macAddresses) { - macAddresses.forEach(function(mac) { - console.log(mac); - }); -}); -``` -**Example** -```js -balena.models.device.getMACAddresses(123).then(function(macAddresses) { - macAddresses.forEach(function(mac) { - console.log(mac); - }); -}); -``` - -* * * - - - -##### device.getMetrics(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the metrics related information for a device -**Access**: public -**Fulfil**: Object - device metrics - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getMetrics('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceMetrics) { - console.log(deviceMetrics); -}); -``` -**Example** -```js -balena.models.device.getMetrics(123).then(function(deviceMetrics) { - console.log(deviceMetrics); -}); -``` - -* * * - - - -##### device.getName(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the name of a device -**Access**: public -**Fulfil**: String - device name - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getName('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceName) { - console.log(deviceName); -}); -``` -**Example** -```js -balena.models.device.getName(123).then(function(deviceName) { - console.log(deviceName); -}); -``` - -* * * - - - -##### device.getOsVersion(device) ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the OS version (version number and variant combined) running on a device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
deviceObject

A device object

-
- -**Example** -```js -balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { - console.log(device.os_version); // => 'balenaOS 2.26.0+rev1' - console.log(device.os_variant); // => 'prod' - balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod' -}) -``` - -* * * - - - -##### device.getProgress(uuidOrId) ⇒ Promise -Convenience method for getting the overall progress of a device. -It's recommended to use `balena.models.device.get()` instead, -in case that you need to retrieve more device fields than just the progress. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the progress of a device -**Access**: public -**Fulfil**: Number\|null - device progress -**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field. - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getProgress('7cf02a69e4d34c9da573914963cf54fd').then(function(progress) { - console.log(progress); -}); -``` -**Example** -```js -balena.models.device.getProgress(123).then(function(progress) { - console.log(progress); -}); -``` - -* * * - - - -##### device.getStatus(uuidOrId) ⇒ Promise -Convenience method for getting the overall status of a device. -It's recommended to use `balena.models.device.get()` instead, -in case that you need to retrieve more device fields than just the status. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the status of a device -**Access**: public -**Fulfil**: String - device status -**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field. - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getStatus('7cf02a69e4d34c9da573914963cf54fd').then(function(status) { - console.log(status); -}); -``` -**Example** -```js -balena.models.device.getStatus(123).then(function(status) { - console.log(status); -}); -``` - -* * * - - - -##### device.getSupervisorState(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the supervisor state on a device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getSupervisorState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorState(123).then(function(state) { - console.log(state); -}); -``` - -* * * - - - -##### device.getSupervisorTargetState(uuidOrId, version) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the target supervisor state on a device -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
versionNumber

(optional) target state version (2 or 3), default to 2

-
- -**Example** -```js -balena.models.device.getSupervisorTargetState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetState(123).then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetState(123, 3).then(function(state) { - console.log(state); -}); -``` - -* * * - - - -##### device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the target supervisor state on a "generic" device on a fleet -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

fleet uuid (string) or id (number)

-
releaseString

(optional) release uuid (default tracked)

-
- -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a69e4d34c9da573914963cf54fd').then(function(state) { - console.log(state); -}); -``` - -* * * - - - -##### device.getTargetReleaseHash(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the hash of the currently tracked release for a specific device -**Access**: public -**Fulfil**: String - The release hash of the currently tracked release - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd', function(release) { - console.log(release); -}); -``` - -* * * - - - -##### device.getWithServiceDetails(uuidOrId, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want more control, or to see the raw model -directly, use `device.get(uuidOrId, options)` instead. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a single device along with its associated services' details, -including their associated commit -**Access**: public -**Fulfil**: Object - device with service details - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.getWithServiceDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.getWithServiceDetails(123).then(function(device) { - console.log(device); -}) -``` - -* * * - - - -##### device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Grant support access to a device until a specified time -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
expiryTimestampNumber

a timestamp in ms for when the support access will expire

-
- -**Example** -```js -balena.models.device.grantSupportAccess('7cf02a69e4d34c9da573914963cf54fd', Date.now() + 3600 * 1000); -``` -**Example** -```js -balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000); -``` - -* * * - - - -##### device.has(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device exists -**Access**: public -**Fulfil**: Boolean - has device - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.has('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDevice) { - console.log(hasDevice); -}); -``` -**Example** -```js -balena.models.device.has(123).then(function(hasDevice) { - console.log(hasDevice); -}); -``` - -* * * - - - -##### device.hasDeviceUrl(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device is web accessible with device utls -**Access**: public -**Fulfil**: Boolean - has device url - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.hasDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDeviceUrl) { - if (hasDeviceUrl) { - console.log('The device has device URL enabled'); - } -}); -``` -**Example** -```js -balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) { - if (hasDeviceUrl) { - console.log('The device has device URL enabled'); - } -}); -``` - -* * * - - - -##### device.hasLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device has the lock override enabled -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.hasLockOverride('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.hasLockOverride(123); -``` - -* * * - - - -##### device.identify(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Identify device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.identify('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.identify(123); -``` - -* * * - - - -##### device.isInLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if local mode is enabled on the device -**Access**: public -**Fulfil**: Boolean - has device url - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.isInLocalMode('7cf02a69e4d34c9da573914963cf54fd').then(function(isInLocalMode) { - if (isInLocalMode) { - console.log('The device has local mode enabled'); - } -}); -``` -**Example** -```js -balena.models.device.isInLocalMode(123).then(function(isInLocalMode) { - if (isInLocalMode) { - console.log('The device has local mode enabled'); - } -}); -``` - -* * * - - - -##### device.isOnline(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device is online -**Access**: public -**Fulfil**: Boolean - is device online - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.isOnline('7cf02a69e4d34c9da573914963cf54fd').then(function(isOnline) { - console.log('Is device online?', isOnline); -}); -``` -**Example** -```js -balena.models.device.isOnline(123).then(function(isOnline) { - console.log('Is device online?', isOnline); -}); -``` - -* * * - - - -##### device.isTrackingApplicationRelease(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get whether the device is configured to track the current application release -**Access**: public -**Fulfil**: Boolean - is tracking the current application release - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.isTrackingApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(isEnabled) { - console.log(isEnabled); -}); -``` - -* * * - - - -##### device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Move a device to another application -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.move('7cf02a69e4d34c9da573914963cf54fd', 'myorganization/myapp'); -``` -**Example** -```js -balena.models.device.move(123, 'myorganization/myapp'); -``` -**Example** -```js -balena.models.device.move(123, 456); -``` - -* * * - - - -##### device.ping(uuidOrId) ⇒ Promise -This is useful to signal that the supervisor is alive and responding. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Ping a device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.ping('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.ping(123); -``` - -* * * - - - -##### device.pinToOsRelease(uuidOrIdOrArray, osVersionOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Mark a specific device to be updated to a particular OS release -**Access**: public -**Experimental**: - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
osVersionOrIdString

the raw version of a OS release (string) or id (number) -Unsupported (unpublished) version will result in rejection. -The version must be the exact version number, a "prod" variant and greater than or equal to the one running on the device. -To resolve compatible update targets for a device use balena.models.os.getSupportedOsUpdateVersions.

-
- -**Example** -```js -await balena.models.device.pinToOsRelease('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod'); -``` - -* * * - - - -##### device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ Promise -Configures the device to run a particular release -and not get updated when the current application release changes. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a specific device to run a particular release -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
fullReleaseHashOrIdString | Number

the hash of a successful release (string) or id (number)

-
- -**Example** -```js -balena.models.device.pinToRelease('7cf02a69e4d34c9da573914963cf54fd', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` - -* * * - - - -##### device.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ Promise -Configures the device to run a particular supervisor release. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a specific device to run a particular supervisor release -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
supervisorVersionOrIdString | Number

the raw version of a supervisor release (string) or id (number)

-
- -**Example** -```js -balena.models.device.pinToSupervisorRelease('7cf02a69e4d34c9da573914963cf54fd', '10.8.0').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.pinToSupervisorRelease(123, '11.4.14').then(function() { - ... -}); -``` - -* * * - - - -##### device.purge(uuidOrId) ⇒ Promise -This function clears the user application's `/data` directory. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Purge device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.purge('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.purge(123); -``` - -* * * - - - -##### device.reboot(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Reboot device -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object

options

-
[options.force]Booleanfalse

override update lock

-
- -**Example** -```js -balena.models.device.reboot('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.reboot(123); -``` - -* * * - - - -##### device.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Register a new device with a Balena application. -**Access**: public -**Fulfil**: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." }) - - - - - - - - - - - - - - -
ParamTypeDescription
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
uuidString

device uuid

-
[deviceTypeSlug]String

device type slug (string) or alias (string)

-
- -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register(123, uuid).then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` - -* * * - - - -##### device.remove(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Remove device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
- -**Example** -```js -balena.models.device.remove('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.remove(123); -``` - -* * * - - - -##### device.rename(uuidOrId, newName) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Rename device -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
newNameString

the device new name

-
- -**Example** -```js -balena.models.device.rename('7cf02a69e4d34c9da573914963cf54fd', 'NewName'); -``` -**Example** -```js -balena.models.device.rename(123, 'NewName'); -``` - -* * * - - - -##### device.restartApplication(uuidOrId) ⇒ Promise -This function restarts the Docker container running -the application on the device, but doesn't reboot -the device itself. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Restart application on device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
- -**Example** -```js -balena.models.device.restartApplication('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.restartApplication(123); -``` - -* * * - - - -##### device.restartService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Restart a service on a device -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
imageIdNumber

id of the image to restart

-
- -**Example** -```js -balena.models.device.restartService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.restartService(1, 123).then(function() { - ... -}); -``` - -* * * - - - -##### device.revokeSupportAccess(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Revoke support access to a device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
- -**Example** -```js -balena.models.device.revokeSupportAccess('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.revokeSupportAccess(123); -``` - -* * * - - - -##### device.setCustomLocation(uuidOrIdOrArray, location) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a custom location for a device -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
locationObject

the location ({ latitude: 123, longitude: 456 })

-
- -**Example** -```js -balena.models.device.setCustomLocation('7cf02a69e4d34c9da573914963cf54fd', { latitude: 123, longitude: 456 }); -``` -**Example** -```js -balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 }); -``` - -* * * - - - -##### device.setNote(uuidOrIdOrArray, note) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Note a device -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
noteString

the note

-
- -**Example** -```js -balena.models.device.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); -``` -**Example** -```js -balena.models.device.setNote(123, 'My useful note'); -``` - -* * * - - - -##### device.shutdown(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Shutdown device -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object

options

-
[options.force]Booleanfalse

override update lock

-
- -**Example** -```js -balena.models.device.shutdown('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.shutdown(123); -``` - -* * * - - - -##### device.startOsUpdate(uuidOrUuids, targetOsVersion, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start an OS update on a device -**Access**: public -**Fulfil**: Object - action response - - - - - - - - - - - - - - - - -
ParamTypeDescription
uuidOrUuidsString | Array.<String>

full device uuid or array of full uuids

-
targetOsVersionString

semver-compatible version for the target device -Unsupported (unpublished) version will result in rejection. -The version must be the exact version number, a "prod" variant and greater than the one running on the device. -To resolve the semver-compatible range use balena.model.os.getMaxSatisfyingVersion.

-
[options]Object

options

-
[options.runDetached]Boolean

run the update in detached mode. True by default

-
- -**Example** -```js -balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { - console.log(result.status); -}); -``` - -* * * - - - -##### device.startService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start a service on a device -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
imageIdNumber

id of the image to start

-
- -**Example** -```js -balena.models.device.startService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.startService(1, 123).then(function() { - ... -}); -``` - -* * * - - - -##### device.stopService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Stop a service on a device -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
imageIdNumber

id of the image to stop

-
- -**Example** -```js -balena.models.device.stopService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.stopService(1, 123).then(function() { - ... -}); -``` - -* * * - - - -##### device.trackApplicationRelease(uuidOrIdOrArray) ⇒ Promise -The device's current release will be updated with each new successfully built release. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Configure a specific device to track the current application release -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
- -**Example** -```js -balena.models.device.trackApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function() { - ... -}); -``` - -* * * - - - -##### device.unsetCustomLocation(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Clear the custom location of a device -**Access**: public - - - - - - - - - - -
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

-
- -**Example** -```js -balena.models.device.unsetCustomLocation('7cf02a69e4d34c9da573914963cf54fd'); -``` -**Example** -```js -balena.models.device.unsetCustomLocation(123); -``` - -* * * - - - -##### device.update(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Trigger an update check on the supervisor -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object

options

-
[options.force]Booleanfalse

override update lock

-
- -**Example** -```js -balena.models.device.update('7cf02a69e4d34c9da573914963cf54fd', { - force: true -}); -``` -**Example** -```js -balena.models.device.update(123, { - force: true -}); -``` - -* * * - - - -##### device.configVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.configVar](#balena.models.device.configVar) : object - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - - -* * * - - - -###### configVar.get(uuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get the value of a specific config variable -**Access**: public -**Fulfil**: String\|undefined - the config variable value (or undefined) - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
keyString

config variable name

-
- -**Example** -```js -balena.models.device.configVar.get('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` - -* * * - - - -###### configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get all device config variables by application -**Access**: public -**Fulfil**: Object[] - device config variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.configVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### configVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get all config variables for a device -**Access**: public -**Fulfil**: Object[] - device config variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.configVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.configVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### configVar.remove(uuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Clear the value of a specific config variable -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
keyString

config variable name

-
- -**Example** -```js -balena.models.device.configVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() { - ... -}); -``` - -* * * - - - -###### configVar.set(uuidOrId, key, value) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Set the value of a specific config variable -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
keyString

config variable name

-
valueString

config variable value

-
- -**Example** -```js -balena.models.device.configVar.set('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` - -* * * - - - -##### device.envVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.envVar](#balena.models.device.envVar) : object - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - - -* * * - - - -###### envVar.get(uuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get the value of a specific environment variable -**Access**: public -**Fulfil**: String\|undefined - the environment variable value (or undefined) - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
keyString

environment variable name

-
- -**Example** -```js -balena.models.device.envVar.get('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.envVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - -* * * - - - -###### envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get all device environment variables by application -**Access**: public -**Fulfil**: Object[] - device environment variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.envVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### envVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get all environment variables for a device -**Access**: public -**Fulfil**: Object[] - device environment variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.envVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.envVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### envVar.remove(uuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Clear the value of a specific environment variable -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
keyString

environment variable name

-
- -**Example** -```js -balena.models.device.envVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.envVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - -* * * - - - -###### envVar.set(uuidOrId, key, value) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Set the value of a specific environment variable -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
keyString

environment variable name

-
valueString

environment variable value

-
- -**Example** -```js -balena.models.device.envVar.set('7cf02a69e4d34c9da573914963cf54fd', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - -* * * - - - -##### device.history : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.history](#balena.models.device.history) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - - -* * * - - - -###### history.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [history](#balena.models.device.history) -**Summary**: Get all device history entries by application with time frame -**Access**: public -**Fulfil**: Object[] - device history - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

-
[dateFilter.toDate]Date

history entries younger or equal to this date

-
[options]Object

extra pine options to use

-
- -**Example** -```js -balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -balena.models.device.history.getAllByApplication(999999).then(function(entries) { - console.log(entries); -}); - - -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByApplication( - 999999, - { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10), - { $top: 10, $orderby: { id: 'desc' }} -}); -``` - -* * * - - - -###### history.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [history](#balena.models.device.history) -**Summary**: Get all history entries for a device -**Access**: public -**Fulfil**: Object[] - device history - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (32 / 62 digits string) or id (number)

-
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

-
[dateFilter.toDate]Date

history entries younger or equal to this date

-
[options]Object

extra pine options to use

-
- -**Example** -```js -balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -balena.models.device.history.getAllByDevice(999999).then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByDevice( - 999999, - { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}, - { $top: 10, $orderby: { id: 'desc' }} -) -``` - -* * * - - - -##### device.serviceVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.serviceVar](#balena.models.device.serviceVar) : object - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - - -* * * - - - -###### serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get the overriden value of a service variable on a device -**Access**: public -**Fulfil**: String\|undefined - the variable value (or undefined) - - - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
serviceNameOrIdString | Number

service name (string) or id (number)

-
keyString

variable name

-
- -**Example** -```js -balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) { - console.log(value); -}); -``` - -* * * - - - -###### serviceVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get all device service variable overrides by application -**Access**: public -**Fulfil**: Object[] - service variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### serviceVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get all service variable overrides for a device -**Access**: public -**Fulfil**: Object[] - service variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.serviceVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Clear the overridden value of a service variable on a device -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
serviceNameOrIdString | Number

service name (string) or id (number)

-
keyString

variable name

-
- -**Example** -```js -balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() { - ... -}); -``` - -* * * - - - -###### serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Set the overriden value of a service variable on a device -**Access**: public - - - - - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
serviceNameOrIdString | Number

service name (string) or id (number)

-
keyString

variable name

-
valueString

variable value

-
- -**Example** -```js -balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR', 'override').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR', 'override').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() { - ... -}); -``` - -* * * - - - -##### device.tags : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - - -* * * - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Get all device tags for an application -**Access**: public -**Fulfil**: Object[] - device tags - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.device.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - -* * * - - - -###### tags.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Get all device tags for a device -**Access**: public -**Fulfil**: Object[] - device tags - - - - - - - - - - - - -
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.device.tags.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.device.tags.getAllByDevice(123).then(function(tags) { - console.log(tags); -}); -``` - -* * * - - - -###### tags.remove(uuidOrId, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Remove a device tag -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
tagKeyString

tag key

-
- -**Example** -```js -balena.models.device.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); -``` - -* * * - - - -###### tags.set(uuidOrId, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Set a device tag -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

-
tagKeyString

tag key

-
valueString | undefined

tag value

-
- -**Example** -```js -balena.models.device.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.device.tags.set(123, 'EDITOR', 'vim'); -``` - -* * * - - - -#### models.deviceType : object -**Kind**: static namespace of [models](#balena.models) - -* [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - - -* * * - - - -##### deviceType.get(idOrSlug, [options]) ⇒ Promise -This method returns a single device type. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a single deviceType -**Access**: public -**Fulfil**: Object[] - device types - - - - - - - - - - - - -
ParamTypeDefaultDescription
idOrSlugString | Number

device type slug (string) or alias (string) or id

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.deviceType.get('raspberry-pi').then(function(deviceType) { - console.log(deviceType); -}); -``` -**Example** -```js -balena.models.deviceType.get('raspberrypi').then(function(deviceType) { - console.log('resolved alias:', deviceType); -}); -``` - -* * * - - - -##### deviceType.getAll([options]) ⇒ Promise -This method returns all device types. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get all deviceTypes -**Access**: public -**Fulfil**: Object[] - device types - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.deviceType.getAll().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` -**Example** -```js -balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) { - console.log(deviceTypes); -}) -``` - -* * * - - - -##### deviceType.getAllSupported([options]) ⇒ Promise -This method returns all supported device types. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get all supported deviceTypes -**Access**: public -**Fulfil**: Object[] - device types - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.deviceType.getAllSupported().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` -**Example** -```js -balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) { - console.log(deviceTypes); -}) -``` - -* * * - - - -##### deviceType.getBySlugOrName(slugOrName) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a deviceType by slug or name -**Access**: public -**Fulfil**: Object - device type - - - - - - - - - - -
ParamTypeDescription
slugOrNameString

deviceType slug

-
- -**Example** -```js -balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { - console.log(deviceType); -}); -``` - -* * * - - - -##### deviceType.getInstallMethod(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get installation method on a given device type -**Access**: public -**Fulfil**: String - the installation method supported for the given device type slug - - - - - - - - - - -
ParamTypeDescription
deviceTypeSlugString

device type slug

-
- -**Example** -```js -balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { - console.log(method); - // externalBoot -}); -``` - -* * * - - - -##### deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get instructions for installing a host OS on a given device type -**Access**: public -**Fulfil**: Object \| String[] - step by step instructions for installing the host OS to the device - - - - - - - - - - -
ParamTypeDescription
deviceTypeSlugOrContractString | Object

device type slug or contract

-
- -**Example** -```js -balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { - for (let instruction of instructions.values()) { - console.log(instruction); - } - // Insert the sdcard to the host machine. - // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. - // Wait for writing of BalenaOS to complete. - // Remove the sdcard from the host machine. - // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). - // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. -}); -``` - -* * * - - - -##### deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a contract with resolved partial templates -**Access**: public -**Fulfil**: Contract - device type contract with resolved partials - - - - - - - - - - -
ParamTypeDescription
deviceTypeSlugString

device type slug

-
- -**Example** -```js -balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { - for (const partial in contract.partials) { - console.log(`${partial}: ${contract.partials[partial]}`); - } - // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] -}); -``` - -* * * - - - -##### deviceType.getName(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get display name for a device -**Access**: public -**Fulfil**: String - device display name - - - - - - - - - - -
ParamTypeDescription
deviceTypeSlugString

device type slug

-
- -**Example** -```js -balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { - console.log(deviceTypeName); - // Raspberry Pi -}); -``` - -* * * - - - -##### deviceType.getSlugByName(deviceTypeName) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get device slug -**Access**: public -**Fulfil**: String - device slug name - - - - - - - - - - -
ParamTypeDescription
deviceTypeNameString

device type name

-
- -**Example** -```js -balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { - console.log(deviceTypeSlug); - // raspberry-pi -}); -``` - -* * * - - - -#### models.image : object -**Kind**: static namespace of [models](#balena.models) - -* [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - - -* * * - - - -##### image.get(id, [options]) ⇒ Promise -**Kind**: static method of [image](#balena.models.image) -**Summary**: Get a specific image -**Access**: public -**Fulfil**: Object - image - - - - - - - - - - - - -
ParamTypeDefaultDescription
idNumber

image id

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.image.get(123).then(function(image) { - console.log(image); -}); -``` - -* * * - - - -##### image.getLogs(id) ⇒ Promise -**Kind**: static method of [image](#balena.models.image) -**Summary**: Get the logs for an image -**Access**: public -**Fulfil**: string \| null - logs - - - - - - - - - - -
ParamTypeDescription
idNumber

image id

-
- -**Example** -```js -balena.models.image.getLogs(123).then(function(logs) { - console.log(logs); -}); -``` - -* * * - - - -#### models.key : object -**Kind**: static namespace of [models](#balena.models) - -* [.key](#balena.models.key) : object - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - - -* * * - - - -##### key.create(title, key) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Create a ssh key -**Access**: public -**Fulfil**: Object - ssh key - - - - - - - - - - - - -
ParamTypeDescription
titleString

key title

-
keyString

the public ssh key

-
- -**Example** -```js -balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) { - console.log(key); -}); -``` - -* * * - - - -##### key.get(id) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Get a single ssh key -**Access**: public -**Fulfil**: Object - ssh key - - - - - - - - - - -
ParamTypeDescription
idNumber

key id

-
- -**Example** -```js -balena.models.key.get(51).then(function(key) { - console.log(key); -}); -``` - -* * * - - - -##### key.getAll([options]) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Get all ssh keys -**Access**: public -**Fulfil**: Object[] - ssh keys - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.key.getAll().then(function(keys) { - console.log(keys); -}); -``` - -* * * - - - -##### key.remove(id) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Remove ssh key -**Access**: public - - - - - - - - - - -
ParamTypeDescription
idNumber

key id

-
- -**Example** -```js -balena.models.key.remove(51); -``` - -* * * - - - -#### models.organization : object -**Kind**: static namespace of [models](#balena.models) - -* [.organization](#balena.models.organization) : object - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.membership](#balena.models.organization.membership) : object - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - - -* * * - - - -##### organization.create(options) ⇒ Promise -This method creates a new organization with the current user as an administrator. - -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Creates a new organization -**Access**: public -**Fulfil**: String - Organization - - - - - - - - - - - - - - -
ParamTypeDescription
optionsObject

Organization parameters to use.

-
options.nameString

Required: the name of the organization that will be created.

-
[options.handle]String

The handle of the organization that will be created.

-
- -**Example** -```js -balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.create({ - name:'MyOrganization', - logo_image: new File( - imageContent, - 'img.jpeg' - ); -}) -.then(function(organization) { - console.log(organization); -}); -``` - -* * * - - - -##### organization.get(handleOrId, [options]) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Get a single organization -**Access**: public -**Fulfil**: Object - organization - - - - - - - - - - - - -
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.organization.get('myorganization').then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.get(123).then(function(organization) { - console.log(organization); -}); -``` - -* * * - - - -##### organization.getAll([options]) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Get all Organizations -**Access**: public -**Fulfil**: Object[] - organizations - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.organization.getAll().then(function(organizations) { - console.log(organizations); -}); -``` - -* * * - - - -##### organization.remove(handleOrId) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Remove an Organization -**Access**: public - - - - - - - - - - -
ParamTypeDescription
handleOrIdString | Number

organization handle (string) or id (number).

-
- -**Example** -```js -balena.models.organization.remove(123); -``` - -* * * - - - -##### organization.invite : object -**Kind**: static namespace of [organization](#balena.models.organization) - -* [.invite](#balena.models.organization.invite) : object - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - - -* * * - - - -###### invite.accept(invitationToken) ⇒ Promise -This method adds the calling user to the organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Accepts an invite -**Access**: public - - - - - - - - - - -
ParamTypeDescription
invitationTokenString

invite token

-
- -**Example** -```js -balena.models.organization.invite.accept("qwerty-invitation-token"); -``` - -* * * - - - -###### invite.create(handleOrId, options, [message]) ⇒ Promise -This method invites a user by their email to an organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Creates a new invite for an organization -**Access**: public -**Fulfil**: String - organization invite - - - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

-
optionsObject

invite creation parameters

-
options.inviteeString

the email of the invitee

-
[options.roleName]String"developer"

the role name to be granted to the invitee

-
[message]String

the message to send along with the invite

-
- -**Example** -```js -balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) { - console.log(invite); -}); -``` - -* * * - - - -###### invite.getAll([options]) ⇒ Promise -This method returns all invites. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Get all invites -**Access**: public -**Fulfil**: Object[] - invites - - - - - - - - - - -
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.organization.invite.getAll().then(function(invites) { - console.log(invites); -}); -``` - -* * * - - - -###### invite.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all invites for a specific organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Get all invites by organization -**Access**: public -**Fulfil**: Object[] - invites - - - - - - - - - - - - -
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) { - console.log(invites); -}); -``` -**Example** -```js -balena.models.organization.invite.getAllByOrganization(123).then(function(invites) { - console.log(invites); -}); -``` - -* * * - - - -###### invite.revoke(id) ⇒ Promise -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Revoke an invite -**Access**: public - - - - - - - - - - -
ParamTypeDescription
idNumber

organization invite id

-
- -**Example** -```js -balena.models.organization.invite.revoke(123); -``` - -* * * - - - -##### organization.membership : object -**Kind**: static namespace of [organization](#balena.models.organization) - -* [.membership](#balena.models.organization.membership) : object - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - - -* * * - - - -###### membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise -This method changes the role of an organization member. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Changes the role of an organization member -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership that will be changed

-
roleNameString

the role name to be granted to the membership

-
- -**Example** -```js -balena.models.organization.membership.changeRole(123, "member").then(function() { - console.log('OK'); -}); -``` -**Example** -```js -balena.models.organization.membership.changeRole({ - user: 123, - is_member_of__organization: 125, -}, "member").then(function() { - console.log('OK'); -}); -``` - -* * * - - - -###### membership.get(membershipId, [options]) ⇒ Promise -This method returns a single organization membership. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get a single organization membership -**Access**: public -**Fulfil**: Object - organization membership - - - - - - - - - - - - -
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.organization.membership.get(5).then(function(memberships) { - console.log(memberships); -}); -``` - -* * * - - - -###### membership.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all organization memberships for a specific organization. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get all memberships by organization -**Access**: public -**Fulfil**: Object[] - organization memberships - - - - - - - - - - - - -
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) { - console.log(memberships); -}); -``` - -* * * - - - -###### membership.getAllByUser(usernameOrId, [options]) ⇒ Promise -This method returns all organization memberships for a specific user. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get all memberships by user -**Access**: public -**Fulfil**: Object[] - organization memberships - - - - - - - - - - - - -
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.organization.membership.getAllByUser(123).then(function(memberships) { - console.log(memberships); -}); -``` - -* * * - - - -###### membership.remove(id) ⇒ Promise -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Remove a membership -**Access**: public - - - - - - - - - - -
ParamTypeDescription
idNumber

organization membership id

-
- -**Example** -```js -balena.models.organization.membership.remove(123); -``` -**Example** -```js -balena.models.organization.membership.remove({ - user: 123, - is_member_of__application: 125, -}); -``` - -* * * - - - -#### models.os : object -**Kind**: static namespace of [models](#balena.models) - -* [.os](#balena.models.os) : object - * [.download(options)](#balena.models.os.download) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getAvailableOsVersions(deviceTypes, [pineOptions], [extraOptions])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ Promise - * [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ Promise.<String> - * [.getSupportedOsUpdateVersions(deviceType, currentVersion, [options])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ Promise - * [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ Boolean - * [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ Promise - - -* * * - - - -##### os.download(options) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Download an OS image -**Access**: public -**Fulfil**: ReadableStream - download stream - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
optionsObject

OS image options to use.

-
options.deviceTypeString

device type slug

-
[options.version]String'latest'

semver-compatible version or 'latest', defaults to 'latest' -Unsupported (unpublished) version will result in rejection. -The version must be the exact version number.

-
[options.developmentMode]Boolean

controls development mode for unified balenaOS releases.

-
[options.appId]Number

the application ID (number).

-
[options.fileType]String

download file type. One of '.img' or '.zip' or '.gz'.

-
[options.imageType]String

download file type. One of 'raw' or 'flasher'

-
[options.appUpdatePollInterval]Number

how often the OS checks for updates, in minutes.

-
[options.network]String

the network type that the device will use, one of 'ethernet' or 'wifi'.

-
[options.wifiKey]String

the key for the wifi network the device will connect to if network is wifi.

-
[options.wifiSsid]String

the ssid for the wifi network the device will connect to if network is wifi.

-
- -**Example** -```js -balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) { - stream.pipe(fs.createWriteStream('foo/bar/image.img')); -}); -``` - -* * * - - - -##### os.getAllOsVersions(deviceTypes, [options]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. - - - - - - - - - - - - -
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.os.getAllOsVersions('raspberrypi3'); -``` -**Example** -```js -balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']); -``` -**Example** -```js -balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } }); -``` - -* * * - - - -##### os.getAvailableOsVersions(deviceTypes, [pineOptions], [extraOptions]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the supported OS versions for the provided device type(s) -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

-
[pineOptions]Object

Extra pine options to use

-
[extraOptions]Object

Extra convenience options to use

-
[extraOptions.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

-
- -**Example** -```js -balena.models.os.getAvailableOsVersions('raspberrypi3'); -``` -**Example** -```js -balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']); -``` - -* * * - - - -##### os.getConfig(slugOrUuidOrId, options) ⇒ Promise -Builds the config.json for a device in the given application, with the given -options. - -Note that an OS version is required. For versions < 2.7.8, config -generation is only supported when using a session token, not an API key. - -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get an applications config.json -**Access**: public -**Fulfil**: Object - application configuration as a JSON object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number).

-
optionsObject

OS configuration options to use.

-
options.versionString

Required: the OS version of the image.

-
[options.network]String'ethernet'

The network type that -the device will use, one of 'ethernet' or 'wifi'.

-
[options.appUpdatePollInterval]Number

How often the OS checks -for updates, in minutes.

-
[options.provisioningKeyName]String

Name assigned to API key

-
[options.provisioningKeyExpiryDate]String

Expiry Date assigned to API key

-
[options.developmentMode]Boolean

Controls development mode for unified balenaOS releases.

-
[options.wifiKey]String

The key for the wifi network the -device will connect to.

-
[options.wifiSsid]String

The ssid for the wifi network the -device will connect to.

-
[options.ip]String

static ip address.

-
[options.gateway]String

static ip gateway.

-
[options.netmask]String

static ip netmask.

-
- -**Example** -```js -balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) { - fs.writeFile('foo/bar/config.json', JSON.stringify(config)); -}); - -balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) { - fs.writeFile('foo/bar/config.json', JSON.stringify(config)); -}); -``` - -* * * - - - -##### os.getDownloadSize(deviceType, [version]) ⇒ Promise -**Note!** Currently only the raw (uncompressed) size is reported. - -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get OS download size estimate -**Access**: public -**Fulfil**: Number - OS image download size, in bytes. - - - - - - - - - - - - -
ParamTypeDescription
deviceTypeString

device type slug

-
[version]String

semver-compatible version or 'latest', defaults to 'latest'. -The version must be the exact version number.

-
- -**Example** -```js -balena.models.os.getDownloadSize('raspberry-pi').then(function(size) { - console.log('The OS download size for raspberry-pi', size); -}); -``` - -* * * - - - -##### os.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the max OS version satisfying the given range -**Access**: public -**Fulfil**: String\|null - the version number, or `null` if no matching versions are found - - - - - - - - - - - - - - -
ParamTypeDescription
deviceTypeString

device type slug

-
versionOrRangeString

can be one of

-
    -
  • the exact version number, -in which case it is returned if the version is supported, -or null is returned otherwise,
  • -
  • a semver-compatible -range specification, in which case the most recent satisfying version is returned -if it exists, or null is returned,
  • -
  • 'latest' in which case the most recent version is returned, excluding pre-releases, -Defaults to 'latest'.
  • -
-
[osType]String

can be one of 'default', 'esr' or null to include all types

-
- -**Example** -```js -balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) { - console.log(version); -}); -``` - -* * * - - - -##### 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 - - - - - - - - - - - - - - -
ParamTypeDescription
deviceTypeString

device type slug

-
currentVersionString

semver-compatible version for the starting OS version

-
targetVersionString

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.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options]) ⇒ Promise.<String> -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns the Releases of the supervisor for the CPU Architecture -**Returns**: Promise.<String> - - An array of Release objects that can be used to manage a device as supervisors. -**Access**: public - - - - - - - - - - - - -
ParamTypeDefaultDescription
cpuArchitectureSlugOrIdString | Number

The slug (string) or id (number) for the CPU Architecture

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64'); - -const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( - 'aarch64', - { $filter: { raw_version: '12.11.0' } }, -); - -const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( - 'aarch64', - { - $select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'], - $expand: { - release_image: { - $select: 'id', - $expand: { - image: { - $select: 'is_stored_at__image_location', - }, - }, - }, - }, - $filter: { raw_version: '12.11.0' } - }, -); -``` - -* * * - - - -##### os.getSupportedOsUpdateVersions(deviceType, currentVersion, [options]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns the supported OS update targets for the provided device type -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. -**Fulfil**: Object - the versions information, of the following structure: -* versions - an array of strings, -containing exact version numbers that OS update is supported -* recommended - the recommended version, i.e. the most recent version -that is _not_ pre-release, can be `null` -* current - the provided current version after normalization - - - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
deviceTypeString

device type slug

-
currentVersionString

semver-compatible version for the starting OS version

-
[options]Object

Extra options to filter the OS releases by

-
[options.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

-
[options.osType]String | null

Can be one of 'default', 'esr' or null which includes all types

-
- -**Example** -```js -balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) { - console.log(isSupported); -}); -``` - -* * * - - - -##### os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ Boolean -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns whether the specified OS architecture is compatible with the target architecture -**Returns**: Boolean - - Whether the specified OS architecture is capable of running -applications build for the target architecture -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
osArchitectureString

The OS's architecture as specified in its device type

-
applicationArchitectureString

The application's architecture as specified in its device type

-
- -**Example** -```js -const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf'); -console.log(result1); - -const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64'); -console.log(result2); -``` - -* * * - - - -##### os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions -**Access**: public -**Fulfil**: Boolean - whether upgrading the OS to the target version is supported - - - - - - - - - - - - - - -
ParamTypeDescription
deviceTypeString

device type slug

-
currentVersionString

semver-compatible version for the starting OS version

-
targetVersionString

semver-compatible version for the target OS version

-
- -**Example** -```js -balena.models.os.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) { - console.log(isSupported); -}); -``` - -* * * - - - -#### models.release : object -**Kind**: static namespace of [models](#balena.models) - -* [.release](#balena.models.release) : object - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.asset](#balena.models.release.asset) : object - * [.download(id)](#balena.models.release.asset.download) ⇒ Promise - * [.get(id, [options])](#balena.models.release.asset.get) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.asset.getAllByRelease) ⇒ Promise - * [.remove(id)](#balena.models.release.asset.remove) ⇒ Promise - * [.upload(uploadParams, [options])](#balena.models.release.asset.upload) ⇒ Promise - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - - -* * * - - - -##### release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Create a new release built from the source in the provided url -**Access**: public -**Fulfil**: number - release ID - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
urlDeployOptionsObject

builder options

-
urlDeployOptions.urlString

a url with a tarball of the project to build

-
[urlDeployOptions.shouldFlatten]Booleantrue

Should be true when the tarball includes an extra root folder with all the content

-
- -**Example** -```js -balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { - console.log(releaseId); -}); -``` -**Example** -```js -balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { - console.log(releaseId); -}); -``` - -* * * - - - -##### release.finalize(commitOrIdOrRawVersion) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Finalizes a draft release -**Access**: public -**Fulfil**: void - - - - - - - - - - -
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
- -**Example** -```js -balena.models.release.finalize(123).then(function() { - console.log('finalized!'); -}); -``` -**Example** -```js -balena.models.release.finalize('7cf02a69e4d34c9da573914963cf54fd').then(function() { - console.log('finalized!'); -}); -``` -**Example** -```js -balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log('finalized!'); -}); -``` - -* * * - - - -##### release.get(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get a specific release -**Access**: public -**Fulfil**: Object - release - - - - - - - - - - - - -
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.release.get(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.get('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log(release); -}); -``` - -* * * - - - -##### release.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get all releases from an application -**Access**: public -**Fulfil**: Object[] - releases - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) { - console.log(releases); -}); -``` -**Example** -```js -balena.models.release.getAllByApplication(123).then(function(releases) { - console.log(releases); -}); -``` - -* * * - - - -##### release.getLatestByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get the latest successful release for an application -**Access**: public -**Fulfil**: Object\|undefined - release - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) { - console.log(releases); -}); -``` -**Example** -```js -balena.models.release.getLatestByApplication(123).then(function(releases) { - console.log(releases); -}); -``` - -* * * - - - -##### release.getWithImageDetails(commitOrIdOrRawVersion, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want significantly more control, or to see the -raw model directly, use `release.get(id, options)` instead. - -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get a specific release with the details of the images built -**Access**: public -**Fulfil**: Object - release with image details - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
[options]Object{}

a map of extra pine options

-
[options.release]Boolean{}

extra pine options for releases

-
[options.image]Object{}

extra pine options for images

-
- -**Example** -```js -balena.models.release.getWithImageDetails(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } }) -.then(function(release) { - console.log(release.images[0].build_log); -}); -``` - -* * * - - - -##### release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Set the is_invalidated property of a release to true or false -**Access**: public -**Fulfil**: void - - - - - - - - - - - - -
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
isInvalidatedBoolean

boolean value, true for invalidated, false for validated

-
- -**Example** -```js -balena.models.release.setIsInvalidated(123, true).then(function() { - console.log('invalidated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', true).then(function() { - console.log('invalidated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log('invalidated!); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated(123, false).then(function() { - console.log('validated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', false).then(function() { - console.log('validated!'); -}); -``` - -* * * - - - -##### release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Add a known issue list to a release -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
knownIssueListOrNullString | null

the known issue list

-
- -**Example** -```js -balena.models.release.setKnownIssueList('7cf02a69e4d34c9da573914963cf54fd', 'This is an issue'); -``` -**Example** -```js -balena.models.release.setKnownIssueList(123, 'This is an issue'); -``` -**Example** -```js -balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue'); -``` - -* * * - - - -##### release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Add a note to a release -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
noteOrNullString | null

the note

-
- -**Example** -```js -balena.models.release.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); -``` -**Example** -```js -balena.models.release.setNote(123, 'My useful note'); -``` -**Example** -```js -balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note'); -``` - -* * * - - - -##### release.asset : object -**Kind**: static namespace of [release](#balena.models.release) - -* [.asset](#balena.models.release.asset) : object - * [.download(id)](#balena.models.release.asset.download) ⇒ Promise - * [.get(id, [options])](#balena.models.release.asset.get) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.asset.getAllByRelease) ⇒ Promise - * [.remove(id)](#balena.models.release.asset.remove) ⇒ Promise - * [.upload(uploadParams, [options])](#balena.models.release.asset.upload) ⇒ Promise - - -* * * - - - -###### asset.download(id) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Download a release asset -**Access**: public -**Fulfil**: NodeJS.ReadableStream - download stream - - - - - - - - - - -
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

-
- -**Example** -```js -balena.models.release.asset.download(123).then(function(stream) { - stream.pipe(fs.createWriteStream('logo.png')); -}); -``` -**Example** -```js -balena.models.release.asset.download({ - asset_key: 'logo.png', - release: 123 -}).then(function(stream) { - stream.pipe(fs.createWriteStream('logo.png')); -}); -``` - -* * * - - - -###### asset.get(id, [options]) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Get a specific release asset -**Access**: public -**Fulfil**: Object - release asset - - - - - - - - - - - - -
ParamTypeDefaultDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.release.asset.get(123).then(function(asset) { - console.log(asset); -}); -``` -**Example** -```js -balena.models.release.asset.get({ - asset_key: 'logo.png', - release: 123 -}).then(function(asset) { - console.log(asset); -}); -``` - -* * * - - - -###### asset.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Get all release assets for a release -**Access**: public -**Fulfil**: Object[] - release assets - - - - - - - - - - - - -
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.release.asset.getAllByRelease(123).then(function(assets) { - console.log(assets); -}); -``` -**Example** -```js -balena.models.release.asset.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(assets) { - console.log(assets); -}); -``` -**Example** -```js -balena.models.release.asset.getAllByRelease({ application: 456, raw_version: '1.2.3' }).then(function(assets) { - console.log(assets); -}); -``` - -* * * - - - -###### asset.remove(id) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Remove a release asset -**Access**: public - - - - - - - - - - -
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

-
- -**Example** -```js -balena.models.release.asset.remove(123); -``` -**Example** -```js -balena.models.release.asset.remove({ - asset_key: 'logo.png', - release: 123 -}); -``` - -* * * - - - -###### asset.upload(uploadParams, [options]) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Upload a release asset -**Access**: public -**Fulfil**: Object - uploaded release asset - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParamTypeDefaultDescription
uploadParamsObject

upload parameters

-
uploadParams.assetString | File

asset file path (string, Node.js only) or File object (Node.js & browser). For File objects, use new File([content], filename, {type: mimeType})

-
uploadParams.asset_keyString

unique key for the asset within the release

-
uploadParams.releaseNumber

release ID

-
[options]Object{}

upload options

-
[options.chunkSize]Number5242880

chunk size for multipart uploads (5MiB default)

-
[options.parallelUploads]Number5

number of parallel uploads for multipart

-
[options.overwrite]Booleanfalse

whether to overwrite existing asset

-
[options.onUploadProgress]function

callback for upload progress

-
- -**Example** -```js -// Upload from file path (Node.js) -balena.models.release.asset.upload({ - asset: '/path/to/logo.png', - asset_key: 'logo.png', - release: 123 -}).then(function(asset) { - console.log('Asset uploaded:', asset); -}); -``` -**Example** -```js -// Upload with File API (Node.js and browser) -const content = Buffer.from('Hello, World!', 'utf-8'); -const file = new File([content], 'readme.txt', { type: 'text/plain' }); - -balena.models.release.asset.upload({ - asset: file, - asset_key: 'readme.txt', - release: 123 -}).then(function(asset) { - console.log('Asset uploaded:', asset); -}); -``` -**Example** -```js -// Upload large file with File API and progress tracking -const largeContent = new Uint8Array(10 * 1024 * 1024); // 10MB -const largeFile = new File([largeContent], 'data.bin', { type: 'application/octet-stream' }); - -balena.models.release.asset.upload({ - asset: largeFile, - asset_key: 'data.bin', - release: 123 -}, { - chunkSize: 5 * 1024 * 1024, // 5MB chunks - parallelUploads: 3, - onUploadProgress: function(progress) { - const percent = (progress.uploaded / progress.total * 100).toFixed(2); - console.log(`Upload progress: ${percent}%`); - } -}).then(function(asset) { - console.log('Large file uploaded:', asset); -}); -``` -**Example** -```js -// Browser: Upload file from input element -const fileInput = document.getElementById('fileInput'); -const file = fileInput.files[0]; // File object from input - -balena.models.release.asset.upload({ - asset: file, - asset_key: file.name, - release: 123 -}).then(function(asset) { - console.log('File uploaded from browser:', asset); -}); -``` -**Example** -```js -// Upload with overwrite option -balena.models.release.asset.upload({ - asset: '/path/to/logo.png', - asset_key: 'logo.png', - release: 123 -}, { - overwrite: true -}).then(function(asset) { - console.log('Asset uploaded/updated:', asset); -}); -``` - -* * * - - - -##### release.tags : object -**Kind**: static namespace of [release](#balena.models.release) - -* [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - - -* * * - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Get all release tags for an application -**Access**: public -**Fulfil**: Object[] - release tags - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - -* * * - - - -###### tags.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Get all release tags for a release -**Access**: public -**Fulfil**: Object[] - release tags - - - - - - - - - - - - -
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.release.tags.getAllByRelease(123).then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) { - console.log(tags); -}); -``` - -* * * - - - -###### tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Remove a release tag -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
tagKeyString

tag key

-
- -**Example** -```js -balena.models.release.tags.remove(123, 'EDITOR'); -``` -**Example** -```js -balena.models.release.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); -``` -**Example** -```js -balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR'); -``` - -* * * - - - -###### tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Set a release tag -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

-
tagKeyString

tag key

-
valueString | undefined

tag value

-
- -**Example** -```js -balena.models.release.tags.set(123, 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.release.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim'); -``` - -* * * - - - -#### models.service : object -**Kind**: static namespace of [models](#balena.models) - -* [.service](#balena.models.service) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.var](#balena.models.service.var) : object - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - - -* * * - - - -##### service.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [service](#balena.models.service) -**Summary**: Get all services from an application -**Access**: public -**Fulfil**: Object[] - services - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) { - console.log(services); -}); -``` -**Example** -```js -balena.models.service.getAllByApplication(123).then(function(services) { - console.log(services); -}); -``` - -* * * - - - -##### service.var : object -**Kind**: static namespace of [service](#balena.models.service) - -* [.var](#balena.models.service.var) : object - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - - -* * * - - - -###### var.get(serviceIdOrNaturalKey, key) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get the value of a specific service variable -**Access**: public -**Fulfil**: String\|undefined - the variable value (or undefined) - - - - - - - - - - - - -
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

-
keyString

variable name

-
- -**Example** -```js -balena.models.service.var.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) { - console.log(value); -}); -``` - -* * * - - - -###### var.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get all service variables by application -**Access**: public -**Fulfil**: Object[] - service variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.service.var.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### var.getAllByService(serviceIdOrNaturalKey, [options]) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get all variables for a service -**Access**: public -**Fulfil**: Object[] - service variables - - - - - - - - - - - - -
ParamTypeDefaultDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.service.var.getAllByService(999999).then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) { - console.log(vars); -}); -``` - -* * * - - - -###### var.remove(serviceIdOrNaturalKey, key) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Clear the value of a specific service variable -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

-
keyString

variable name

-
- -**Example** -```js -balena.models.service.var.remove(999999, 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() { - ... -}); -``` - -* * * - - - -###### var.set(serviceIdOrNaturalKey, key, value) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Set the value of a specific service variable -**Access**: public - - - - - - - - - - - - - - -
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

-
keyString

variable name

-
valueString

variable value

-
- -**Example** -```js -balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() { - ... -}); -``` - -* * * - - - -#### models.team : object -**Kind**: static namespace of [models](#balena.models) - -* [.team](#balena.models.team) : object - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - - -* * * - - - -##### team.create(organizationSlugOrId, name) ⇒ Promise -This method creates a new team. - -**Kind**: static method of [team](#balena.models.team) -**Summary**: Creates a new Team -**Access**: public -**Fulfil**: Object - Team - - - - - - - - - - - - -
ParamTypeDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team will be part of.

-
nameString

Required: the name of the team that will be created.

-
- -**Example** -```js -balena.models.team.create(1239948, 'MyTeam').then(function(team) { - console.log(team); -}); -``` -**Example** -```js -balena.models.team.create('myOrgHandle', 'MyTeam') -.then(function(team) { - console.log(team); -}); -``` - -* * * - - - -##### team.get(teamId, [options]) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Get a single Team -**Access**: public -**Fulfil**: Object - Team - - - - - - - - - - - - -
ParamTypeDefaultDescription
teamIdNumber

team id (number).

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.team.get(123).then(function(team) { - console.log(team); -}); -``` - -* * * - - - -##### team.getAllByOrganization(organizationSlugOrId, [options]) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Get all Teams of a specific Organization -**Access**: public -**Fulfil**: Object[] - Teams - - - - - - - - - - - - -
ParamTypeDefaultDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team is part of.

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.team.getAllByOrganization(123).then(function(teams) { - console.log(teams); -}); -``` -**Example** -```js -balena.models.team.getAllByOrganization('MyOrganizationHandle').then(function(teams) { - console.log(teams); -}); -``` - -* * * - - - -##### team.remove(teamId) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Remove a Team -**Access**: public - - - - - - - - - - -
ParamTypeDescription
teamIdNumber

team id (number).

-
- -**Example** -```js -balena.models.team.remove(123); -``` - -* * * - - - -##### team.rename(teamId, newName) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Rename Team -**Access**: public - - - - - - - - - - - - -
ParamTypeDescription
teamIdNumber

team id (number)

-
newNameString

new team name (string)

-
- -**Example** -```js -balena.models.team.rename(123, 'MyNewTeamName'); -``` - -* * * - - - -##### team.applicationAccess : object -**Kind**: static namespace of [team](#balena.models.team) - -* [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - - -* * * - - - -###### applicationAccess.get(teamApplicationAccessId, [options]) ⇒ Promise -This method get specific team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Get team applications access -**Access**: public -**Fulfil**: Object - TeamApplicationAccess - - - - - - - - - - - - -
ParamTypeDefaultDescription
teamApplicationAccessIdNumber

Required: the team application access id.

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.team.applicationAccess.get(1239948).then(function(teamApplicationAccess) { - console.log(teamApplicationAccess); -}); -``` - -* * * - - - -###### applicationAccess.getAllByTeam(teamId, [options]) ⇒ Promise -This method get all team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Get all team applications access -**Access**: public -**Fulfil**: Object[] - team application access - - - - - - - - - - - - -
ParamTypeDefaultDescription
teamIdNumber

Required: the team id.

-
[options]Object{}

extra pine options to use

-
- -**Example** -```js -balena.models.team.applicationAccess.getAllByTeam(1239948).then(function(teamApplicationAccesses) { - console.log(teamApplicationAccesses); -}); -``` - -* * * - - - -###### applicationAccess.remove(teamApplicationAccessId) ⇒ Promise -This remove a team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Remove team application access -**Access**: public -**Fulfil**: void - - - - - - - - - - -
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

-
- -**Example** -```js -balena.models.team.remove(123).then(function(teams) { - console.log(teams); -}); -``` - -* * * - - - -###### applicationAccess.update(teamApplicationAccessId, roleName) ⇒ Promise -This method update a team application access role. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Update team application access -**Access**: public -**Fulfil**: Object - TeamApplicationAccess - - - - - - - - - - - - -
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

-
roleNameString

Required: The new role to assing (ApplicationMembershipRoles).

-
- -**Example** -```js -balena.models.team.update(123, 'developer').then(function(teamApplicationAccess) { - console.log(teamApplicationAccess); -}); -``` - -* * * - - - -### balena.settings : object -**Kind**: static namespace of [balena](#balena) - -* [.settings](#balena.settings) : object - * [.get([key])](#balena.settings.get) ⇒ Promise - * [.getAll()](#balena.settings.getAll) ⇒ Promise - - -* * * - - - -#### settings.get([key]) ⇒ Promise -**Kind**: static method of [settings](#balena.settings) -**Summary**: Get a single setting. **Only implemented in Node.js** -**Access**: public -**Fulfil**: \* - setting value - - - - - - - - - - -
ParamTypeDescription
[key]String

setting key

-
- -**Example** -```js -balena.settings.get('apiUrl').then(function(apiUrl) { - console.log(apiUrl); -}); -``` - -* * * - - - -#### settings.getAll() ⇒ Promise -**Kind**: static method of [settings](#balena.settings) -**Summary**: Get all settings **Only implemented in Node.js** -**Access**: public -**Fulfil**: Object - settings -**Example** -```js -balena.settings.getAll().then(function(settings) { - console.log(settings); -}); -``` - -* * * - - - -### balena.utils : object -**Kind**: static namespace of [balena](#balena) - -* * * - diff --git a/pages/external-docs/sdk/node-sdk/latest/README.md b/pages/external-docs/sdk/node-sdk/latest/README.md new file mode 100644 index 0000000000..9a659fa912 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/README.md @@ -0,0 +1 @@ +# v23.2.0 (latest) \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/latest/auth.md b/pages/external-docs/sdk/node-sdk/latest/auth.md new file mode 100644 index 0000000000..0011e51751 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/auth.md @@ -0,0 +1,497 @@ +# auth +balena.auth : object + +**Kind**: static namespace + +* * * + +## authenticate +balena.auth.authenticate(credentials) ⇒ Promise + +You should use [login](#balena.auth.login) when possible, +as it takes care of saving the token and email as well. + +Notice that if `credentials` contains extra keys, they'll be discarted +by the server automatically. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Authenticate with the server +**Access**: protected +**Fulfil**: String - session token + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of email, password

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
+ +**Example** +```js +balena.auth.authenticate(credentials).then(function(token) { + console.log('My token is:', token); +}); +``` + +* * * + +## getActorId +balena.auth.getActorId() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in actor id +**Access**: public +**Fulfil**: Number - actor id +**Example** +```js +balena.auth.getActorId().then(function(actorId) { + console.log(actorId); +}); +``` + +* * * + +## getToken +balena.auth.getToken() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in user's raw API key or session token +**Access**: public +**Fulfil**: String - raw API key or session token +**Example** +```js +balena.auth.getToken().then(function(token) { + console.log(token); +}); +``` + +* * * + +## getUserInfo +balena.auth.getUserInfo() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in user's info +**Access**: public +**Fulfil**: Object - user info +**Example** +```js +balena.auth.getUserInfo().then(function(userInfo) { + console.log(userInfo); +}); +``` + +* * * + +## isLoggedIn +balena.auth.isLoggedIn() ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Check if you're logged in +**Access**: public +**Fulfil**: Boolean - is logged in +**Example** +```js +balena.auth.isLoggedIn().then(function(isLoggedIn) { + if (isLoggedIn) { + console.log('I\'m in!'); + } else { + console.log('Too bad!'); + } +}); +``` + +* * * + +## login +balena.auth.login(credentials) ⇒ Promise + +If the login is successful, the token is persisted between sessions. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Login +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of email, password

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
+ +**Example** +```js +balena.auth.login(credentials); +``` + +* * * + +## loginWithToken +balena.auth.loginWithToken(authToken) ⇒ Promise + +Login to balena with a session token or api key instead of with credentials. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Login with a token or api key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
authTokenString

the auth token

+
+ +**Example** +```js +balena.auth.loginWithToken(authToken); +``` + +* * * + +## logout +balena.auth.logout() ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Logout +**Access**: public +**Example** +```js +balena.auth.logout(); +``` + +* * * + +## register +balena.auth.register(credentials) ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Register a user account +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of username, password and email

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
[credentials.'g-recaptcha-response']String | undefined

the captcha response

+
+ +**Example** +```js +balena.auth.register({ + email: 'johndoe@gmail.com', + password: 'secret' +}).then(function(token) { + console.log(token); +}); +``` + +* * * + +## requestVerificationEmail +balena.auth.requestVerificationEmail() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Re-send verification email to the user +**Access**: public +**Example** +```js +balena.auth.requestVerificationEmail().then(function() { + console.log('Requesting verification email operation complete!'); +}) +``` + +* * * + +## verifyEmail +balena.auth.verifyEmail(verificationPayload) ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Verifies an email +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + + + + + +
ParamTypeDescription
verificationPayloadObject

in the form of email, and token

+
verificationPayload.emailString

the email

+
verificationPayload.tokenString

the verification token

+
+ +**Example** +```js +balena.auth.verifyEmail({ + email: 'johndoe@gmail.com', + token: '5bb11d90eefb34a70318f06a43ef063f' +}).then(function(jwt) { + console.log(jwt); +}); +``` + +* * * + +## whoami +balena.auth.whoami() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Return current logged in information +**Access**: public +**Fulfil**: (Object\|undefined) - actor information, if it exists +**Example** +```js +balena.auth.whoami().then(function(result) { + if (!result) { + console.log('I\'m not logged in!'); + } else { + console.log('My result is:', result); + } +}); +``` + +* * * + +## twoFactor +balena.auth.twoFactor : object + +**Kind**: static namespace of [auth](#balena.auth) + +* * * + +### challenge +balena.auth.twoFactor.challenge(code) ⇒ Promise + +You should use [login](#balena.auth.login) when possible, +as it takes care of saving the token and email as well. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Challenge two factor authentication and complete login +**Access**: public + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +balena.auth.twoFactor.challenge('1234'); +``` + +* * * + +### disable +balena.auth.twoFactor.disable(password) ⇒ Promise + +Disables two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Disable two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
passwordString

password

+
+ +**Example** +```js +const token = balena.auth.twoFactor.disable('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + +### enable +balena.auth.twoFactor.enable(code) ⇒ Promise + +Enables two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Enable two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +const token = balena.auth.twoFactor.enable('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + +### getSetupKey +balena.auth.twoFactor.getSetupKey() ⇒ Promise + +Retrieves a setup key for enabling two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Get two factor authentication setup key +**Access**: public +**Fulfil**: String - setup key +**Example** +```js +const setupKey = balena.auth.twoFactor.getSetupKey(); +console.log(setupKey); +``` + +* * * + +### isEnabled +balena.auth.twoFactor.isEnabled() ⇒ Promise + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Check if two factor authentication is enabled +**Access**: public +**Fulfil**: Boolean - whether 2fa is enabled +**Example** +```js +balena.auth.twoFactor.isEnabled().then(function(isEnabled) { + if (isEnabled) { + console.log('2FA is enabled for this account'); + } +}); +``` + +* * * + +### isPassed +balena.auth.twoFactor.isPassed() ⇒ Promise + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Check if two factor authentication challenge was passed +**Access**: public +**Fulfil**: Boolean - whether 2fa challenge was passed +**Example** +```js +balena.auth.twoFactor.isPassed().then(function(isPassed) { + if (isPassed) { + console.log('2FA challenge passed'); + } +}); +``` + +* * * + +### verify +balena.auth.twoFactor.verify(code) ⇒ Promise + +Verifies two factor authentication. +Note that this method not update the token automatically. +You should use [challenge](#balena.auth.twoFactor.challenge) when possible, +as it takes care of that as well. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Verify two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +const token = balena.auth.twoFactor.verify('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/errors.md b/pages/external-docs/sdk/node-sdk/latest/errors.md new file mode 100644 index 0000000000..132e5c1184 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/errors.md @@ -0,0 +1,24 @@ +# errors +balena.errors : Object + +The balena-errors module used internally. This is provided primarily for +convenience, and to avoid the necessity for separate balena-errors +dependencies. You'll want to use this if you need to match on the specific +type of error thrown by the SDK. + +**Kind**: static member +**Summary**: Balena errors module +**Access**: public +**Example** +```js +balena.models.device.get(123).catch(function (error) { + if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) { + ... + } else if (error.code === balena.errors.BalenaRequestError.prototype.code) { + ... + } +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/fromSharedOptions.md b/pages/external-docs/sdk/node-sdk/latest/fromSharedOptions.md new file mode 100644 index 0000000000..73f0097d6d --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/fromSharedOptions.md @@ -0,0 +1,18 @@ +# fromSharedOptions +module:balena-sdk~fromSharedOptions() + +Create an SDK instance using shared default options set using the `setSharedOptions()` method. +If options have not been set using this method, then this method will use the +same defaults as the main SDK factory function. + +**Kind**: inner function +**Summary**: Create an SDK instance using shared default options +**Access**: public +**Example** +```js +import { fromSharedOptions } from 'balena-sdk'; +const sdk = fromSharedOptions(); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/getSdk.md b/pages/external-docs/sdk/node-sdk/latest/getSdk.md new file mode 100644 index 0000000000..dff2249899 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/getSdk.md @@ -0,0 +1,22 @@ +# getSdk +module:balena-sdk~getSdk() + +The module exports a single factory function. + +**Kind**: inner function +**Summary**: Creates a new SDK instance using the default or the provided options. +**Example** +```js +// with es6 imports +import { getSdk } from 'balena-sdk'; +// or with node require +const { getSdk } = require('balena-sdk'); + +const balena = getSdk({ + apiUrl: "https://api.balena-cloud.com/", + dataDirectory: "/opt/local/balena" +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/interceptors.md b/pages/external-docs/sdk/node-sdk/latest/interceptors.md new file mode 100644 index 0000000000..0da46482a3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/interceptors.md @@ -0,0 +1,68 @@ +# interceptors +balena.interceptors : Array.<Interceptor> + +The current array of interceptors to use. Interceptors intercept requests made +internally and are executed in the order they appear in this array for requests, +and in the reverse order for responses. + +**Kind**: static member +**Summary**: Array of interceptors +**Access**: public +**Example** +```js +balena.interceptors.push({ + responseError: function (error) { + console.log(error); + throw error; + }) +}); +``` + +* * * + +## Interceptor +balena.interceptors.Interceptor : object + +An interceptor implements some set of the four interception hook callbacks. +To continue processing, each function should return a value or a promise that +successfully resolves to a value. + +To halt processing, each function should throw an error or return a promise that +rejects with an error. + +**Kind**: static typedef of [interceptors](#balena.interceptors) +**Properties** + + + + + + + + + + + + + + + + + +
NameTypeDescription
[request]function

Callback invoked before requests are made. Called with +the request options, should return (or resolve to) new request options, or throw/reject.

+
[response]function

Callback invoked before responses are returned. Called with +the response, should return (or resolve to) a new response, or throw/reject.

+
[requestError]function

Callback invoked if an error happens before a request. +Called with the error itself, caused by a preceeding request interceptor rejecting/throwing +an error for the request, or a failing in preflight token validation. Should return (or resolve +to) new request options, or throw/reject.

+
[responseError]function

Callback invoked if an error happens in the response. +Called with the error itself, caused by a preceeding response interceptor rejecting/throwing +an error for the request, a network error, or an error response from the server. Should return +(or resolve to) a new response, or throw/reject.

+
+ + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/introduction.md b/pages/external-docs/sdk/node-sdk/latest/introduction.md new file mode 100644 index 0000000000..1220aa46ef --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/introduction.md @@ -0,0 +1,59 @@ +# Introduction + +Welcome to the balena Node SDK documentation. These pages aim to describe all the functions supported by the SDK, as well as showing examples of their expected usage. + +## Installation + +Install the balena SDK by running: + +```sh +$ npm install --save balena-sdk +``` + +### Bundling for browsers + +If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. + +If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: + +* fs +* path +* balena-settings-client +* node-localstorage +* fs/promises +* mime + +### Bundling with pkg + +The balena SDK includes builds for various ECMAScript versions that are +dynamically selected at runtime (using +[@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). +For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not +able to automatically detect which assets to include in the output package. The +following sample `pkg` section should be added to your application's +`package.json` file to instruct `pkg` to bundle the required assets: + +```json + "pkg": { + "scripts": [ + "node_modules/balena-sdk/**/*.js" + ], + "assets": [ + "node_modules/pinejs-client-core/**/*" + ] + } +``` + +For more information, please refer to the respective +[documentation from the `pkg` project](https://github.com/vercel/pkg#config). + +## Trying balenaSDK in the browser + +BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. +To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries. + +![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png) + + +If you feel something is missing, not clear or could be improved, please don't hesitate to open an +[issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help. \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/latest/logs.md b/pages/external-docs/sdk/node-sdk/latest/logs.md new file mode 100644 index 0000000000..47357db4ba --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/logs.md @@ -0,0 +1,179 @@ +# logs +balena.logs : object + +**Kind**: static namespace + +* * * + +## history +balena.logs.history(uuidOrId, [options]) ⇒ Promise + +Get an array of the latest log messages for a given device. + +**Kind**: static method of [logs](#balena.logs) +**Summary**: Get device logs history +**Access**: public +**Fulfil**: Object[] - history lines + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.count]Number | 'all'1000

number of log messages to return (or 'all')

+
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages

+
+ +**Example** +```js +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd').then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +balena.logs.history(123).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +const oneDayAgoTimestamp = Date.now() - 24*60*60*1000; +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoTimestamp }).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +const oneDayAgoIsoDateString = new Date(Date.now() - 24*60*60*1000).toISOString(); +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoIsoDateString }).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` + +* * * + +## subscribe +balena.logs.subscribe(uuidOrId, [options]) ⇒ Promise.<LogSubscription> + +Connects to the stream of devices logs, returning a LogSubscription, which +can be used to listen for logs as they appear, line by line. + +**Kind**: static method of [logs](#balena.logs) +**Summary**: Subscribe to device logs +**Access**: public +**Fulfil**: [LogSubscription](#balena.logs.LogSubscription) + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.count]Number | 'all'0

number of historical messages to include (or 'all')

+
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages. When specified, the count parameter needs to also be provided.

+
+ +**Example** +```js +balena.logs.subscribe('7cf02a69e4d34c9da573914963cf54fd').then(function(logs) { + logs.on('line', function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +balena.logs.subscribe(123).then(function(logs) { + logs.on('line', function(line) { + console.log(line); + }); +}); +``` + +* * * + +## LogSubscription +balena.logs.LogSubscription : EventEmitter + +The log subscription emits events as log data arrives. +You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)` + +**Kind**: static typedef of [logs](#balena.logs) + +* * * + +### unsubscribe +balena.logs.LogSubscription.unsubscribe() + +Disconnect from the logs feed and stop receiving any future events on this emitter. + +**Kind**: static method of [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Unsubscribe from device logs +**Access**: public +**Example** +```js +logs.unsubscribe(); +``` + +* * * + +### error +balena.logs.LogSubscription.event:error + +**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Event fired when an error has occured reading the device logs +**Example** +```js +logs.on('error', function(error) { + console.error(error); +}); +``` + +* * * + +### line +balena.logs.LogSubscription.event:line + +**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Event fired when a new line of log output is available +**Example** +```js +logs.on('line', function(line) { + console.log(line); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/README.md b/pages/external-docs/sdk/node-sdk/latest/models/README.md new file mode 100644 index 0000000000..e89b5f2b2b --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/README.md @@ -0,0 +1 @@ +# Models \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/latest/models/apiKey.md b/pages/external-docs/sdk/node-sdk/latest/models/apiKey.md new file mode 100644 index 0000000000..3e118ba1c1 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/apiKey.md @@ -0,0 +1,242 @@ +# apiKey +balena.models.apiKey : object + +**Kind**: static namespace + +* * * + +## create +balena.models.apiKey.create(createApiKeyParams) ⇒ Promise + +This method registers a new api key for the current user with the name given. + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Creates a new user API key +**Access**: public +**Fulfil**: String - API key + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
createApiKeyParamsObject

an object containing the parameters for the creation of an API key

+
createApiKeyParams.nameString

the API key name

+
createApiKeyParams.expiryDateString

the API key expiry date

+
[createApiKeyParams.description]String

the API key description

+
+ +**Example** +```js +balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12}).then(function(apiKey) { + console.log(apiKey); +}); +``` +**Example** +```js +balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12, description: apiKeyDescription}).then(function(apiKey) { + console.log(apiKey); +}); +``` + +* * * + +## getAll +balena.models.apiKey.getAll([options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all accessible API keys +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getAll().then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getAllNamedUserApiKeys +balena.models.apiKey.getAllNamedUserApiKeys([options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all named user API keys of the current user +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getDeviceApiKeysByDevice +balena.models.apiKey.getDeviceApiKeysByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all API keys for a device +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device, uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getProvisioningApiKeysByApplication +balena.models.apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all provisioning API keys for an application +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## revoke +balena.models.apiKey.revoke(id) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Revoke an API key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

API key id

+
+ +**Example** +```js +balena.models.apiKey.revoke(123); +``` + +* * * + +## update +balena.models.apiKey.update(id, apiKeyInfo) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Update the details of an API key +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idNumber

API key id

+
apiKeyInfoObject

an object with the updated name|description|expiryDate

+
+ +**Example** +```js +balena.models.apiKey.update(123, { name: 'updatedName' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { description: 'updated description' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { expiryDate: '2022-04-29' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' }); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/application.md b/pages/external-docs/sdk/node-sdk/latest/models/application.md new file mode 100644 index 0000000000..1f405f01f4 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/application.md @@ -0,0 +1,1956 @@ +# application +balena.models.application : object + +**Kind**: static namespace + +* * * + +## create +balena.models.application.create(options) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Create an application +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
optionsObject

application creation parameters

+
options.nameString

application name

+
options.organizationString | Number

handle (string) or id (number) of the organization that the application will belong to or null

+
[options.uuid]String

application uuid

+
[options.applicationClass]String

application class: 'app' | 'fleet' | 'block'

+
options.deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.application.create({ name: 'My App', organization: 'myorganization', deviceType: 'raspberry-pi' }).then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.create({ name: 'My Block', organization: 'myorganization', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) { + console.log(application); +}); +``` + +* * * + +## disableDeviceUrls +balena.models.application.disableDeviceUrls(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Disable device urls for all devices that belong to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.disableDeviceUrls('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.disableDeviceUrls(123); +``` + +* * * + +## enableDeviceUrls +balena.models.application.enableDeviceUrls(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Enable device urls for all devices that belong to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.enableDeviceUrls('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.enableDeviceUrls(123); +``` + +* * * + +## generateProvisioningKey +balena.models.application.generateProvisioningKey(generateProvisioningKeyParams) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Generate a device provisioning key for a specific application +**Access**: public +**Fulfil**: String - device provisioning key + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
generateProvisioningKeyParamsObject

an object containing the parameters for the provisioning key generation

+
generateProvisioningKeyParams.slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
generateProvisioningKeyParams.keyExpiryDateString

Expiry Date for provisioning key

+
[generateProvisioningKeyParams.keyName]String

Provisioning key name

+
[generateProvisioningKeyParams.keyDescription]String

Description for provisioning key

+
+ +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 'myorganization/myapp', keyExpiryDate: '2030-10-12'}).then(function(key) { + console.log(key); +}); +``` +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12'}).then(function(key) { + console.log(key); +}); +``` +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12', keyName: 'api key name', keyDescription: 'api key long description'}).then(function(key) { + console.log(key); +}); +``` + +* * * + +## get +balena.models.application.get(slugOrUuidOrId, [options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.get('myorganization/myapp').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.get(123).then(function(application) { + console.log(application); +}); +``` + +* * * + +## getAll +balena.models.application.getAll([options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.getAll().then(function(applications) { + console.log(applications); +}); +``` + +* * * + +## getAllByOrganization +balena.models.application.getAllByOrganization(orgHandleOrId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications of an organization +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + + + +
ParamTypeDefaultDescription
orgHandleOrIdNumber | String

organization handle (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getAllByOrganization('myorganization').then(function(applications) { + console.log(applications); +}); +``` +**Example** +```js +const applications = await sdk.models.application.getAllByOrganization('myorganization', { + $select: ['app_name', 'slug'], + $expand: { + owns__device: { + $select: ['uuid', 'overall_status', 'is_connected_to_vpn', 'api_heartbeat_state'], + }, + }, + }); +``` + +* * * + +## getAllDirectlyAccessible +balena.models.application.getAllDirectlyAccessible([options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications directly accessible by the user +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getAllDirectlyAccessible().then(function(applications) { + console.log(applications); +}); +``` + +* * * + +## getAppByName +balena.models.application.getAppByName(appName, [options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application using the appname and the handle of the owning organization +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appNameString

application name

+
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.getAppByName('MyApp').then(function(application) { + console.log(application); +}); +``` + +* * * + +## getDashboardUrl +balena.models.application.getDashboardUrl(id) ⇒ String + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get Dashboard URL for a specific application +**Returns**: String - - Dashboard URL for the specific application +**Throws**: + +- Exception if the id is not a finite number + + + + + + + + + + + +
ParamTypeDescription
idNumber

Application id

+
+ +**Example** +```js +balena.models.application.get('myorganization/myapp').then(function(application) { + const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); + console.log(dashboardApplicationUrl); +}); +``` + +* * * + +## getDirectlyAccessible +balena.models.application.getDirectlyAccessible(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application directly accessible by the user +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.getDirectlyAccessible(123).then(function(application) { + console.log(application); +}); +``` + +* * * + +## getTargetReleaseHash +balena.models.application.getTargetReleaseHash(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get the hash of the current release for a specific application +**Access**: public +**Fulfil**: String\|undefined - The release hash of the current release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.application.getTargetReleaseHash(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) { + console.log(release); +}); +``` + +* * * + +## getWithDeviceServiceDetails +balena.models.application.getWithDeviceServiceDetails(slugOrUuidOrId, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want more control, or to see the raw model +directly, use `application.get(uuidOrId, options)` instead. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application and its devices, along with each device's +associated services' essential details +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.application.getWithDeviceServiceDetails(123).then(function(device) { + console.log(device); +}) +``` + +* * * + +## grantSupportAccess +balena.models.application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Grant support access to an application until a specified time +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
expiryTimestampNumber

a timestamp in ms for when the support access will expire

+
+ +**Example** +```js +balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000); +``` +**Example** +```js +balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000); +``` + +* * * + +## has +balena.models.application.has(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Check if an application exists +**Access**: public +**Fulfil**: Boolean - has application + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.has('myorganization/myapp').then(function(hasApp) { + console.log(hasApp); +}); +``` +**Example** +```js +balena.models.application.has(123).then(function(hasApp) { + console.log(hasApp); +}); +``` + +* * * + +## hasAny +balena.models.application.hasAny() ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Check if the user has access to any applications +**Access**: public +**Fulfil**: Boolean - has any applications +**Example** +```js +balena.models.application.hasAny().then(function(hasAny) { + console.log('Has any?', hasAny); +}); +``` + +* * * + +## isTrackingLatestRelease +balena.models.application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates +**Access**: public +**Fulfil**: Boolean - is tracking the latest release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) { + console.log(isEnabled); +}); +``` +**Example** +```js +balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## pinToRelease +balena.models.application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ Promise + +Configures the application to run a particular release +and not get updated when the latest release changes. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Set a specific application to run a particular release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
fullReleaseHashString

the hash of a successful release (string)

+
+ +**Example** +```js +balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` + +* * * + +## purge +balena.models.application.purge(appId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Purge devices by application id +**Access**: public + + + + + + + + + + +
ParamTypeDescription
appIdNumber

application id

+
+ +**Example** +```js +balena.models.application.purge(123); +``` + +* * * + +## reboot +balena.models.application.reboot(appId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Reboot devices by application id +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appIdNumber

application id

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.application.reboot(123); +``` + +* * * + +## remove +balena.models.application.remove(slugOrUuidOrIdOrIds) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Remove application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdOrIdsString | Number | Array.<Number>

application slug (string), uuid (string) or id (number) or array of ids

+
+ +**Example** +```js +balena.models.application.remove('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.remove(123); +``` + +* * * + +## rename +balena.models.application.rename(slugOrUuidOrId, newName) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Rename application +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
newNameString

new application name (string)

+
+ +**Example** +```js +balena.models.application.rename('myorganization/myapp', 'MyRenamedApp'); +``` +**Example** +```js +balena.models.application.rename(123, 'MyRenamedApp'); +``` + +* * * + +## restart +balena.models.application.restart(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Restart application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.restart('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.restart(123); +``` + +* * * + +## revokeSupportAccess +balena.models.application.revokeSupportAccess(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Revoke support access to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.revokeSupportAccess('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.revokeSupportAccess(123); +``` + +* * * + +## shutdown +balena.models.application.shutdown(appId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Shutdown devices by application id +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appIdNumber

application id

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.application.shutdown(123); +``` + +* * * + +## trackLatestRelease +balena.models.application.trackLatestRelease(slugOrUuidOrId) ⇒ Promise + +The application's current release will be updated with each new successfully built release. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Configure a specific application to track the latest finalized available release +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.trackLatestRelease('myorganization/myapp').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.trackLatestRelease(123).then(function() { + ... +}); +``` + +* * * + +## willTrackNewReleases +balena.models.application.willTrackNewReleases(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get whether the application is configured to receive updates whenever a new release is available +**Access**: public +**Fulfil**: Boolean - is tracking the latest release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) { + console.log(isEnabled); +}); +``` +**Example** +```js +balena.models.application.willTrackNewReleases(123).then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## buildVar +balena.models.application.buildVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.buildVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Get the value of a specific build environment variable +**Access**: public +**Fulfil**: String\|undefined - the build environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
+ +**Example** +```js +balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.buildVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.buildVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Get all build environment variables for an application +**Access**: public +**Fulfil**: Object[] - application build environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.buildVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Clear the value of a specific build environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
+ +**Example** +```js +balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.buildVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.buildVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Set the value of a specific build environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
valueString

build environment variable value

+
+ +**Example** +```js +balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## configVar +balena.models.application.configVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.configVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Get the value of a specific config variable +**Access**: public +**Fulfil**: String\|undefined - the config variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Get all config variables for an application +**Access**: public +**Fulfil**: Object[] - application config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.configVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.configVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Clear the value of a specific config variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.configVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Set the value of a specific config variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
valueString

config variable value

+
+ +**Example** +```js +balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## envVar +balena.models.application.envVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.envVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Get the value of a specific environment variable +**Access**: public +**Fulfil**: String\|undefined - the environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.envVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Get all environment variables for an application +**Access**: public +**Fulfil**: Object[] - application environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.envVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.envVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Clear the value of a specific environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.envVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.envVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Set the value of a specific environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
valueString

environment variable value

+
+ +**Example** +```js +balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## invite +balena.models.application.invite : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### accept +balena.models.application.invite.accept(invitationToken) ⇒ Promise + +This method adds the calling user to the application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Accepts an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
invitationTokenString

invite token

+
+ +**Example** +```js +balena.models.application.invite.accept("qwerty-invitation-token"); +``` + +* * * + +### create +balena.models.application.invite.create(slugOrUuidOrId, options, [message]) ⇒ Promise + +This method invites a user by their email to an application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Creates a new invite for an application +**Access**: public +**Fulfil**: String - application invite + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
optionsObject

invite creation parameters

+
options.inviteeString

the email of the invitee

+
[options.roleName]String"developer"

the role name to be granted to the invitee

+
[message]String

the message to send along with the invite

+
+ +**Example** +```js +balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) { + console.log(invite); +}); +``` + +* * * + +### getAll +balena.models.application.invite.getAll([options]) ⇒ Promise + +This method returns all invites. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Get all invites +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.invite.getAll().then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.invite.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all invites for a specific application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Get all invites by application +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) { + console.log(invites); +}); +``` +**Example** +```js +balena.models.application.invite.getAllByApplication(123).then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### revoke +balena.models.application.invite.revoke(id) ⇒ Promise + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Revoke an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

application invite id

+
+ +**Example** +```js +balena.models.application.invite.revoke(123); +``` + +* * * + +## membership +balena.models.application.membership : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### changeRole +balena.models.application.membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise + +This method changes the role of an application member. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Changes the role of an application member +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be changed

+
roleNameString

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.application.membership.changeRole(123, "member").then(function() { + console.log('OK'); +}); +``` +**Example** +```js +balena.models.application.membership.changeRole({ + user: 123, + is_member_of__application: 125, +}, "member").then(function() { + console.log('OK'); +}); +``` + +* * * + +### create +balena.models.application.membership.create(options) ⇒ Promise + +This method adds a user to an application by their username if they are a member of the organization. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Creates a new membership for an application +**Access**: public +**Fulfil**: Object - application membership + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

membership creation parameters

+
options.applicationString | Number

application handle (string), or id (number)

+
options.usernameString

the username of the balena user that will become a member

+
[options.roleName]String"member"

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { + console.log(membership); +}); +``` + +* * * + +### get +balena.models.application.membership.get(membershipId, [options]) ⇒ Promise + +This method returns a single application membership. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get a single application membership +**Access**: public +**Fulfil**: Object - application membership + + + + + + + + + + + + +
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.get(5).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.membership.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all application memberships for a specific application. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get all memberships by application +**Access**: public +**Fulfil**: Object[] - application memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.application.membership.getAllByApplication(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByUser +balena.models.application.membership.getAllByUser(usernameOrId, [options]) ⇒ Promise + +This method returns all application memberships for a specific user. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get all memberships by user +**Access**: public +**Fulfil**: Object[] - application memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.application.membership.getAllByUser(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### remove +balena.models.application.membership.remove(idOrUniqueKey) ⇒ Promise + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Remove a membership +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be removed

+
+ +**Example** +```js +balena.models.application.membership.remove(123); +``` +**Example** +```js +balena.models.application.membership.remove({ + user: 123, + is_member_of__application: 125, +}); +``` + +* * * + +## tags +balena.models.application.tags : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### getAllByApplication +balena.models.application.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Get all application tags for an application +**Access**: public +**Fulfil**: Object[] - application tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.application.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.application.tags.remove(slugOrUuidOrId, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Remove an application tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.application.tags.remove('myorganization/myapp', 'EDITOR'); +``` + +* * * + +### set +balena.models.application.tags.set(slugOrUuidOrId, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Set an application tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.application.tags.set(123, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/billing.md b/pages/external-docs/sdk/node-sdk/latest/models/billing.md new file mode 100644 index 0000000000..fd9bdf75a2 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/billing.md @@ -0,0 +1,339 @@ +# billing +balena.models.billing : object + +**Note!** The billing methods are available on Balena.io exclusively. + +**Kind**: static namespace + +* * * + +## changePlan +balena.models.billing.changePlan(organization, planChangeOptions) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Change the current billing plan +**Access**: public + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
planChangeOptionsObject

an object containing the billing plan change options

+
billingInfo.tierString

the code of the target billing plan

+
billingInfo.cycleString

the billing cycle

+
[billingInfo.planChangeReason]String

the reason for changing the current plan

+
+ +**Example** +```js +balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() { + console.log('Plan changed!'); +}); +``` + +* * * + +## createSetupIntent +balena.models.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 + + + + + + + + + + + + + + +
ParamTypeDescription
setupIntentParamsObject

an object containing the parameters for the setup intent creation

+
extraParams.organizationString | 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); +}); +``` + +* * * + +## downloadInvoice +balena.models.billing.downloadInvoice(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Download a specific invoice +**Access**: public +**Fulfil**: Blob\|ReadableStream - blob on the browser, download stream on node + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
String

an invoice number

+
+ +**Example** +```js +# Browser +balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) { + console.log(blob); +}); +# Node +balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) { + stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf')); +}); +``` + +* * * + +## getAccount +balena.models.billing.getAccount(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the user's billing account +**Access**: public +**Fulfil**: Object - billing account + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getAccount(orgId).then(function(billingAccount) { + console.log(billingAccount); +}); +``` + +* * * + +## getBillingInfo +balena.models.billing.getBillingInfo(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the current billing information +**Access**: public +**Fulfil**: Object - billing information + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getBillingInfo(orgId).then(function(billingInfo) { + console.log(billingInfo); +}); +``` + +* * * + +## getInvoices +balena.models.billing.getInvoices(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the available invoices +**Access**: public +**Fulfil**: Object - invoices + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getInvoices(orgId).then(function(invoices) { + console.log(invoices); +}); +``` + +* * * + +## getPlan +balena.models.billing.getPlan(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the current billing plan +**Access**: public +**Fulfil**: Object - billing plan + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getPlan(orgId).then(function(billingPlan) { + console.log(billingPlan); +}); +``` + +* * * + +## removeBillingInfo +balena.models.billing.removeBillingInfo(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Remove an organization's billing information +**Access**: public + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.removeBillingInfo(orgId).then(function() { + console.log("Success"); +}); +``` + +* * * + +## updateAccountInfo +balena.models.billing.updateAccountInfo(organization, accountInfo) + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Update the current billing account information +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
accountInfoAccountInfo

an object containing billing account info

+
+ +**Example** +```js +balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) +``` +**Example** +```js +balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) +``` + +* * * + +## updateBillingInfo +balena.models.billing.updateBillingInfo(organization, billingInfo) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Update the current billing information +**Access**: public +**Fulfil**: Object - billing information + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
billingInfoObject

an object containing a billing info token_id

+
billingInfo.token_idString

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 +balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) { + console.log(billingInfo); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/config.md b/pages/external-docs/sdk/node-sdk/latest/models/config.md new file mode 100644 index 0000000000..676ca030aa --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/config.md @@ -0,0 +1,130 @@ +# config +balena.models.config : object + +**Kind**: static namespace + +* * * + +## getAll +balena.models.config.getAll() ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get all configuration +**Access**: public +**Fulfil**: Object - configuration +**Example** +```js +balena.models.config.getAll().then(function(config) { + console.log(config); +}); +``` + +* * * + +## getConfigVarSchema +balena.models.config.getConfigVarSchema(deviceType) ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get configuration variables schema for a device type +**Access**: public +**Fulfil**: Object[] - configuration options + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) { + console.log(options); +}); +``` + +* * * + +## getDeviceOptions +balena.models.config.getDeviceOptions(deviceType) ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get configuration/initialization options for a device type +**Access**: public +**Fulfil**: Object[] - configuration options + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) { + console.log(options); +}); +``` + +* * * + +## getDeviceTypeManifestBySlug +balena.models.config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise + +***use balena.models.deviceType.getBySlugOrName*** + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get a device type manifest by slug +**Access**: public +**Fulfil**: Object - device type manifest + + + + + + + + + + +
ParamTypeDescription
slugOrNameString

device type slug

+
+ +**Example** +```js +balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) { + console.log(manifest); +}); +``` + +* * * + +## getDeviceTypes +balena.models.config.getDeviceTypes() ⇒ Promise + +***use balena.models.deviceType.getAll*** + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get device types +**Access**: public +**Fulfil**: Object[] - device types +**Example** +```js +balena.models.config.getDeviceTypes().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/creditBundle.md b/pages/external-docs/sdk/node-sdk/latest/models/creditBundle.md new file mode 100644 index 0000000000..9b3025c4e4 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/creditBundle.md @@ -0,0 +1,74 @@ +# creditBundle +balena.models.creditBundle : object + +**Kind**: static namespace + +* * * + +## create +balena.models.creditBundle.create(organization, featureId, creditsToPurchase) ⇒ Promise + +**Kind**: static method of [creditBundle](#balena.models.creditBundle) +**Summary**: Purchase a credit bundle for the given feature and org of the given quantity +**Access**: public +**Fulfil**: Object[] - credit bundles + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
featureIdNumber

id (number) of the feature for which credits are being purchased.

+
creditsToPurchaseNumber

number of credits being purchased.

+
+ +**Example** +```js +balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) { + console.log(creditBundle); +}); +``` + +* * * + +## getAllByOrg +balena.models.creditBundle.getAllByOrg(organization, [options]) ⇒ Promise + +**Kind**: static method of [creditBundle](#balena.models.creditBundle) +**Summary**: Get all of the credit bundles purchased by the given org +**Access**: public +**Fulfil**: Object[] - credit bundles + + + + + + + + + + + + +
ParamTypeDefaultDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) { + console.log(creditBundles); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/device.md b/pages/external-docs/sdk/node-sdk/latest/models/device.md new file mode 100644 index 0000000000..49a47aeac3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/device.md @@ -0,0 +1,2986 @@ +# device +balena.models.device : object + +**Kind**: static namespace + +* * * + +## deactivate +balena.models.device.deactivate(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Deactivate device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.deactivate('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.deactivate(123); +``` + +* * * + +## disableDeviceUrl +balena.models.device.disableDeviceUrl(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable device url for a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.disableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableDeviceUrl(123); +``` + +* * * + +## disableLocalMode +balena.models.device.disableLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable local mode +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.disableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableLocalMode(123); +``` + +* * * + +## disableLockOverride +balena.models.device.disableLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable lock override +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.disableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableLockOverride(123); +``` + +* * * + +## enableDeviceUrl +balena.models.device.enableDeviceUrl(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable device url for a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.enableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableDeviceUrl(123); +``` + +* * * + +## enableLocalMode +balena.models.device.enableLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable local mode +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.enableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableLocalMode(123); +``` + +* * * + +## enableLockOverride +balena.models.device.enableLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable lock override +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.enableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableLockOverride(123); +``` + +* * * + +## generateDeviceKey +balena.models.device.generateDeviceKey(uuidOrId, [keyName], [keyDescription]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Generate a device key +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[keyName]String

Device key name

+
[keyDescription]String

Description for device key

+
+ +**Example** +```js +balena.models.device.generateDeviceKey('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceApiKey) { + console.log(deviceApiKey); +}); +``` +**Example** +```js +balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) { + console.log(deviceApiKey); +}); +``` + +* * * + +## generateUniqueKey +balena.models.device.generateUniqueKey() ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Generate a random key, useful for both uuid and api key. +**Returns**: String - A generated key +**Access**: public +**Example** +```js +randomKey = balena.models.device.generateUniqueKey(); +// randomKey is a randomly generated key that can be used as either a uuid or an api key +console.log(randomKey); +``` + +* * * + +## get +balena.models.device.get(uuidOrId, [options]) ⇒ Promise + +This method returns a single device by id or uuid. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a single device +**Access**: public +**Fulfil**: Object - device + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.get(123).then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getAllByApplication +balena.models.device.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all devices of a specific application. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get all devices by application +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByApplication(123).then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getAllByOrganization +balena.models.device.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all devices of a specific application. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get all devices by organization +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getAllByOrganization('myorganization').then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByOrganization(123).then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getApplicationName +balena.models.device.getApplicationName(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get application name +**Access**: public +**Fulfil**: String - application name + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getApplicationName('7cf02a69e4d34c9da573914963cf54fd').then(function(applicationName) { + console.log(applicationName); +}); +``` +**Example** +```js +balena.models.device.getApplicationName(123).then(function(applicationName) { + console.log(applicationName); +}); +``` + +* * * + +## getByName +balena.models.device.getByName(name) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get devices by name +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + +
ParamTypeDescription
nameString

device name

+
+ +**Example** +```js +balena.models.device.getByName('MyDevice').then(function(devices) { + console.log(devices); +}); +``` + +* * * + +## getDashboardUrl +balena.models.device.getDashboardUrl(uuid) ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get Dashboard URL for a specific device +**Returns**: String - - Dashboard URL for the specific device +**Throws**: + +- Exception if the uuid is empty + + + + + + + + + + + +
ParamTypeDescription
uuidString

Device uuid

+
+ +**Example** +```js +dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8') +``` + +* * * + +## getDeviceUrl +balena.models.device.getDeviceUrl(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a device url +**Access**: public +**Fulfil**: String - device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(url) { + console.log(url); +}); +``` +**Example** +```js +balena.models.device.getDeviceUrl(123).then(function(url) { + console.log(url); +}); +``` + +* * * + +## getLocalIPAddresses +balena.models.device.getLocalIPAddresses(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the local IP addresses of a device +**Access**: public +**Fulfil**: String[] - local ip addresses +**Reject**: Error Will reject if the device is offline + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getLocalIPAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(localIPAddresses) { + localIPAddresses.forEach(function(localIP) { + console.log(localIP); + }); +}); +``` +**Example** +```js +balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) { + localIPAddresses.forEach(function(localIP) { + console.log(localIP); + }); +}); +``` + +* * * + +## getLocalModeSupport +balena.models.device.getLocalModeSupport(device) ⇒ Object + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported. +**Returns**: Object - Local mode support info ({ supported: true/false, message: "..." }) +**Access**: public + + + + + + + + + + +
ParamTypeDescription
deviceObject

A device object

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + balena.models.device.getLocalModeSupport(device); +}) +``` + +* * * + +## getMACAddresses +balena.models.device.getMACAddresses(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the MAC addresses of a device +**Access**: public +**Fulfil**: String[] - mac addresses + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getMACAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(macAddresses) { + macAddresses.forEach(function(mac) { + console.log(mac); + }); +}); +``` +**Example** +```js +balena.models.device.getMACAddresses(123).then(function(macAddresses) { + macAddresses.forEach(function(mac) { + console.log(mac); + }); +}); +``` + +* * * + +## getMetrics +balena.models.device.getMetrics(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the metrics related information for a device +**Access**: public +**Fulfil**: Object - device metrics + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getMetrics('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceMetrics) { + console.log(deviceMetrics); +}); +``` +**Example** +```js +balena.models.device.getMetrics(123).then(function(deviceMetrics) { + console.log(deviceMetrics); +}); +``` + +* * * + +## getName +balena.models.device.getName(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the name of a device +**Access**: public +**Fulfil**: String - device name + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getName('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceName) { + console.log(deviceName); +}); +``` +**Example** +```js +balena.models.device.getName(123).then(function(deviceName) { + console.log(deviceName); +}); +``` + +* * * + +## getOsVersion +balena.models.device.getOsVersion(device) ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the OS version (version number and variant combined) running on a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
deviceObject

A device object

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device.os_version); // => 'balenaOS 2.26.0+rev1' + console.log(device.os_variant); // => 'prod' + balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod' +}) +``` + +* * * + +## getProgress +balena.models.device.getProgress(uuidOrId) ⇒ Promise + +Convenience method for getting the overall progress of a device. +It's recommended to use `balena.models.device.get()` instead, +in case that you need to retrieve more device fields than just the progress. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the progress of a device +**Access**: public +**Fulfil**: Number\|null - device progress +**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field. + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getProgress('7cf02a69e4d34c9da573914963cf54fd').then(function(progress) { + console.log(progress); +}); +``` +**Example** +```js +balena.models.device.getProgress(123).then(function(progress) { + console.log(progress); +}); +``` + +* * * + +## getStatus +balena.models.device.getStatus(uuidOrId) ⇒ Promise + +Convenience method for getting the overall status of a device. +It's recommended to use `balena.models.device.get()` instead, +in case that you need to retrieve more device fields than just the status. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the status of a device +**Access**: public +**Fulfil**: String - device status +**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field. + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getStatus('7cf02a69e4d34c9da573914963cf54fd').then(function(status) { + console.log(status); +}); +``` +**Example** +```js +balena.models.device.getStatus(123).then(function(status) { + console.log(status); +}); +``` + +* * * + +## getSupervisorState +balena.models.device.getSupervisorState(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the supervisor state on a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getSupervisorState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorState(123).then(function(state) { + console.log(state); +}); +``` + +* * * + +## getSupervisorTargetState +balena.models.device.getSupervisorTargetState(uuidOrId, version) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the target supervisor state on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
versionNumber

(optional) target state version (2 or 3), default to 2

+
+ +**Example** +```js +balena.models.device.getSupervisorTargetState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetState(123).then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetState(123, 3).then(function(state) { + console.log(state); +}); +``` + +* * * + +## getSupervisorTargetStateForApp +balena.models.device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the target supervisor state on a "generic" device on a fleet +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

fleet uuid (string) or id (number)

+
releaseString

(optional) release uuid (default tracked)

+
+ +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` + +* * * + +## getTargetReleaseHash +balena.models.device.getTargetReleaseHash(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the hash of the currently tracked release for a specific device +**Access**: public +**Fulfil**: String - The release hash of the currently tracked release + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd', function(release) { + console.log(release); +}); +``` + +* * * + +## getWithServiceDetails +balena.models.device.getWithServiceDetails(uuidOrId, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want more control, or to see the raw model +directly, use `device.get(uuidOrId, options)` instead. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a single device along with its associated services' details, +including their associated commit +**Access**: public +**Fulfil**: Object - device with service details + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getWithServiceDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.getWithServiceDetails(123).then(function(device) { + console.log(device); +}) +``` + +* * * + +## grantSupportAccess +balena.models.device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Grant support access to a device until a specified time +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
expiryTimestampNumber

a timestamp in ms for when the support access will expire

+
+ +**Example** +```js +balena.models.device.grantSupportAccess('7cf02a69e4d34c9da573914963cf54fd', Date.now() + 3600 * 1000); +``` +**Example** +```js +balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000); +``` + +* * * + +## has +balena.models.device.has(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device exists +**Access**: public +**Fulfil**: Boolean - has device + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.has('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDevice) { + console.log(hasDevice); +}); +``` +**Example** +```js +balena.models.device.has(123).then(function(hasDevice) { + console.log(hasDevice); +}); +``` + +* * * + +## hasDeviceUrl +balena.models.device.hasDeviceUrl(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device is web accessible with device utls +**Access**: public +**Fulfil**: Boolean - has device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.hasDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDeviceUrl) { + if (hasDeviceUrl) { + console.log('The device has device URL enabled'); + } +}); +``` +**Example** +```js +balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) { + if (hasDeviceUrl) { + console.log('The device has device URL enabled'); + } +}); +``` + +* * * + +## hasLockOverride +balena.models.device.hasLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device has the lock override enabled +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.hasLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.hasLockOverride(123); +``` + +* * * + +## identify +balena.models.device.identify(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Identify device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.identify('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.identify(123); +``` + +* * * + +## isInLocalMode +balena.models.device.isInLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if local mode is enabled on the device +**Access**: public +**Fulfil**: Boolean - has device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isInLocalMode('7cf02a69e4d34c9da573914963cf54fd').then(function(isInLocalMode) { + if (isInLocalMode) { + console.log('The device has local mode enabled'); + } +}); +``` +**Example** +```js +balena.models.device.isInLocalMode(123).then(function(isInLocalMode) { + if (isInLocalMode) { + console.log('The device has local mode enabled'); + } +}); +``` + +* * * + +## isOnline +balena.models.device.isOnline(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device is online +**Access**: public +**Fulfil**: Boolean - is device online + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isOnline('7cf02a69e4d34c9da573914963cf54fd').then(function(isOnline) { + console.log('Is device online?', isOnline); +}); +``` +**Example** +```js +balena.models.device.isOnline(123).then(function(isOnline) { + console.log('Is device online?', isOnline); +}); +``` + +* * * + +## isTrackingApplicationRelease +balena.models.device.isTrackingApplicationRelease(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get whether the device is configured to track the current application release +**Access**: public +**Fulfil**: Boolean - is tracking the current application release + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isTrackingApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## move +balena.models.device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Move a device to another application +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.move('7cf02a69e4d34c9da573914963cf54fd', 'myorganization/myapp'); +``` +**Example** +```js +balena.models.device.move(123, 'myorganization/myapp'); +``` +**Example** +```js +balena.models.device.move(123, 456); +``` + +* * * + +## ping +balena.models.device.ping(uuidOrId) ⇒ Promise + +This is useful to signal that the supervisor is alive and responding. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Ping a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.ping('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.ping(123); +``` + +* * * + +## pinToOsRelease +balena.models.device.pinToOsRelease(uuidOrIdOrArray, osVersionOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Mark a specific device to be updated to a particular OS release +**Access**: public +**Experimental**: + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
osVersionOrIdString

the raw version of a OS release (string) or id (number) +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number, a "prod" variant and greater than or equal to the one running on the device. +To resolve compatible update targets for a device use balena.models.os.getSupportedOsUpdateVersions.

+
+ +**Example** +```js +await balena.models.device.pinToOsRelease('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod'); +``` + +* * * + +## pinToRelease +balena.models.device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ Promise + +Configures the device to run a particular release +and not get updated when the current application release changes. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a specific device to run a particular release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
fullReleaseHashOrIdString | Number

the hash of a successful release (string) or id (number)

+
+ +**Example** +```js +balena.models.device.pinToRelease('7cf02a69e4d34c9da573914963cf54fd', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` + +* * * + +## pinToSupervisorRelease +balena.models.device.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ Promise + +Configures the device to run a particular supervisor release. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a specific device to run a particular supervisor release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
supervisorVersionOrIdString | Number

the raw version of a supervisor release (string) or id (number)

+
+ +**Example** +```js +balena.models.device.pinToSupervisorRelease('7cf02a69e4d34c9da573914963cf54fd', '10.8.0').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.pinToSupervisorRelease(123, '11.4.14').then(function() { + ... +}); +``` + +* * * + +## purge +balena.models.device.purge(uuidOrId) ⇒ Promise + +This function clears the user application's `/data` directory. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Purge device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.purge('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.purge(123); +``` + +* * * + +## reboot +balena.models.device.reboot(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Reboot device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.reboot('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.reboot(123); +``` + +* * * + +## register +balena.models.device.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Register a new device with a Balena application. +**Access**: public +**Fulfil**: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." }) + + + + + + + + + + + + + + +
ParamTypeDescription
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
uuidString

device uuid

+
[deviceTypeSlug]String

device type slug (string) or alias (string)

+
+ +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register(123, uuid).then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` + +* * * + +## remove +balena.models.device.remove(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Remove device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.remove('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.remove(123); +``` + +* * * + +## rename +balena.models.device.rename(uuidOrId, newName) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Rename device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
newNameString

the device new name

+
+ +**Example** +```js +balena.models.device.rename('7cf02a69e4d34c9da573914963cf54fd', 'NewName'); +``` +**Example** +```js +balena.models.device.rename(123, 'NewName'); +``` + +* * * + +## restartApplication +balena.models.device.restartApplication(uuidOrId) ⇒ Promise + +This function restarts the Docker container running +the application on the device, but doesn't reboot +the device itself. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Restart application on device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.restartApplication('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.restartApplication(123); +``` + +* * * + +## restartService +balena.models.device.restartService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Restart a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to restart

+
+ +**Example** +```js +balena.models.device.restartService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.restartService(1, 123).then(function() { + ... +}); +``` + +* * * + +## revokeSupportAccess +balena.models.device.revokeSupportAccess(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Revoke support access to a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.revokeSupportAccess('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.revokeSupportAccess(123); +``` + +* * * + +## setCustomLocation +balena.models.device.setCustomLocation(uuidOrIdOrArray, location) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a custom location for a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
locationObject

the location ({ latitude: 123, longitude: 456 })

+
+ +**Example** +```js +balena.models.device.setCustomLocation('7cf02a69e4d34c9da573914963cf54fd', { latitude: 123, longitude: 456 }); +``` +**Example** +```js +balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 }); +``` + +* * * + +## setNote +balena.models.device.setNote(uuidOrIdOrArray, note) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Note a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
noteString

the note

+
+ +**Example** +```js +balena.models.device.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); +``` +**Example** +```js +balena.models.device.setNote(123, 'My useful note'); +``` + +* * * + +## shutdown +balena.models.device.shutdown(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Shutdown device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.shutdown('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.shutdown(123); +``` + +* * * + +## startOsUpdate +balena.models.device.startOsUpdate(uuidOrUuids, targetOsVersion, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Start an OS update on a device +**Access**: public +**Fulfil**: Object - action response + + + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrUuidsString | Array.<String>

full device uuid or array of full uuids

+
targetOsVersionString

semver-compatible version for the target device +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number, a "prod" variant and greater than the one running on the device. +To resolve the semver-compatible range use balena.model.os.getMaxSatisfyingVersion.

+
[options]Object

options

+
[options.runDetached]Boolean

run the update in detached mode. True by default

+
+ +**Example** +```js +balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { + console.log(result.status); +}); +``` + +* * * + +## startService +balena.models.device.startService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Start a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to start

+
+ +**Example** +```js +balena.models.device.startService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.startService(1, 123).then(function() { + ... +}); +``` + +* * * + +## stopService +balena.models.device.stopService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Stop a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to stop

+
+ +**Example** +```js +balena.models.device.stopService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.stopService(1, 123).then(function() { + ... +}); +``` + +* * * + +## trackApplicationRelease +balena.models.device.trackApplicationRelease(uuidOrIdOrArray) ⇒ Promise + +The device's current release will be updated with each new successfully built release. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Configure a specific device to track the current application release +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.trackApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function() { + ... +}); +``` + +* * * + +## unsetCustomLocation +balena.models.device.unsetCustomLocation(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Clear the custom location of a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.unsetCustomLocation('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.unsetCustomLocation(123); +``` + +* * * + +## update +balena.models.device.update(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Trigger an update check on the supervisor +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.update('7cf02a69e4d34c9da573914963cf54fd', { + force: true +}); +``` +**Example** +```js +balena.models.device.update(123, { + force: true +}); +``` + +* * * + +## configVar +balena.models.device.configVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.configVar.get(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get the value of a specific config variable +**Access**: public +**Fulfil**: String\|undefined - the config variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.device.configVar.get('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get all device config variables by application +**Access**: public +**Fulfil**: Object[] - device config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.configVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.configVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get all config variables for a device +**Access**: public +**Fulfil**: Object[] - device config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.configVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.configVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.configVar.remove(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Clear the value of a specific config variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.device.configVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.configVar.set(uuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Set the value of a specific config variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
valueString

config variable value

+
+ +**Example** +```js +balena.models.device.configVar.set('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## envVar +balena.models.device.envVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.envVar.get(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get the value of a specific environment variable +**Access**: public +**Fulfil**: String\|undefined - the environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.device.envVar.get('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.envVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get all device environment variables by application +**Access**: public +**Fulfil**: Object[] - device environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.envVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.envVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get all environment variables for a device +**Access**: public +**Fulfil**: Object[] - device environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.envVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.envVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.envVar.remove(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Clear the value of a specific environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.device.envVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.envVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.envVar.set(uuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Set the value of a specific environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
valueString

environment variable value

+
+ +**Example** +```js +balena.models.device.envVar.set('7cf02a69e4d34c9da573914963cf54fd', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## history +balena.models.device.history : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### getAllByApplication +balena.models.device.history.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [history](#balena.models.device.history) +**Summary**: Get all device history entries by application with time frame +**Access**: public +**Fulfil**: Object[] - device history + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

+
[dateFilter.toDate]Date

history entries younger or equal to this date

+
[options]Object

extra pine options to use

+
+ +**Example** +```js +balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +balena.models.device.history.getAllByApplication(999999).then(function(entries) { + console.log(entries); +}); + + +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByApplication( + 999999, + { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10), + { $top: 10, $orderby: { id: 'desc' }} +}); +``` + +* * * + +### getAllByDevice +balena.models.device.history.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [history](#balena.models.device.history) +**Summary**: Get all history entries for a device +**Access**: public +**Fulfil**: Object[] - device history + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (32 / 62 digits string) or id (number)

+
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

+
[dateFilter.toDate]Date

history entries younger or equal to this date

+
[options]Object

extra pine options to use

+
+ +**Example** +```js +balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +balena.models.device.history.getAllByDevice(999999).then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByDevice( + 999999, + { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}, + { $top: 10, $orderby: { id: 'desc' }} +) +``` + +* * * + +## serviceVar +balena.models.device.serviceVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get the overriden value of a service variable on a device +**Access**: public +**Fulfil**: String\|undefined - the variable value (or undefined) + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
+ +**Example** +```js +balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.serviceVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get all device service variable overrides by application +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.serviceVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get all service variable overrides for a device +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.serviceVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Clear the overridden value of a service variable on a device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
+ +**Example** +```js +balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Set the overriden value of a service variable on a device +**Access**: public + + + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
valueString

variable value

+
+ +**Example** +```js +balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR', 'override').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR', 'override').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() { + ... +}); +``` + +* * * + +## tags +balena.models.device.tags : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### getAllByApplication +balena.models.device.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Get all device tags for an application +**Access**: public +**Fulfil**: Object[] - device tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.device.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.tags.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Get all device tags for a device +**Access**: public +**Fulfil**: Object[] - device tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.tags.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.device.tags.getAllByDevice(123).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.device.tags.remove(uuidOrId, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Remove a device tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.device.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); +``` + +* * * + +### set +balena.models.device.tags.set(uuidOrId, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Set a device tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.device.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.device.tags.set(123, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/deviceType.md b/pages/external-docs/sdk/node-sdk/latest/models/deviceType.md new file mode 100644 index 0000000000..d5057f98ff --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/deviceType.md @@ -0,0 +1,309 @@ +# deviceType +balena.models.deviceType : object + +**Kind**: static namespace + +* * * + +## get +balena.models.deviceType.get(idOrSlug, [options]) ⇒ Promise + +This method returns a single device type. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a single deviceType +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + + + +
ParamTypeDefaultDescription
idOrSlugString | Number

device type slug (string) or alias (string) or id

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.get('raspberry-pi').then(function(deviceType) { + console.log(deviceType); +}); +``` +**Example** +```js +balena.models.deviceType.get('raspberrypi').then(function(deviceType) { + console.log('resolved alias:', deviceType); +}); +``` + +* * * + +## getAll +balena.models.deviceType.getAll([options]) ⇒ Promise + +This method returns all device types. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get all deviceTypes +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.getAll().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` +**Example** +```js +balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) { + console.log(deviceTypes); +}) +``` + +* * * + +## getAllSupported +balena.models.deviceType.getAllSupported([options]) ⇒ Promise + +This method returns all supported device types. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get all supported deviceTypes +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.getAllSupported().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` +**Example** +```js +balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) { + console.log(deviceTypes); +}) +``` + +* * * + +## getBySlugOrName +balena.models.deviceType.getBySlugOrName(slugOrName) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a deviceType by slug or name +**Access**: public +**Fulfil**: Object - device type + + + + + + + + + + +
ParamTypeDescription
slugOrNameString

deviceType slug

+
+ +**Example** +```js +balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { + console.log(deviceType); +}); +``` + +* * * + +## getInstallMethod +balena.models.deviceType.getInstallMethod(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get installation method on a given device type +**Access**: public +**Fulfil**: String - the installation method supported for the given device type slug + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { + console.log(method); + // externalBoot +}); +``` + +* * * + +## getInstructions +balena.models.deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get instructions for installing a host OS on a given device type +**Access**: public +**Fulfil**: Object \| String[] - step by step instructions for installing the host OS to the device + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugOrContractString | Object

device type slug or contract

+
+ +**Example** +```js +balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { + for (let instruction of instructions.values()) { + console.log(instruction); + } + // Insert the sdcard to the host machine. + // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. + // Wait for writing of BalenaOS to complete. + // Remove the sdcard from the host machine. + // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). + // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. +}); +``` + +* * * + +## getInterpolatedPartials +balena.models.deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a contract with resolved partial templates +**Access**: public +**Fulfil**: Contract - device type contract with resolved partials + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { + for (const partial in contract.partials) { + console.log(`${partial}: ${contract.partials[partial]}`); + } + // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] +}); +``` + +* * * + +## getName +balena.models.deviceType.getName(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get display name for a device +**Access**: public +**Fulfil**: String - device display name + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { + console.log(deviceTypeName); + // Raspberry Pi +}); +``` + +* * * + +## getSlugByName +balena.models.deviceType.getSlugByName(deviceTypeName) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get device slug +**Access**: public +**Fulfil**: String - device slug name + + + + + + + + + + +
ParamTypeDescription
deviceTypeNameString

device type name

+
+ +**Example** +```js +balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { + console.log(deviceTypeSlug); + // raspberry-pi +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/image.md b/pages/external-docs/sdk/node-sdk/latest/models/image.md new file mode 100644 index 0000000000..7e3a9e6e82 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/image.md @@ -0,0 +1,68 @@ +# image +balena.models.image : object + +**Kind**: static namespace + +* * * + +## get +balena.models.image.get(id, [options]) ⇒ Promise + +**Kind**: static method of [image](#balena.models.image) +**Summary**: Get a specific image +**Access**: public +**Fulfil**: Object - image + + + + + + + + + + + + +
ParamTypeDefaultDescription
idNumber

image id

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.image.get(123).then(function(image) { + console.log(image); +}); +``` + +* * * + +## getLogs +balena.models.image.getLogs(id) ⇒ Promise + +**Kind**: static method of [image](#balena.models.image) +**Summary**: Get the logs for an image +**Access**: public +**Fulfil**: string \| null - logs + + + + + + + + + + +
ParamTypeDescription
idNumber

image id

+
+ +**Example** +```js +balena.models.image.getLogs(123).then(function(logs) { + console.log(logs); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/key.md b/pages/external-docs/sdk/node-sdk/latest/models/key.md new file mode 100644 index 0000000000..9d4db96169 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/key.md @@ -0,0 +1,123 @@ +# key +balena.models.key : object + +**Kind**: static namespace + +* * * + +## create +balena.models.key.create(title, key) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Create a ssh key +**Access**: public +**Fulfil**: Object - ssh key + + + + + + + + + + + + +
ParamTypeDescription
titleString

key title

+
keyString

the public ssh key

+
+ +**Example** +```js +balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) { + console.log(key); +}); +``` + +* * * + +## get +balena.models.key.get(id) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Get a single ssh key +**Access**: public +**Fulfil**: Object - ssh key + + + + + + + + + + +
ParamTypeDescription
idNumber

key id

+
+ +**Example** +```js +balena.models.key.get(51).then(function(key) { + console.log(key); +}); +``` + +* * * + +## getAll +balena.models.key.getAll([options]) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Get all ssh keys +**Access**: public +**Fulfil**: Object[] - ssh keys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.key.getAll().then(function(keys) { + console.log(keys); +}); +``` + +* * * + +## remove +balena.models.key.remove(id) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Remove ssh key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

key id

+
+ +**Example** +```js +balena.models.key.remove(51); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/organization.md b/pages/external-docs/sdk/node-sdk/latest/models/organization.md new file mode 100644 index 0000000000..e195cd08f6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/organization.md @@ -0,0 +1,521 @@ +# organization +balena.models.organization : object + +**Kind**: static namespace + +* * * + +## create +balena.models.organization.create(options) ⇒ Promise + +This method creates a new organization with the current user as an administrator. + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Creates a new organization +**Access**: public +**Fulfil**: String - Organization + + + + + + + + + + + + + + +
ParamTypeDescription
optionsObject

Organization parameters to use.

+
options.nameString

Required: the name of the organization that will be created.

+
[options.handle]String

The handle of the organization that will be created.

+
+ +**Example** +```js +balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) { + console.log(organization); +}); +``` +**Example** +```js +balena.models.organization.create({ + name:'MyOrganization', + logo_image: new File( + imageContent, + 'img.jpeg' + ); +}) +.then(function(organization) { + console.log(organization); +}); +``` + +* * * + +## get +balena.models.organization.get(handleOrId, [options]) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Get a single organization +**Access**: public +**Fulfil**: Object - organization + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.get('myorganization').then(function(organization) { + console.log(organization); +}); +``` +**Example** +```js +balena.models.organization.get(123).then(function(organization) { + console.log(organization); +}); +``` + +* * * + +## getAll +balena.models.organization.getAll([options]) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Get all Organizations +**Access**: public +**Fulfil**: Object[] - organizations + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.getAll().then(function(organizations) { + console.log(organizations); +}); +``` + +* * * + +## remove +balena.models.organization.remove(handleOrId) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Remove an Organization +**Access**: public + + + + + + + + + + +
ParamTypeDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
+ +**Example** +```js +balena.models.organization.remove(123); +``` + +* * * + +## invite +balena.models.organization.invite : object + +**Kind**: static namespace of [organization](#balena.models.organization) + +* * * + +### accept +balena.models.organization.invite.accept(invitationToken) ⇒ Promise + +This method adds the calling user to the organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Accepts an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
invitationTokenString

invite token

+
+ +**Example** +```js +balena.models.organization.invite.accept("qwerty-invitation-token"); +``` + +* * * + +### create +balena.models.organization.invite.create(handleOrId, options, [message]) ⇒ Promise + +This method invites a user by their email to an organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Creates a new invite for an organization +**Access**: public +**Fulfil**: String - organization invite + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

+
optionsObject

invite creation parameters

+
options.inviteeString

the email of the invitee

+
[options.roleName]String"developer"

the role name to be granted to the invitee

+
[message]String

the message to send along with the invite

+
+ +**Example** +```js +balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) { + console.log(invite); +}); +``` + +* * * + +### getAll +balena.models.organization.invite.getAll([options]) ⇒ Promise + +This method returns all invites. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Get all invites +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.invite.getAll().then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### getAllByOrganization +balena.models.organization.invite.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all invites for a specific organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Get all invites by organization +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) { + console.log(invites); +}); +``` +**Example** +```js +balena.models.organization.invite.getAllByOrganization(123).then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### revoke +balena.models.organization.invite.revoke(id) ⇒ Promise + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Revoke an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

organization invite id

+
+ +**Example** +```js +balena.models.organization.invite.revoke(123); +``` + +* * * + +## membership +balena.models.organization.membership : object + +**Kind**: static namespace of [organization](#balena.models.organization) + +* * * + +### changeRole +balena.models.organization.membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise + +This method changes the role of an organization member. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Changes the role of an organization member +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership that will be changed

+
roleNameString

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.organization.membership.changeRole(123, "member").then(function() { + console.log('OK'); +}); +``` +**Example** +```js +balena.models.organization.membership.changeRole({ + user: 123, + is_member_of__organization: 125, +}, "member").then(function() { + console.log('OK'); +}); +``` + +* * * + +### get +balena.models.organization.membership.get(membershipId, [options]) ⇒ Promise + +This method returns a single organization membership. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get a single organization membership +**Access**: public +**Fulfil**: Object - organization membership + + + + + + + + + + + + +
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.get(5).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByOrganization +balena.models.organization.membership.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all organization memberships for a specific organization. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get all memberships by organization +**Access**: public +**Fulfil**: Object[] - organization memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByUser +balena.models.organization.membership.getAllByUser(usernameOrId, [options]) ⇒ Promise + +This method returns all organization memberships for a specific user. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get all memberships by user +**Access**: public +**Fulfil**: Object[] - organization memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.organization.membership.getAllByUser(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### remove +balena.models.organization.membership.remove(id) ⇒ Promise + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Remove a membership +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

organization membership id

+
+ +**Example** +```js +balena.models.organization.membership.remove(123); +``` +**Example** +```js +balena.models.organization.membership.remove({ + user: 123, + is_member_of__application: 125, +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/os.md b/pages/external-docs/sdk/node-sdk/latest/models/os.md new file mode 100644 index 0000000000..e9e7ac87f6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/os.md @@ -0,0 +1,523 @@ +# os +balena.models.os : object + +**Kind**: static namespace + +* * * + +## download +balena.models.os.download(options) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Download an OS image +**Access**: public +**Fulfil**: ReadableStream - download stream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

OS image options to use.

+
options.deviceTypeString

device type slug

+
[options.version]String'latest'

semver-compatible version or 'latest', defaults to 'latest' +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number.

+
[options.developmentMode]Boolean

controls development mode for unified balenaOS releases.

+
[options.appId]Number

the application ID (number).

+
[options.fileType]String

download file type. One of '.img' or '.zip' or '.gz'.

+
[options.imageType]String

download file type. One of 'raw' or 'flasher'

+
[options.appUpdatePollInterval]Number

how often the OS checks for updates, in minutes.

+
[options.network]String

the network type that the device will use, one of 'ethernet' or 'wifi'.

+
[options.wifiKey]String

the key for the wifi network the device will connect to if network is wifi.

+
[options.wifiSsid]String

the ssid for the wifi network the device will connect to if network is wifi.

+
+ +**Example** +```js +balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) { + stream.pipe(fs.createWriteStream('foo/bar/image.img')); +}); +``` + +* * * + +## getAllOsVersions +balena.models.os.getAllOsVersions(deviceTypes, [options]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.os.getAllOsVersions('raspberrypi3'); +``` +**Example** +```js +balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']); +``` +**Example** +```js +balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } }); +``` + +* * * + +## getAvailableOsVersions +balena.models.os.getAvailableOsVersions(deviceTypes, [pineOptions], [extraOptions]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get the supported OS versions for the provided device type(s) +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

+
[pineOptions]Object

Extra pine options to use

+
[extraOptions]Object

Extra convenience options to use

+
[extraOptions.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

+
+ +**Example** +```js +balena.models.os.getAvailableOsVersions('raspberrypi3'); +``` +**Example** +```js +balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']); +``` + +* * * + +## getConfig +balena.models.os.getConfig(slugOrUuidOrId, options) ⇒ Promise + +Builds the config.json for a device in the given application, with the given +options. + +Note that an OS version is required. For versions < 2.7.8, config +generation is only supported when using a session token, not an API key. + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get an applications config.json +**Access**: public +**Fulfil**: Object - application configuration as a JSON object. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number).

+
optionsObject

OS configuration options to use.

+
options.versionString

Required: the OS version of the image.

+
[options.network]String'ethernet'

The network type that +the device will use, one of 'ethernet' or 'wifi'.

+
[options.appUpdatePollInterval]Number

How often the OS checks +for updates, in minutes.

+
[options.provisioningKeyName]String

Name assigned to API key

+
[options.provisioningKeyExpiryDate]String

Expiry Date assigned to API key

+
[options.developmentMode]Boolean

Controls development mode for unified balenaOS releases.

+
[options.wifiKey]String

The key for the wifi network the +device will connect to.

+
[options.wifiSsid]String

The ssid for the wifi network the +device will connect to.

+
[options.ip]String

static ip address.

+
[options.gateway]String

static ip gateway.

+
[options.netmask]String

static ip netmask.

+
+ +**Example** +```js +balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) { + fs.writeFile('foo/bar/config.json', JSON.stringify(config)); +}); + +balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) { + fs.writeFile('foo/bar/config.json', JSON.stringify(config)); +}); +``` + +* * * + +## getDownloadSize +balena.models.os.getDownloadSize(deviceType, [version]) ⇒ Promise + +**Note!** Currently only the raw (uncompressed) size is reported. + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get OS download size estimate +**Access**: public +**Fulfil**: Number - OS image download size, in bytes. + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
[version]String

semver-compatible version or 'latest', defaults to 'latest'. +The version must be the exact version number.

+
+ +**Example** +```js +balena.models.os.getDownloadSize('raspberry-pi').then(function(size) { + console.log('The OS download size for raspberry-pi', size); +}); +``` + +* * * + +## getMaxSatisfyingVersion +balena.models.os.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get the max OS version satisfying the given range +**Access**: public +**Fulfil**: String\|null - the version number, or `null` if no matching versions are found + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
versionOrRangeString

can be one of

+
    +
  • the exact version number, +in which case it is returned if the version is supported, +or null is returned otherwise,
  • +
  • a semver-compatible +range specification, in which case the most recent satisfying version is returned +if it exists, or null is returned,
  • +
  • 'latest' in which case the most recent version is returned, excluding pre-releases, +Defaults to 'latest'.
  • +
+
[osType]String

can be one of 'default', 'esr' or null to include all types

+
+ +**Example** +```js +balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) { + console.log(version); +}); +``` + +* * * + +## getOsUpdateType +balena.models.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 + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
targetVersionString

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); +}); +``` + +* * * + +## getSupervisorReleasesForCpuArchitecture +balena.models.os.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options]) ⇒ Promise.<String> + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns the Releases of the supervisor for the CPU Architecture +**Returns**: Promise.<String> - - An array of Release objects that can be used to manage a device as supervisors. +**Access**: public + + + + + + + + + + + + +
ParamTypeDefaultDescription
cpuArchitectureSlugOrIdString | Number

The slug (string) or id (number) for the CPU Architecture

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64'); + +const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( + 'aarch64', + { $filter: { raw_version: '12.11.0' } }, +); + +const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( + 'aarch64', + { + $select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'], + $expand: { + release_image: { + $select: 'id', + $expand: { + image: { + $select: 'is_stored_at__image_location', + }, + }, + }, + }, + $filter: { raw_version: '12.11.0' } + }, +); +``` + +* * * + +## getSupportedOsUpdateVersions +balena.models.os.getSupportedOsUpdateVersions(deviceType, currentVersion, [options]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns the supported OS update targets for the provided device type +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. +**Fulfil**: Object - the versions information, of the following structure: +* versions - an array of strings, +containing exact version numbers that OS update is supported +* recommended - the recommended version, i.e. the most recent version +that is _not_ pre-release, can be `null` +* current - the provided current version after normalization + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
[options]Object

Extra options to filter the OS releases by

+
[options.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

+
[options.osType]String | null

Can be one of 'default', 'esr' or null which includes all types

+
+ +**Example** +```js +balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) { + console.log(isSupported); +}); +``` + +* * * + +## isArchitectureCompatibleWith +balena.models.os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ Boolean + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns whether the specified OS architecture is compatible with the target architecture +**Returns**: Boolean - - Whether the specified OS architecture is capable of running +applications build for the target architecture +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
osArchitectureString

The OS's architecture as specified in its device type

+
applicationArchitectureString

The application's architecture as specified in its device type

+
+ +**Example** +```js +const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf'); +console.log(result1); + +const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64'); +console.log(result2); +``` + +* * * + +## isSupportedOsUpdate +balena.models.os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions +**Access**: public +**Fulfil**: Boolean - whether upgrading the OS to the target version is supported + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
targetVersionString

semver-compatible version for the target OS version

+
+ +**Example** +```js +balena.models.os.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) { + console.log(isSupported); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/release.md b/pages/external-docs/sdk/node-sdk/latest/models/release.md new file mode 100644 index 0000000000..d4e3a33717 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/release.md @@ -0,0 +1,853 @@ +# release +balena.models.release : object + +**Kind**: static namespace + +* * * + +## createFromUrl +balena.models.release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Create a new release built from the source in the provided url +**Access**: public +**Fulfil**: number - release ID + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
urlDeployOptionsObject

builder options

+
urlDeployOptions.urlString

a url with a tarball of the project to build

+
[urlDeployOptions.shouldFlatten]Booleantrue

Should be true when the tarball includes an extra root folder with all the content

+
+ +**Example** +```js +balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { + console.log(releaseId); +}); +``` +**Example** +```js +balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { + console.log(releaseId); +}); +``` + +* * * + +## finalize +balena.models.release.finalize(commitOrIdOrRawVersion) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Finalizes a draft release +**Access**: public +**Fulfil**: void + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
+ +**Example** +```js +balena.models.release.finalize(123).then(function() { + console.log('finalized!'); +}); +``` +**Example** +```js +balena.models.release.finalize('7cf02a69e4d34c9da573914963cf54fd').then(function() { + console.log('finalized!'); +}); +``` +**Example** +```js +balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log('finalized!'); +}); +``` + +* * * + +## get +balena.models.release.get(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get a specific release +**Access**: public +**Fulfil**: Object - release + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.get(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.get('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log(release); +}); +``` + +* * * + +## getAllByApplication +balena.models.release.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get all releases from an application +**Access**: public +**Fulfil**: Object[] - releases + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) { + console.log(releases); +}); +``` +**Example** +```js +balena.models.release.getAllByApplication(123).then(function(releases) { + console.log(releases); +}); +``` + +* * * + +## getLatestByApplication +balena.models.release.getLatestByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get the latest successful release for an application +**Access**: public +**Fulfil**: Object\|undefined - release + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) { + console.log(releases); +}); +``` +**Example** +```js +balena.models.release.getLatestByApplication(123).then(function(releases) { + console.log(releases); +}); +``` + +* * * + +## getWithImageDetails +balena.models.release.getWithImageDetails(commitOrIdOrRawVersion, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want significantly more control, or to see the +raw model directly, use `release.get(id, options)` instead. + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get a specific release with the details of the images built +**Access**: public +**Fulfil**: Object - release with image details + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

a map of extra pine options

+
[options.release]Boolean{}

extra pine options for releases

+
[options.image]Object{}

extra pine options for images

+
+ +**Example** +```js +balena.models.release.getWithImageDetails(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } }) +.then(function(release) { + console.log(release.images[0].build_log); +}); +``` + +* * * + +## setIsInvalidated +balena.models.release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Set the is_invalidated property of a release to true or false +**Access**: public +**Fulfil**: void + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
isInvalidatedBoolean

boolean value, true for invalidated, false for validated

+
+ +**Example** +```js +balena.models.release.setIsInvalidated(123, true).then(function() { + console.log('invalidated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', true).then(function() { + console.log('invalidated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log('invalidated!); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated(123, false).then(function() { + console.log('validated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', false).then(function() { + console.log('validated!'); +}); +``` + +* * * + +## setKnownIssueList +balena.models.release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Add a known issue list to a release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
knownIssueListOrNullString | null

the known issue list

+
+ +**Example** +```js +balena.models.release.setKnownIssueList('7cf02a69e4d34c9da573914963cf54fd', 'This is an issue'); +``` +**Example** +```js +balena.models.release.setKnownIssueList(123, 'This is an issue'); +``` +**Example** +```js +balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue'); +``` + +* * * + +## setNote +balena.models.release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Add a note to a release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
noteOrNullString | null

the note

+
+ +**Example** +```js +balena.models.release.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); +``` +**Example** +```js +balena.models.release.setNote(123, 'My useful note'); +``` +**Example** +```js +balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note'); +``` + +* * * + +## asset +balena.models.release.asset : object + +**Kind**: static namespace of [release](#balena.models.release) + +* * * + +### download +balena.models.release.asset.download(id) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Download a release asset +**Access**: public +**Fulfil**: NodeJS.ReadableStream - download stream + + + + + + + + + + +
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
+ +**Example** +```js +balena.models.release.asset.download(123).then(function(stream) { + stream.pipe(fs.createWriteStream('logo.png')); +}); +``` +**Example** +```js +balena.models.release.asset.download({ + asset_key: 'logo.png', + release: 123 +}).then(function(stream) { + stream.pipe(fs.createWriteStream('logo.png')); +}); +``` + +* * * + +### get +balena.models.release.asset.get(id, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Get a specific release asset +**Access**: public +**Fulfil**: Object - release asset + + + + + + + + + + + + +
ParamTypeDefaultDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.asset.get(123).then(function(asset) { + console.log(asset); +}); +``` +**Example** +```js +balena.models.release.asset.get({ + asset_key: 'logo.png', + release: 123 +}).then(function(asset) { + console.log(asset); +}); +``` + +* * * + +### getAllByRelease +balena.models.release.asset.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Get all release assets for a release +**Access**: public +**Fulfil**: Object[] - release assets + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.asset.getAllByRelease(123).then(function(assets) { + console.log(assets); +}); +``` +**Example** +```js +balena.models.release.asset.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(assets) { + console.log(assets); +}); +``` +**Example** +```js +balena.models.release.asset.getAllByRelease({ application: 456, raw_version: '1.2.3' }).then(function(assets) { + console.log(assets); +}); +``` + +* * * + +### remove +balena.models.release.asset.remove(id) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Remove a release asset +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
+ +**Example** +```js +balena.models.release.asset.remove(123); +``` +**Example** +```js +balena.models.release.asset.remove({ + asset_key: 'logo.png', + release: 123 +}); +``` + +* * * + +### upload +balena.models.release.asset.upload(uploadParams, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Upload a release asset +**Access**: public +**Fulfil**: Object - uploaded release asset + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uploadParamsObject

upload parameters

+
uploadParams.assetString | File

asset file path (string, Node.js only) or File object (Node.js & browser). For File objects, use new File([content], filename, {type: mimeType})

+
uploadParams.asset_keyString

unique key for the asset within the release

+
uploadParams.releaseNumber

release ID

+
[options]Object{}

upload options

+
[options.chunkSize]Number5242880

chunk size for multipart uploads (5MiB default)

+
[options.parallelUploads]Number5

number of parallel uploads for multipart

+
[options.overwrite]Booleanfalse

whether to overwrite existing asset

+
[options.onUploadProgress]function

callback for upload progress

+
+ +**Example** +```js +// Upload from file path (Node.js) +balena.models.release.asset.upload({ + asset: '/path/to/logo.png', + asset_key: 'logo.png', + release: 123 +}).then(function(asset) { + console.log('Asset uploaded:', asset); +}); +``` +**Example** +```js +// Upload with File API (Node.js and browser) +const content = Buffer.from('Hello, World!', 'utf-8'); +const file = new File([content], 'readme.txt', { type: 'text/plain' }); + +balena.models.release.asset.upload({ + asset: file, + asset_key: 'readme.txt', + release: 123 +}).then(function(asset) { + console.log('Asset uploaded:', asset); +}); +``` +**Example** +```js +// Upload large file with File API and progress tracking +const largeContent = new Uint8Array(10 * 1024 * 1024); // 10MB +const largeFile = new File([largeContent], 'data.bin', { type: 'application/octet-stream' }); + +balena.models.release.asset.upload({ + asset: largeFile, + asset_key: 'data.bin', + release: 123 +}, { + chunkSize: 5 * 1024 * 1024, // 5MB chunks + parallelUploads: 3, + onUploadProgress: function(progress) { + const percent = (progress.uploaded / progress.total * 100).toFixed(2); + console.log(`Upload progress: ${percent}%`); + } +}).then(function(asset) { + console.log('Large file uploaded:', asset); +}); +``` +**Example** +```js +// Browser: Upload file from input element +const fileInput = document.getElementById('fileInput'); +const file = fileInput.files[0]; // File object from input + +balena.models.release.asset.upload({ + asset: file, + asset_key: file.name, + release: 123 +}).then(function(asset) { + console.log('File uploaded from browser:', asset); +}); +``` +**Example** +```js +// Upload with overwrite option +balena.models.release.asset.upload({ + asset: '/path/to/logo.png', + asset_key: 'logo.png', + release: 123 +}, { + overwrite: true +}).then(function(asset) { + console.log('Asset uploaded/updated:', asset); +}); +``` + +* * * + +## tags +balena.models.release.tags : object + +**Kind**: static namespace of [release](#balena.models.release) + +* * * + +### getAllByApplication +balena.models.release.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Get all release tags for an application +**Access**: public +**Fulfil**: Object[] - release tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### getAllByRelease +balena.models.release.tags.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Get all release tags for a release +**Access**: public +**Fulfil**: Object[] - release tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.tags.getAllByRelease(123).then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.release.tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Remove a release tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.release.tags.remove(123, 'EDITOR'); +``` +**Example** +```js +balena.models.release.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); +``` +**Example** +```js +balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR'); +``` + +* * * + +### set +balena.models.release.tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Set a release tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.release.tags.set(123, 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.release.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/service.md b/pages/external-docs/sdk/node-sdk/latest/models/service.md new file mode 100644 index 0000000000..03d4f527e3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/service.md @@ -0,0 +1,243 @@ +# service +balena.models.service : object + +**Kind**: static namespace + +* * * + +## getAllByApplication +balena.models.service.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [service](#balena.models.service) +**Summary**: Get all services from an application +**Access**: public +**Fulfil**: Object[] - services + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) { + console.log(services); +}); +``` +**Example** +```js +balena.models.service.getAllByApplication(123).then(function(services) { + console.log(services); +}); +``` + +* * * + +## var +balena.models.service.var : object + +**Kind**: static namespace of [service](#balena.models.service) + +* * * + +### get +balena.models.service.var.get(serviceIdOrNaturalKey, key) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get the value of a specific service variable +**Access**: public +**Fulfil**: String\|undefined - the variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
+ +**Example** +```js +balena.models.service.var.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.service.var.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get all service variables by application +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.service.var.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByService +balena.models.service.var.getAllByService(serviceIdOrNaturalKey, [options]) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get all variables for a service +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.var.getAllByService(999999).then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.service.var.remove(serviceIdOrNaturalKey, key) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Clear the value of a specific service variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
+ +**Example** +```js +balena.models.service.var.remove(999999, 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.service.var.set(serviceIdOrNaturalKey, key, value) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Set the value of a specific service variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
valueString

variable value

+
+ +**Example** +```js +balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/models/team.md b/pages/external-docs/sdk/node-sdk/latest/models/team.md new file mode 100644 index 0000000000..882fd8c89b --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/models/team.md @@ -0,0 +1,313 @@ +# team +balena.models.team : object + +**Kind**: static namespace + +* * * + +## create +balena.models.team.create(organizationSlugOrId, name) ⇒ Promise + +This method creates a new team. + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Creates a new Team +**Access**: public +**Fulfil**: Object - Team + + + + + + + + + + + + +
ParamTypeDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team will be part of.

+
nameString

Required: the name of the team that will be created.

+
+ +**Example** +```js +balena.models.team.create(1239948, 'MyTeam').then(function(team) { + console.log(team); +}); +``` +**Example** +```js +balena.models.team.create('myOrgHandle', 'MyTeam') +.then(function(team) { + console.log(team); +}); +``` + +* * * + +## get +balena.models.team.get(teamId, [options]) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Get a single Team +**Access**: public +**Fulfil**: Object - Team + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamIdNumber

team id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.get(123).then(function(team) { + console.log(team); +}); +``` + +* * * + +## getAllByOrganization +balena.models.team.getAllByOrganization(organizationSlugOrId, [options]) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Get all Teams of a specific Organization +**Access**: public +**Fulfil**: Object[] - Teams + + + + + + + + + + + + +
ParamTypeDefaultDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team is part of.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.getAllByOrganization(123).then(function(teams) { + console.log(teams); +}); +``` +**Example** +```js +balena.models.team.getAllByOrganization('MyOrganizationHandle').then(function(teams) { + console.log(teams); +}); +``` + +* * * + +## remove +balena.models.team.remove(teamId) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Remove a Team +**Access**: public + + + + + + + + + + +
ParamTypeDescription
teamIdNumber

team id (number).

+
+ +**Example** +```js +balena.models.team.remove(123); +``` + +* * * + +## rename +balena.models.team.rename(teamId, newName) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Rename Team +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
teamIdNumber

team id (number)

+
newNameString

new team name (string)

+
+ +**Example** +```js +balena.models.team.rename(123, 'MyNewTeamName'); +``` + +* * * + +## applicationAccess +balena.models.team.applicationAccess : object + +**Kind**: static namespace of [team](#balena.models.team) + +* * * + +### get +balena.models.team.applicationAccess.get(teamApplicationAccessId, [options]) ⇒ Promise + +This method get specific team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Get team applications access +**Access**: public +**Fulfil**: Object - TeamApplicationAccess + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.applicationAccess.get(1239948).then(function(teamApplicationAccess) { + console.log(teamApplicationAccess); +}); +``` + +* * * + +### getAllByTeam +balena.models.team.applicationAccess.getAllByTeam(teamId, [options]) ⇒ Promise + +This method get all team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Get all team applications access +**Access**: public +**Fulfil**: Object[] - team application access + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamIdNumber

Required: the team id.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.applicationAccess.getAllByTeam(1239948).then(function(teamApplicationAccesses) { + console.log(teamApplicationAccesses); +}); +``` + +* * * + +### remove +balena.models.team.applicationAccess.remove(teamApplicationAccessId) ⇒ Promise + +This remove a team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Remove team application access +**Access**: public +**Fulfil**: void + + + + + + + + + + +
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
+ +**Example** +```js +balena.models.team.remove(123).then(function(teams) { + console.log(teams); +}); +``` + +* * * + +### update +balena.models.team.applicationAccess.update(teamApplicationAccessId, roleName) ⇒ Promise + +This method update a team application access role. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Update team application access +**Access**: public +**Fulfil**: Object - TeamApplicationAccess + + + + + + + + + + + + +
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
roleNameString

Required: The new role to assing (ApplicationMembershipRoles).

+
+ +**Example** +```js +balena.models.team.update(123, 'developer').then(function(teamApplicationAccess) { + console.log(teamApplicationAccess); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/pine.md b/pages/external-docs/sdk/node-sdk/latest/pine.md new file mode 100644 index 0000000000..edb6c4bdfc --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/pine.md @@ -0,0 +1,25 @@ +# pine +balena.pine : Object + +The pinejs-client instance used internally. This should not be necessary +in normal usage, but can be useful if you want to directly make pine +queries to the api for some resource that isn't directly supported +in the SDK. + +**Kind**: static member +**Summary**: Balena pine instance +**Access**: public +**Example** +```js +balena.pine.get({ + resource: 'release', + options: { + $count: { + $filter: { belongs_to__application: applicationId } + } + } +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/request.md b/pages/external-docs/sdk/node-sdk/latest/request.md new file mode 100644 index 0000000000..0ba55a90d6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/request.md @@ -0,0 +1,17 @@ +# request +balena.request : Object + +The balena-request instance used internally. This should not be necessary +in normal usage, but can be useful if you want to make an API request directly, +using the same token and hooks as the SDK. + +**Kind**: static member +**Summary**: Balena request instance +**Access**: public +**Example** +```js +balena.request.send({ url: 'http://api.balena-cloud.com/ping' }); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/setSharedOptions.md b/pages/external-docs/sdk/node-sdk/latest/setSharedOptions.md new file mode 100644 index 0000000000..f2e444fc97 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/setSharedOptions.md @@ -0,0 +1,68 @@ +# setSharedOptions +module:balena-sdk~setSharedOptions(options) + +Set options that are used by calls to `fromSharedOptions()`. +The options accepted are the same as those used in the main SDK factory function. +If you use this method, it should be called as soon as possible during app +startup and before any calls to `fromSharedOptions()` are made. + +**Kind**: inner function +**Summary**: Set shared default options +**Access**: public + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

The shared default options

+
[options.apiUrl]String'https://api.balena-cloud.com/'

the balena API url to use.

+
[options.builderUrl]String'https://builder.balena-cloud.com/'

the balena builder url to use.

+
[options.deviceUrlsBase]String'balena-devices.com'

the base balena device API url to use.

+
[options.requestLimit]Number

the number of requests per requestLimitInterval that the SDK should respect.

+
[options.requestLimitInterval]Number60000

the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute).

+
[options.retryRateLimitedRequests]Boolean | functionfalse

Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header.

+
    +
  • If false, rate-limited requests will not be retried, and the rate limit error will be propagated.
  • +
  • If true, all rate-limited requests will be retried after the duration specified by the Retry-After header.
  • +
  • If a function (retryAfterMs: number) => boolean is provided, it will be called with the retry duration in ms and the request will be retried only when true is returned.
  • +
+
[options.dataDirectory]String | False'$HOME/.balena'

ignored in the browser unless false, the directory where the user settings are stored, normally retrieved like require('balena-settings-client').get('dataDirectory'). Providing false creates an isolated in-memory instance.

+
[options.isBrowser]Boolean

the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global window value.

+
[options.debug]Boolean

when set will print some extra debug information.

+
+ +**Example** +```js +import { setSharedOptions } from 'balena-sdk'; +setSharedOptions({ + apiUrl: 'https://api.balena-cloud.com/', + builderUrl: 'https://builder.balena-cloud.com/', + isBrowser: true, +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/settings.md b/pages/external-docs/sdk/node-sdk/latest/settings.md new file mode 100644 index 0000000000..1bbc80552d --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/settings.md @@ -0,0 +1,52 @@ +# settings +balena.settings : object + +**Kind**: static namespace + +* * * + +## get +balena.settings.get([key]) ⇒ Promise + +**Kind**: static method of [settings](#balena.settings) +**Summary**: Get a single setting. **Only implemented in Node.js** +**Access**: public +**Fulfil**: \* - setting value + + + + + + + + + + +
ParamTypeDescription
[key]String

setting key

+
+ +**Example** +```js +balena.settings.get('apiUrl').then(function(apiUrl) { + console.log(apiUrl); +}); +``` + +* * * + +## getAll +balena.settings.getAll() ⇒ Promise + +**Kind**: static method of [settings](#balena.settings) +**Summary**: Get all settings **Only implemented in Node.js** +**Access**: public +**Fulfil**: Object - settings +**Example** +```js +balena.settings.getAll().then(function(settings) { + console.log(settings); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/latest/utils.md b/pages/external-docs/sdk/node-sdk/latest/utils.md new file mode 100644 index 0000000000..c8a5d1720c --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/latest/utils.md @@ -0,0 +1,18 @@ +# utils +balena.utils : Object + +The utils instance offers some convenient features for clients. + +**Kind**: static member +**Summary**: Balena utils instance +**Access**: public +**Example** +```js +balena.utils.mergePineOptions( + { $expand: { device: { $select: ['id'] } } }, + { $expand: { device: { $select: ['name'] } } }, +); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1.md b/pages/external-docs/sdk/node-sdk/v20.9.1.md deleted file mode 100644 index eeea029df1..0000000000 --- a/pages/external-docs/sdk/node-sdk/v20.9.1.md +++ /dev/null @@ -1,7145 +0,0 @@ - -## Installation - -Install the balena SDK by running: - -```sh -$ npm install --save balena-sdk -``` - -### Bundling for browsers - -If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. - -If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: - -* fs -* path -* balena-settings-client -* node-localstorage - -### Bundling with pkg - -The balena SDK includes builds for various ECMAScript versions that are -dynamically selected at runtime (using -[@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). -For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not -able to automatically detect which assets to include in the output package. The -following sample `pkg` section should be added to your application's -`package.json` file to instruct `pkg` to bundle the required assets: - -```json - "pkg": { - "scripts": [ - "node_modules/balena-sdk/**/*.js" - ], - "assets": [ - "node_modules/pinejs-client-core/**/*" - ] - } -``` - -For more information, please refer to the respective -[documentation from the `pkg` project](https://github.com/vercel/pkg#config). - -## Trying balenaSDK in the browser - -BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. -To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries. - -![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png) - - -If you feel something is missing, not clear or could be improved, please don't hesitate to open an -[issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help. - - -## Modules - -
-
balena-sdk
-
-
- -## Objects - -
-
balena : object
-
-
- -## Functions - -
-
listImagesFromTargetState(targetState)
-
-
- - - -## balena-sdk - -* [balena-sdk](#module_balena-sdk) - * [~getSdk()](#module_balena-sdk..getSdk) - * [~setSharedOptions(options)](#module_balena-sdk..setSharedOptions) - * [~fromSharedOptions()](#module_balena-sdk..fromSharedOptions) - - - -### balena-sdk~getSdk() -The module exports a single factory function. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Creates a new SDK instance using the default or the provided options. -**Example** -```js -// with es6 imports -import { getSdk } from 'balena-sdk'; -// or with node require -const { getSdk } = require('balena-sdk'); - -const balena = getSdk({ - apiUrl: "https://api.balena-cloud.com/", - dataDirectory: "/opt/local/balena" -}); -``` - - -### balena-sdk~setSharedOptions(options) -Set options that are used by calls to `fromSharedOptions()`. -The options accepted are the same as those used in the main SDK factory function. -If you use this method, it should be called as soon as possible during app -startup and before any calls to `fromSharedOptions()` are made. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Set shared default options -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | The shared default options | -| [options.apiUrl] | String | 'https://api.balena-cloud.com/' | the balena API url to use. | -| [options.builderUrl] | String | 'https://builder.balena-cloud.com/' | the balena builder url to use. | -| [options.deviceUrlsBase] | String | 'balena-devices.com' | the base balena device API url to use. | -| [options.requestLimit] | Number | | the number of requests per requestLimitInterval that the SDK should respect. | -| [options.requestLimitInterval] | Number | 60000 | the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute). | -| [options.retryRateLimitedRequests] | Boolean | false | when enabled the sdk will retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header. | -| [options.dataDirectory] | String \| False | '$HOME/.balena' | *ignored in the browser unless false*, the directory where the user settings are stored, normally retrieved like `require('balena-settings-client').get('dataDirectory')`. Providing `false` creates an isolated in-memory instance. | -| [options.isBrowser] | Boolean | | the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global `window` value. | -| [options.debug] | Boolean | | when set will print some extra debug information. | - -**Example** -```js -import { setSharedOptions } from 'balena-sdk'; -setSharedOptions({ - apiUrl: 'https://api.balena-cloud.com/', - builderUrl: 'https://builder.balena-cloud.com/', - isBrowser: true, -}); -``` - - -### balena-sdk~fromSharedOptions() -Create an SDK instance using shared default options set using the `setSharedOptions()` method. -If options have not been set using this method, then this method will use the -same defaults as the main SDK factory function. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Create an SDK instance using shared default options -**Access**: public -**Example** -```js -import { fromSharedOptions } from 'balena-sdk'; -const sdk = fromSharedOptions(); -``` - - -## balena : object -**Kind**: global namespace - -* [balena](#balena) : object - * [.interceptors](#balena.interceptors) : Array.<Interceptor> - * [.Interceptor](#balena.interceptors.Interceptor) : object - * [.utils](#balena.utils) : Object - * [.request](#balena.request) : Object - * [.pine](#balena.pine) : Object - * [.errors](#balena.errors) : Object - * [.models](#balena.models) : object - * [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * ~~[.generateApiKey(slugOrUuidOrId)](#balena.models.application.generateApiKey) ⇒ Promise~~ - * [.generateProvisioningKey(slugOrUuidOrId, [keyName], [keyDescription], [keyExpiryDate])](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * ~~[.getOsUpdateStatus(uuid)](#balena.models.device.getOsUpdateStatus) ⇒ Promise~~ - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * ~~[.getApplicationInfo(uuidOrId)](#balena.models.device.getApplicationInfo) ⇒ Promise~~ - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * ~~[.startApplication(uuidOrId)](#balena.models.device.startApplication) ⇒ Promise~~ - * ~~[.stopApplication(uuidOrId)](#balena.models.device.stopApplication) ⇒ Promise~~ - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.apiKey](#balena.models.apiKey) : object - * [.create(name, [description])](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * ~~[.create(options)](#balena.models.organization.membership.create) ⇒ Promise~~ - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.getLastModified(deviceType, [version])](#balena.models.os.getLastModified) ⇒ Promise - * [.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> - * [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - * [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - * [.auth](#balena.auth) : object - * [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.whoami()](#balena.auth.whoami) ⇒ Promise - * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ Promise - * [.login(credentials)](#balena.auth.login) ⇒ Promise - * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ Promise - * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ Promise - * [.getToken()](#balena.auth.getToken) ⇒ Promise - * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ Promise - * [.getActorId()](#balena.auth.getActorId) ⇒ Promise - * [.logout()](#balena.auth.logout) ⇒ Promise - * [.register(credentials)](#balena.auth.register) ⇒ Promise - * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ Promise - * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ Promise - * [.logs](#balena.logs) : object - * [.subscribe(uuidOrId, [options])](#balena.logs.subscribe) ⇒ Promise.<LogSubscription> - * [.history(uuidOrId, [options])](#balena.logs.history) ⇒ Promise - * [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - * [.settings](#balena.settings) : object - * [.get([key])](#balena.settings.get) ⇒ Promise - * [.getAll()](#balena.settings.getAll) ⇒ Promise - * [.utils](#balena.utils) : object - - - -### balena.interceptors : Array.<Interceptor> -The current array of interceptors to use. Interceptors intercept requests made -internally and are executed in the order they appear in this array for requests, -and in the reverse order for responses. - -**Kind**: static property of [balena](#balena) -**Summary**: Array of interceptors -**Access**: public -**Example** -```js -balena.interceptors.push({ - responseError: function (error) { - console.log(error); - throw error; - }) -}); -``` - - -#### interceptors.Interceptor : object -An interceptor implements some set of the four interception hook callbacks. -To continue processing, each function should return a value or a promise that -successfully resolves to a value. - -To halt processing, each function should throw an error or return a promise that -rejects with an error. - -**Kind**: static typedef of [interceptors](#balena.interceptors) -**Properties** - -| Name | Type | Description | -| --- | --- | --- | -| [request] | function | Callback invoked before requests are made. Called with the request options, should return (or resolve to) new request options, or throw/reject. | -| [response] | function | Callback invoked before responses are returned. Called with the response, should return (or resolve to) a new response, or throw/reject. | -| [requestError] | function | Callback invoked if an error happens before a request. Called with the error itself, caused by a preceeding request interceptor rejecting/throwing an error for the request, or a failing in preflight token validation. Should return (or resolve to) new request options, or throw/reject. | -| [responseError] | function | Callback invoked if an error happens in the response. Called with the error itself, caused by a preceeding response interceptor rejecting/throwing an error for the request, a network error, or an error response from the server. Should return (or resolve to) a new response, or throw/reject. | - - - -### balena.utils : Object -The utils instance offers some convenient features for clients. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena utils instance -**Access**: public -**Example** -```js -balena.utils.mergePineOptions( - { $expand: { device: { $select: ['id'] } } }, - { $expand: { device: { $select: ['name'] } } }, -); -``` -**Example** -```js -// Creating a new WebResourceFile in case 'File' API is not available. -new balena.utils.BalenaWebResourceFile( - [fs.readFileSync('./file.tgz')], - 'file.tgz' -); -``` - - -### balena.request : Object -The balena-request instance used internally. This should not be necessary -in normal usage, but can be useful if you want to make an API request directly, -using the same token and hooks as the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena request instance -**Access**: public -**Example** -```js -balena.request.send({ url: 'http://api.balena-cloud.com/ping' }); -``` - - -### balena.pine : Object -The pinejs-client instance used internally. This should not be necessary -in normal usage, but can be useful if you want to directly make pine -queries to the api for some resource that isn't directly supported -in the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena pine instance -**Access**: public -**Example** -```js -balena.pine.get({ - resource: 'release', - options: { - $count: { - $filter: { belongs_to__application: applicationId } - } - } -}); -``` - - -### balena.errors : Object -The balena-errors module used internally. This is provided primarily for -convenience, and to avoid the necessity for separate balena-errors -dependencies. You'll want to use this if you need to match on the specific -type of error thrown by the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena errors module -**Access**: public -**Example** -```js -balena.models.device.get(123).catch(function (error) { - if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) { - ... - } else if (error.code === balena.errors.BalenaRequestError.prototype.code) { - ... - } -}); -``` - - -### balena.models : object -**Kind**: static namespace of [balena](#balena) - -* [.models](#balena.models) : object - * [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * ~~[.generateApiKey(slugOrUuidOrId)](#balena.models.application.generateApiKey) ⇒ Promise~~ - * [.generateProvisioningKey(slugOrUuidOrId, [keyName], [keyDescription], [keyExpiryDate])](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * ~~[.getOsUpdateStatus(uuid)](#balena.models.device.getOsUpdateStatus) ⇒ Promise~~ - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * ~~[.getApplicationInfo(uuidOrId)](#balena.models.device.getApplicationInfo) ⇒ Promise~~ - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * ~~[.startApplication(uuidOrId)](#balena.models.device.startApplication) ⇒ Promise~~ - * ~~[.stopApplication(uuidOrId)](#balena.models.device.stopApplication) ⇒ Promise~~ - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.apiKey](#balena.models.apiKey) : object - * [.create(name, [description])](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * ~~[.create(options)](#balena.models.organization.membership.create) ⇒ Promise~~ - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.getLastModified(deviceType, [version])](#balena.models.os.getLastModified) ⇒ Promise - * [.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> - * [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - * [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - - - -#### models.application : object -**Kind**: static namespace of [models](#balena.models) - -* [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * ~~[.generateApiKey(slugOrUuidOrId)](#balena.models.application.generateApiKey) ⇒ Promise~~ - * [.generateProvisioningKey(slugOrUuidOrId, [keyName], [keyDescription], [keyExpiryDate])](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - - - -##### application.tags : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Get all application tags for an application -**Access**: public -**Fulfil**: Object[] - application tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.application.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(slugOrUuidOrId, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Set an application tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.application.tags.set(123, 'EDITOR', 'vim'); -``` - - -###### tags.remove(slugOrUuidOrId, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Remove an application tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| tagKey | String | tag key | - -**Example** -```js -balena.models.application.tags.remove('myorganization/myapp', 'EDITOR'); -``` - - -##### application.configVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - - - -###### configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Get all config variables for an application -**Access**: public -**Fulfil**: Object[] - application config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.configVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Get the value of a specific config variable -**Access**: public -**Fulfil**: String\|undefined - the config variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` - - -###### configVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Set the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | -| value | String | config variable value | - -**Example** -```js -balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### configVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Clear the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() { - ... -}); -``` - - -##### application.envVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - - - -###### envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Get all environment variables for an application -**Access**: public -**Fulfil**: Object[] - application environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.envVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Get the value of a specific environment variable -**Access**: public -**Fulfil**: String\|undefined - the environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.envVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### envVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Set the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | -| value | String | environment variable value | - -**Example** -```js -balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### envVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Clear the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.envVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### application.buildVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - - - -###### buildVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Get all build environment variables for an application -**Access**: public -**Fulfil**: Object[] - application build environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### buildVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Get the value of a specific build environment variable -**Access**: public -**Fulfil**: String\|undefined - the build environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | - -**Example** -```js -balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.buildVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### buildVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Set the value of a specific build environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | -| value | String | build environment variable value | - -**Example** -```js -balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### buildVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Clear the value of a specific build environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | - -**Example** -```js -balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.buildVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### application.membership : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - - - -###### membership.get(membershipId, [options]) ⇒ Promise -This method returns a single application membership. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get a single application membership -**Access**: public -**Fulfil**: Object - application membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| membershipId | number \| Object | | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.get(5).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all application memberships for a specific application. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get all memberships by application -**Access**: public -**Fulfil**: Object[] - application memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.application.membership.getAllByApplication(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByUser(usernameOrId, [options]) ⇒ Promise -This method returns all application memberships for a specific user. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get all memberships by user -**Access**: public -**Fulfil**: Object[] - application memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| usernameOrId | String \| Number | | the user's username (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.application.membership.getAllByUser(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.create(options) ⇒ Promise -This method adds a user to an application by their username. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Creates a new membership for an application -**Access**: public -**Fulfil**: Object - application membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | membership creation parameters | -| options.application | String \| Number | | application handle (string), or id (number) | -| options.username | String | | the username of the balena user that will become a member | -| [options.roleName] | String | "member" | the role name to be granted to the membership | - -**Example** -```js -balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { - console.log(membership); -}); -``` - - -###### membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise -This method changes the role of an application member. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Changes the role of an application member -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be changed | -| roleName | String | the role name to be granted to the membership | - -**Example** -```js -balena.models.application.membership.changeRole(123, "member").then(function() { - console.log('OK'); -}); -``` -**Example** -```js -balena.models.application.membership.changeRole({ - user: 123, - is_member_of__application: 125, -}, "member").then(function() { - console.log('OK'); -}); -``` - - -###### membership.remove(idOrUniqueKey) ⇒ Promise -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Remove a membership -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be removed | - -**Example** -```js -balena.models.application.membership.remove(123); -``` -**Example** -```js -balena.models.application.membership.remove({ - user: 123, - is_member_of__application: 125, -}); -``` - - -##### application.invite : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - - - -###### invite.getAll([options]) ⇒ Promise -This method returns all invites. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Get all invites -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.invite.getAll().then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all invites for a specific application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Get all invites by application -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) { - console.log(invites); -}); -``` -**Example** -```js -balena.models.application.invite.getAllByApplication(123).then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.create(slugOrUuidOrId, options, [message]) ⇒ Promise -This method invites a user by their email to an application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Creates a new invite for an application -**Access**: public -**Fulfil**: String - application invite - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| options | Object | | invite creation parameters | -| options.invitee | String | | the email of the invitee | -| [options.roleName] | String | "developer" | the role name to be granted to the invitee | -| [message] | String | | the message to send along with the invite | - -**Example** -```js -balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) { - console.log(invite); -}); -``` - - -###### invite.revoke(id) ⇒ Promise -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Revoke an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | application invite id | - -**Example** -```js -balena.models.application.invite.revoke(123); -``` - - -###### invite.accept(invitationToken) ⇒ Promise -This method adds the calling user to the application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Accepts an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| invitationToken | String | invite token | - -**Example** -```js -balena.models.application.invite.accept("qwerty-invitation-token"); -``` - - -##### application.getDashboardUrl(id) ⇒ String -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get Dashboard URL for a specific application -**Returns**: String - - Dashboard URL for the specific application -**Throws**: - -- Exception if the id is not a finite number - - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | Application id | - -**Example** -```js -balena.models.application.get('myorganization/myapp').then(function(application) { - const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); - console.log(dashboardApplicationUrl); -}); -``` - - -##### application.getAll([options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.getAll().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.getAllDirectlyAccessible([options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications directly accessible by the user -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getAllDirectlyAccessible().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.getAllByOrganization(orgHandleOrId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications of an organization -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| orgHandleOrId | Number \| String | | organization handle (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getAllByOrganization().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.get(slugOrUuidOrId, [options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.get('myorganization/myapp').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.get(123).then(function(application) { - console.log(application); -}); -``` - - -##### application.getDirectlyAccessible(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application directly accessible by the user -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.getDirectlyAccessible(123).then(function(application) { - console.log(application); -}); -``` - - -##### application.getWithDeviceServiceDetails(slugOrUuidOrId, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want more control, or to see the raw model -directly, use `application.get(uuidOrId, options)` instead. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application and its devices, along with each device's -associated services' essential details -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.application.getWithDeviceServiceDetails(123).then(function(device) { - console.log(device); -}) -``` - - -##### application.getAppByName(appName, [options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application using the appname and the handle of the owning organization -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appName | String | | application name | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.getAppByName('MyApp').then(function(application) { - console.log(application); -}); -``` - - -##### application.has(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Check if an application exists -**Access**: public -**Fulfil**: Boolean - has application - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.has('myorganization/myapp').then(function(hasApp) { - console.log(hasApp); -}); -``` -**Example** -```js -balena.models.application.has(123).then(function(hasApp) { - console.log(hasApp); -}); -``` - - -##### application.hasAny() ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Check if the user has access to any applications -**Access**: public -**Fulfil**: Boolean - has any applications -**Example** -```js -balena.models.application.hasAny().then(function(hasAny) { - console.log('Has any?', hasAny); -}); -``` - - -##### application.create(options) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Create an application -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Description | -| --- | --- | --- | -| options | Object | application creation parameters | -| options.name | String | application name | -| [options.uuid] | String | application uuid | -| [options.applicationClass] | String | application class: 'app' | 'fleet' | 'block' | -| options.deviceType | String | device type slug | -| options.organization | String \| Number | handle (string) or id (number) of the organization that the application will belong to or null | - -**Example** -```js -balena.models.application.create({ name: 'My App', deviceType: 'raspberry-pi' }).then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.create({ name: 'My Block', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.create({ name: 'My App', deviceType: 'raspberry-pi', parent: 'ParentApp' }).then(function(application) { - console.log(application); -}); -``` - - -##### application.remove(slugOrUuidOrIdOrIds) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Remove application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrIdOrIds | String \| Number \| Array.<Number> | application slug (string), uuid (string) or id (number) or array of ids | - -**Example** -```js -balena.models.application.remove('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.remove(123); -``` - - -##### application.rename(slugOrUuidOrId, newName) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Rename application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| newName | String | new application name (string) | - -**Example** -```js -balena.models.application.rename('myorganization/myapp', 'MyRenamedApp'); -``` -**Example** -```js -balena.models.application.rename(123, 'MyRenamedApp'); -``` - - -##### application.restart(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Restart application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.restart('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.restart(123); -``` - - -##### ~~application.generateApiKey(slugOrUuidOrId) ⇒ Promise~~ -***Deprecated*** - -Generally you shouldn't use this method: if you're provisioning a recent BalenaOS -version (2.4.0+) then generateProvisioningKey should work just as well, but -be more secure. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Generate an API key for a specific application -**Access**: public -**Fulfil**: String - api key - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.generateApiKey('myorganization/myapp').then(function(apiKey) { - console.log(apiKey); -}); -``` -**Example** -```js -balena.models.application.generateApiKey(123).then(function(apiKey) { - console.log(apiKey); -}); -``` - - -##### application.generateProvisioningKey(slugOrUuidOrId, [keyName], [keyDescription], [keyExpiryDate]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Generate a device provisioning key for a specific application -**Access**: public -**Fulfil**: String - device provisioning key - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| [keyName] | String | Provisioning key name | -| [keyDescription] | String | Description for provisioning key | -| [keyExpiryDate] | String | Expiry Date for provisioning key | - -**Example** -```js -balena.models.application.generateProvisioningKey('myorganization/myapp').then(function(key) { - console.log(key); -}); -``` -**Example** -```js -balena.models.application.generateProvisioningKey(123).then(function(key) { - console.log(key); -}); -``` -**Example** -```js -balena.models.application.generateProvisioningKey(123, 'api key name', 'api key long description', '2030-01-01T00:00:00Z').then(function(key) { - console.log(key); -}); -``` - - -##### application.purge(appId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Purge devices by application id -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| appId | Number | application id | - -**Example** -```js -balena.models.application.purge(123); -``` - - -##### application.shutdown(appId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Shutdown devices by application id -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appId | Number | | application id | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.application.shutdown(123); -``` - - -##### application.reboot(appId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Reboot devices by application id -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appId | Number | | application id | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.application.reboot(123); -``` - - -##### application.willTrackNewReleases(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get whether the application is configured to receive updates whenever a new release is available -**Access**: public -**Fulfil**: Boolean - is tracking the latest release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) { - console.log(isEnabled); -}); -``` -**Example** -```js -balena.models.application.willTrackNewReleases(123).then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates -**Access**: public -**Fulfil**: Boolean - is tracking the latest release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) { - console.log(isEnabled); -}); -``` -**Example** -```js -balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ Promise -Configures the application to run a particular release -and not get updated when the latest release changes. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Set a specific application to run a particular release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| fullReleaseHash | String | the hash of a successful release (string) | - -**Example** -```js -balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` - - -##### application.getTargetReleaseHash(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get the hash of the current release for a specific application -**Access**: public -**Fulfil**: String\|undefined - The release hash of the current release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.application.getTargetReleaseHash(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) { - console.log(release); -}); -``` - - -##### application.trackLatestRelease(slugOrUuidOrId) ⇒ Promise -The application's current release will be updated with each new successfully built release. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Configure a specific application to track the latest finalized available release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.trackLatestRelease('myorganization/myapp').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.trackLatestRelease(123).then(function() { - ... -}); -``` - - -##### application.enableDeviceUrls(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Enable device urls for all devices that belong to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.enableDeviceUrls('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.enableDeviceUrls(123); -``` - - -##### application.disableDeviceUrls(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Disable device urls for all devices that belong to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.disableDeviceUrls('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.disableDeviceUrls(123); -``` - - -##### application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Grant support access to an application until a specified time -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| expiryTimestamp | Number | a timestamp in ms for when the support access will expire | - -**Example** -```js -balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000); -``` -**Example** -```js -balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000); -``` - - -##### application.revokeSupportAccess(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Revoke support access to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.revokeSupportAccess('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.revokeSupportAccess(123); -``` - - -#### models.device : object -**Kind**: static namespace of [models](#balena.models) - -* [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * ~~[.getOsUpdateStatus(uuid)](#balena.models.device.getOsUpdateStatus) ⇒ Promise~~ - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * ~~[.getApplicationInfo(uuidOrId)](#balena.models.device.getApplicationInfo) ⇒ Promise~~ - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * ~~[.startApplication(uuidOrId)](#balena.models.device.startApplication) ⇒ Promise~~ - * ~~[.stopApplication(uuidOrId)](#balena.models.device.stopApplication) ⇒ Promise~~ - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - - - -##### device.tags : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Get all device tags for an application -**Access**: public -**Fulfil**: Object[] - device tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.device.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Get all device tags for a device -**Access**: public -**Fulfil**: Object[] - device tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.tags.getAllByDevice('7cf02a6').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.device.tags.getAllByDevice(123).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(uuidOrId, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Set a device tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.device.tags.set('7cf02a6', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.device.tags.set(123, 'EDITOR', 'vim'); -``` - - -###### tags.remove(uuidOrId, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Remove a device tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| tagKey | String | tag key | - -**Example** -```js -balena.models.device.tags.remove('7cf02a6', 'EDITOR'); -``` - - -##### device.configVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - - - -###### configVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get all config variables for a device -**Access**: public -**Fulfil**: Object[] - device config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.configVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.configVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get all device config variables by application -**Access**: public -**Fulfil**: Object[] - device config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.configVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.get(uuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get the value of a specific config variable -**Access**: public -**Fulfil**: String\|undefined - the config variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.device.configVar.get('7cf02a6', 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` - - -###### configVar.set(uuidOrId, key, value) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Set the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | -| value | String | config variable value | - -**Example** -```js -balena.models.device.configVar.set('7cf02a6', 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### configVar.remove(uuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Clear the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.device.configVar.remove('7cf02a6', 'BALENA_VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() { - ... -}); -``` - - -##### device.envVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - - - -###### envVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get all environment variables for a device -**Access**: public -**Fulfil**: Object[] - device environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.envVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.envVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get all device environment variables by application -**Access**: public -**Fulfil**: Object[] - device environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.envVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.get(uuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get the value of a specific environment variable -**Access**: public -**Fulfil**: String\|undefined - the environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.device.envVar.get('7cf02a6', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.envVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### envVar.set(uuidOrId, key, value) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Set the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | -| value | String | environment variable value | - -**Example** -```js -balena.models.device.envVar.set('7cf02a6', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### envVar.remove(uuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Clear the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.device.envVar.remove('7cf02a6', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.envVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### device.serviceVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - - - -###### serviceVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get all service variable overrides for a device -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.serviceVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### serviceVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get all device service variable overrides by application -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get the overriden value of a service variable on a device -**Access**: public -**Fulfil**: String\|undefined - the variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | - -**Example** -```js -balena.models.device.serviceVar.get('7cf02a6', 123, 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.serviceVar.get('7cf02a6', 'myservice', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Set the overriden value of a service variable on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | -| value | String | variable value | - -**Example** -```js -balena.models.device.serviceVar.set('7cf02a6', 123, 'VAR', 'override').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.set('7cf02a6', 'myservice', 'VAR', 'override').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() { - ... -}); -``` - - -###### serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Clear the overridden value of a service variable on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | - -**Example** -```js -balena.models.device.serviceVar.remove('7cf02a6', 123, 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.remove('7cf02a6', 'myservice', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() { - ... -}); -``` - - -##### device.history : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - - - -###### history.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [history](#balena.models.device.history) -**Summary**: Get all history entries for a device -**Access**: public -**Fulfil**: Object[] - device history - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (32 / 62 digits string) or id (number) | -| [options] | Object | | options | -| [options.fromDate] | Date | subDays(new Date(), 7) | history entries older or equal to this date - default now() - 7 days | -| [options.toDate] | Date | | history entries younger or equal to this date | - -**Example** -```js -balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -balena.models.device.history.getAllByDevice(999999).then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) -``` - - -###### history.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [history](#balena.models.device.history) -**Summary**: Get all device history entries by application with time frame -**Access**: public -**Fulfil**: Object[] - device history - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | | options | -| [options.fromDate] | Date | subDays(new Date(), 7) | history entries older or equal to this date - default now() - 7 days | -| [options.toDate] | Date | | history entries younger or equal to this date | - -**Example** -```js -balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -balena.models.device.history.getAllByApplication(999999).then(function(entries) { - console.log(entries); -}); - - -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) -``` - - -##### device.getDashboardUrl(uuid) ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get Dashboard URL for a specific device -**Returns**: String - - Dashboard URL for the specific device -**Throws**: - -- Exception if the uuid is empty - - -| Param | Type | Description | -| --- | --- | --- | -| uuid | String | Device uuid | - -**Example** -```js -dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8') -``` - - -##### device.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all devices of a specific application. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get all devices by application -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByApplication(123).then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all devices of a specific application. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get all devices by organization -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getAllByOrganization('myorganization').then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByOrganization(123).then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.get(uuidOrId, [options]) ⇒ Promise -This method returns a single device by id or uuid. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a single device -**Access**: public -**Fulfil**: Object - device - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.get(123).then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.get('7cf02a6', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.getWithServiceDetails(uuidOrId, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want more control, or to see the raw model -directly, use `device.get(uuidOrId, options)` instead. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a single device along with its associated services' details, -including their associated commit -**Access**: public -**Fulfil**: Object - device with service details - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getWithServiceDetails('7cf02a6').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.getWithServiceDetails(123).then(function(device) { - console.log(device); -}) -``` - - -##### device.getByName(name) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get devices by name -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Description | -| --- | --- | --- | -| name | String | device name | - -**Example** -```js -balena.models.device.getByName('MyDevice').then(function(devices) { - console.log(devices); -}); -``` - - -##### device.getName(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the name of a device -**Access**: public -**Fulfil**: String - device name - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getName('7cf02a6').then(function(deviceName) { - console.log(deviceName); -}); -``` -**Example** -```js -balena.models.device.getName(123).then(function(deviceName) { - console.log(deviceName); -}); -``` - - -##### device.getApplicationName(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get application name -**Access**: public -**Fulfil**: String - application name - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getApplicationName('7cf02a6').then(function(applicationName) { - console.log(applicationName); -}); -``` -**Example** -```js -balena.models.device.getApplicationName(123).then(function(applicationName) { - console.log(applicationName); -}); -``` - - -##### device.has(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device exists -**Access**: public -**Fulfil**: Boolean - has device - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.has('7cf02a6').then(function(hasDevice) { - console.log(hasDevice); -}); -``` -**Example** -```js -balena.models.device.has(123).then(function(hasDevice) { - console.log(hasDevice); -}); -``` - - -##### device.isOnline(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device is online -**Access**: public -**Fulfil**: Boolean - is device online - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isOnline('7cf02a6').then(function(isOnline) { - console.log('Is device online?', isOnline); -}); -``` -**Example** -```js -balena.models.device.isOnline(123).then(function(isOnline) { - console.log('Is device online?', isOnline); -}); -``` - - -##### device.getLocalIPAddresses(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the local IP addresses of a device -**Access**: public -**Fulfil**: String[] - local ip addresses -**Reject**: Error Will reject if the device is offline - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getLocalIPAddresses('7cf02a6').then(function(localIPAddresses) { - localIPAddresses.forEach(function(localIP) { - console.log(localIP); - }); -}); -``` -**Example** -```js -balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) { - localIPAddresses.forEach(function(localIP) { - console.log(localIP); - }); -}); -``` - - -##### device.getMACAddresses(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the MAC addresses of a device -**Access**: public -**Fulfil**: String[] - mac addresses - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getMACAddresses('7cf02a6').then(function(macAddresses) { - macAddresses.forEach(function(mac) { - console.log(mac); - }); -}); -``` -**Example** -```js -balena.models.device.getMACAddresses(123).then(function(macAddresses) { - macAddresses.forEach(function(mac) { - console.log(mac); - }); -}); -``` - - -##### device.getMetrics(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the metrics related information for a device -**Access**: public -**Fulfil**: Object - device metrics - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getMetrics('7cf02a6').then(function(deviceMetrics) { - console.log(deviceMetrics); -}); -``` -**Example** -```js -balena.models.device.getMetrics(123).then(function(deviceMetrics) { - console.log(deviceMetrics); -}); -``` - - -##### device.remove(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Remove device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.remove('7cf02a6'); -``` -**Example** -```js -balena.models.device.remove(123); -``` - - -##### device.deactivate(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Deactivate device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.deactivate('7cf02a6'); -``` -**Example** -```js -balena.models.device.deactivate(123); -``` - - -##### device.rename(uuidOrId, newName) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Rename device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| newName | String | the device new name | - -**Example** -```js -balena.models.device.rename('7cf02a6', 'NewName'); -``` -**Example** -```js -balena.models.device.rename(123, 'NewName'); -``` - - -##### device.setNote(uuidOrIdOrArray, note) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Note a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| note | String | the note | - -**Example** -```js -balena.models.device.setNote('7cf02a6', 'My useful note'); -``` -**Example** -```js -balena.models.device.setNote(123, 'My useful note'); -``` - - -##### device.setCustomLocation(uuidOrIdOrArray, location) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a custom location for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| location | Object | the location ({ latitude: 123, longitude: 456 }) | - -**Example** -```js -balena.models.device.setCustomLocation('7cf02a6', { latitude: 123, longitude: 456 }); -``` -**Example** -```js -balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 }); -``` - - -##### device.unsetCustomLocation(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Clear the custom location of a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.unsetCustomLocation('7cf02a6'); -``` -**Example** -```js -balena.models.device.unsetCustomLocation(123); -``` - - -##### device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Move a device to another application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| applicationSlugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.device.move('7cf02a6', 'myorganization/myapp'); -``` -**Example** -```js -balena.models.device.move(123, 'myorganization/myapp'); -``` -**Example** -```js -balena.models.device.move(123, 456); -``` - - -##### device.getSupervisorTargetState(uuidOrId, version) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the target supervisor state on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| version | Number | (optional) target state version (2 or 3), default to 2 | - -**Example** -```js -balena.models.device.getSupervisorTargetState('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetState(123).then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetState(123, 3).then(function(state) { - console.log(state); -}); -``` - - -##### device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the target supervisor state on a "generic" device on a fleet -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | fleet uuid (string) or id (number) | -| release | String | (optional) release uuid (default tracked) | - -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a6').then(function(state) { - console.log(state); -}); -``` - - -##### device.generateUniqueKey() ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Generate a random key, useful for both uuid and api key. -**Returns**: String - A generated key -**Access**: public -**Example** -```js -randomKey = balena.models.device.generateUniqueKey(); -// randomKey is a randomly generated key that can be used as either a uuid or an api key -console.log(randomKey); -``` - - -##### device.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Register a new device with a Balena application. -**Access**: public -**Fulfil**: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." }) - -| Param | Type | Description | -| --- | --- | --- | -| applicationSlugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| uuid | String | device uuid | -| [deviceTypeSlug] | String | device type slug (string) or alias (string) | - -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register(123, uuid).then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` - - -##### device.generateDeviceKey(uuidOrId, [keyName], [keyDescription]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Generate a device key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| [keyName] | String | Device key name | -| [keyDescription] | String | Description for device key | - -**Example** -```js -balena.models.device.generateDeviceKey('7cf02a6').then(function(deviceApiKey) { - console.log(deviceApiKey); -}); -``` -**Example** -```js -balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) { - console.log(deviceApiKey); -}); -``` - - -##### device.hasDeviceUrl(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device is web accessible with device utls -**Access**: public -**Fulfil**: Boolean - has device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.hasDeviceUrl('7cf02a6').then(function(hasDeviceUrl) { - if (hasDeviceUrl) { - console.log('The device has device URL enabled'); - } -}); -``` -**Example** -```js -balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) { - if (hasDeviceUrl) { - console.log('The device has device URL enabled'); - } -}); -``` - - -##### device.getDeviceUrl(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a device url -**Access**: public -**Fulfil**: String - device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getDeviceUrl('7cf02a6').then(function(url) { - console.log(url); -}); -``` -**Example** -```js -balena.models.device.getDeviceUrl(123).then(function(url) { - console.log(url); -}); -``` - - -##### device.enableDeviceUrl(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable device url for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.enableDeviceUrl('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableDeviceUrl(123); -``` - - -##### device.disableDeviceUrl(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable device url for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.disableDeviceUrl('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableDeviceUrl(123); -``` - - -##### device.enableLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable local mode -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.enableLocalMode('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableLocalMode(123); -``` - - -##### device.disableLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable local mode -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.disableLocalMode('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableLocalMode(123); -``` - - -##### device.isInLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if local mode is enabled on the device -**Access**: public -**Fulfil**: Boolean - has device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isInLocalMode('7cf02a6').then(function(isInLocalMode) { - if (isInLocalMode) { - console.log('The device has local mode enabled'); - } -}); -``` -**Example** -```js -balena.models.device.isInLocalMode(123).then(function(isInLocalMode) { - if (isInLocalMode) { - console.log('The device has local mode enabled'); - } -}); -``` - - -##### device.getLocalModeSupport(device) ⇒ Object -**Kind**: static method of [device](#balena.models.device) -**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported. -**Returns**: Object - Local mode support info ({ supported: true/false, message: "..." }) -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - balena.models.device.getLocalModeSupport(device); -}) -``` - - -##### device.enableLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable lock override -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.enableLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableLockOverride(123); -``` - - -##### device.disableLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable lock override -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.disableLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableLockOverride(123); -``` - - -##### device.hasLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device has the lock override enabled -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.hasLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.hasLockOverride(123); -``` - - -##### device.getStatus(uuidOrId) ⇒ Promise -Convenience method for getting the overall status of a device. -It's recommended to use `balena.models.device.get()` instead, -in case that you need to retrieve more device fields than just the status. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the status of a device -**Access**: public -**Fulfil**: String - device status -**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field. - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getStatus('7cf02a6').then(function(status) { - console.log(status); -}); -``` -**Example** -```js -balena.models.device.getStatus(123).then(function(status) { - console.log(status); -}); -``` - - -##### device.getProgress(uuidOrId) ⇒ Promise -Convenience method for getting the overall progress of a device. -It's recommended to use `balena.models.device.get()` instead, -in case that you need to retrieve more device fields than just the progress. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the progress of a device -**Access**: public -**Fulfil**: Number\|Null - device progress -**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field. - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getProgress('7cf02a6').then(function(progress) { - console.log(progress); -}); -``` -**Example** -```js -balena.models.device.getProgress(123).then(function(progress) { - console.log(progress); -}); -``` - - -##### device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Grant support access to a device until a specified time -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| expiryTimestamp | Number | a timestamp in ms for when the support access will expire | - -**Example** -```js -balena.models.device.grantSupportAccess('7cf02a6', Date.now() + 3600 * 1000); -``` -**Example** -```js -balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000); -``` - - -##### device.revokeSupportAccess(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Revoke support access to a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.revokeSupportAccess('7cf02a6'); -``` -**Example** -```js -balena.models.device.revokeSupportAccess(123); -``` - - -##### device.lastOnline(device) ⇒ String -If the device has never been online this method returns the string `Connecting...`. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a string showing when a device was last set as online -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - balena.models.device.lastOnline(device); -}) -``` - - -##### device.getOsVersion(device) ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the OS version (version number and variant combined) running on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - console.log(device.os_version); // => 'balenaOS 2.26.0+rev1' - console.log(device.os_variant); // => 'prod' - balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod' -}) -``` - - -##### device.isTrackingApplicationRelease(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get whether the device is configured to track the current application release -**Access**: public -**Fulfil**: Boolean - is tracking the current application release - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isTrackingApplicationRelease('7cf02a6').then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### device.getTargetReleaseHash(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the hash of the currently tracked release for a specific device -**Access**: public -**Fulfil**: String - The release hash of the currently tracked release - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getTargetReleaseHash('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.device.getTargetReleaseHash('7cf02a6', function(release) { - console.log(release); -}); -``` - - -##### device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ Promise -Configures the device to run a particular release -and not get updated when the current application release changes. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a specific device to run a particular release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| fullReleaseHashOrId | String \| Number | the hash of a successful release (string) or id (number) | - -**Example** -```js -balena.models.device.pinToRelease('7cf02a6', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` - - -##### device.trackApplicationRelease(uuidOrIdOrArray) ⇒ Promise -The device's current release will be updated with each new successfully built release. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Configure a specific device to track the current application release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.trackApplicationRelease('7cf02a6').then(function() { - ... -}); -``` - - -##### device.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ Promise -Configures the device to run a particular supervisor release. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a specific device to run a particular supervisor release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| supervisorVersionOrId | String \| Number | the raw version of a supervisor release (string) or id (number) | - -**Example** -```js -balena.models.device.setSupervisorRelease('7cf02a6', '10.8.0').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.setSupervisorRelease(123, '11.4.14').then(function() { - ... -}); -``` - - -##### device.startOsUpdate(uuidOrUuids, targetOsVersion, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start an OS update on a device -**Access**: public -**Fulfil**: Object - action response - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrUuids | String \| Array.<String> | full device uuid or array of full uuids | -| targetOsVersion | String | semver-compatible version for the target device Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number, a "prod" variant and greater than the one running on the device. To resolve the semver-compatible range use `balena.model.os.getMaxSatisfyingVersion`. | -| [options] | Object | options | -| [options.runDetached] | Boolean | run the update in detached mode. Default behaviour is runDetached=false but is DEPRECATED and will be removed in a future release. Use runDetached=true for more reliable updates. | - -**Example** -```js -balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { - console.log(result.status); -}); -``` - - -##### ~~device.getOsUpdateStatus(uuid) ⇒ Promise~~ -***Deprecated*** - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the OS update status of a device. This will no longer return a useful status for runDetached=true updates. -**Access**: public -**Fulfil**: Object - action response - -| Param | Type | Description | -| --- | --- | --- | -| uuid | String | full device uuid | - -**Example** -```js -balena.models.device.getOsUpdateStatus('7cf02a687b74206f92cb455969cf8e98').then(function(status) { - console.log(result.status); -}); -``` - - -##### device.ping(uuidOrId) ⇒ Promise -This is useful to signal that the supervisor is alive and responding. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Ping a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.ping('7cf02a6'); -``` -**Example** -```js -balena.models.device.ping(123); -``` - - -##### ~~device.getApplicationInfo(uuidOrId) ⇒ Promise~~ -***Deprecated*** - -This is not supported on multicontainer devices, and will be removed in a future major release - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get application container information -**Access**: public -**Fulfil**: Object - application info - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getApplicationInfo('7cf02a6').then(function(appInfo) { - console.log(appInfo); -}); -``` -**Example** -```js -balena.models.device.getApplicationInfo(123).then(function(appInfo) { - console.log(appInfo); -}); -``` - - -##### device.identify(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Identify device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.identify('7cf02a6'); -``` -**Example** -```js -balena.models.device.identify(123); -``` - - -##### device.restartApplication(uuidOrId) ⇒ Promise -This function restarts the Docker container running -the application on the device, but doesn't reboot -the device itself. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Restart application on device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.restartApplication('7cf02a6'); -``` -**Example** -```js -balena.models.device.restartApplication(123); -``` - - -##### ~~device.startApplication(uuidOrId) ⇒ Promise~~ -***Deprecated*** - -This is not supported on multicontainer devices, and will be removed in a future major release - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start application on device -**Access**: public -**Fulfil**: String - application container id - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.startApplication('7cf02a6').then(function(containerId) { - console.log(containerId); -}); -``` -**Example** -```js -balena.models.device.startApplication(123).then(function(containerId) { - console.log(containerId); -}); -``` - - -##### ~~device.stopApplication(uuidOrId) ⇒ Promise~~ -***Deprecated*** - -This is not supported on multicontainer devices, and will be removed in a future major release - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Stop application on device -**Access**: public -**Fulfil**: String - application container id - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.stopApplication('7cf02a6').then(function(containerId) { - console.log(containerId); -}); -``` -**Example** -```js -balena.models.device.stopApplication(123).then(function(containerId) { - console.log(containerId); -}); -``` - - -##### device.reboot(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Reboot device -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.reboot('7cf02a6'); -``` -**Example** -```js -balena.models.device.reboot(123); -``` - - -##### device.shutdown(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Shutdown device -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.shutdown('7cf02a6'); -``` -**Example** -```js -balena.models.device.shutdown(123); -``` - - -##### device.purge(uuidOrId) ⇒ Promise -This function clears the user application's `/data` directory. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Purge device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.purge('7cf02a6'); -``` -**Example** -```js -balena.models.device.purge(123); -``` - - -##### device.update(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Trigger an update check on the supervisor -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.update('7cf02a6', { - force: true -}); -``` -**Example** -```js -balena.models.device.update(123, { - force: true -}); -``` - - -##### device.getSupervisorState(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the supervisor state on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getSupervisorState('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorState(123).then(function(state) { - console.log(state); -}); -``` - - -##### device.startService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to start | - -**Example** -```js -balena.models.device.startService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.startService(1, 123).then(function() { - ... -}); -``` - - -##### device.stopService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Stop a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to stop | - -**Example** -```js -balena.models.device.stopService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.stopService(1, 123).then(function() { - ... -}); -``` - - -##### device.restartService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Restart a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to restart | - -**Example** -```js -balena.models.device.restartService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.restartService(1, 123).then(function() { - ... -}); -``` - - -#### models.deviceType : object -**Kind**: static namespace of [models](#balena.models) - -* [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - - - -##### deviceType.get(idOrSlug, [options]) ⇒ Promise -This method returns a single device type. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a single deviceType -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| idOrSlug | String \| Number | | device type slug (string) or alias (string) or id | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.get('raspberry-pi').then(function(deviceType) { - console.log(deviceType); -}); -``` -**Example** -```js -balena.models.deviceType.get('raspberrypi').then(function(deviceType) { - console.log('resolved alias:', deviceType); -}); -``` - - -##### deviceType.getAll([options]) ⇒ Promise -This method returns all device types. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get all deviceTypes -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.getAll().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` -**Example** -```js -balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) { - console.log(deviceTypes); -}) -``` - - -##### deviceType.getAllSupported([options]) ⇒ Promise -This method returns all supported device types. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get all supported deviceTypes -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.getAllSupported().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` -**Example** -```js -balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) { - console.log(deviceTypes); -}) -``` - - -##### deviceType.getBySlugOrName(slugOrName) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a deviceType by slug or name -**Access**: public -**Fulfil**: Object - device type - -| Param | Type | Description | -| --- | --- | --- | -| slugOrName | String | deviceType slug | - -**Example** -```js -balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { - console.log(deviceType); -}); -``` - - -##### deviceType.getName(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get display name for a device -**Access**: public -**Fulfil**: String - device display name - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { - console.log(deviceTypeName); - // Raspberry Pi -}); -``` - - -##### deviceType.getSlugByName(deviceTypeName) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get device slug -**Access**: public -**Fulfil**: String - device slug name - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeName | String | device type name | - -**Example** -```js -balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { - console.log(deviceTypeSlug); - // raspberry-pi -}); -``` - - -##### deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a contract with resolved partial templates -**Access**: public -**Fulfil**: Contract - device type contract with resolved partials - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { - for (const partial in contract.partials) { - console.log(`${partial}: ${contract.partials[partial]}`); - } - // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] -}); -``` - - -##### deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get instructions for installing a host OS on a given device type -**Access**: public -**Fulfil**: Object \| String[] - step by step instructions for installing the host OS to the device - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlugOrContract | String \| Object | device type slug or contract | - -**Example** -```js -balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { - for (let instruction of instructions.values()) { - console.log(instruction); - } - // Insert the sdcard to the host machine. - // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. - // Wait for writing of BalenaOS to complete. - // Remove the sdcard from the host machine. - // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). - // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. -}); -``` - - -##### deviceType.getInstallMethod(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get installation method on a given device type -**Access**: public -**Fulfil**: String - the installation method supported for the given device type slug - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { - console.log(method); - // externalBoot -}); -``` - - -#### models.apiKey : object -**Kind**: static namespace of [models](#balena.models) - -* [.apiKey](#balena.models.apiKey) : object - * [.create(name, [description])](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - - - -##### apiKey.create(name, [description]) ⇒ Promise -This method registers a new api key for the current user with the name given. - -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Creates a new user API key -**Access**: public -**Fulfil**: String - API key - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| name | String | | the API key name | -| [description] | String | | the API key description | - -**Example** -```js -balena.models.apiKey.create(apiKeyName).then(function(apiKey) { - console.log(apiKey); -}); -``` -**Example** -```js -balena.models.apiKey.create(apiKeyName, apiKeyDescription).then(function(apiKey) { - console.log(apiKey); -}); -``` - - -##### apiKey.getAll([options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all accessible API keys -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getAll().then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getAllNamedUserApiKeys([options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all named user API keys of the current user -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all provisioning API keys for an application -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getDeviceApiKeysByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all API keys for a device -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device, uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a6').then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.update(id, apiKeyInfo) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Update the details of an API key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | API key id | -| apiKeyInfo | Object | an object with the updated name|description|expiryDate | - -**Example** -```js -balena.models.apiKey.update(123, { name: 'updatedName' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { description: 'updated description' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { expiryDate: '2022-04-29' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' }); -``` - - -##### apiKey.revoke(id) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Revoke an API key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | API key id | - -**Example** -```js -balena.models.apiKey.revoke(123); -``` - - -#### models.key : object -**Kind**: static namespace of [models](#balena.models) - -* [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - - - -##### key.getAll([options]) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Get all ssh keys -**Access**: public -**Fulfil**: Object[] - ssh keys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.key.getAll().then(function(keys) { - console.log(keys); -}); -``` - - -##### key.get(id) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Get a single ssh key -**Access**: public -**Fulfil**: Object - ssh key - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | key id | - -**Example** -```js -balena.models.key.get(51).then(function(key) { - console.log(key); -}); -``` - - -##### key.remove(id) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Remove ssh key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | key id | - -**Example** -```js -balena.models.key.remove(51); -``` - - -##### key.create(title, key) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Create a ssh key -**Access**: public -**Fulfil**: Object - ssh key - -| Param | Type | Description | -| --- | --- | --- | -| title | String | key title | -| key | String | the public ssh key | - -**Example** -```js -balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) { - console.log(key); -}); -``` - - -#### models.organization : object -**Kind**: static namespace of [models](#balena.models) - -* [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * ~~[.create(options)](#balena.models.organization.membership.create) ⇒ Promise~~ - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - - - -##### organization.membership : object -**Kind**: static namespace of [organization](#balena.models.organization) - -* [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * ~~[.create(options)](#balena.models.organization.membership.create) ⇒ Promise~~ - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - - - -###### membership.get(membershipId, [options]) ⇒ Promise -This method returns a single organization membership. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get a single organization membership -**Access**: public -**Fulfil**: Object - organization membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| membershipId | number \| Object | | the id or an object with the unique `user` & `is_member_of__organization` numeric pair of the membership | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.get(5).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all organization memberships for a specific organization. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get all memberships by organization -**Access**: public -**Fulfil**: Object[] - organization memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByUser(usernameOrId, [options]) ⇒ Promise -This method returns all organization memberships for a specific user. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get all memberships by user -**Access**: public -**Fulfil**: Object[] - organization memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| usernameOrId | String \| Number | | the user's username (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.organization.membership.getAllByUser(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### ~~membership.create(options) ⇒ Promise~~ -***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. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Creates a new membership for an organization -**Access**: public -**Fulfil**: Object - organization membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | membership creation parameters | -| options.organization | String \| Number | | organization handle (string), or id (number) | -| options.username | String | | the username of the balena user that will become a member | -| [options.roleName] | String | "member" | the role name to be granted to the membership | - -**Example** -```js -balena.models.organization.membership.create({ organization: "myorg", username: "user123", roleName: "member" }).then(function(membership) { - console.log(membership); -}); -``` - - -###### membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise -This method changes the role of an organization member. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Changes the role of an organization member -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__organization` numeric pair of the membership that will be changed | -| roleName | String | the role name to be granted to the membership | - -**Example** -```js -balena.models.organization.membership.changeRole(123, "member").then(function() { - console.log('OK'); -}); -``` -**Example** -```js -balena.models.organization.membership.changeRole({ - user: 123, - is_member_of__organization: 125, -}, "member").then(function() { - console.log('OK'); -}); -``` - - -###### membership.remove(id) ⇒ Promise -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Remove a membership -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | organization membership id | - -**Example** -```js -balena.models.organization.membership.remove(123); -``` -**Example** -```js -balena.models.organization.membership.remove({ - user: 123, - is_member_of__application: 125, -}); -``` - - -##### organization.invite : object -**Kind**: static namespace of [organization](#balena.models.organization) - -* [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - - - -###### invite.getAll([options]) ⇒ Promise -This method returns all invites. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Get all invites -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.invite.getAll().then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all invites for a specific organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Get all invites by organization -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string), or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) { - console.log(invites); -}); -``` -**Example** -```js -balena.models.organization.invite.getAllByOrganization(123).then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.create(handleOrId, options, [message]) ⇒ Promise -This method invites a user by their email to an organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Creates a new invite for an organization -**Access**: public -**Fulfil**: String - organization invite - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string), or id (number) | -| options | Object | | invite creation parameters | -| options.invitee | String | | the email of the invitee | -| [options.roleName] | String | "developer" | the role name to be granted to the invitee | -| [message] | String | | the message to send along with the invite | - -**Example** -```js -balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) { - console.log(invite); -}); -``` - - -###### invite.revoke(id) ⇒ Promise -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Revoke an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | organization invite id | - -**Example** -```js -balena.models.organization.invite.revoke(123); -``` - - -###### invite.accept(invitationToken) ⇒ Promise -This method adds the calling user to the organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Accepts an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| invitationToken | String | invite token | - -**Example** -```js -balena.models.organization.invite.accept("qwerty-invitation-token"); -``` - - -##### organization.create(options) ⇒ Promise -This method creates a new organization with the current user as an administrator. - -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Creates a new organization -**Access**: public -**Fulfil**: String - Organization - -| Param | Type | Description | -| --- | --- | --- | -| options | Object | Organization parameters to use. | -| options.name | String | Required: the name of the organization that will be created. | -| [options.handle] | String | The handle of the organization that will be created. | - -**Example** -```js -balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.create({ - name:'MyOrganization', - logo_image: new balena.utils.BalenaWebResourceFile( - [fs.readFileSync('./img.jpeg')], - 'img.jpeg' - ); -}) -.then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.create({ - name:'MyOrganization', - // Only in case File API is avaialable (most browsers and Node 20+) - logo_image: new File( - imageContent, - 'img.jpeg' - ); -}) -.then(function(organization) { - console.log(organization); -}); -``` - - -##### organization.getAll([options]) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Get all Organizations -**Access**: public -**Fulfil**: Object[] - organizations - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.getAll().then(function(organizations) { - console.log(organizations); -}); -``` - - -##### organization.get(handleOrId, [options]) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Get a single organization -**Access**: public -**Fulfil**: Object - organization - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.get('myorganization').then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.get(123).then(function(organization) { - console.log(organization); -}); -``` - - -##### organization.remove(handleOrId) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Remove an Organization -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| handleOrId | String \| Number | organization handle (string) or id (number). | - -**Example** -```js -balena.models.organization.remove(123); -``` - - -#### models.os : object -**Kind**: static namespace of [models](#balena.models) - -* [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.getLastModified(deviceType, [version])](#balena.models.os.getLastModified) ⇒ Promise - * [.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> - - - -##### os.getAvailableOsVersions(deviceTypes, [options]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the supported OS versions for the provided device type(s) -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceTypes | String \| Array.<String> | | device type slug or array of slugs | -| [options] | Object | | Extra options to filter the OS releases by | -| [options.includeDraft] | Boolean | false | Whether pre-releases should be included in the results | - -**Example** -```js -balena.models.os.getAvailableOsVersions('raspberrypi3'); -``` -**Example** -```js -balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']); -``` - - -##### os.getAllOsVersions(deviceTypes, [options]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceTypes | String \| Array.<String> | | device type slug or array of slugs | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.os.getAllOsVersions('raspberrypi3'); -``` -**Example** -```js -balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']); -``` -**Example** -```js -balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } }); -``` - - -##### os.getDownloadSize(deviceType, [version]) ⇒ Promise -**Note!** Currently only the raw (uncompressed) size is reported. - -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get OS download size estimate -**Access**: public -**Fulfil**: Number - OS image download size, in bytes. - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | -| [version] | String | semver-compatible version or 'latest', defaults to 'latest'. The version **must** be the exact version number. | - -**Example** -```js -balena.models.os.getDownloadSize('raspberry-pi').then(function(size) { - console.log('The OS download size for raspberry-pi', size); -}); -``` - - -##### os.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the max OS version satisfying the given range -**Access**: public -**Fulfil**: String\|null - the version number, or `null` if no matching versions are found - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | -| versionOrRange | String | can be one of * the exact version number, in which case it is returned if the version is supported, or `null` is returned otherwise, * a [semver](https://www.npmjs.com/package/semver)-compatible range specification, in which case the most recent satisfying version is returned if it exists, or `null` is returned, * `'latest'` in which case the most recent version is returned, including pre-releases, * `'recommended'` in which case the recommended version is returned, i.e. the most recent version excluding pre-releases, which can be `null` if only pre-release versions are available, * `'default'` in which case the recommended version is returned if available, or `latest` is returned otherwise. Defaults to `'latest'`. | -| [osType] | String | can be one of 'default', 'esr' or null to include all types | - -**Example** -```js -balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) { - console.log(version); -}); -``` - - -##### os.getLastModified(deviceType, [version]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the OS image last modified date -**Access**: public -**Fulfil**: Date - last modified date - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | -| [version] | String | semver-compatible version or 'latest', defaults to 'latest'. Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number. To resolve the semver-compatible range use `balena.model.os.getMaxSatisfyingVersion`. | - -**Example** -```js -balena.models.os.getLastModified('raspberry-pi').then(function(date) { - console.log('The raspberry-pi image was last modified in ' + date); -}); - -balena.models.os.getLastModified('raspberrypi3', '2.0.0').then(function(date) { - console.log('The raspberry-pi image was last modified in ' + date); -}); -``` - - -##### os.download(options) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Download an OS image -**Access**: public -**Fulfil**: ReadableStream - download stream - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | OS image options to use. | -| options.deviceType | String | | device type slug | -| [options.version] | String | 'latest' | semver-compatible version or 'latest', defaults to 'latest' Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number. | -| [options.developmentMode] | Boolean | | controls development mode for unified balenaOS releases. | -| [options.appId] | Number | | the application ID (number). | -| [options.fileType] | String | | download file type. One of '.img' or '.zip' or '.gz'. | -| [options.imageType] | String | | download file type. One of 'raw' or 'flasher' | -| [options.appUpdatePollInterval] | Number | | how often the OS checks for updates, in minutes. | -| [options.network] | String | | the network type that the device will use, one of 'ethernet' or 'wifi'. | -| [options.wifiKey] | String | | the key for the wifi network the device will connect to if network is wifi. | -| [options.wifiSsid] | String | | the ssid for the wifi network the device will connect to if network is wifi. | - -**Example** -```js -balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) { - stream.pipe(fs.createWriteStream('foo/bar/image.img')); -}); -``` - - -##### os.getConfig(slugOrUuidOrId, options) ⇒ Promise -Builds the config.json for a device in the given application, with the given -options. - -Note that an OS version is required. For versions < 2.7.8, config -generation is only supported when using a session token, not an API key. - -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get an applications config.json -**Access**: public -**Fulfil**: Object - application configuration as a JSON object. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number). | -| options | Object | | OS configuration options to use. | -| options.version | String | | Required: the OS version of the image. | -| [options.network] | String | 'ethernet' | The network type that the device will use, one of 'ethernet' or 'wifi'. | -| [options.appUpdatePollInterval] | Number | | How often the OS checks for updates, in minutes. | -| [options.provisioningKeyName] | String | | Name assigned to API key | -| [options.provisioningKeyExpiryDate] | String | | Expiry Date assigned to API key | -| [options.developmentMode] | Boolean | | Controls development mode for unified balenaOS releases. | -| [options.wifiKey] | String | | The key for the wifi network the device will connect to. | -| [options.wifiSsid] | String | | The ssid for the wifi network the device will connect to. | -| [options.ip] | String | | static ip address. | -| [options.gateway] | String | | static ip gateway. | -| [options.netmask] | String | | static ip netmask. | - -**Example** -```js -balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) { - fs.writeFile('foo/bar/config.json', JSON.stringify(config)); -}); - -balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) { - fs.writeFile('foo/bar/config.json', JSON.stringify(config)); -}); -``` - - -##### os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions -**Access**: public -**Fulfil**: Boolean - whether upgrading the OS to the target version is supported - -| 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.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) { - 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 -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns the supported OS update targets for the provided device type -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. -**Fulfil**: Object - the versions information, of the following structure: -* versions - an array of strings, -containing exact version numbers that OS update is supported -* recommended - the recommended version, i.e. the most recent version -that is _not_ pre-release, can be `null` -* current - the provided current version after normalization - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceType | String | | device type slug | -| currentVersion | String | | semver-compatible version for the starting OS version | -| [options] | Object | | Extra options to filter the OS releases by | -| [options.includeDraft] | Boolean | false | Whether pre-releases should be included in the results | - -**Example** -```js -balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) { - console.log(isSupported); -}); -``` - - -##### os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ Boolean -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns whether the specified OS architecture is compatible with the target architecture -**Returns**: Boolean - - Whether the specified OS architecture is capable of running -applications build for the target architecture -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| osArchitecture | String | The OS's architecture as specified in its device type | -| applicationArchitecture | String | The application's architecture as specified in its device type | - -**Example** -```js -const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf'); -console.log(result1); - -const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64'); -console.log(result2); -``` - - -##### os.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options]) ⇒ Promise.<String> -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns the Releases of the supervisor for the CPU Architecture -**Returns**: Promise.<String> - - An array of Release objects that can be used to manage a device as supervisors. -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| cpuArchitectureSlugOrId | String \| Number | | The slug (string) or id (number) for the CPU Architecture | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64'); - -const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( - 'aarch64', - { $filter: { raw_version: '12.11.0' } }, -); - -const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( - 'aarch64', - { - $select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'], - $expand: { - release_image: { - $select: 'id', - $expand: { - image: { - $select: 'is_stored_at__image_location', - }, - }, - }, - }, - $filter: { raw_version: '12.11.0' } - }, -); -``` - - -#### models.config : object -**Kind**: static namespace of [models](#balena.models) - -* [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - - - -##### config.getAll() ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get all configuration -**Access**: public -**Fulfil**: Object - configuration -**Example** -```js -balena.models.config.getAll().then(function(config) { - console.log(config); -}); -``` - - -##### ~~config.getDeviceTypes() ⇒ Promise~~ -***use balena.models.deviceType.getAll*** - -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get device types -**Access**: public -**Fulfil**: Object[] - device types -**Example** -```js -balena.models.config.getDeviceTypes().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` - - -##### ~~config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise~~ -***use balena.models.deviceType.getBySlugOrName*** - -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get a device type manifest by slug -**Access**: public -**Fulfil**: Object - device type manifest - -| Param | Type | Description | -| --- | --- | --- | -| slugOrName | String | device type slug | - -**Example** -```js -balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) { - console.log(manifest); -}); -``` - - -##### config.getDeviceOptions(deviceType) ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get configuration/initialization options for a device type -**Access**: public -**Fulfil**: Object[] - configuration options - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | - -**Example** -```js -balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) { - console.log(options); -}); -``` - - -##### config.getConfigVarSchema(deviceType) ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get configuration variables schema for a device type -**Access**: public -**Fulfil**: Object[] - configuration options - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | - -**Example** -```js -balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) { - console.log(options); -}); -``` - - -#### models.release : object -**Kind**: static namespace of [models](#balena.models) - -* [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - - - -##### release.tags : object -**Kind**: static namespace of [release](#balena.models.release) - -* [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Get all release tags for an application -**Access**: public -**Fulfil**: Object[] - release tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Get all release tags for a release -**Access**: public -**Fulfil**: Object[] - release tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.tags.getAllByRelease(123).then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByRelease('7cf02a6').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Set a release tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.release.tags.set(123, 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.release.tags.set('7cf02a6', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim'); -``` - - -###### tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Remove a release tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| tagKey | String | tag key | - -**Example** -```js -balena.models.release.tags.remove(123, 'EDITOR'); -``` -**Example** -```js -balena.models.release.tags.remove('7cf02a6', 'EDITOR'); -``` -**Example** -```js -balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR'); -``` - - -##### release.get(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get a specific release -**Access**: public -**Fulfil**: Object - release - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.get(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.get('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log(release); -}); -``` - - -##### release.getWithImageDetails(commitOrIdOrRawVersion, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want significantly more control, or to see the -raw model directly, use `release.get(id, options)` instead. - -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get a specific release with the details of the images built -**Access**: public -**Fulfil**: Object - release with image details - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | a map of extra pine options | -| [options.release] | Boolean | {} | extra pine options for releases | -| [options.image] | Object | {} | extra pine options for images | - -**Example** -```js -balena.models.release.getWithImageDetails(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } }) -.then(function(release) { - console.log(release.images[0].build_log); -}); -``` - - -##### release.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get all releases from an application -**Access**: public -**Fulfil**: Object[] - releases - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) { - console.log(releases); -}); -``` -**Example** -```js -balena.models.release.getAllByApplication(123).then(function(releases) { - console.log(releases); -}); -``` - - -##### release.getLatestByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get the latest successful release for an application -**Access**: public -**Fulfil**: Object\|undefined - release - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) { - console.log(releases); -}); -``` -**Example** -```js -balena.models.release.getLatestByApplication(123).then(function(releases) { - console.log(releases); -}); -``` - - -##### release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Create a new release built from the source in the provided url -**Access**: public -**Fulfil**: number - release ID - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| urlDeployOptions | Object | | builder options | -| urlDeployOptions.url | String | | a url with a tarball of the project to build | -| [urlDeployOptions.shouldFlatten] | Boolean | true | Should be true when the tarball includes an extra root folder with all the content | - -**Example** -```js -balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { - console.log(releaseId); -}); -``` -**Example** -```js -balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { - console.log(releaseId); -}); -``` - - -##### release.finalize(commitOrIdOrRawVersion) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Finalizes a draft release -**Access**: public -**Fulfil**: void - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | - -**Example** -```js -balena.models.release.finalize(123).then(function() { - console.log('finalized!'); -}); -``` -**Example** -```js -balena.models.release.finalize('7cf02a6').then(function() { - console.log('finalized!'); -}); -``` -**Example** -```js -balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log('finalized!'); -}); -``` - - -##### release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Set the is_invalidated property of a release to true or false -**Access**: public -**Fulfil**: void - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| isInvalidated | Boolean | boolean value, true for invalidated, false for validated | - -**Example** -```js -balena.models.release.setIsInvalidated(123, true).then(function() { - console.log('invalidated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated('7cf02a6', true).then(function() { - console.log('invalidated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log('invalidated!); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated(123, false).then(function() { - console.log('validated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated('7cf02a6', false).then(function() { - console.log('validated!'); -}); -``` - - -##### release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Add a note to a release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| noteOrNull | String \| Null | the note | - -**Example** -```js -balena.models.release.setNote('7cf02a6', 'My useful note'); -``` -**Example** -```js -balena.models.release.setNote(123, 'My useful note'); -``` -**Example** -```js -balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note'); -``` - - -##### release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Add a known issue list to a release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| knownIssueListOrNull | String \| Null | the known issue list | - -**Example** -```js -balena.models.release.setKnownIssueList('7cf02a6', 'This is an issue'); -``` -**Example** -```js -balena.models.release.setKnownIssueList(123, 'This is an issue'); -``` -**Example** -```js -balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue'); -``` - - -#### models.service : object -**Kind**: static namespace of [models](#balena.models) - -* [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - - - -##### service.var : object -**Kind**: static namespace of [service](#balena.models.service) - -* [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - - - -###### var.getAllByService(serviceIdOrNaturalKey, [options]) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get all variables for a service -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | | service id (number) or appliation-service_name pair | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.var.getAllByService(999999).then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) { - console.log(vars); -}); -``` - - -###### var.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get all service variables by application -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.service.var.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### var.get(serviceIdOrNaturalKey, key) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get the value of a specific service variable -**Access**: public -**Fulfil**: String\|undefined - the variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | - -**Example** -```js -balena.models.service.var.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### var.set(serviceIdOrNaturalKey, key, value) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Set the value of a specific service variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | -| value | String | variable value | - -**Example** -```js -balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### var.remove(serviceIdOrNaturalKey, key) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Clear the value of a specific service variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | - -**Example** -```js -balena.models.service.var.remove(999999, 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() { - ... -}); -``` - - -##### service.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [service](#balena.models.service) -**Summary**: Get all services from an application -**Access**: public -**Fulfil**: Object[] - services - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) { - console.log(services); -}); -``` -**Example** -```js -balena.models.service.getAllByApplication(123).then(function(services) { - console.log(services); -}); -``` - - -#### models.image : object -**Kind**: static namespace of [models](#balena.models) - -* [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - - - -##### image.get(id, [options]) ⇒ Promise -**Kind**: static method of [image](#balena.models.image) -**Summary**: Get a specific image -**Access**: public -**Fulfil**: Object - image - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| id | Number | | image id | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.image.get(123).then(function(image) { - console.log(image); -}); -``` - - -##### image.getLogs(id) ⇒ Promise -**Kind**: static method of [image](#balena.models.image) -**Summary**: Get the logs for an image -**Access**: public -**Fulfil**: string \| null - logs - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | image id | - -**Example** -```js -balena.models.image.getLogs(123).then(function(logs) { - console.log(logs); -}); -``` - - -#### models.creditBundle : object -**Kind**: static namespace of [models](#balena.models) - -* [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - - - -##### creditBundle.getAllByOrg(organization, [options]) ⇒ Promise -**Kind**: static method of [creditBundle](#balena.models.creditBundle) -**Summary**: Get all of the credit bundles purchased by the given org -**Access**: public -**Fulfil**: Object[] - credit bundles - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| organization | String \| Number | | handle (string) or id (number) of the target organization. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) { - console.log(creditBundles); -}); -``` - - -##### creditBundle.create(organization, featureId, creditsToPurchase) ⇒ Promise -**Kind**: static method of [creditBundle](#balena.models.creditBundle) -**Summary**: Purchase a credit bundle for the given feature and org of the given quantity -**Access**: public -**Fulfil**: Object[] - credit bundles - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| featureId | Number | id (number) of the feature for which credits are being purchased. | -| creditsToPurchase | Number | number of credits being purchased. | - -**Example** -```js -balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) { - console.log(creditBundle); -}); -``` - - -#### models.billing : object -**Note!** The billing methods are available on Balena.io exclusively. - -**Kind**: static namespace of [models](#balena.models) - -* [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - - - -##### billing.getAccount(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the user's billing account -**Access**: public -**Fulfil**: Object - billing account - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getAccount(orgId).then(function(billingAccount) { - console.log(billingAccount); -}); -``` - - -##### billing.getPlan(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the current billing plan -**Access**: public -**Fulfil**: Object - billing plan - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getPlan(orgId).then(function(billingPlan) { - console.log(billingPlan); -}); -``` - - -##### billing.getBillingInfo(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the current billing information -**Access**: public -**Fulfil**: Object - billing information - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -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 -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Update the current billing information -**Access**: public -**Fulfil**: Object - billing information - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| 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 -balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) { - console.log(billingInfo); -}); -``` - - -##### billing.removeBillingInfo(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Remove an organization's billing information -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.removeBillingInfo(orgId).then(function() { - console.log("Success"); -}); -``` - - -##### billing.updateAccountInfo(organization, accountInfo) -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Update the current billing account information -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| accountInfo | Partial.<Pick.<BillingAccountInfo, ('email'\|'cc\_emails')>> | an object containing billing account info | - -**Example** -```js -balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) -``` -**Example** -```js -balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) -``` - - -##### billing.changePlan(organization, planChangeOptions) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Change the current billing plan -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| planChangeOptions | Object | an object containing the billing plan change options | -| billingInfo.tier | String | the code of the target billing plan | -| billingInfo.cycle | String | the billing cycle | -| [billingInfo.planChangeReason] | String | the reason for changing the current plan | - -**Example** -```js -balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() { - console.log('Plan changed!'); -}); -``` - - -##### billing.getInvoices(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the available invoices -**Access**: public -**Fulfil**: Object - invoices - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getInvoices(orgId).then(function(invoices) { - console.log(invoices); -}); -``` - - -##### billing.downloadInvoice(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Download a specific invoice -**Access**: public -**Fulfil**: Blob\|ReadableStream - blob on the browser, download stream on node - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| | String | an invoice number | - -**Example** -```js -# Browser -balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) { - console.log(blob); -}); -# Node -balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) { - stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf')); -}); -``` - - -### balena.auth : object -**Kind**: static namespace of [balena](#balena) - -* [.auth](#balena.auth) : object - * [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.whoami()](#balena.auth.whoami) ⇒ Promise - * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ Promise - * [.login(credentials)](#balena.auth.login) ⇒ Promise - * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ Promise - * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ Promise - * [.getToken()](#balena.auth.getToken) ⇒ Promise - * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ Promise - * [.getActorId()](#balena.auth.getActorId) ⇒ Promise - * [.logout()](#balena.auth.logout) ⇒ Promise - * [.register(credentials)](#balena.auth.register) ⇒ Promise - * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ Promise - * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ Promise - - - -#### auth.twoFactor : object -**Kind**: static namespace of [auth](#balena.auth) - -* [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - - - -##### twoFactor.isEnabled() ⇒ Promise -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Check if two factor authentication is enabled -**Access**: public -**Fulfil**: Boolean - whether 2fa is enabled -**Example** -```js -balena.auth.twoFactor.isEnabled().then(function(isEnabled) { - if (isEnabled) { - console.log('2FA is enabled for this account'); - } -}); -``` - - -##### twoFactor.isPassed() ⇒ Promise -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Check if two factor authentication challenge was passed -**Access**: public -**Fulfil**: Boolean - whether 2fa challenge was passed -**Example** -```js -balena.auth.twoFactor.isPassed().then(function(isPassed) { - if (isPassed) { - console.log('2FA challenge passed'); - } -}); -``` - - -##### twoFactor.verify(code) ⇒ Promise -Verifies two factor authentication. -Note that this method not update the token automatically. -You should use [challenge](#balena.auth.twoFactor.challenge) when possible, -as it takes care of that as well. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Verify two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -const token = balena.auth.twoFactor.verify('1234'); -balena.auth.loginWithToken(token); -``` - - -##### twoFactor.getSetupKey() ⇒ Promise -Retrieves a setup key for enabling two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Get two factor authentication setup key -**Access**: public -**Fulfil**: String - setup key -**Example** -```js -const setupKey = balena.auth.twoFactor.getSetupKey(); -console.log(setupKey); -``` - - -##### twoFactor.enable(code) ⇒ Promise -Enables two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Enable two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -const token = balena.auth.twoFactor.enable('1234'); -balena.auth.loginWithToken(token); -``` - - -##### twoFactor.challenge(code) ⇒ Promise -You should use [login](#balena.auth.login) when possible, -as it takes care of saving the token and email as well. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Challenge two factor authentication and complete login -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -balena.auth.twoFactor.challenge('1234'); -``` - - -##### twoFactor.disable(password) ⇒ Promise -Disables two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Disable two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| password | String | password | - -**Example** -```js -const token = balena.auth.twoFactor.disable('1234'); -balena.auth.loginWithToken(token); -``` - - -#### auth.whoami() ⇒ Promise -This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Return current logged in information -**Access**: public -**Fulfil**: (Object\|undefined) - actor information, if it exists -**Example** -```js -balena.auth.whoami().then(function(result) { - if (!result) { - console.log('I\'m not logged in!'); - } else { - console.log('My result is:', result); - } -}); -``` - - -#### auth.authenticate(credentials) ⇒ Promise -You should use [login](#balena.auth.login) when possible, -as it takes care of saving the token and email as well. - -Notice that if `credentials` contains extra keys, they'll be discarted -by the server automatically. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Authenticate with the server -**Access**: protected -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of email, password | -| credentials.email | String | the email | -| credentials.password | String | the password | - -**Example** -```js -balena.auth.authenticate(credentials).then(function(token) { - console.log('My token is:', token); -}); -``` - - -#### auth.login(credentials) ⇒ Promise -If the login is successful, the token is persisted between sessions. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Login -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of email, password | -| credentials.email | String | the email | -| credentials.password | String | the password | - -**Example** -```js -balena.auth.login(credentials); -``` - - -#### auth.loginWithToken(authToken) ⇒ Promise -Login to balena with a session token or api key instead of with credentials. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Login with a token or api key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| authToken | String | the auth token | - -**Example** -```js -balena.auth.loginWithToken(authToken); -``` - - -#### auth.isLoggedIn() ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Check if you're logged in -**Access**: public -**Fulfil**: Boolean - is logged in -**Example** -```js -balena.auth.isLoggedIn().then(function(isLoggedIn) { - if (isLoggedIn) { - console.log('I\'m in!'); - } else { - console.log('Too bad!'); - } -}); -``` - - -#### auth.getToken() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in user's raw API key or session token -**Access**: public -**Fulfil**: String - raw API key or session token -**Example** -```js -balena.auth.getToken().then(function(token) { - console.log(token); -}); -``` - - -#### auth.getUserInfo() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in user's info -**Access**: public -**Fulfil**: Object - user info -**Example** -```js -balena.auth.getUserInfo().then(function(userInfo) { - console.log(userInfo); -}); -``` - - -#### auth.getActorId() ⇒ Promise -This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in actor id -**Access**: public -**Fulfil**: Number - actor id -**Example** -```js -balena.auth.getActorId().then(function(actorId) { - console.log(actorId); -}); -``` - - -#### auth.logout() ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Logout -**Access**: public -**Example** -```js -balena.auth.logout(); -``` - - -#### auth.register(credentials) ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Register a user account -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of username, password and email | -| credentials.email | String | the email | -| credentials.password | String | the password | -| [credentials.'g-recaptcha-response'] | String \| undefined | the captcha response | - -**Example** -```js -balena.auth.register({ - email: 'johndoe@gmail.com', - password: 'secret' -}).then(function(token) { - console.log(token); -}); -``` - - -#### auth.verifyEmail(verificationPayload) ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Verifies an email -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| verificationPayload | Object | in the form of email, and token | -| verificationPayload.email | String | the email | -| verificationPayload.token | String | the verification token | - -**Example** -```js -balena.auth.verifyEmail({ - email: 'johndoe@gmail.com', - token: '5bb11d90eefb34a70318f06a43ef063f' -}).then(function(jwt) { - console.log(jwt); -}); -``` - - -#### auth.requestVerificationEmail() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Re-send verification email to the user -**Access**: public -**Example** -```js -balena.auth.requestVerificationEmail().then(function() { - console.log('Requesting verification email operation complete!'); -}) -``` - - -### balena.logs : object -**Kind**: static namespace of [balena](#balena) - -* [.logs](#balena.logs) : object - * [.subscribe(uuidOrId, [options])](#balena.logs.subscribe) ⇒ Promise.<LogSubscription> - * [.history(uuidOrId, [options])](#balena.logs.history) ⇒ Promise - * [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - - - -#### logs.subscribe(uuidOrId, [options]) ⇒ Promise.<LogSubscription> -Connects to the stream of devices logs, returning a LogSubscription, which -can be used to listen for logs as they appear, line by line. - -**Kind**: static method of [logs](#balena.logs) -**Summary**: Subscribe to device logs -**Access**: public -**Fulfil**: [LogSubscription](#balena.logs.LogSubscription) - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.count] | Number \| 'all' | 0 | number of historical messages to include (or 'all') | - -**Example** -```js -balena.logs.subscribe('7cf02a6').then(function(logs) { - logs.on('line', function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -balena.logs.subscribe(123).then(function(logs) { - logs.on('line', function(line) { - console.log(line); - }); -}); -``` - - -#### logs.history(uuidOrId, [options]) ⇒ Promise -Get an array of the latest log messages for a given device. - -**Kind**: static method of [logs](#balena.logs) -**Summary**: Get device logs history -**Access**: public -**Fulfil**: Object[] - history lines - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.count] | Number \| 'all' | 1000 | number of log messages to return (or 'all') | - -**Example** -```js -balena.logs.history('7cf02a6').then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -balena.logs.history(123).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` - - -#### logs.LogSubscription : EventEmitter -The log subscription emits events as log data arrives. -You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)` - -**Kind**: static typedef of [logs](#balena.logs) - -* [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - - - -##### LogSubscription.unsubscribe() -Disconnect from the logs feed and stop receiving any future events on this emitter. - -**Kind**: static method of [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Unsubscribe from device logs -**Access**: public -**Example** -```js -logs.unsubscribe(); -``` - - -##### "line" -**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Event fired when a new line of log output is available -**Example** -```js -logs.on('line', function(line) { - console.log(line); -}); -``` - - -##### "error" -**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Event fired when an error has occured reading the device logs -**Example** -```js -logs.on('error', function(error) { - console.error(error); -}); -``` - - -### balena.settings : object -**Kind**: static namespace of [balena](#balena) - -* [.settings](#balena.settings) : object - * [.get([key])](#balena.settings.get) ⇒ Promise - * [.getAll()](#balena.settings.getAll) ⇒ Promise - - - -#### settings.get([key]) ⇒ Promise -**Kind**: static method of [settings](#balena.settings) -**Summary**: Get a single setting. **Only implemented in Node.js** -**Access**: public -**Fulfil**: \* - setting value - -| Param | Type | Description | -| --- | --- | --- | -| [key] | String | setting key | - -**Example** -```js -balena.settings.get('apiUrl').then(function(apiUrl) { - console.log(apiUrl); -}); -``` - - -#### settings.getAll() ⇒ Promise -**Kind**: static method of [settings](#balena.settings) -**Summary**: Get all settings **Only implemented in Node.js** -**Access**: public -**Fulfil**: Object - settings -**Example** -```js -balena.settings.getAll().then(function(settings) { - console.log(settings); -}); -``` - - -### balena.utils : object -**Kind**: static namespace of [balena](#balena) - - -## listImagesFromTargetState(targetState) ⇒ -**Kind**: global function -**Returns**: array containing all images for all services for all releases for all apps for the device - -| Param | -| --- | -| targetState | - diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/README.md b/pages/external-docs/sdk/node-sdk/v20.9.1/README.md new file mode 100644 index 0000000000..c53e6671b6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/README.md @@ -0,0 +1 @@ +# v20.9.1 (DEPRECATED) \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/auth.md b/pages/external-docs/sdk/node-sdk/v20.9.1/auth.md new file mode 100644 index 0000000000..0011e51751 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/auth.md @@ -0,0 +1,497 @@ +# auth +balena.auth : object + +**Kind**: static namespace + +* * * + +## authenticate +balena.auth.authenticate(credentials) ⇒ Promise + +You should use [login](#balena.auth.login) when possible, +as it takes care of saving the token and email as well. + +Notice that if `credentials` contains extra keys, they'll be discarted +by the server automatically. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Authenticate with the server +**Access**: protected +**Fulfil**: String - session token + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of email, password

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
+ +**Example** +```js +balena.auth.authenticate(credentials).then(function(token) { + console.log('My token is:', token); +}); +``` + +* * * + +## getActorId +balena.auth.getActorId() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in actor id +**Access**: public +**Fulfil**: Number - actor id +**Example** +```js +balena.auth.getActorId().then(function(actorId) { + console.log(actorId); +}); +``` + +* * * + +## getToken +balena.auth.getToken() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in user's raw API key or session token +**Access**: public +**Fulfil**: String - raw API key or session token +**Example** +```js +balena.auth.getToken().then(function(token) { + console.log(token); +}); +``` + +* * * + +## getUserInfo +balena.auth.getUserInfo() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in user's info +**Access**: public +**Fulfil**: Object - user info +**Example** +```js +balena.auth.getUserInfo().then(function(userInfo) { + console.log(userInfo); +}); +``` + +* * * + +## isLoggedIn +balena.auth.isLoggedIn() ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Check if you're logged in +**Access**: public +**Fulfil**: Boolean - is logged in +**Example** +```js +balena.auth.isLoggedIn().then(function(isLoggedIn) { + if (isLoggedIn) { + console.log('I\'m in!'); + } else { + console.log('Too bad!'); + } +}); +``` + +* * * + +## login +balena.auth.login(credentials) ⇒ Promise + +If the login is successful, the token is persisted between sessions. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Login +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of email, password

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
+ +**Example** +```js +balena.auth.login(credentials); +``` + +* * * + +## loginWithToken +balena.auth.loginWithToken(authToken) ⇒ Promise + +Login to balena with a session token or api key instead of with credentials. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Login with a token or api key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
authTokenString

the auth token

+
+ +**Example** +```js +balena.auth.loginWithToken(authToken); +``` + +* * * + +## logout +balena.auth.logout() ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Logout +**Access**: public +**Example** +```js +balena.auth.logout(); +``` + +* * * + +## register +balena.auth.register(credentials) ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Register a user account +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of username, password and email

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
[credentials.'g-recaptcha-response']String | undefined

the captcha response

+
+ +**Example** +```js +balena.auth.register({ + email: 'johndoe@gmail.com', + password: 'secret' +}).then(function(token) { + console.log(token); +}); +``` + +* * * + +## requestVerificationEmail +balena.auth.requestVerificationEmail() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Re-send verification email to the user +**Access**: public +**Example** +```js +balena.auth.requestVerificationEmail().then(function() { + console.log('Requesting verification email operation complete!'); +}) +``` + +* * * + +## verifyEmail +balena.auth.verifyEmail(verificationPayload) ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Verifies an email +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + + + + + +
ParamTypeDescription
verificationPayloadObject

in the form of email, and token

+
verificationPayload.emailString

the email

+
verificationPayload.tokenString

the verification token

+
+ +**Example** +```js +balena.auth.verifyEmail({ + email: 'johndoe@gmail.com', + token: '5bb11d90eefb34a70318f06a43ef063f' +}).then(function(jwt) { + console.log(jwt); +}); +``` + +* * * + +## whoami +balena.auth.whoami() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Return current logged in information +**Access**: public +**Fulfil**: (Object\|undefined) - actor information, if it exists +**Example** +```js +balena.auth.whoami().then(function(result) { + if (!result) { + console.log('I\'m not logged in!'); + } else { + console.log('My result is:', result); + } +}); +``` + +* * * + +## twoFactor +balena.auth.twoFactor : object + +**Kind**: static namespace of [auth](#balena.auth) + +* * * + +### challenge +balena.auth.twoFactor.challenge(code) ⇒ Promise + +You should use [login](#balena.auth.login) when possible, +as it takes care of saving the token and email as well. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Challenge two factor authentication and complete login +**Access**: public + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +balena.auth.twoFactor.challenge('1234'); +``` + +* * * + +### disable +balena.auth.twoFactor.disable(password) ⇒ Promise + +Disables two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Disable two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
passwordString

password

+
+ +**Example** +```js +const token = balena.auth.twoFactor.disable('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + +### enable +balena.auth.twoFactor.enable(code) ⇒ Promise + +Enables two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Enable two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +const token = balena.auth.twoFactor.enable('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + +### getSetupKey +balena.auth.twoFactor.getSetupKey() ⇒ Promise + +Retrieves a setup key for enabling two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Get two factor authentication setup key +**Access**: public +**Fulfil**: String - setup key +**Example** +```js +const setupKey = balena.auth.twoFactor.getSetupKey(); +console.log(setupKey); +``` + +* * * + +### isEnabled +balena.auth.twoFactor.isEnabled() ⇒ Promise + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Check if two factor authentication is enabled +**Access**: public +**Fulfil**: Boolean - whether 2fa is enabled +**Example** +```js +balena.auth.twoFactor.isEnabled().then(function(isEnabled) { + if (isEnabled) { + console.log('2FA is enabled for this account'); + } +}); +``` + +* * * + +### isPassed +balena.auth.twoFactor.isPassed() ⇒ Promise + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Check if two factor authentication challenge was passed +**Access**: public +**Fulfil**: Boolean - whether 2fa challenge was passed +**Example** +```js +balena.auth.twoFactor.isPassed().then(function(isPassed) { + if (isPassed) { + console.log('2FA challenge passed'); + } +}); +``` + +* * * + +### verify +balena.auth.twoFactor.verify(code) ⇒ Promise + +Verifies two factor authentication. +Note that this method not update the token automatically. +You should use [challenge](#balena.auth.twoFactor.challenge) when possible, +as it takes care of that as well. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Verify two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +const token = balena.auth.twoFactor.verify('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/errors.md b/pages/external-docs/sdk/node-sdk/v20.9.1/errors.md new file mode 100644 index 0000000000..132e5c1184 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/errors.md @@ -0,0 +1,24 @@ +# errors +balena.errors : Object + +The balena-errors module used internally. This is provided primarily for +convenience, and to avoid the necessity for separate balena-errors +dependencies. You'll want to use this if you need to match on the specific +type of error thrown by the SDK. + +**Kind**: static member +**Summary**: Balena errors module +**Access**: public +**Example** +```js +balena.models.device.get(123).catch(function (error) { + if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) { + ... + } else if (error.code === balena.errors.BalenaRequestError.prototype.code) { + ... + } +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/fromSharedOptions.md b/pages/external-docs/sdk/node-sdk/v20.9.1/fromSharedOptions.md new file mode 100644 index 0000000000..73f0097d6d --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/fromSharedOptions.md @@ -0,0 +1,18 @@ +# fromSharedOptions +module:balena-sdk~fromSharedOptions() + +Create an SDK instance using shared default options set using the `setSharedOptions()` method. +If options have not been set using this method, then this method will use the +same defaults as the main SDK factory function. + +**Kind**: inner function +**Summary**: Create an SDK instance using shared default options +**Access**: public +**Example** +```js +import { fromSharedOptions } from 'balena-sdk'; +const sdk = fromSharedOptions(); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/getSdk.md b/pages/external-docs/sdk/node-sdk/v20.9.1/getSdk.md new file mode 100644 index 0000000000..dff2249899 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/getSdk.md @@ -0,0 +1,22 @@ +# getSdk +module:balena-sdk~getSdk() + +The module exports a single factory function. + +**Kind**: inner function +**Summary**: Creates a new SDK instance using the default or the provided options. +**Example** +```js +// with es6 imports +import { getSdk } from 'balena-sdk'; +// or with node require +const { getSdk } = require('balena-sdk'); + +const balena = getSdk({ + apiUrl: "https://api.balena-cloud.com/", + dataDirectory: "/opt/local/balena" +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/interceptors.md b/pages/external-docs/sdk/node-sdk/v20.9.1/interceptors.md new file mode 100644 index 0000000000..0da46482a3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/interceptors.md @@ -0,0 +1,68 @@ +# interceptors +balena.interceptors : Array.<Interceptor> + +The current array of interceptors to use. Interceptors intercept requests made +internally and are executed in the order they appear in this array for requests, +and in the reverse order for responses. + +**Kind**: static member +**Summary**: Array of interceptors +**Access**: public +**Example** +```js +balena.interceptors.push({ + responseError: function (error) { + console.log(error); + throw error; + }) +}); +``` + +* * * + +## Interceptor +balena.interceptors.Interceptor : object + +An interceptor implements some set of the four interception hook callbacks. +To continue processing, each function should return a value or a promise that +successfully resolves to a value. + +To halt processing, each function should throw an error or return a promise that +rejects with an error. + +**Kind**: static typedef of [interceptors](#balena.interceptors) +**Properties** + + + + + + + + + + + + + + + + + +
NameTypeDescription
[request]function

Callback invoked before requests are made. Called with +the request options, should return (or resolve to) new request options, or throw/reject.

+
[response]function

Callback invoked before responses are returned. Called with +the response, should return (or resolve to) a new response, or throw/reject.

+
[requestError]function

Callback invoked if an error happens before a request. +Called with the error itself, caused by a preceeding request interceptor rejecting/throwing +an error for the request, or a failing in preflight token validation. Should return (or resolve +to) new request options, or throw/reject.

+
[responseError]function

Callback invoked if an error happens in the response. +Called with the error itself, caused by a preceeding response interceptor rejecting/throwing +an error for the request, a network error, or an error response from the server. Should return +(or resolve to) a new response, or throw/reject.

+
+ + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/introduction.md b/pages/external-docs/sdk/node-sdk/v20.9.1/introduction.md new file mode 100644 index 0000000000..1220aa46ef --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/introduction.md @@ -0,0 +1,59 @@ +# Introduction + +Welcome to the balena Node SDK documentation. These pages aim to describe all the functions supported by the SDK, as well as showing examples of their expected usage. + +## Installation + +Install the balena SDK by running: + +```sh +$ npm install --save balena-sdk +``` + +### Bundling for browsers + +If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. + +If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: + +* fs +* path +* balena-settings-client +* node-localstorage +* fs/promises +* mime + +### Bundling with pkg + +The balena SDK includes builds for various ECMAScript versions that are +dynamically selected at runtime (using +[@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). +For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not +able to automatically detect which assets to include in the output package. The +following sample `pkg` section should be added to your application's +`package.json` file to instruct `pkg` to bundle the required assets: + +```json + "pkg": { + "scripts": [ + "node_modules/balena-sdk/**/*.js" + ], + "assets": [ + "node_modules/pinejs-client-core/**/*" + ] + } +``` + +For more information, please refer to the respective +[documentation from the `pkg` project](https://github.com/vercel/pkg#config). + +## Trying balenaSDK in the browser + +BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. +To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries. + +![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png) + + +If you feel something is missing, not clear or could be improved, please don't hesitate to open an +[issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help. \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/logs.md b/pages/external-docs/sdk/node-sdk/v20.9.1/logs.md new file mode 100644 index 0000000000..47357db4ba --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/logs.md @@ -0,0 +1,179 @@ +# logs +balena.logs : object + +**Kind**: static namespace + +* * * + +## history +balena.logs.history(uuidOrId, [options]) ⇒ Promise + +Get an array of the latest log messages for a given device. + +**Kind**: static method of [logs](#balena.logs) +**Summary**: Get device logs history +**Access**: public +**Fulfil**: Object[] - history lines + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.count]Number | 'all'1000

number of log messages to return (or 'all')

+
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages

+
+ +**Example** +```js +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd').then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +balena.logs.history(123).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +const oneDayAgoTimestamp = Date.now() - 24*60*60*1000; +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoTimestamp }).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +const oneDayAgoIsoDateString = new Date(Date.now() - 24*60*60*1000).toISOString(); +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoIsoDateString }).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` + +* * * + +## subscribe +balena.logs.subscribe(uuidOrId, [options]) ⇒ Promise.<LogSubscription> + +Connects to the stream of devices logs, returning a LogSubscription, which +can be used to listen for logs as they appear, line by line. + +**Kind**: static method of [logs](#balena.logs) +**Summary**: Subscribe to device logs +**Access**: public +**Fulfil**: [LogSubscription](#balena.logs.LogSubscription) + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.count]Number | 'all'0

number of historical messages to include (or 'all')

+
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages. When specified, the count parameter needs to also be provided.

+
+ +**Example** +```js +balena.logs.subscribe('7cf02a69e4d34c9da573914963cf54fd').then(function(logs) { + logs.on('line', function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +balena.logs.subscribe(123).then(function(logs) { + logs.on('line', function(line) { + console.log(line); + }); +}); +``` + +* * * + +## LogSubscription +balena.logs.LogSubscription : EventEmitter + +The log subscription emits events as log data arrives. +You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)` + +**Kind**: static typedef of [logs](#balena.logs) + +* * * + +### unsubscribe +balena.logs.LogSubscription.unsubscribe() + +Disconnect from the logs feed and stop receiving any future events on this emitter. + +**Kind**: static method of [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Unsubscribe from device logs +**Access**: public +**Example** +```js +logs.unsubscribe(); +``` + +* * * + +### error +balena.logs.LogSubscription.event:error + +**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Event fired when an error has occured reading the device logs +**Example** +```js +logs.on('error', function(error) { + console.error(error); +}); +``` + +* * * + +### line +balena.logs.LogSubscription.event:line + +**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Event fired when a new line of log output is available +**Example** +```js +logs.on('line', function(line) { + console.log(line); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/README.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/README.md new file mode 100644 index 0000000000..e89b5f2b2b --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/README.md @@ -0,0 +1 @@ +# Models \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/apiKey.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/apiKey.md new file mode 100644 index 0000000000..3e118ba1c1 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/apiKey.md @@ -0,0 +1,242 @@ +# apiKey +balena.models.apiKey : object + +**Kind**: static namespace + +* * * + +## create +balena.models.apiKey.create(createApiKeyParams) ⇒ Promise + +This method registers a new api key for the current user with the name given. + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Creates a new user API key +**Access**: public +**Fulfil**: String - API key + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
createApiKeyParamsObject

an object containing the parameters for the creation of an API key

+
createApiKeyParams.nameString

the API key name

+
createApiKeyParams.expiryDateString

the API key expiry date

+
[createApiKeyParams.description]String

the API key description

+
+ +**Example** +```js +balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12}).then(function(apiKey) { + console.log(apiKey); +}); +``` +**Example** +```js +balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12, description: apiKeyDescription}).then(function(apiKey) { + console.log(apiKey); +}); +``` + +* * * + +## getAll +balena.models.apiKey.getAll([options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all accessible API keys +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getAll().then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getAllNamedUserApiKeys +balena.models.apiKey.getAllNamedUserApiKeys([options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all named user API keys of the current user +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getDeviceApiKeysByDevice +balena.models.apiKey.getDeviceApiKeysByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all API keys for a device +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device, uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getProvisioningApiKeysByApplication +balena.models.apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all provisioning API keys for an application +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## revoke +balena.models.apiKey.revoke(id) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Revoke an API key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

API key id

+
+ +**Example** +```js +balena.models.apiKey.revoke(123); +``` + +* * * + +## update +balena.models.apiKey.update(id, apiKeyInfo) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Update the details of an API key +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idNumber

API key id

+
apiKeyInfoObject

an object with the updated name|description|expiryDate

+
+ +**Example** +```js +balena.models.apiKey.update(123, { name: 'updatedName' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { description: 'updated description' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { expiryDate: '2022-04-29' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' }); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/application.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/application.md new file mode 100644 index 0000000000..1f405f01f4 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/application.md @@ -0,0 +1,1956 @@ +# application +balena.models.application : object + +**Kind**: static namespace + +* * * + +## create +balena.models.application.create(options) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Create an application +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
optionsObject

application creation parameters

+
options.nameString

application name

+
options.organizationString | Number

handle (string) or id (number) of the organization that the application will belong to or null

+
[options.uuid]String

application uuid

+
[options.applicationClass]String

application class: 'app' | 'fleet' | 'block'

+
options.deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.application.create({ name: 'My App', organization: 'myorganization', deviceType: 'raspberry-pi' }).then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.create({ name: 'My Block', organization: 'myorganization', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) { + console.log(application); +}); +``` + +* * * + +## disableDeviceUrls +balena.models.application.disableDeviceUrls(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Disable device urls for all devices that belong to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.disableDeviceUrls('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.disableDeviceUrls(123); +``` + +* * * + +## enableDeviceUrls +balena.models.application.enableDeviceUrls(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Enable device urls for all devices that belong to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.enableDeviceUrls('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.enableDeviceUrls(123); +``` + +* * * + +## generateProvisioningKey +balena.models.application.generateProvisioningKey(generateProvisioningKeyParams) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Generate a device provisioning key for a specific application +**Access**: public +**Fulfil**: String - device provisioning key + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
generateProvisioningKeyParamsObject

an object containing the parameters for the provisioning key generation

+
generateProvisioningKeyParams.slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
generateProvisioningKeyParams.keyExpiryDateString

Expiry Date for provisioning key

+
[generateProvisioningKeyParams.keyName]String

Provisioning key name

+
[generateProvisioningKeyParams.keyDescription]String

Description for provisioning key

+
+ +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 'myorganization/myapp', keyExpiryDate: '2030-10-12'}).then(function(key) { + console.log(key); +}); +``` +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12'}).then(function(key) { + console.log(key); +}); +``` +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12', keyName: 'api key name', keyDescription: 'api key long description'}).then(function(key) { + console.log(key); +}); +``` + +* * * + +## get +balena.models.application.get(slugOrUuidOrId, [options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.get('myorganization/myapp').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.get(123).then(function(application) { + console.log(application); +}); +``` + +* * * + +## getAll +balena.models.application.getAll([options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.getAll().then(function(applications) { + console.log(applications); +}); +``` + +* * * + +## getAllByOrganization +balena.models.application.getAllByOrganization(orgHandleOrId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications of an organization +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + + + +
ParamTypeDefaultDescription
orgHandleOrIdNumber | String

organization handle (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getAllByOrganization('myorganization').then(function(applications) { + console.log(applications); +}); +``` +**Example** +```js +const applications = await sdk.models.application.getAllByOrganization('myorganization', { + $select: ['app_name', 'slug'], + $expand: { + owns__device: { + $select: ['uuid', 'overall_status', 'is_connected_to_vpn', 'api_heartbeat_state'], + }, + }, + }); +``` + +* * * + +## getAllDirectlyAccessible +balena.models.application.getAllDirectlyAccessible([options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications directly accessible by the user +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getAllDirectlyAccessible().then(function(applications) { + console.log(applications); +}); +``` + +* * * + +## getAppByName +balena.models.application.getAppByName(appName, [options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application using the appname and the handle of the owning organization +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appNameString

application name

+
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.getAppByName('MyApp').then(function(application) { + console.log(application); +}); +``` + +* * * + +## getDashboardUrl +balena.models.application.getDashboardUrl(id) ⇒ String + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get Dashboard URL for a specific application +**Returns**: String - - Dashboard URL for the specific application +**Throws**: + +- Exception if the id is not a finite number + + + + + + + + + + + +
ParamTypeDescription
idNumber

Application id

+
+ +**Example** +```js +balena.models.application.get('myorganization/myapp').then(function(application) { + const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); + console.log(dashboardApplicationUrl); +}); +``` + +* * * + +## getDirectlyAccessible +balena.models.application.getDirectlyAccessible(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application directly accessible by the user +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.getDirectlyAccessible(123).then(function(application) { + console.log(application); +}); +``` + +* * * + +## getTargetReleaseHash +balena.models.application.getTargetReleaseHash(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get the hash of the current release for a specific application +**Access**: public +**Fulfil**: String\|undefined - The release hash of the current release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.application.getTargetReleaseHash(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) { + console.log(release); +}); +``` + +* * * + +## getWithDeviceServiceDetails +balena.models.application.getWithDeviceServiceDetails(slugOrUuidOrId, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want more control, or to see the raw model +directly, use `application.get(uuidOrId, options)` instead. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application and its devices, along with each device's +associated services' essential details +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.application.getWithDeviceServiceDetails(123).then(function(device) { + console.log(device); +}) +``` + +* * * + +## grantSupportAccess +balena.models.application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Grant support access to an application until a specified time +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
expiryTimestampNumber

a timestamp in ms for when the support access will expire

+
+ +**Example** +```js +balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000); +``` +**Example** +```js +balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000); +``` + +* * * + +## has +balena.models.application.has(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Check if an application exists +**Access**: public +**Fulfil**: Boolean - has application + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.has('myorganization/myapp').then(function(hasApp) { + console.log(hasApp); +}); +``` +**Example** +```js +balena.models.application.has(123).then(function(hasApp) { + console.log(hasApp); +}); +``` + +* * * + +## hasAny +balena.models.application.hasAny() ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Check if the user has access to any applications +**Access**: public +**Fulfil**: Boolean - has any applications +**Example** +```js +balena.models.application.hasAny().then(function(hasAny) { + console.log('Has any?', hasAny); +}); +``` + +* * * + +## isTrackingLatestRelease +balena.models.application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates +**Access**: public +**Fulfil**: Boolean - is tracking the latest release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) { + console.log(isEnabled); +}); +``` +**Example** +```js +balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## pinToRelease +balena.models.application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ Promise + +Configures the application to run a particular release +and not get updated when the latest release changes. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Set a specific application to run a particular release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
fullReleaseHashString

the hash of a successful release (string)

+
+ +**Example** +```js +balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` + +* * * + +## purge +balena.models.application.purge(appId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Purge devices by application id +**Access**: public + + + + + + + + + + +
ParamTypeDescription
appIdNumber

application id

+
+ +**Example** +```js +balena.models.application.purge(123); +``` + +* * * + +## reboot +balena.models.application.reboot(appId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Reboot devices by application id +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appIdNumber

application id

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.application.reboot(123); +``` + +* * * + +## remove +balena.models.application.remove(slugOrUuidOrIdOrIds) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Remove application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdOrIdsString | Number | Array.<Number>

application slug (string), uuid (string) or id (number) or array of ids

+
+ +**Example** +```js +balena.models.application.remove('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.remove(123); +``` + +* * * + +## rename +balena.models.application.rename(slugOrUuidOrId, newName) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Rename application +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
newNameString

new application name (string)

+
+ +**Example** +```js +balena.models.application.rename('myorganization/myapp', 'MyRenamedApp'); +``` +**Example** +```js +balena.models.application.rename(123, 'MyRenamedApp'); +``` + +* * * + +## restart +balena.models.application.restart(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Restart application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.restart('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.restart(123); +``` + +* * * + +## revokeSupportAccess +balena.models.application.revokeSupportAccess(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Revoke support access to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.revokeSupportAccess('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.revokeSupportAccess(123); +``` + +* * * + +## shutdown +balena.models.application.shutdown(appId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Shutdown devices by application id +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appIdNumber

application id

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.application.shutdown(123); +``` + +* * * + +## trackLatestRelease +balena.models.application.trackLatestRelease(slugOrUuidOrId) ⇒ Promise + +The application's current release will be updated with each new successfully built release. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Configure a specific application to track the latest finalized available release +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.trackLatestRelease('myorganization/myapp').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.trackLatestRelease(123).then(function() { + ... +}); +``` + +* * * + +## willTrackNewReleases +balena.models.application.willTrackNewReleases(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get whether the application is configured to receive updates whenever a new release is available +**Access**: public +**Fulfil**: Boolean - is tracking the latest release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) { + console.log(isEnabled); +}); +``` +**Example** +```js +balena.models.application.willTrackNewReleases(123).then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## buildVar +balena.models.application.buildVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.buildVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Get the value of a specific build environment variable +**Access**: public +**Fulfil**: String\|undefined - the build environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
+ +**Example** +```js +balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.buildVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.buildVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Get all build environment variables for an application +**Access**: public +**Fulfil**: Object[] - application build environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.buildVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Clear the value of a specific build environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
+ +**Example** +```js +balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.buildVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.buildVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Set the value of a specific build environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
valueString

build environment variable value

+
+ +**Example** +```js +balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## configVar +balena.models.application.configVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.configVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Get the value of a specific config variable +**Access**: public +**Fulfil**: String\|undefined - the config variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Get all config variables for an application +**Access**: public +**Fulfil**: Object[] - application config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.configVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.configVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Clear the value of a specific config variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.configVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Set the value of a specific config variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
valueString

config variable value

+
+ +**Example** +```js +balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## envVar +balena.models.application.envVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.envVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Get the value of a specific environment variable +**Access**: public +**Fulfil**: String\|undefined - the environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.envVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Get all environment variables for an application +**Access**: public +**Fulfil**: Object[] - application environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.envVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.envVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Clear the value of a specific environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.envVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.envVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Set the value of a specific environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
valueString

environment variable value

+
+ +**Example** +```js +balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## invite +balena.models.application.invite : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### accept +balena.models.application.invite.accept(invitationToken) ⇒ Promise + +This method adds the calling user to the application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Accepts an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
invitationTokenString

invite token

+
+ +**Example** +```js +balena.models.application.invite.accept("qwerty-invitation-token"); +``` + +* * * + +### create +balena.models.application.invite.create(slugOrUuidOrId, options, [message]) ⇒ Promise + +This method invites a user by their email to an application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Creates a new invite for an application +**Access**: public +**Fulfil**: String - application invite + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
optionsObject

invite creation parameters

+
options.inviteeString

the email of the invitee

+
[options.roleName]String"developer"

the role name to be granted to the invitee

+
[message]String

the message to send along with the invite

+
+ +**Example** +```js +balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) { + console.log(invite); +}); +``` + +* * * + +### getAll +balena.models.application.invite.getAll([options]) ⇒ Promise + +This method returns all invites. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Get all invites +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.invite.getAll().then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.invite.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all invites for a specific application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Get all invites by application +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) { + console.log(invites); +}); +``` +**Example** +```js +balena.models.application.invite.getAllByApplication(123).then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### revoke +balena.models.application.invite.revoke(id) ⇒ Promise + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Revoke an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

application invite id

+
+ +**Example** +```js +balena.models.application.invite.revoke(123); +``` + +* * * + +## membership +balena.models.application.membership : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### changeRole +balena.models.application.membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise + +This method changes the role of an application member. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Changes the role of an application member +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be changed

+
roleNameString

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.application.membership.changeRole(123, "member").then(function() { + console.log('OK'); +}); +``` +**Example** +```js +balena.models.application.membership.changeRole({ + user: 123, + is_member_of__application: 125, +}, "member").then(function() { + console.log('OK'); +}); +``` + +* * * + +### create +balena.models.application.membership.create(options) ⇒ Promise + +This method adds a user to an application by their username if they are a member of the organization. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Creates a new membership for an application +**Access**: public +**Fulfil**: Object - application membership + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

membership creation parameters

+
options.applicationString | Number

application handle (string), or id (number)

+
options.usernameString

the username of the balena user that will become a member

+
[options.roleName]String"member"

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { + console.log(membership); +}); +``` + +* * * + +### get +balena.models.application.membership.get(membershipId, [options]) ⇒ Promise + +This method returns a single application membership. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get a single application membership +**Access**: public +**Fulfil**: Object - application membership + + + + + + + + + + + + +
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.get(5).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.membership.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all application memberships for a specific application. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get all memberships by application +**Access**: public +**Fulfil**: Object[] - application memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.application.membership.getAllByApplication(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByUser +balena.models.application.membership.getAllByUser(usernameOrId, [options]) ⇒ Promise + +This method returns all application memberships for a specific user. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get all memberships by user +**Access**: public +**Fulfil**: Object[] - application memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.application.membership.getAllByUser(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### remove +balena.models.application.membership.remove(idOrUniqueKey) ⇒ Promise + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Remove a membership +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be removed

+
+ +**Example** +```js +balena.models.application.membership.remove(123); +``` +**Example** +```js +balena.models.application.membership.remove({ + user: 123, + is_member_of__application: 125, +}); +``` + +* * * + +## tags +balena.models.application.tags : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### getAllByApplication +balena.models.application.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Get all application tags for an application +**Access**: public +**Fulfil**: Object[] - application tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.application.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.application.tags.remove(slugOrUuidOrId, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Remove an application tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.application.tags.remove('myorganization/myapp', 'EDITOR'); +``` + +* * * + +### set +balena.models.application.tags.set(slugOrUuidOrId, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Set an application tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.application.tags.set(123, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/billing.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/billing.md new file mode 100644 index 0000000000..fd9bdf75a2 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/billing.md @@ -0,0 +1,339 @@ +# billing +balena.models.billing : object + +**Note!** The billing methods are available on Balena.io exclusively. + +**Kind**: static namespace + +* * * + +## changePlan +balena.models.billing.changePlan(organization, planChangeOptions) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Change the current billing plan +**Access**: public + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
planChangeOptionsObject

an object containing the billing plan change options

+
billingInfo.tierString

the code of the target billing plan

+
billingInfo.cycleString

the billing cycle

+
[billingInfo.planChangeReason]String

the reason for changing the current plan

+
+ +**Example** +```js +balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() { + console.log('Plan changed!'); +}); +``` + +* * * + +## createSetupIntent +balena.models.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 + + + + + + + + + + + + + + +
ParamTypeDescription
setupIntentParamsObject

an object containing the parameters for the setup intent creation

+
extraParams.organizationString | 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); +}); +``` + +* * * + +## downloadInvoice +balena.models.billing.downloadInvoice(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Download a specific invoice +**Access**: public +**Fulfil**: Blob\|ReadableStream - blob on the browser, download stream on node + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
String

an invoice number

+
+ +**Example** +```js +# Browser +balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) { + console.log(blob); +}); +# Node +balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) { + stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf')); +}); +``` + +* * * + +## getAccount +balena.models.billing.getAccount(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the user's billing account +**Access**: public +**Fulfil**: Object - billing account + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getAccount(orgId).then(function(billingAccount) { + console.log(billingAccount); +}); +``` + +* * * + +## getBillingInfo +balena.models.billing.getBillingInfo(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the current billing information +**Access**: public +**Fulfil**: Object - billing information + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getBillingInfo(orgId).then(function(billingInfo) { + console.log(billingInfo); +}); +``` + +* * * + +## getInvoices +balena.models.billing.getInvoices(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the available invoices +**Access**: public +**Fulfil**: Object - invoices + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getInvoices(orgId).then(function(invoices) { + console.log(invoices); +}); +``` + +* * * + +## getPlan +balena.models.billing.getPlan(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the current billing plan +**Access**: public +**Fulfil**: Object - billing plan + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getPlan(orgId).then(function(billingPlan) { + console.log(billingPlan); +}); +``` + +* * * + +## removeBillingInfo +balena.models.billing.removeBillingInfo(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Remove an organization's billing information +**Access**: public + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.removeBillingInfo(orgId).then(function() { + console.log("Success"); +}); +``` + +* * * + +## updateAccountInfo +balena.models.billing.updateAccountInfo(organization, accountInfo) + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Update the current billing account information +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
accountInfoAccountInfo

an object containing billing account info

+
+ +**Example** +```js +balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) +``` +**Example** +```js +balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) +``` + +* * * + +## updateBillingInfo +balena.models.billing.updateBillingInfo(organization, billingInfo) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Update the current billing information +**Access**: public +**Fulfil**: Object - billing information + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
billingInfoObject

an object containing a billing info token_id

+
billingInfo.token_idString

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 +balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) { + console.log(billingInfo); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/config.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/config.md new file mode 100644 index 0000000000..676ca030aa --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/config.md @@ -0,0 +1,130 @@ +# config +balena.models.config : object + +**Kind**: static namespace + +* * * + +## getAll +balena.models.config.getAll() ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get all configuration +**Access**: public +**Fulfil**: Object - configuration +**Example** +```js +balena.models.config.getAll().then(function(config) { + console.log(config); +}); +``` + +* * * + +## getConfigVarSchema +balena.models.config.getConfigVarSchema(deviceType) ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get configuration variables schema for a device type +**Access**: public +**Fulfil**: Object[] - configuration options + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) { + console.log(options); +}); +``` + +* * * + +## getDeviceOptions +balena.models.config.getDeviceOptions(deviceType) ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get configuration/initialization options for a device type +**Access**: public +**Fulfil**: Object[] - configuration options + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) { + console.log(options); +}); +``` + +* * * + +## getDeviceTypeManifestBySlug +balena.models.config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise + +***use balena.models.deviceType.getBySlugOrName*** + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get a device type manifest by slug +**Access**: public +**Fulfil**: Object - device type manifest + + + + + + + + + + +
ParamTypeDescription
slugOrNameString

device type slug

+
+ +**Example** +```js +balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) { + console.log(manifest); +}); +``` + +* * * + +## getDeviceTypes +balena.models.config.getDeviceTypes() ⇒ Promise + +***use balena.models.deviceType.getAll*** + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get device types +**Access**: public +**Fulfil**: Object[] - device types +**Example** +```js +balena.models.config.getDeviceTypes().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/creditBundle.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/creditBundle.md new file mode 100644 index 0000000000..9b3025c4e4 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/creditBundle.md @@ -0,0 +1,74 @@ +# creditBundle +balena.models.creditBundle : object + +**Kind**: static namespace + +* * * + +## create +balena.models.creditBundle.create(organization, featureId, creditsToPurchase) ⇒ Promise + +**Kind**: static method of [creditBundle](#balena.models.creditBundle) +**Summary**: Purchase a credit bundle for the given feature and org of the given quantity +**Access**: public +**Fulfil**: Object[] - credit bundles + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
featureIdNumber

id (number) of the feature for which credits are being purchased.

+
creditsToPurchaseNumber

number of credits being purchased.

+
+ +**Example** +```js +balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) { + console.log(creditBundle); +}); +``` + +* * * + +## getAllByOrg +balena.models.creditBundle.getAllByOrg(organization, [options]) ⇒ Promise + +**Kind**: static method of [creditBundle](#balena.models.creditBundle) +**Summary**: Get all of the credit bundles purchased by the given org +**Access**: public +**Fulfil**: Object[] - credit bundles + + + + + + + + + + + + +
ParamTypeDefaultDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) { + console.log(creditBundles); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/device.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/device.md new file mode 100644 index 0000000000..49a47aeac3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/device.md @@ -0,0 +1,2986 @@ +# device +balena.models.device : object + +**Kind**: static namespace + +* * * + +## deactivate +balena.models.device.deactivate(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Deactivate device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.deactivate('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.deactivate(123); +``` + +* * * + +## disableDeviceUrl +balena.models.device.disableDeviceUrl(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable device url for a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.disableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableDeviceUrl(123); +``` + +* * * + +## disableLocalMode +balena.models.device.disableLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable local mode +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.disableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableLocalMode(123); +``` + +* * * + +## disableLockOverride +balena.models.device.disableLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable lock override +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.disableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableLockOverride(123); +``` + +* * * + +## enableDeviceUrl +balena.models.device.enableDeviceUrl(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable device url for a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.enableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableDeviceUrl(123); +``` + +* * * + +## enableLocalMode +balena.models.device.enableLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable local mode +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.enableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableLocalMode(123); +``` + +* * * + +## enableLockOverride +balena.models.device.enableLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable lock override +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.enableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableLockOverride(123); +``` + +* * * + +## generateDeviceKey +balena.models.device.generateDeviceKey(uuidOrId, [keyName], [keyDescription]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Generate a device key +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[keyName]String

Device key name

+
[keyDescription]String

Description for device key

+
+ +**Example** +```js +balena.models.device.generateDeviceKey('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceApiKey) { + console.log(deviceApiKey); +}); +``` +**Example** +```js +balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) { + console.log(deviceApiKey); +}); +``` + +* * * + +## generateUniqueKey +balena.models.device.generateUniqueKey() ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Generate a random key, useful for both uuid and api key. +**Returns**: String - A generated key +**Access**: public +**Example** +```js +randomKey = balena.models.device.generateUniqueKey(); +// randomKey is a randomly generated key that can be used as either a uuid or an api key +console.log(randomKey); +``` + +* * * + +## get +balena.models.device.get(uuidOrId, [options]) ⇒ Promise + +This method returns a single device by id or uuid. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a single device +**Access**: public +**Fulfil**: Object - device + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.get(123).then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getAllByApplication +balena.models.device.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all devices of a specific application. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get all devices by application +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByApplication(123).then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getAllByOrganization +balena.models.device.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all devices of a specific application. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get all devices by organization +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getAllByOrganization('myorganization').then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByOrganization(123).then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getApplicationName +balena.models.device.getApplicationName(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get application name +**Access**: public +**Fulfil**: String - application name + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getApplicationName('7cf02a69e4d34c9da573914963cf54fd').then(function(applicationName) { + console.log(applicationName); +}); +``` +**Example** +```js +balena.models.device.getApplicationName(123).then(function(applicationName) { + console.log(applicationName); +}); +``` + +* * * + +## getByName +balena.models.device.getByName(name) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get devices by name +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + +
ParamTypeDescription
nameString

device name

+
+ +**Example** +```js +balena.models.device.getByName('MyDevice').then(function(devices) { + console.log(devices); +}); +``` + +* * * + +## getDashboardUrl +balena.models.device.getDashboardUrl(uuid) ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get Dashboard URL for a specific device +**Returns**: String - - Dashboard URL for the specific device +**Throws**: + +- Exception if the uuid is empty + + + + + + + + + + + +
ParamTypeDescription
uuidString

Device uuid

+
+ +**Example** +```js +dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8') +``` + +* * * + +## getDeviceUrl +balena.models.device.getDeviceUrl(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a device url +**Access**: public +**Fulfil**: String - device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(url) { + console.log(url); +}); +``` +**Example** +```js +balena.models.device.getDeviceUrl(123).then(function(url) { + console.log(url); +}); +``` + +* * * + +## getLocalIPAddresses +balena.models.device.getLocalIPAddresses(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the local IP addresses of a device +**Access**: public +**Fulfil**: String[] - local ip addresses +**Reject**: Error Will reject if the device is offline + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getLocalIPAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(localIPAddresses) { + localIPAddresses.forEach(function(localIP) { + console.log(localIP); + }); +}); +``` +**Example** +```js +balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) { + localIPAddresses.forEach(function(localIP) { + console.log(localIP); + }); +}); +``` + +* * * + +## getLocalModeSupport +balena.models.device.getLocalModeSupport(device) ⇒ Object + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported. +**Returns**: Object - Local mode support info ({ supported: true/false, message: "..." }) +**Access**: public + + + + + + + + + + +
ParamTypeDescription
deviceObject

A device object

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + balena.models.device.getLocalModeSupport(device); +}) +``` + +* * * + +## getMACAddresses +balena.models.device.getMACAddresses(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the MAC addresses of a device +**Access**: public +**Fulfil**: String[] - mac addresses + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getMACAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(macAddresses) { + macAddresses.forEach(function(mac) { + console.log(mac); + }); +}); +``` +**Example** +```js +balena.models.device.getMACAddresses(123).then(function(macAddresses) { + macAddresses.forEach(function(mac) { + console.log(mac); + }); +}); +``` + +* * * + +## getMetrics +balena.models.device.getMetrics(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the metrics related information for a device +**Access**: public +**Fulfil**: Object - device metrics + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getMetrics('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceMetrics) { + console.log(deviceMetrics); +}); +``` +**Example** +```js +balena.models.device.getMetrics(123).then(function(deviceMetrics) { + console.log(deviceMetrics); +}); +``` + +* * * + +## getName +balena.models.device.getName(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the name of a device +**Access**: public +**Fulfil**: String - device name + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getName('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceName) { + console.log(deviceName); +}); +``` +**Example** +```js +balena.models.device.getName(123).then(function(deviceName) { + console.log(deviceName); +}); +``` + +* * * + +## getOsVersion +balena.models.device.getOsVersion(device) ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the OS version (version number and variant combined) running on a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
deviceObject

A device object

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device.os_version); // => 'balenaOS 2.26.0+rev1' + console.log(device.os_variant); // => 'prod' + balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod' +}) +``` + +* * * + +## getProgress +balena.models.device.getProgress(uuidOrId) ⇒ Promise + +Convenience method for getting the overall progress of a device. +It's recommended to use `balena.models.device.get()` instead, +in case that you need to retrieve more device fields than just the progress. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the progress of a device +**Access**: public +**Fulfil**: Number\|null - device progress +**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field. + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getProgress('7cf02a69e4d34c9da573914963cf54fd').then(function(progress) { + console.log(progress); +}); +``` +**Example** +```js +balena.models.device.getProgress(123).then(function(progress) { + console.log(progress); +}); +``` + +* * * + +## getStatus +balena.models.device.getStatus(uuidOrId) ⇒ Promise + +Convenience method for getting the overall status of a device. +It's recommended to use `balena.models.device.get()` instead, +in case that you need to retrieve more device fields than just the status. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the status of a device +**Access**: public +**Fulfil**: String - device status +**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field. + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getStatus('7cf02a69e4d34c9da573914963cf54fd').then(function(status) { + console.log(status); +}); +``` +**Example** +```js +balena.models.device.getStatus(123).then(function(status) { + console.log(status); +}); +``` + +* * * + +## getSupervisorState +balena.models.device.getSupervisorState(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the supervisor state on a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getSupervisorState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorState(123).then(function(state) { + console.log(state); +}); +``` + +* * * + +## getSupervisorTargetState +balena.models.device.getSupervisorTargetState(uuidOrId, version) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the target supervisor state on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
versionNumber

(optional) target state version (2 or 3), default to 2

+
+ +**Example** +```js +balena.models.device.getSupervisorTargetState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetState(123).then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetState(123, 3).then(function(state) { + console.log(state); +}); +``` + +* * * + +## getSupervisorTargetStateForApp +balena.models.device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the target supervisor state on a "generic" device on a fleet +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

fleet uuid (string) or id (number)

+
releaseString

(optional) release uuid (default tracked)

+
+ +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` + +* * * + +## getTargetReleaseHash +balena.models.device.getTargetReleaseHash(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the hash of the currently tracked release for a specific device +**Access**: public +**Fulfil**: String - The release hash of the currently tracked release + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd', function(release) { + console.log(release); +}); +``` + +* * * + +## getWithServiceDetails +balena.models.device.getWithServiceDetails(uuidOrId, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want more control, or to see the raw model +directly, use `device.get(uuidOrId, options)` instead. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a single device along with its associated services' details, +including their associated commit +**Access**: public +**Fulfil**: Object - device with service details + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getWithServiceDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.getWithServiceDetails(123).then(function(device) { + console.log(device); +}) +``` + +* * * + +## grantSupportAccess +balena.models.device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Grant support access to a device until a specified time +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
expiryTimestampNumber

a timestamp in ms for when the support access will expire

+
+ +**Example** +```js +balena.models.device.grantSupportAccess('7cf02a69e4d34c9da573914963cf54fd', Date.now() + 3600 * 1000); +``` +**Example** +```js +balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000); +``` + +* * * + +## has +balena.models.device.has(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device exists +**Access**: public +**Fulfil**: Boolean - has device + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.has('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDevice) { + console.log(hasDevice); +}); +``` +**Example** +```js +balena.models.device.has(123).then(function(hasDevice) { + console.log(hasDevice); +}); +``` + +* * * + +## hasDeviceUrl +balena.models.device.hasDeviceUrl(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device is web accessible with device utls +**Access**: public +**Fulfil**: Boolean - has device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.hasDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDeviceUrl) { + if (hasDeviceUrl) { + console.log('The device has device URL enabled'); + } +}); +``` +**Example** +```js +balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) { + if (hasDeviceUrl) { + console.log('The device has device URL enabled'); + } +}); +``` + +* * * + +## hasLockOverride +balena.models.device.hasLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device has the lock override enabled +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.hasLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.hasLockOverride(123); +``` + +* * * + +## identify +balena.models.device.identify(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Identify device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.identify('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.identify(123); +``` + +* * * + +## isInLocalMode +balena.models.device.isInLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if local mode is enabled on the device +**Access**: public +**Fulfil**: Boolean - has device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isInLocalMode('7cf02a69e4d34c9da573914963cf54fd').then(function(isInLocalMode) { + if (isInLocalMode) { + console.log('The device has local mode enabled'); + } +}); +``` +**Example** +```js +balena.models.device.isInLocalMode(123).then(function(isInLocalMode) { + if (isInLocalMode) { + console.log('The device has local mode enabled'); + } +}); +``` + +* * * + +## isOnline +balena.models.device.isOnline(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device is online +**Access**: public +**Fulfil**: Boolean - is device online + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isOnline('7cf02a69e4d34c9da573914963cf54fd').then(function(isOnline) { + console.log('Is device online?', isOnline); +}); +``` +**Example** +```js +balena.models.device.isOnline(123).then(function(isOnline) { + console.log('Is device online?', isOnline); +}); +``` + +* * * + +## isTrackingApplicationRelease +balena.models.device.isTrackingApplicationRelease(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get whether the device is configured to track the current application release +**Access**: public +**Fulfil**: Boolean - is tracking the current application release + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isTrackingApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## move +balena.models.device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Move a device to another application +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.move('7cf02a69e4d34c9da573914963cf54fd', 'myorganization/myapp'); +``` +**Example** +```js +balena.models.device.move(123, 'myorganization/myapp'); +``` +**Example** +```js +balena.models.device.move(123, 456); +``` + +* * * + +## ping +balena.models.device.ping(uuidOrId) ⇒ Promise + +This is useful to signal that the supervisor is alive and responding. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Ping a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.ping('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.ping(123); +``` + +* * * + +## pinToOsRelease +balena.models.device.pinToOsRelease(uuidOrIdOrArray, osVersionOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Mark a specific device to be updated to a particular OS release +**Access**: public +**Experimental**: + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
osVersionOrIdString

the raw version of a OS release (string) or id (number) +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number, a "prod" variant and greater than or equal to the one running on the device. +To resolve compatible update targets for a device use balena.models.os.getSupportedOsUpdateVersions.

+
+ +**Example** +```js +await balena.models.device.pinToOsRelease('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod'); +``` + +* * * + +## pinToRelease +balena.models.device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ Promise + +Configures the device to run a particular release +and not get updated when the current application release changes. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a specific device to run a particular release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
fullReleaseHashOrIdString | Number

the hash of a successful release (string) or id (number)

+
+ +**Example** +```js +balena.models.device.pinToRelease('7cf02a69e4d34c9da573914963cf54fd', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` + +* * * + +## pinToSupervisorRelease +balena.models.device.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ Promise + +Configures the device to run a particular supervisor release. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a specific device to run a particular supervisor release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
supervisorVersionOrIdString | Number

the raw version of a supervisor release (string) or id (number)

+
+ +**Example** +```js +balena.models.device.pinToSupervisorRelease('7cf02a69e4d34c9da573914963cf54fd', '10.8.0').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.pinToSupervisorRelease(123, '11.4.14').then(function() { + ... +}); +``` + +* * * + +## purge +balena.models.device.purge(uuidOrId) ⇒ Promise + +This function clears the user application's `/data` directory. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Purge device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.purge('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.purge(123); +``` + +* * * + +## reboot +balena.models.device.reboot(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Reboot device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.reboot('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.reboot(123); +``` + +* * * + +## register +balena.models.device.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Register a new device with a Balena application. +**Access**: public +**Fulfil**: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." }) + + + + + + + + + + + + + + +
ParamTypeDescription
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
uuidString

device uuid

+
[deviceTypeSlug]String

device type slug (string) or alias (string)

+
+ +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register(123, uuid).then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` + +* * * + +## remove +balena.models.device.remove(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Remove device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.remove('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.remove(123); +``` + +* * * + +## rename +balena.models.device.rename(uuidOrId, newName) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Rename device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
newNameString

the device new name

+
+ +**Example** +```js +balena.models.device.rename('7cf02a69e4d34c9da573914963cf54fd', 'NewName'); +``` +**Example** +```js +balena.models.device.rename(123, 'NewName'); +``` + +* * * + +## restartApplication +balena.models.device.restartApplication(uuidOrId) ⇒ Promise + +This function restarts the Docker container running +the application on the device, but doesn't reboot +the device itself. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Restart application on device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.restartApplication('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.restartApplication(123); +``` + +* * * + +## restartService +balena.models.device.restartService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Restart a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to restart

+
+ +**Example** +```js +balena.models.device.restartService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.restartService(1, 123).then(function() { + ... +}); +``` + +* * * + +## revokeSupportAccess +balena.models.device.revokeSupportAccess(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Revoke support access to a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.revokeSupportAccess('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.revokeSupportAccess(123); +``` + +* * * + +## setCustomLocation +balena.models.device.setCustomLocation(uuidOrIdOrArray, location) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a custom location for a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
locationObject

the location ({ latitude: 123, longitude: 456 })

+
+ +**Example** +```js +balena.models.device.setCustomLocation('7cf02a69e4d34c9da573914963cf54fd', { latitude: 123, longitude: 456 }); +``` +**Example** +```js +balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 }); +``` + +* * * + +## setNote +balena.models.device.setNote(uuidOrIdOrArray, note) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Note a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
noteString

the note

+
+ +**Example** +```js +balena.models.device.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); +``` +**Example** +```js +balena.models.device.setNote(123, 'My useful note'); +``` + +* * * + +## shutdown +balena.models.device.shutdown(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Shutdown device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.shutdown('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.shutdown(123); +``` + +* * * + +## startOsUpdate +balena.models.device.startOsUpdate(uuidOrUuids, targetOsVersion, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Start an OS update on a device +**Access**: public +**Fulfil**: Object - action response + + + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrUuidsString | Array.<String>

full device uuid or array of full uuids

+
targetOsVersionString

semver-compatible version for the target device +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number, a "prod" variant and greater than the one running on the device. +To resolve the semver-compatible range use balena.model.os.getMaxSatisfyingVersion.

+
[options]Object

options

+
[options.runDetached]Boolean

run the update in detached mode. True by default

+
+ +**Example** +```js +balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { + console.log(result.status); +}); +``` + +* * * + +## startService +balena.models.device.startService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Start a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to start

+
+ +**Example** +```js +balena.models.device.startService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.startService(1, 123).then(function() { + ... +}); +``` + +* * * + +## stopService +balena.models.device.stopService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Stop a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to stop

+
+ +**Example** +```js +balena.models.device.stopService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.stopService(1, 123).then(function() { + ... +}); +``` + +* * * + +## trackApplicationRelease +balena.models.device.trackApplicationRelease(uuidOrIdOrArray) ⇒ Promise + +The device's current release will be updated with each new successfully built release. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Configure a specific device to track the current application release +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.trackApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function() { + ... +}); +``` + +* * * + +## unsetCustomLocation +balena.models.device.unsetCustomLocation(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Clear the custom location of a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.unsetCustomLocation('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.unsetCustomLocation(123); +``` + +* * * + +## update +balena.models.device.update(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Trigger an update check on the supervisor +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.update('7cf02a69e4d34c9da573914963cf54fd', { + force: true +}); +``` +**Example** +```js +balena.models.device.update(123, { + force: true +}); +``` + +* * * + +## configVar +balena.models.device.configVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.configVar.get(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get the value of a specific config variable +**Access**: public +**Fulfil**: String\|undefined - the config variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.device.configVar.get('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get all device config variables by application +**Access**: public +**Fulfil**: Object[] - device config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.configVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.configVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get all config variables for a device +**Access**: public +**Fulfil**: Object[] - device config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.configVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.configVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.configVar.remove(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Clear the value of a specific config variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.device.configVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.configVar.set(uuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Set the value of a specific config variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
valueString

config variable value

+
+ +**Example** +```js +balena.models.device.configVar.set('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## envVar +balena.models.device.envVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.envVar.get(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get the value of a specific environment variable +**Access**: public +**Fulfil**: String\|undefined - the environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.device.envVar.get('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.envVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get all device environment variables by application +**Access**: public +**Fulfil**: Object[] - device environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.envVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.envVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get all environment variables for a device +**Access**: public +**Fulfil**: Object[] - device environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.envVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.envVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.envVar.remove(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Clear the value of a specific environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.device.envVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.envVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.envVar.set(uuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Set the value of a specific environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
valueString

environment variable value

+
+ +**Example** +```js +balena.models.device.envVar.set('7cf02a69e4d34c9da573914963cf54fd', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## history +balena.models.device.history : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### getAllByApplication +balena.models.device.history.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [history](#balena.models.device.history) +**Summary**: Get all device history entries by application with time frame +**Access**: public +**Fulfil**: Object[] - device history + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

+
[dateFilter.toDate]Date

history entries younger or equal to this date

+
[options]Object

extra pine options to use

+
+ +**Example** +```js +balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +balena.models.device.history.getAllByApplication(999999).then(function(entries) { + console.log(entries); +}); + + +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByApplication( + 999999, + { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10), + { $top: 10, $orderby: { id: 'desc' }} +}); +``` + +* * * + +### getAllByDevice +balena.models.device.history.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [history](#balena.models.device.history) +**Summary**: Get all history entries for a device +**Access**: public +**Fulfil**: Object[] - device history + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (32 / 62 digits string) or id (number)

+
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

+
[dateFilter.toDate]Date

history entries younger or equal to this date

+
[options]Object

extra pine options to use

+
+ +**Example** +```js +balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +balena.models.device.history.getAllByDevice(999999).then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByDevice( + 999999, + { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}, + { $top: 10, $orderby: { id: 'desc' }} +) +``` + +* * * + +## serviceVar +balena.models.device.serviceVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get the overriden value of a service variable on a device +**Access**: public +**Fulfil**: String\|undefined - the variable value (or undefined) + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
+ +**Example** +```js +balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.serviceVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get all device service variable overrides by application +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.serviceVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get all service variable overrides for a device +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.serviceVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Clear the overridden value of a service variable on a device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
+ +**Example** +```js +balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Set the overriden value of a service variable on a device +**Access**: public + + + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
valueString

variable value

+
+ +**Example** +```js +balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR', 'override').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR', 'override').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() { + ... +}); +``` + +* * * + +## tags +balena.models.device.tags : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### getAllByApplication +balena.models.device.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Get all device tags for an application +**Access**: public +**Fulfil**: Object[] - device tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.device.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.tags.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Get all device tags for a device +**Access**: public +**Fulfil**: Object[] - device tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.tags.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.device.tags.getAllByDevice(123).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.device.tags.remove(uuidOrId, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Remove a device tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.device.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); +``` + +* * * + +### set +balena.models.device.tags.set(uuidOrId, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Set a device tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.device.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.device.tags.set(123, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/deviceType.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/deviceType.md new file mode 100644 index 0000000000..d5057f98ff --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/deviceType.md @@ -0,0 +1,309 @@ +# deviceType +balena.models.deviceType : object + +**Kind**: static namespace + +* * * + +## get +balena.models.deviceType.get(idOrSlug, [options]) ⇒ Promise + +This method returns a single device type. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a single deviceType +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + + + +
ParamTypeDefaultDescription
idOrSlugString | Number

device type slug (string) or alias (string) or id

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.get('raspberry-pi').then(function(deviceType) { + console.log(deviceType); +}); +``` +**Example** +```js +balena.models.deviceType.get('raspberrypi').then(function(deviceType) { + console.log('resolved alias:', deviceType); +}); +``` + +* * * + +## getAll +balena.models.deviceType.getAll([options]) ⇒ Promise + +This method returns all device types. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get all deviceTypes +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.getAll().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` +**Example** +```js +balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) { + console.log(deviceTypes); +}) +``` + +* * * + +## getAllSupported +balena.models.deviceType.getAllSupported([options]) ⇒ Promise + +This method returns all supported device types. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get all supported deviceTypes +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.getAllSupported().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` +**Example** +```js +balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) { + console.log(deviceTypes); +}) +``` + +* * * + +## getBySlugOrName +balena.models.deviceType.getBySlugOrName(slugOrName) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a deviceType by slug or name +**Access**: public +**Fulfil**: Object - device type + + + + + + + + + + +
ParamTypeDescription
slugOrNameString

deviceType slug

+
+ +**Example** +```js +balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { + console.log(deviceType); +}); +``` + +* * * + +## getInstallMethod +balena.models.deviceType.getInstallMethod(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get installation method on a given device type +**Access**: public +**Fulfil**: String - the installation method supported for the given device type slug + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { + console.log(method); + // externalBoot +}); +``` + +* * * + +## getInstructions +balena.models.deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get instructions for installing a host OS on a given device type +**Access**: public +**Fulfil**: Object \| String[] - step by step instructions for installing the host OS to the device + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugOrContractString | Object

device type slug or contract

+
+ +**Example** +```js +balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { + for (let instruction of instructions.values()) { + console.log(instruction); + } + // Insert the sdcard to the host machine. + // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. + // Wait for writing of BalenaOS to complete. + // Remove the sdcard from the host machine. + // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). + // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. +}); +``` + +* * * + +## getInterpolatedPartials +balena.models.deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a contract with resolved partial templates +**Access**: public +**Fulfil**: Contract - device type contract with resolved partials + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { + for (const partial in contract.partials) { + console.log(`${partial}: ${contract.partials[partial]}`); + } + // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] +}); +``` + +* * * + +## getName +balena.models.deviceType.getName(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get display name for a device +**Access**: public +**Fulfil**: String - device display name + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { + console.log(deviceTypeName); + // Raspberry Pi +}); +``` + +* * * + +## getSlugByName +balena.models.deviceType.getSlugByName(deviceTypeName) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get device slug +**Access**: public +**Fulfil**: String - device slug name + + + + + + + + + + +
ParamTypeDescription
deviceTypeNameString

device type name

+
+ +**Example** +```js +balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { + console.log(deviceTypeSlug); + // raspberry-pi +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/image.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/image.md new file mode 100644 index 0000000000..7e3a9e6e82 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/image.md @@ -0,0 +1,68 @@ +# image +balena.models.image : object + +**Kind**: static namespace + +* * * + +## get +balena.models.image.get(id, [options]) ⇒ Promise + +**Kind**: static method of [image](#balena.models.image) +**Summary**: Get a specific image +**Access**: public +**Fulfil**: Object - image + + + + + + + + + + + + +
ParamTypeDefaultDescription
idNumber

image id

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.image.get(123).then(function(image) { + console.log(image); +}); +``` + +* * * + +## getLogs +balena.models.image.getLogs(id) ⇒ Promise + +**Kind**: static method of [image](#balena.models.image) +**Summary**: Get the logs for an image +**Access**: public +**Fulfil**: string \| null - logs + + + + + + + + + + +
ParamTypeDescription
idNumber

image id

+
+ +**Example** +```js +balena.models.image.getLogs(123).then(function(logs) { + console.log(logs); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/key.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/key.md new file mode 100644 index 0000000000..9d4db96169 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/key.md @@ -0,0 +1,123 @@ +# key +balena.models.key : object + +**Kind**: static namespace + +* * * + +## create +balena.models.key.create(title, key) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Create a ssh key +**Access**: public +**Fulfil**: Object - ssh key + + + + + + + + + + + + +
ParamTypeDescription
titleString

key title

+
keyString

the public ssh key

+
+ +**Example** +```js +balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) { + console.log(key); +}); +``` + +* * * + +## get +balena.models.key.get(id) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Get a single ssh key +**Access**: public +**Fulfil**: Object - ssh key + + + + + + + + + + +
ParamTypeDescription
idNumber

key id

+
+ +**Example** +```js +balena.models.key.get(51).then(function(key) { + console.log(key); +}); +``` + +* * * + +## getAll +balena.models.key.getAll([options]) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Get all ssh keys +**Access**: public +**Fulfil**: Object[] - ssh keys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.key.getAll().then(function(keys) { + console.log(keys); +}); +``` + +* * * + +## remove +balena.models.key.remove(id) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Remove ssh key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

key id

+
+ +**Example** +```js +balena.models.key.remove(51); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/organization.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/organization.md new file mode 100644 index 0000000000..e195cd08f6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/organization.md @@ -0,0 +1,521 @@ +# organization +balena.models.organization : object + +**Kind**: static namespace + +* * * + +## create +balena.models.organization.create(options) ⇒ Promise + +This method creates a new organization with the current user as an administrator. + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Creates a new organization +**Access**: public +**Fulfil**: String - Organization + + + + + + + + + + + + + + +
ParamTypeDescription
optionsObject

Organization parameters to use.

+
options.nameString

Required: the name of the organization that will be created.

+
[options.handle]String

The handle of the organization that will be created.

+
+ +**Example** +```js +balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) { + console.log(organization); +}); +``` +**Example** +```js +balena.models.organization.create({ + name:'MyOrganization', + logo_image: new File( + imageContent, + 'img.jpeg' + ); +}) +.then(function(organization) { + console.log(organization); +}); +``` + +* * * + +## get +balena.models.organization.get(handleOrId, [options]) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Get a single organization +**Access**: public +**Fulfil**: Object - organization + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.get('myorganization').then(function(organization) { + console.log(organization); +}); +``` +**Example** +```js +balena.models.organization.get(123).then(function(organization) { + console.log(organization); +}); +``` + +* * * + +## getAll +balena.models.organization.getAll([options]) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Get all Organizations +**Access**: public +**Fulfil**: Object[] - organizations + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.getAll().then(function(organizations) { + console.log(organizations); +}); +``` + +* * * + +## remove +balena.models.organization.remove(handleOrId) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Remove an Organization +**Access**: public + + + + + + + + + + +
ParamTypeDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
+ +**Example** +```js +balena.models.organization.remove(123); +``` + +* * * + +## invite +balena.models.organization.invite : object + +**Kind**: static namespace of [organization](#balena.models.organization) + +* * * + +### accept +balena.models.organization.invite.accept(invitationToken) ⇒ Promise + +This method adds the calling user to the organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Accepts an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
invitationTokenString

invite token

+
+ +**Example** +```js +balena.models.organization.invite.accept("qwerty-invitation-token"); +``` + +* * * + +### create +balena.models.organization.invite.create(handleOrId, options, [message]) ⇒ Promise + +This method invites a user by their email to an organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Creates a new invite for an organization +**Access**: public +**Fulfil**: String - organization invite + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

+
optionsObject

invite creation parameters

+
options.inviteeString

the email of the invitee

+
[options.roleName]String"developer"

the role name to be granted to the invitee

+
[message]String

the message to send along with the invite

+
+ +**Example** +```js +balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) { + console.log(invite); +}); +``` + +* * * + +### getAll +balena.models.organization.invite.getAll([options]) ⇒ Promise + +This method returns all invites. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Get all invites +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.invite.getAll().then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### getAllByOrganization +balena.models.organization.invite.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all invites for a specific organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Get all invites by organization +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) { + console.log(invites); +}); +``` +**Example** +```js +balena.models.organization.invite.getAllByOrganization(123).then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### revoke +balena.models.organization.invite.revoke(id) ⇒ Promise + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Revoke an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

organization invite id

+
+ +**Example** +```js +balena.models.organization.invite.revoke(123); +``` + +* * * + +## membership +balena.models.organization.membership : object + +**Kind**: static namespace of [organization](#balena.models.organization) + +* * * + +### changeRole +balena.models.organization.membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise + +This method changes the role of an organization member. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Changes the role of an organization member +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership that will be changed

+
roleNameString

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.organization.membership.changeRole(123, "member").then(function() { + console.log('OK'); +}); +``` +**Example** +```js +balena.models.organization.membership.changeRole({ + user: 123, + is_member_of__organization: 125, +}, "member").then(function() { + console.log('OK'); +}); +``` + +* * * + +### get +balena.models.organization.membership.get(membershipId, [options]) ⇒ Promise + +This method returns a single organization membership. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get a single organization membership +**Access**: public +**Fulfil**: Object - organization membership + + + + + + + + + + + + +
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.get(5).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByOrganization +balena.models.organization.membership.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all organization memberships for a specific organization. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get all memberships by organization +**Access**: public +**Fulfil**: Object[] - organization memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByUser +balena.models.organization.membership.getAllByUser(usernameOrId, [options]) ⇒ Promise + +This method returns all organization memberships for a specific user. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get all memberships by user +**Access**: public +**Fulfil**: Object[] - organization memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.organization.membership.getAllByUser(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### remove +balena.models.organization.membership.remove(id) ⇒ Promise + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Remove a membership +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

organization membership id

+
+ +**Example** +```js +balena.models.organization.membership.remove(123); +``` +**Example** +```js +balena.models.organization.membership.remove({ + user: 123, + is_member_of__application: 125, +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/os.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/os.md new file mode 100644 index 0000000000..e9e7ac87f6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/os.md @@ -0,0 +1,523 @@ +# os +balena.models.os : object + +**Kind**: static namespace + +* * * + +## download +balena.models.os.download(options) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Download an OS image +**Access**: public +**Fulfil**: ReadableStream - download stream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

OS image options to use.

+
options.deviceTypeString

device type slug

+
[options.version]String'latest'

semver-compatible version or 'latest', defaults to 'latest' +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number.

+
[options.developmentMode]Boolean

controls development mode for unified balenaOS releases.

+
[options.appId]Number

the application ID (number).

+
[options.fileType]String

download file type. One of '.img' or '.zip' or '.gz'.

+
[options.imageType]String

download file type. One of 'raw' or 'flasher'

+
[options.appUpdatePollInterval]Number

how often the OS checks for updates, in minutes.

+
[options.network]String

the network type that the device will use, one of 'ethernet' or 'wifi'.

+
[options.wifiKey]String

the key for the wifi network the device will connect to if network is wifi.

+
[options.wifiSsid]String

the ssid for the wifi network the device will connect to if network is wifi.

+
+ +**Example** +```js +balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) { + stream.pipe(fs.createWriteStream('foo/bar/image.img')); +}); +``` + +* * * + +## getAllOsVersions +balena.models.os.getAllOsVersions(deviceTypes, [options]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.os.getAllOsVersions('raspberrypi3'); +``` +**Example** +```js +balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']); +``` +**Example** +```js +balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } }); +``` + +* * * + +## getAvailableOsVersions +balena.models.os.getAvailableOsVersions(deviceTypes, [pineOptions], [extraOptions]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get the supported OS versions for the provided device type(s) +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

+
[pineOptions]Object

Extra pine options to use

+
[extraOptions]Object

Extra convenience options to use

+
[extraOptions.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

+
+ +**Example** +```js +balena.models.os.getAvailableOsVersions('raspberrypi3'); +``` +**Example** +```js +balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']); +``` + +* * * + +## getConfig +balena.models.os.getConfig(slugOrUuidOrId, options) ⇒ Promise + +Builds the config.json for a device in the given application, with the given +options. + +Note that an OS version is required. For versions < 2.7.8, config +generation is only supported when using a session token, not an API key. + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get an applications config.json +**Access**: public +**Fulfil**: Object - application configuration as a JSON object. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number).

+
optionsObject

OS configuration options to use.

+
options.versionString

Required: the OS version of the image.

+
[options.network]String'ethernet'

The network type that +the device will use, one of 'ethernet' or 'wifi'.

+
[options.appUpdatePollInterval]Number

How often the OS checks +for updates, in minutes.

+
[options.provisioningKeyName]String

Name assigned to API key

+
[options.provisioningKeyExpiryDate]String

Expiry Date assigned to API key

+
[options.developmentMode]Boolean

Controls development mode for unified balenaOS releases.

+
[options.wifiKey]String

The key for the wifi network the +device will connect to.

+
[options.wifiSsid]String

The ssid for the wifi network the +device will connect to.

+
[options.ip]String

static ip address.

+
[options.gateway]String

static ip gateway.

+
[options.netmask]String

static ip netmask.

+
+ +**Example** +```js +balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) { + fs.writeFile('foo/bar/config.json', JSON.stringify(config)); +}); + +balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) { + fs.writeFile('foo/bar/config.json', JSON.stringify(config)); +}); +``` + +* * * + +## getDownloadSize +balena.models.os.getDownloadSize(deviceType, [version]) ⇒ Promise + +**Note!** Currently only the raw (uncompressed) size is reported. + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get OS download size estimate +**Access**: public +**Fulfil**: Number - OS image download size, in bytes. + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
[version]String

semver-compatible version or 'latest', defaults to 'latest'. +The version must be the exact version number.

+
+ +**Example** +```js +balena.models.os.getDownloadSize('raspberry-pi').then(function(size) { + console.log('The OS download size for raspberry-pi', size); +}); +``` + +* * * + +## getMaxSatisfyingVersion +balena.models.os.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get the max OS version satisfying the given range +**Access**: public +**Fulfil**: String\|null - the version number, or `null` if no matching versions are found + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
versionOrRangeString

can be one of

+
    +
  • the exact version number, +in which case it is returned if the version is supported, +or null is returned otherwise,
  • +
  • a semver-compatible +range specification, in which case the most recent satisfying version is returned +if it exists, or null is returned,
  • +
  • 'latest' in which case the most recent version is returned, excluding pre-releases, +Defaults to 'latest'.
  • +
+
[osType]String

can be one of 'default', 'esr' or null to include all types

+
+ +**Example** +```js +balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) { + console.log(version); +}); +``` + +* * * + +## getOsUpdateType +balena.models.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 + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
targetVersionString

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); +}); +``` + +* * * + +## getSupervisorReleasesForCpuArchitecture +balena.models.os.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options]) ⇒ Promise.<String> + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns the Releases of the supervisor for the CPU Architecture +**Returns**: Promise.<String> - - An array of Release objects that can be used to manage a device as supervisors. +**Access**: public + + + + + + + + + + + + +
ParamTypeDefaultDescription
cpuArchitectureSlugOrIdString | Number

The slug (string) or id (number) for the CPU Architecture

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64'); + +const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( + 'aarch64', + { $filter: { raw_version: '12.11.0' } }, +); + +const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( + 'aarch64', + { + $select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'], + $expand: { + release_image: { + $select: 'id', + $expand: { + image: { + $select: 'is_stored_at__image_location', + }, + }, + }, + }, + $filter: { raw_version: '12.11.0' } + }, +); +``` + +* * * + +## getSupportedOsUpdateVersions +balena.models.os.getSupportedOsUpdateVersions(deviceType, currentVersion, [options]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns the supported OS update targets for the provided device type +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. +**Fulfil**: Object - the versions information, of the following structure: +* versions - an array of strings, +containing exact version numbers that OS update is supported +* recommended - the recommended version, i.e. the most recent version +that is _not_ pre-release, can be `null` +* current - the provided current version after normalization + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
[options]Object

Extra options to filter the OS releases by

+
[options.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

+
[options.osType]String | null

Can be one of 'default', 'esr' or null which includes all types

+
+ +**Example** +```js +balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) { + console.log(isSupported); +}); +``` + +* * * + +## isArchitectureCompatibleWith +balena.models.os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ Boolean + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns whether the specified OS architecture is compatible with the target architecture +**Returns**: Boolean - - Whether the specified OS architecture is capable of running +applications build for the target architecture +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
osArchitectureString

The OS's architecture as specified in its device type

+
applicationArchitectureString

The application's architecture as specified in its device type

+
+ +**Example** +```js +const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf'); +console.log(result1); + +const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64'); +console.log(result2); +``` + +* * * + +## isSupportedOsUpdate +balena.models.os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions +**Access**: public +**Fulfil**: Boolean - whether upgrading the OS to the target version is supported + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
targetVersionString

semver-compatible version for the target OS version

+
+ +**Example** +```js +balena.models.os.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) { + console.log(isSupported); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/release.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/release.md new file mode 100644 index 0000000000..d4e3a33717 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/release.md @@ -0,0 +1,853 @@ +# release +balena.models.release : object + +**Kind**: static namespace + +* * * + +## createFromUrl +balena.models.release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Create a new release built from the source in the provided url +**Access**: public +**Fulfil**: number - release ID + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
urlDeployOptionsObject

builder options

+
urlDeployOptions.urlString

a url with a tarball of the project to build

+
[urlDeployOptions.shouldFlatten]Booleantrue

Should be true when the tarball includes an extra root folder with all the content

+
+ +**Example** +```js +balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { + console.log(releaseId); +}); +``` +**Example** +```js +balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { + console.log(releaseId); +}); +``` + +* * * + +## finalize +balena.models.release.finalize(commitOrIdOrRawVersion) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Finalizes a draft release +**Access**: public +**Fulfil**: void + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
+ +**Example** +```js +balena.models.release.finalize(123).then(function() { + console.log('finalized!'); +}); +``` +**Example** +```js +balena.models.release.finalize('7cf02a69e4d34c9da573914963cf54fd').then(function() { + console.log('finalized!'); +}); +``` +**Example** +```js +balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log('finalized!'); +}); +``` + +* * * + +## get +balena.models.release.get(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get a specific release +**Access**: public +**Fulfil**: Object - release + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.get(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.get('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log(release); +}); +``` + +* * * + +## getAllByApplication +balena.models.release.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get all releases from an application +**Access**: public +**Fulfil**: Object[] - releases + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) { + console.log(releases); +}); +``` +**Example** +```js +balena.models.release.getAllByApplication(123).then(function(releases) { + console.log(releases); +}); +``` + +* * * + +## getLatestByApplication +balena.models.release.getLatestByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get the latest successful release for an application +**Access**: public +**Fulfil**: Object\|undefined - release + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) { + console.log(releases); +}); +``` +**Example** +```js +balena.models.release.getLatestByApplication(123).then(function(releases) { + console.log(releases); +}); +``` + +* * * + +## getWithImageDetails +balena.models.release.getWithImageDetails(commitOrIdOrRawVersion, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want significantly more control, or to see the +raw model directly, use `release.get(id, options)` instead. + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get a specific release with the details of the images built +**Access**: public +**Fulfil**: Object - release with image details + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

a map of extra pine options

+
[options.release]Boolean{}

extra pine options for releases

+
[options.image]Object{}

extra pine options for images

+
+ +**Example** +```js +balena.models.release.getWithImageDetails(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } }) +.then(function(release) { + console.log(release.images[0].build_log); +}); +``` + +* * * + +## setIsInvalidated +balena.models.release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Set the is_invalidated property of a release to true or false +**Access**: public +**Fulfil**: void + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
isInvalidatedBoolean

boolean value, true for invalidated, false for validated

+
+ +**Example** +```js +balena.models.release.setIsInvalidated(123, true).then(function() { + console.log('invalidated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', true).then(function() { + console.log('invalidated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log('invalidated!); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated(123, false).then(function() { + console.log('validated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', false).then(function() { + console.log('validated!'); +}); +``` + +* * * + +## setKnownIssueList +balena.models.release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Add a known issue list to a release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
knownIssueListOrNullString | null

the known issue list

+
+ +**Example** +```js +balena.models.release.setKnownIssueList('7cf02a69e4d34c9da573914963cf54fd', 'This is an issue'); +``` +**Example** +```js +balena.models.release.setKnownIssueList(123, 'This is an issue'); +``` +**Example** +```js +balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue'); +``` + +* * * + +## setNote +balena.models.release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Add a note to a release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
noteOrNullString | null

the note

+
+ +**Example** +```js +balena.models.release.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); +``` +**Example** +```js +balena.models.release.setNote(123, 'My useful note'); +``` +**Example** +```js +balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note'); +``` + +* * * + +## asset +balena.models.release.asset : object + +**Kind**: static namespace of [release](#balena.models.release) + +* * * + +### download +balena.models.release.asset.download(id) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Download a release asset +**Access**: public +**Fulfil**: NodeJS.ReadableStream - download stream + + + + + + + + + + +
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
+ +**Example** +```js +balena.models.release.asset.download(123).then(function(stream) { + stream.pipe(fs.createWriteStream('logo.png')); +}); +``` +**Example** +```js +balena.models.release.asset.download({ + asset_key: 'logo.png', + release: 123 +}).then(function(stream) { + stream.pipe(fs.createWriteStream('logo.png')); +}); +``` + +* * * + +### get +balena.models.release.asset.get(id, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Get a specific release asset +**Access**: public +**Fulfil**: Object - release asset + + + + + + + + + + + + +
ParamTypeDefaultDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.asset.get(123).then(function(asset) { + console.log(asset); +}); +``` +**Example** +```js +balena.models.release.asset.get({ + asset_key: 'logo.png', + release: 123 +}).then(function(asset) { + console.log(asset); +}); +``` + +* * * + +### getAllByRelease +balena.models.release.asset.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Get all release assets for a release +**Access**: public +**Fulfil**: Object[] - release assets + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.asset.getAllByRelease(123).then(function(assets) { + console.log(assets); +}); +``` +**Example** +```js +balena.models.release.asset.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(assets) { + console.log(assets); +}); +``` +**Example** +```js +balena.models.release.asset.getAllByRelease({ application: 456, raw_version: '1.2.3' }).then(function(assets) { + console.log(assets); +}); +``` + +* * * + +### remove +balena.models.release.asset.remove(id) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Remove a release asset +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
+ +**Example** +```js +balena.models.release.asset.remove(123); +``` +**Example** +```js +balena.models.release.asset.remove({ + asset_key: 'logo.png', + release: 123 +}); +``` + +* * * + +### upload +balena.models.release.asset.upload(uploadParams, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Upload a release asset +**Access**: public +**Fulfil**: Object - uploaded release asset + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uploadParamsObject

upload parameters

+
uploadParams.assetString | File

asset file path (string, Node.js only) or File object (Node.js & browser). For File objects, use new File([content], filename, {type: mimeType})

+
uploadParams.asset_keyString

unique key for the asset within the release

+
uploadParams.releaseNumber

release ID

+
[options]Object{}

upload options

+
[options.chunkSize]Number5242880

chunk size for multipart uploads (5MiB default)

+
[options.parallelUploads]Number5

number of parallel uploads for multipart

+
[options.overwrite]Booleanfalse

whether to overwrite existing asset

+
[options.onUploadProgress]function

callback for upload progress

+
+ +**Example** +```js +// Upload from file path (Node.js) +balena.models.release.asset.upload({ + asset: '/path/to/logo.png', + asset_key: 'logo.png', + release: 123 +}).then(function(asset) { + console.log('Asset uploaded:', asset); +}); +``` +**Example** +```js +// Upload with File API (Node.js and browser) +const content = Buffer.from('Hello, World!', 'utf-8'); +const file = new File([content], 'readme.txt', { type: 'text/plain' }); + +balena.models.release.asset.upload({ + asset: file, + asset_key: 'readme.txt', + release: 123 +}).then(function(asset) { + console.log('Asset uploaded:', asset); +}); +``` +**Example** +```js +// Upload large file with File API and progress tracking +const largeContent = new Uint8Array(10 * 1024 * 1024); // 10MB +const largeFile = new File([largeContent], 'data.bin', { type: 'application/octet-stream' }); + +balena.models.release.asset.upload({ + asset: largeFile, + asset_key: 'data.bin', + release: 123 +}, { + chunkSize: 5 * 1024 * 1024, // 5MB chunks + parallelUploads: 3, + onUploadProgress: function(progress) { + const percent = (progress.uploaded / progress.total * 100).toFixed(2); + console.log(`Upload progress: ${percent}%`); + } +}).then(function(asset) { + console.log('Large file uploaded:', asset); +}); +``` +**Example** +```js +// Browser: Upload file from input element +const fileInput = document.getElementById('fileInput'); +const file = fileInput.files[0]; // File object from input + +balena.models.release.asset.upload({ + asset: file, + asset_key: file.name, + release: 123 +}).then(function(asset) { + console.log('File uploaded from browser:', asset); +}); +``` +**Example** +```js +// Upload with overwrite option +balena.models.release.asset.upload({ + asset: '/path/to/logo.png', + asset_key: 'logo.png', + release: 123 +}, { + overwrite: true +}).then(function(asset) { + console.log('Asset uploaded/updated:', asset); +}); +``` + +* * * + +## tags +balena.models.release.tags : object + +**Kind**: static namespace of [release](#balena.models.release) + +* * * + +### getAllByApplication +balena.models.release.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Get all release tags for an application +**Access**: public +**Fulfil**: Object[] - release tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### getAllByRelease +balena.models.release.tags.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Get all release tags for a release +**Access**: public +**Fulfil**: Object[] - release tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.tags.getAllByRelease(123).then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.release.tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Remove a release tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.release.tags.remove(123, 'EDITOR'); +``` +**Example** +```js +balena.models.release.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); +``` +**Example** +```js +balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR'); +``` + +* * * + +### set +balena.models.release.tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Set a release tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.release.tags.set(123, 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.release.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/service.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/service.md new file mode 100644 index 0000000000..03d4f527e3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/service.md @@ -0,0 +1,243 @@ +# service +balena.models.service : object + +**Kind**: static namespace + +* * * + +## getAllByApplication +balena.models.service.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [service](#balena.models.service) +**Summary**: Get all services from an application +**Access**: public +**Fulfil**: Object[] - services + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) { + console.log(services); +}); +``` +**Example** +```js +balena.models.service.getAllByApplication(123).then(function(services) { + console.log(services); +}); +``` + +* * * + +## var +balena.models.service.var : object + +**Kind**: static namespace of [service](#balena.models.service) + +* * * + +### get +balena.models.service.var.get(serviceIdOrNaturalKey, key) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get the value of a specific service variable +**Access**: public +**Fulfil**: String\|undefined - the variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
+ +**Example** +```js +balena.models.service.var.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.service.var.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get all service variables by application +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.service.var.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByService +balena.models.service.var.getAllByService(serviceIdOrNaturalKey, [options]) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get all variables for a service +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.var.getAllByService(999999).then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.service.var.remove(serviceIdOrNaturalKey, key) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Clear the value of a specific service variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
+ +**Example** +```js +balena.models.service.var.remove(999999, 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.service.var.set(serviceIdOrNaturalKey, key, value) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Set the value of a specific service variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
valueString

variable value

+
+ +**Example** +```js +balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/models/team.md b/pages/external-docs/sdk/node-sdk/v20.9.1/models/team.md new file mode 100644 index 0000000000..882fd8c89b --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/models/team.md @@ -0,0 +1,313 @@ +# team +balena.models.team : object + +**Kind**: static namespace + +* * * + +## create +balena.models.team.create(organizationSlugOrId, name) ⇒ Promise + +This method creates a new team. + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Creates a new Team +**Access**: public +**Fulfil**: Object - Team + + + + + + + + + + + + +
ParamTypeDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team will be part of.

+
nameString

Required: the name of the team that will be created.

+
+ +**Example** +```js +balena.models.team.create(1239948, 'MyTeam').then(function(team) { + console.log(team); +}); +``` +**Example** +```js +balena.models.team.create('myOrgHandle', 'MyTeam') +.then(function(team) { + console.log(team); +}); +``` + +* * * + +## get +balena.models.team.get(teamId, [options]) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Get a single Team +**Access**: public +**Fulfil**: Object - Team + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamIdNumber

team id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.get(123).then(function(team) { + console.log(team); +}); +``` + +* * * + +## getAllByOrganization +balena.models.team.getAllByOrganization(organizationSlugOrId, [options]) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Get all Teams of a specific Organization +**Access**: public +**Fulfil**: Object[] - Teams + + + + + + + + + + + + +
ParamTypeDefaultDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team is part of.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.getAllByOrganization(123).then(function(teams) { + console.log(teams); +}); +``` +**Example** +```js +balena.models.team.getAllByOrganization('MyOrganizationHandle').then(function(teams) { + console.log(teams); +}); +``` + +* * * + +## remove +balena.models.team.remove(teamId) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Remove a Team +**Access**: public + + + + + + + + + + +
ParamTypeDescription
teamIdNumber

team id (number).

+
+ +**Example** +```js +balena.models.team.remove(123); +``` + +* * * + +## rename +balena.models.team.rename(teamId, newName) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Rename Team +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
teamIdNumber

team id (number)

+
newNameString

new team name (string)

+
+ +**Example** +```js +balena.models.team.rename(123, 'MyNewTeamName'); +``` + +* * * + +## applicationAccess +balena.models.team.applicationAccess : object + +**Kind**: static namespace of [team](#balena.models.team) + +* * * + +### get +balena.models.team.applicationAccess.get(teamApplicationAccessId, [options]) ⇒ Promise + +This method get specific team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Get team applications access +**Access**: public +**Fulfil**: Object - TeamApplicationAccess + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.applicationAccess.get(1239948).then(function(teamApplicationAccess) { + console.log(teamApplicationAccess); +}); +``` + +* * * + +### getAllByTeam +balena.models.team.applicationAccess.getAllByTeam(teamId, [options]) ⇒ Promise + +This method get all team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Get all team applications access +**Access**: public +**Fulfil**: Object[] - team application access + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamIdNumber

Required: the team id.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.applicationAccess.getAllByTeam(1239948).then(function(teamApplicationAccesses) { + console.log(teamApplicationAccesses); +}); +``` + +* * * + +### remove +balena.models.team.applicationAccess.remove(teamApplicationAccessId) ⇒ Promise + +This remove a team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Remove team application access +**Access**: public +**Fulfil**: void + + + + + + + + + + +
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
+ +**Example** +```js +balena.models.team.remove(123).then(function(teams) { + console.log(teams); +}); +``` + +* * * + +### update +balena.models.team.applicationAccess.update(teamApplicationAccessId, roleName) ⇒ Promise + +This method update a team application access role. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Update team application access +**Access**: public +**Fulfil**: Object - TeamApplicationAccess + + + + + + + + + + + + +
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
roleNameString

Required: The new role to assing (ApplicationMembershipRoles).

+
+ +**Example** +```js +balena.models.team.update(123, 'developer').then(function(teamApplicationAccess) { + console.log(teamApplicationAccess); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/pine.md b/pages/external-docs/sdk/node-sdk/v20.9.1/pine.md new file mode 100644 index 0000000000..edb6c4bdfc --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/pine.md @@ -0,0 +1,25 @@ +# pine +balena.pine : Object + +The pinejs-client instance used internally. This should not be necessary +in normal usage, but can be useful if you want to directly make pine +queries to the api for some resource that isn't directly supported +in the SDK. + +**Kind**: static member +**Summary**: Balena pine instance +**Access**: public +**Example** +```js +balena.pine.get({ + resource: 'release', + options: { + $count: { + $filter: { belongs_to__application: applicationId } + } + } +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/request.md b/pages/external-docs/sdk/node-sdk/v20.9.1/request.md new file mode 100644 index 0000000000..0ba55a90d6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/request.md @@ -0,0 +1,17 @@ +# request +balena.request : Object + +The balena-request instance used internally. This should not be necessary +in normal usage, but can be useful if you want to make an API request directly, +using the same token and hooks as the SDK. + +**Kind**: static member +**Summary**: Balena request instance +**Access**: public +**Example** +```js +balena.request.send({ url: 'http://api.balena-cloud.com/ping' }); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/setSharedOptions.md b/pages/external-docs/sdk/node-sdk/v20.9.1/setSharedOptions.md new file mode 100644 index 0000000000..f2e444fc97 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/setSharedOptions.md @@ -0,0 +1,68 @@ +# setSharedOptions +module:balena-sdk~setSharedOptions(options) + +Set options that are used by calls to `fromSharedOptions()`. +The options accepted are the same as those used in the main SDK factory function. +If you use this method, it should be called as soon as possible during app +startup and before any calls to `fromSharedOptions()` are made. + +**Kind**: inner function +**Summary**: Set shared default options +**Access**: public + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

The shared default options

+
[options.apiUrl]String'https://api.balena-cloud.com/'

the balena API url to use.

+
[options.builderUrl]String'https://builder.balena-cloud.com/'

the balena builder url to use.

+
[options.deviceUrlsBase]String'balena-devices.com'

the base balena device API url to use.

+
[options.requestLimit]Number

the number of requests per requestLimitInterval that the SDK should respect.

+
[options.requestLimitInterval]Number60000

the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute).

+
[options.retryRateLimitedRequests]Boolean | functionfalse

Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header.

+
    +
  • If false, rate-limited requests will not be retried, and the rate limit error will be propagated.
  • +
  • If true, all rate-limited requests will be retried after the duration specified by the Retry-After header.
  • +
  • If a function (retryAfterMs: number) => boolean is provided, it will be called with the retry duration in ms and the request will be retried only when true is returned.
  • +
+
[options.dataDirectory]String | False'$HOME/.balena'

ignored in the browser unless false, the directory where the user settings are stored, normally retrieved like require('balena-settings-client').get('dataDirectory'). Providing false creates an isolated in-memory instance.

+
[options.isBrowser]Boolean

the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global window value.

+
[options.debug]Boolean

when set will print some extra debug information.

+
+ +**Example** +```js +import { setSharedOptions } from 'balena-sdk'; +setSharedOptions({ + apiUrl: 'https://api.balena-cloud.com/', + builderUrl: 'https://builder.balena-cloud.com/', + isBrowser: true, +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/settings.md b/pages/external-docs/sdk/node-sdk/v20.9.1/settings.md new file mode 100644 index 0000000000..1bbc80552d --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/settings.md @@ -0,0 +1,52 @@ +# settings +balena.settings : object + +**Kind**: static namespace + +* * * + +## get +balena.settings.get([key]) ⇒ Promise + +**Kind**: static method of [settings](#balena.settings) +**Summary**: Get a single setting. **Only implemented in Node.js** +**Access**: public +**Fulfil**: \* - setting value + + + + + + + + + + +
ParamTypeDescription
[key]String

setting key

+
+ +**Example** +```js +balena.settings.get('apiUrl').then(function(apiUrl) { + console.log(apiUrl); +}); +``` + +* * * + +## getAll +balena.settings.getAll() ⇒ Promise + +**Kind**: static method of [settings](#balena.settings) +**Summary**: Get all settings **Only implemented in Node.js** +**Access**: public +**Fulfil**: Object - settings +**Example** +```js +balena.settings.getAll().then(function(settings) { + console.log(settings); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v20.9.1/utils.md b/pages/external-docs/sdk/node-sdk/v20.9.1/utils.md new file mode 100644 index 0000000000..c8a5d1720c --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v20.9.1/utils.md @@ -0,0 +1,18 @@ +# utils +balena.utils : Object + +The utils instance offers some convenient features for clients. + +**Kind**: static member +**Summary**: Balena utils instance +**Access**: public +**Example** +```js +balena.utils.mergePineOptions( + { $expand: { device: { $select: ['id'] } } }, + { $expand: { device: { $select: ['name'] } } }, +); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4.md b/pages/external-docs/sdk/node-sdk/v21.7.4.md deleted file mode 100644 index 9854e63e8d..0000000000 --- a/pages/external-docs/sdk/node-sdk/v21.7.4.md +++ /dev/null @@ -1,7199 +0,0 @@ - -## Installation - -Install the balena SDK by running: - -```sh -$ npm install --save balena-sdk -``` - -### Bundling for browsers - -If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. - -If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: - -* fs -* path -* balena-settings-client -* node-localstorage - -### Bundling with pkg - -The balena SDK includes builds for various ECMAScript versions that are -dynamically selected at runtime (using -[@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). -For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not -able to automatically detect which assets to include in the output package. The -following sample `pkg` section should be added to your application's -`package.json` file to instruct `pkg` to bundle the required assets: - -```json - "pkg": { - "scripts": [ - "node_modules/balena-sdk/**/*.js" - ], - "assets": [ - "node_modules/pinejs-client-core/**/*" - ] - } -``` - -For more information, please refer to the respective -[documentation from the `pkg` project](https://github.com/vercel/pkg#config). - -## Trying balenaSDK in the browser - -BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. -To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries. - -![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png) - - -If you feel something is missing, not clear or could be improved, please don't hesitate to open an -[issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help. - - -## Modules - -
-
balena-sdk
-
-
- -## Objects - -
-
balena : object
-
-
- -## Functions - -
-
listImagesFromTargetState(targetState)
-
-
- - - -## balena-sdk - -* [balena-sdk](#module_balena-sdk) - * [~getSdk()](#module_balena-sdk..getSdk) - * [~setSharedOptions(options)](#module_balena-sdk..setSharedOptions) - * [~fromSharedOptions()](#module_balena-sdk..fromSharedOptions) - - - -### balena-sdk~getSdk() -The module exports a single factory function. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Creates a new SDK instance using the default or the provided options. -**Example** -```js -// with es6 imports -import { getSdk } from 'balena-sdk'; -// or with node require -const { getSdk } = require('balena-sdk'); - -const balena = getSdk({ - apiUrl: "https://api.balena-cloud.com/", - dataDirectory: "/opt/local/balena" -}); -``` - - -### balena-sdk~setSharedOptions(options) -Set options that are used by calls to `fromSharedOptions()`. -The options accepted are the same as those used in the main SDK factory function. -If you use this method, it should be called as soon as possible during app -startup and before any calls to `fromSharedOptions()` are made. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Set shared default options -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | The shared default options | -| [options.apiUrl] | String | 'https://api.balena-cloud.com/' | the balena API url to use. | -| [options.builderUrl] | String | 'https://builder.balena-cloud.com/' | the balena builder url to use. | -| [options.deviceUrlsBase] | String | 'balena-devices.com' | the base balena device API url to use. | -| [options.requestLimit] | Number | | the number of requests per requestLimitInterval that the SDK should respect. | -| [options.requestLimitInterval] | Number | 60000 | the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute). | -| [options.retryRateLimitedRequests] | Boolean \| function | false | Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header. - If `false`, rate-limited requests will not be retried, and the rate limit error will be propagated. - If `true`, all rate-limited requests will be retried after the duration specified by the `Retry-After` header. - If a function `(retryAfterMs: number) => boolean` is provided, it will be called with the retry duration in ms and the request will be retried only when `true` is returned. | -| [options.dataDirectory] | String \| False | '$HOME/.balena' | *ignored in the browser unless false*, the directory where the user settings are stored, normally retrieved like `require('balena-settings-client').get('dataDirectory')`. Providing `false` creates an isolated in-memory instance. | -| [options.isBrowser] | Boolean | | the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global `window` value. | -| [options.debug] | Boolean | | when set will print some extra debug information. | - -**Example** -```js -import { setSharedOptions } from 'balena-sdk'; -setSharedOptions({ - apiUrl: 'https://api.balena-cloud.com/', - builderUrl: 'https://builder.balena-cloud.com/', - isBrowser: true, -}); -``` - - -### balena-sdk~fromSharedOptions() -Create an SDK instance using shared default options set using the `setSharedOptions()` method. -If options have not been set using this method, then this method will use the -same defaults as the main SDK factory function. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Create an SDK instance using shared default options -**Access**: public -**Example** -```js -import { fromSharedOptions } from 'balena-sdk'; -const sdk = fromSharedOptions(); -``` - - -## balena : object -**Kind**: global namespace - -* [balena](#balena) : object - * [.interceptors](#balena.interceptors) : Array.<Interceptor> - * [.Interceptor](#balena.interceptors.Interceptor) : object - * [.utils](#balena.utils) : Object - * [.request](#balena.request) : Object - * [.pine](#balena.pine) : Object - * [.errors](#balena.errors) : Object - * [.models](#balena.models) : object - * [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.team](#balena.models.team) : object - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - * [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.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> - * [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - * [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - * [.auth](#balena.auth) : object - * [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.whoami()](#balena.auth.whoami) ⇒ Promise - * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ Promise - * [.login(credentials)](#balena.auth.login) ⇒ Promise - * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ Promise - * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ Promise - * [.getToken()](#balena.auth.getToken) ⇒ Promise - * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ Promise - * [.getActorId()](#balena.auth.getActorId) ⇒ Promise - * [.logout()](#balena.auth.logout) ⇒ Promise - * [.register(credentials)](#balena.auth.register) ⇒ Promise - * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ Promise - * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ Promise - * [.logs](#balena.logs) : object - * [.subscribe(uuidOrId, [options])](#balena.logs.subscribe) ⇒ Promise.<LogSubscription> - * [.history(uuidOrId, [options])](#balena.logs.history) ⇒ Promise - * [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - * [.settings](#balena.settings) : object - * [.get([key])](#balena.settings.get) ⇒ Promise - * [.getAll()](#balena.settings.getAll) ⇒ Promise - * [.utils](#balena.utils) : object - - - -### balena.interceptors : Array.<Interceptor> -The current array of interceptors to use. Interceptors intercept requests made -internally and are executed in the order they appear in this array for requests, -and in the reverse order for responses. - -**Kind**: static property of [balena](#balena) -**Summary**: Array of interceptors -**Access**: public -**Example** -```js -balena.interceptors.push({ - responseError: function (error) { - console.log(error); - throw error; - }) -}); -``` - - -#### interceptors.Interceptor : object -An interceptor implements some set of the four interception hook callbacks. -To continue processing, each function should return a value or a promise that -successfully resolves to a value. - -To halt processing, each function should throw an error or return a promise that -rejects with an error. - -**Kind**: static typedef of [interceptors](#balena.interceptors) -**Properties** - -| Name | Type | Description | -| --- | --- | --- | -| [request] | function | Callback invoked before requests are made. Called with the request options, should return (or resolve to) new request options, or throw/reject. | -| [response] | function | Callback invoked before responses are returned. Called with the response, should return (or resolve to) a new response, or throw/reject. | -| [requestError] | function | Callback invoked if an error happens before a request. Called with the error itself, caused by a preceeding request interceptor rejecting/throwing an error for the request, or a failing in preflight token validation. Should return (or resolve to) new request options, or throw/reject. | -| [responseError] | function | Callback invoked if an error happens in the response. Called with the error itself, caused by a preceeding response interceptor rejecting/throwing an error for the request, a network error, or an error response from the server. Should return (or resolve to) a new response, or throw/reject. | - - - -### balena.utils : Object -The utils instance offers some convenient features for clients. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena utils instance -**Access**: public -**Example** -```js -balena.utils.mergePineOptions( - { $expand: { device: { $select: ['id'] } } }, - { $expand: { device: { $select: ['name'] } } }, -); -``` -**Example** -```js -// Creating a new WebResourceFile in case 'File' API is not available. -new balena.utils.BalenaWebResourceFile( - [fs.readFileSync('./file.tgz')], - 'file.tgz' -); -``` - - -### balena.request : Object -The balena-request instance used internally. This should not be necessary -in normal usage, but can be useful if you want to make an API request directly, -using the same token and hooks as the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena request instance -**Access**: public -**Example** -```js -balena.request.send({ url: 'http://api.balena-cloud.com/ping' }); -``` - - -### balena.pine : Object -The pinejs-client instance used internally. This should not be necessary -in normal usage, but can be useful if you want to directly make pine -queries to the api for some resource that isn't directly supported -in the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena pine instance -**Access**: public -**Example** -```js -balena.pine.get({ - resource: 'release', - options: { - $count: { - $filter: { belongs_to__application: applicationId } - } - } -}); -``` - - -### balena.errors : Object -The balena-errors module used internally. This is provided primarily for -convenience, and to avoid the necessity for separate balena-errors -dependencies. You'll want to use this if you need to match on the specific -type of error thrown by the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena errors module -**Access**: public -**Example** -```js -balena.models.device.get(123).catch(function (error) { - if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) { - ... - } else if (error.code === balena.errors.BalenaRequestError.prototype.code) { - ... - } -}); -``` - - -### balena.models : object -**Kind**: static namespace of [balena](#balena) - -* [.models](#balena.models) : object - * [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.team](#balena.models.team) : object - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - * [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.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> - * [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - * [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - - - -#### models.application : object -**Kind**: static namespace of [models](#balena.models) - -* [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - - - -##### application.tags : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Get all application tags for an application -**Access**: public -**Fulfil**: Object[] - application tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.application.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(slugOrUuidOrId, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Set an application tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.application.tags.set(123, 'EDITOR', 'vim'); -``` - - -###### tags.remove(slugOrUuidOrId, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Remove an application tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| tagKey | String | tag key | - -**Example** -```js -balena.models.application.tags.remove('myorganization/myapp', 'EDITOR'); -``` - - -##### application.configVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - - - -###### configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Get all config variables for an application -**Access**: public -**Fulfil**: Object[] - application config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.configVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Get the value of a specific config variable -**Access**: public -**Fulfil**: String\|undefined - the config variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` - - -###### configVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Set the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | -| value | String | config variable value | - -**Example** -```js -balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### configVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Clear the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() { - ... -}); -``` - - -##### application.envVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - - - -###### envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Get all environment variables for an application -**Access**: public -**Fulfil**: Object[] - application environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.envVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Get the value of a specific environment variable -**Access**: public -**Fulfil**: String\|undefined - the environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.envVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### envVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Set the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | -| value | String | environment variable value | - -**Example** -```js -balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### envVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Clear the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.envVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### application.buildVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - - - -###### buildVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Get all build environment variables for an application -**Access**: public -**Fulfil**: Object[] - application build environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### buildVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Get the value of a specific build environment variable -**Access**: public -**Fulfil**: String\|undefined - the build environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | - -**Example** -```js -balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.buildVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### buildVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Set the value of a specific build environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | -| value | String | build environment variable value | - -**Example** -```js -balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### buildVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Clear the value of a specific build environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | - -**Example** -```js -balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.buildVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### application.membership : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - - - -###### membership.get(membershipId, [options]) ⇒ Promise -This method returns a single application membership. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get a single application membership -**Access**: public -**Fulfil**: Object - application membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| membershipId | number \| Object | | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.get(5).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all application memberships for a specific application. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get all memberships by application -**Access**: public -**Fulfil**: Object[] - application memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.application.membership.getAllByApplication(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByUser(usernameOrId, [options]) ⇒ Promise -This method returns all application memberships for a specific user. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get all memberships by user -**Access**: public -**Fulfil**: Object[] - application memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| usernameOrId | String \| Number | | the user's username (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.application.membership.getAllByUser(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.create(options) ⇒ Promise -This method adds a user to an application by their username if they are a member of the organization. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Creates a new membership for an application -**Access**: public -**Fulfil**: Object - application membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | membership creation parameters | -| options.application | String \| Number | | application handle (string), or id (number) | -| options.username | String | | the username of the balena user that will become a member | -| [options.roleName] | String | "member" | the role name to be granted to the membership | - -**Example** -```js -balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { - console.log(membership); -}); -``` - - -###### membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise -This method changes the role of an application member. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Changes the role of an application member -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be changed | -| roleName | String | the role name to be granted to the membership | - -**Example** -```js -balena.models.application.membership.changeRole(123, "member").then(function() { - console.log('OK'); -}); -``` -**Example** -```js -balena.models.application.membership.changeRole({ - user: 123, - is_member_of__application: 125, -}, "member").then(function() { - console.log('OK'); -}); -``` - - -###### membership.remove(idOrUniqueKey) ⇒ Promise -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Remove a membership -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be removed | - -**Example** -```js -balena.models.application.membership.remove(123); -``` -**Example** -```js -balena.models.application.membership.remove({ - user: 123, - is_member_of__application: 125, -}); -``` - - -##### application.invite : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - - - -###### invite.getAll([options]) ⇒ Promise -This method returns all invites. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Get all invites -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.invite.getAll().then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all invites for a specific application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Get all invites by application -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) { - console.log(invites); -}); -``` -**Example** -```js -balena.models.application.invite.getAllByApplication(123).then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.create(slugOrUuidOrId, options, [message]) ⇒ Promise -This method invites a user by their email to an application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Creates a new invite for an application -**Access**: public -**Fulfil**: String - application invite - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| options | Object | | invite creation parameters | -| options.invitee | String | | the email of the invitee | -| [options.roleName] | String | "developer" | the role name to be granted to the invitee | -| [message] | String | | the message to send along with the invite | - -**Example** -```js -balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) { - console.log(invite); -}); -``` - - -###### invite.revoke(id) ⇒ Promise -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Revoke an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | application invite id | - -**Example** -```js -balena.models.application.invite.revoke(123); -``` - - -###### invite.accept(invitationToken) ⇒ Promise -This method adds the calling user to the application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Accepts an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| invitationToken | String | invite token | - -**Example** -```js -balena.models.application.invite.accept("qwerty-invitation-token"); -``` - - -##### application.getDashboardUrl(id) ⇒ String -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get Dashboard URL for a specific application -**Returns**: String - - Dashboard URL for the specific application -**Throws**: - -- Exception if the id is not a finite number - - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | Application id | - -**Example** -```js -balena.models.application.get('myorganization/myapp').then(function(application) { - const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); - console.log(dashboardApplicationUrl); -}); -``` - - -##### application.getAll([options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.getAll().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.getAllDirectlyAccessible([options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications directly accessible by the user -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getAllDirectlyAccessible().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.getAllByOrganization(orgHandleOrId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications of an organization -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| orgHandleOrId | Number \| String | | organization handle (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getAllByOrganization().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.get(slugOrUuidOrId, [options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.get('myorganization/myapp').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.get(123).then(function(application) { - console.log(application); -}); -``` - - -##### application.getDirectlyAccessible(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application directly accessible by the user -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.getDirectlyAccessible(123).then(function(application) { - console.log(application); -}); -``` - - -##### application.getWithDeviceServiceDetails(slugOrUuidOrId, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want more control, or to see the raw model -directly, use `application.get(uuidOrId, options)` instead. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application and its devices, along with each device's -associated services' essential details -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.application.getWithDeviceServiceDetails(123).then(function(device) { - console.log(device); -}) -``` - - -##### application.getAppByName(appName, [options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application using the appname and the handle of the owning organization -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appName | String | | application name | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.getAppByName('MyApp').then(function(application) { - console.log(application); -}); -``` - - -##### application.has(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Check if an application exists -**Access**: public -**Fulfil**: Boolean - has application - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.has('myorganization/myapp').then(function(hasApp) { - console.log(hasApp); -}); -``` -**Example** -```js -balena.models.application.has(123).then(function(hasApp) { - console.log(hasApp); -}); -``` - - -##### application.hasAny() ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Check if the user has access to any applications -**Access**: public -**Fulfil**: Boolean - has any applications -**Example** -```js -balena.models.application.hasAny().then(function(hasAny) { - console.log('Has any?', hasAny); -}); -``` - - -##### application.create(options) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Create an application -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Description | -| --- | --- | --- | -| options | Object | application creation parameters | -| options.name | String | application name | -| [options.uuid] | String | application uuid | -| [options.applicationClass] | String | application class: 'app' | 'fleet' | 'block' | -| options.deviceType | String | device type slug | -| options.organization | String \| Number | handle (string) or id (number) of the organization that the application will belong to or null | - -**Example** -```js -balena.models.application.create({ name: 'My App', deviceType: 'raspberry-pi' }).then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.create({ name: 'My Block', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.create({ name: 'My App', deviceType: 'raspberry-pi', parent: 'ParentApp' }).then(function(application) { - console.log(application); -}); -``` - - -##### application.remove(slugOrUuidOrIdOrIds) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Remove application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrIdOrIds | String \| Number \| Array.<Number> | application slug (string), uuid (string) or id (number) or array of ids | - -**Example** -```js -balena.models.application.remove('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.remove(123); -``` - - -##### application.rename(slugOrUuidOrId, newName) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Rename application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| newName | String | new application name (string) | - -**Example** -```js -balena.models.application.rename('myorganization/myapp', 'MyRenamedApp'); -``` -**Example** -```js -balena.models.application.rename(123, 'MyRenamedApp'); -``` - - -##### application.restart(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Restart application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.restart('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.restart(123); -``` - - -##### application.generateProvisioningKey(generateProvisioningKeyParams) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Generate a device provisioning key for a specific application -**Access**: public -**Fulfil**: String - device provisioning key - -| Param | Type | Description | -| --- | --- | --- | -| generateProvisioningKeyParams | Object | an object containing the parameters for the provisioning key generation | -| generateProvisioningKeyParams.slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| generateProvisioningKeyParams.keyExpiryDate | String | Expiry Date for provisioning key | -| [generateProvisioningKeyParams.keyName] | String | Provisioning key name | -| [generateProvisioningKeyParams.keyDescription] | String | Description for provisioning key | - -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 'myorganization/myapp', keyExpiryDate: '2030-10-12'}).then(function(key) { - console.log(key); -}); -``` -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12'}).then(function(key) { - console.log(key); -}); -``` -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12', keyName: 'api key name', keyDescription: 'api key long description'}).then(function(key) { - console.log(key); -}); -``` - - -##### application.purge(appId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Purge devices by application id -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| appId | Number | application id | - -**Example** -```js -balena.models.application.purge(123); -``` - - -##### application.shutdown(appId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Shutdown devices by application id -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appId | Number | | application id | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.application.shutdown(123); -``` - - -##### application.reboot(appId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Reboot devices by application id -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appId | Number | | application id | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.application.reboot(123); -``` - - -##### application.willTrackNewReleases(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get whether the application is configured to receive updates whenever a new release is available -**Access**: public -**Fulfil**: Boolean - is tracking the latest release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) { - console.log(isEnabled); -}); -``` -**Example** -```js -balena.models.application.willTrackNewReleases(123).then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates -**Access**: public -**Fulfil**: Boolean - is tracking the latest release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) { - console.log(isEnabled); -}); -``` -**Example** -```js -balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ Promise -Configures the application to run a particular release -and not get updated when the latest release changes. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Set a specific application to run a particular release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| fullReleaseHash | String | the hash of a successful release (string) | - -**Example** -```js -balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` - - -##### application.getTargetReleaseHash(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get the hash of the current release for a specific application -**Access**: public -**Fulfil**: String\|undefined - The release hash of the current release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.application.getTargetReleaseHash(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) { - console.log(release); -}); -``` - - -##### application.trackLatestRelease(slugOrUuidOrId) ⇒ Promise -The application's current release will be updated with each new successfully built release. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Configure a specific application to track the latest finalized available release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.trackLatestRelease('myorganization/myapp').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.trackLatestRelease(123).then(function() { - ... -}); -``` - - -##### application.enableDeviceUrls(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Enable device urls for all devices that belong to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.enableDeviceUrls('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.enableDeviceUrls(123); -``` - - -##### application.disableDeviceUrls(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Disable device urls for all devices that belong to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.disableDeviceUrls('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.disableDeviceUrls(123); -``` - - -##### application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Grant support access to an application until a specified time -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| expiryTimestamp | Number | a timestamp in ms for when the support access will expire | - -**Example** -```js -balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000); -``` -**Example** -```js -balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000); -``` - - -##### application.revokeSupportAccess(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Revoke support access to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.revokeSupportAccess('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.revokeSupportAccess(123); -``` - - -#### models.device : object -**Kind**: static namespace of [models](#balena.models) - -* [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * [.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - - - -##### device.tags : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Get all device tags for an application -**Access**: public -**Fulfil**: Object[] - device tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.device.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Get all device tags for a device -**Access**: public -**Fulfil**: Object[] - device tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.tags.getAllByDevice('7cf02a6').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.device.tags.getAllByDevice(123).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(uuidOrId, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Set a device tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.device.tags.set('7cf02a6', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.device.tags.set(123, 'EDITOR', 'vim'); -``` - - -###### tags.remove(uuidOrId, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Remove a device tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| tagKey | String | tag key | - -**Example** -```js -balena.models.device.tags.remove('7cf02a6', 'EDITOR'); -``` - - -##### device.configVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - - - -###### configVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get all config variables for a device -**Access**: public -**Fulfil**: Object[] - device config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.configVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.configVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get all device config variables by application -**Access**: public -**Fulfil**: Object[] - device config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.configVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.get(uuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get the value of a specific config variable -**Access**: public -**Fulfil**: String\|undefined - the config variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.device.configVar.get('7cf02a6', 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` - - -###### configVar.set(uuidOrId, key, value) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Set the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | -| value | String | config variable value | - -**Example** -```js -balena.models.device.configVar.set('7cf02a6', 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### configVar.remove(uuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Clear the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.device.configVar.remove('7cf02a6', 'BALENA_VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() { - ... -}); -``` - - -##### device.envVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - - - -###### envVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get all environment variables for a device -**Access**: public -**Fulfil**: Object[] - device environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.envVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.envVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get all device environment variables by application -**Access**: public -**Fulfil**: Object[] - device environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.envVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.get(uuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get the value of a specific environment variable -**Access**: public -**Fulfil**: String\|undefined - the environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.device.envVar.get('7cf02a6', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.envVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### envVar.set(uuidOrId, key, value) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Set the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | -| value | String | environment variable value | - -**Example** -```js -balena.models.device.envVar.set('7cf02a6', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### envVar.remove(uuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Clear the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.device.envVar.remove('7cf02a6', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.envVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### device.serviceVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - - - -###### serviceVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get all service variable overrides for a device -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.serviceVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### serviceVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get all device service variable overrides by application -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get the overriden value of a service variable on a device -**Access**: public -**Fulfil**: String\|undefined - the variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | - -**Example** -```js -balena.models.device.serviceVar.get('7cf02a6', 123, 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.serviceVar.get('7cf02a6', 'myservice', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Set the overriden value of a service variable on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | -| value | String | variable value | - -**Example** -```js -balena.models.device.serviceVar.set('7cf02a6', 123, 'VAR', 'override').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.set('7cf02a6', 'myservice', 'VAR', 'override').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() { - ... -}); -``` - - -###### serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Clear the overridden value of a service variable on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | - -**Example** -```js -balena.models.device.serviceVar.remove('7cf02a6', 123, 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.remove('7cf02a6', 'myservice', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() { - ... -}); -``` - - -##### device.history : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - - - -###### history.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [history](#balena.models.device.history) -**Summary**: Get all history entries for a device -**Access**: public -**Fulfil**: Object[] - device history - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (32 / 62 digits string) or id (number) | -| [options] | Object | | options | -| [options.fromDate] | Date | subDays(new Date(), 7) | history entries older or equal to this date - default now() - 7 days | -| [options.toDate] | Date | | history entries younger or equal to this date | - -**Example** -```js -balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -balena.models.device.history.getAllByDevice(999999).then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) -``` - - -###### history.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [history](#balena.models.device.history) -**Summary**: Get all device history entries by application with time frame -**Access**: public -**Fulfil**: Object[] - device history - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | | options | -| [options.fromDate] | Date | subDays(new Date(), 7) | history entries older or equal to this date - default now() - 7 days | -| [options.toDate] | Date | | history entries younger or equal to this date | - -**Example** -```js -balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -balena.models.device.history.getAllByApplication(999999).then(function(entries) { - console.log(entries); -}); - - -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) -``` - - -##### device.getDashboardUrl(uuid) ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get Dashboard URL for a specific device -**Returns**: String - - Dashboard URL for the specific device -**Throws**: - -- Exception if the uuid is empty - - -| Param | Type | Description | -| --- | --- | --- | -| uuid | String | Device uuid | - -**Example** -```js -dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8') -``` - - -##### device.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all devices of a specific application. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get all devices by application -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByApplication(123).then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all devices of a specific application. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get all devices by organization -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getAllByOrganization('myorganization').then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByOrganization(123).then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.get(uuidOrId, [options]) ⇒ Promise -This method returns a single device by id or uuid. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a single device -**Access**: public -**Fulfil**: Object - device - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.get(123).then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.get('7cf02a6', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.getWithServiceDetails(uuidOrId, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want more control, or to see the raw model -directly, use `device.get(uuidOrId, options)` instead. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a single device along with its associated services' details, -including their associated commit -**Access**: public -**Fulfil**: Object - device with service details - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getWithServiceDetails('7cf02a6').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.getWithServiceDetails(123).then(function(device) { - console.log(device); -}) -``` - - -##### device.getByName(name) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get devices by name -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Description | -| --- | --- | --- | -| name | String | device name | - -**Example** -```js -balena.models.device.getByName('MyDevice').then(function(devices) { - console.log(devices); -}); -``` - - -##### device.getName(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the name of a device -**Access**: public -**Fulfil**: String - device name - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getName('7cf02a6').then(function(deviceName) { - console.log(deviceName); -}); -``` -**Example** -```js -balena.models.device.getName(123).then(function(deviceName) { - console.log(deviceName); -}); -``` - - -##### device.getApplicationName(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get application name -**Access**: public -**Fulfil**: String - application name - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getApplicationName('7cf02a6').then(function(applicationName) { - console.log(applicationName); -}); -``` -**Example** -```js -balena.models.device.getApplicationName(123).then(function(applicationName) { - console.log(applicationName); -}); -``` - - -##### device.has(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device exists -**Access**: public -**Fulfil**: Boolean - has device - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.has('7cf02a6').then(function(hasDevice) { - console.log(hasDevice); -}); -``` -**Example** -```js -balena.models.device.has(123).then(function(hasDevice) { - console.log(hasDevice); -}); -``` - - -##### device.isOnline(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device is online -**Access**: public -**Fulfil**: Boolean - is device online - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isOnline('7cf02a6').then(function(isOnline) { - console.log('Is device online?', isOnline); -}); -``` -**Example** -```js -balena.models.device.isOnline(123).then(function(isOnline) { - console.log('Is device online?', isOnline); -}); -``` - - -##### device.getLocalIPAddresses(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the local IP addresses of a device -**Access**: public -**Fulfil**: String[] - local ip addresses -**Reject**: Error Will reject if the device is offline - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getLocalIPAddresses('7cf02a6').then(function(localIPAddresses) { - localIPAddresses.forEach(function(localIP) { - console.log(localIP); - }); -}); -``` -**Example** -```js -balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) { - localIPAddresses.forEach(function(localIP) { - console.log(localIP); - }); -}); -``` - - -##### device.getMACAddresses(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the MAC addresses of a device -**Access**: public -**Fulfil**: String[] - mac addresses - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getMACAddresses('7cf02a6').then(function(macAddresses) { - macAddresses.forEach(function(mac) { - console.log(mac); - }); -}); -``` -**Example** -```js -balena.models.device.getMACAddresses(123).then(function(macAddresses) { - macAddresses.forEach(function(mac) { - console.log(mac); - }); -}); -``` - - -##### device.getMetrics(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the metrics related information for a device -**Access**: public -**Fulfil**: Object - device metrics - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getMetrics('7cf02a6').then(function(deviceMetrics) { - console.log(deviceMetrics); -}); -``` -**Example** -```js -balena.models.device.getMetrics(123).then(function(deviceMetrics) { - console.log(deviceMetrics); -}); -``` - - -##### device.remove(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Remove device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.remove('7cf02a6'); -``` -**Example** -```js -balena.models.device.remove(123); -``` - - -##### device.deactivate(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Deactivate device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.deactivate('7cf02a6'); -``` -**Example** -```js -balena.models.device.deactivate(123); -``` - - -##### device.rename(uuidOrId, newName) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Rename device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| newName | String | the device new name | - -**Example** -```js -balena.models.device.rename('7cf02a6', 'NewName'); -``` -**Example** -```js -balena.models.device.rename(123, 'NewName'); -``` - - -##### device.setNote(uuidOrIdOrArray, note) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Note a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| note | String | the note | - -**Example** -```js -balena.models.device.setNote('7cf02a6', 'My useful note'); -``` -**Example** -```js -balena.models.device.setNote(123, 'My useful note'); -``` - - -##### device.setCustomLocation(uuidOrIdOrArray, location) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a custom location for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| location | Object | the location ({ latitude: 123, longitude: 456 }) | - -**Example** -```js -balena.models.device.setCustomLocation('7cf02a6', { latitude: 123, longitude: 456 }); -``` -**Example** -```js -balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 }); -``` - - -##### device.unsetCustomLocation(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Clear the custom location of a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.unsetCustomLocation('7cf02a6'); -``` -**Example** -```js -balena.models.device.unsetCustomLocation(123); -``` - - -##### device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Move a device to another application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| applicationSlugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.device.move('7cf02a6', 'myorganization/myapp'); -``` -**Example** -```js -balena.models.device.move(123, 'myorganization/myapp'); -``` -**Example** -```js -balena.models.device.move(123, 456); -``` - - -##### device.getSupervisorTargetState(uuidOrId, version) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the target supervisor state on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| version | Number | (optional) target state version (2 or 3), default to 2 | - -**Example** -```js -balena.models.device.getSupervisorTargetState('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetState(123).then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetState(123, 3).then(function(state) { - console.log(state); -}); -``` - - -##### device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the target supervisor state on a "generic" device on a fleet -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | fleet uuid (string) or id (number) | -| release | String | (optional) release uuid (default tracked) | - -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a6').then(function(state) { - console.log(state); -}); -``` - - -##### device.generateUniqueKey() ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Generate a random key, useful for both uuid and api key. -**Returns**: String - A generated key -**Access**: public -**Example** -```js -randomKey = balena.models.device.generateUniqueKey(); -// randomKey is a randomly generated key that can be used as either a uuid or an api key -console.log(randomKey); -``` - - -##### device.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Register a new device with a Balena application. -**Access**: public -**Fulfil**: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." }) - -| Param | Type | Description | -| --- | --- | --- | -| applicationSlugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| uuid | String | device uuid | -| [deviceTypeSlug] | String | device type slug (string) or alias (string) | - -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register(123, uuid).then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` - - -##### device.generateDeviceKey(uuidOrId, [keyName], [keyDescription]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Generate a device key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| [keyName] | String | Device key name | -| [keyDescription] | String | Description for device key | - -**Example** -```js -balena.models.device.generateDeviceKey('7cf02a6').then(function(deviceApiKey) { - console.log(deviceApiKey); -}); -``` -**Example** -```js -balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) { - console.log(deviceApiKey); -}); -``` - - -##### device.hasDeviceUrl(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device is web accessible with device utls -**Access**: public -**Fulfil**: Boolean - has device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.hasDeviceUrl('7cf02a6').then(function(hasDeviceUrl) { - if (hasDeviceUrl) { - console.log('The device has device URL enabled'); - } -}); -``` -**Example** -```js -balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) { - if (hasDeviceUrl) { - console.log('The device has device URL enabled'); - } -}); -``` - - -##### device.getDeviceUrl(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a device url -**Access**: public -**Fulfil**: String - device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getDeviceUrl('7cf02a6').then(function(url) { - console.log(url); -}); -``` -**Example** -```js -balena.models.device.getDeviceUrl(123).then(function(url) { - console.log(url); -}); -``` - - -##### device.enableDeviceUrl(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable device url for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.enableDeviceUrl('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableDeviceUrl(123); -``` - - -##### device.disableDeviceUrl(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable device url for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.disableDeviceUrl('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableDeviceUrl(123); -``` - - -##### device.enableLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable local mode -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.enableLocalMode('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableLocalMode(123); -``` - - -##### device.disableLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable local mode -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.disableLocalMode('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableLocalMode(123); -``` - - -##### device.isInLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if local mode is enabled on the device -**Access**: public -**Fulfil**: Boolean - has device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isInLocalMode('7cf02a6').then(function(isInLocalMode) { - if (isInLocalMode) { - console.log('The device has local mode enabled'); - } -}); -``` -**Example** -```js -balena.models.device.isInLocalMode(123).then(function(isInLocalMode) { - if (isInLocalMode) { - console.log('The device has local mode enabled'); - } -}); -``` - - -##### device.getLocalModeSupport(device) ⇒ Object -**Kind**: static method of [device](#balena.models.device) -**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported. -**Returns**: Object - Local mode support info ({ supported: true/false, message: "..." }) -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - balena.models.device.getLocalModeSupport(device); -}) -``` - - -##### device.enableLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable lock override -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.enableLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableLockOverride(123); -``` - - -##### device.disableLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable lock override -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.disableLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableLockOverride(123); -``` - - -##### device.hasLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device has the lock override enabled -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.hasLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.hasLockOverride(123); -``` - - -##### device.getStatus(uuidOrId) ⇒ Promise -Convenience method for getting the overall status of a device. -It's recommended to use `balena.models.device.get()` instead, -in case that you need to retrieve more device fields than just the status. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the status of a device -**Access**: public -**Fulfil**: String - device status -**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field. - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getStatus('7cf02a6').then(function(status) { - console.log(status); -}); -``` -**Example** -```js -balena.models.device.getStatus(123).then(function(status) { - console.log(status); -}); -``` - - -##### device.getProgress(uuidOrId) ⇒ Promise -Convenience method for getting the overall progress of a device. -It's recommended to use `balena.models.device.get()` instead, -in case that you need to retrieve more device fields than just the progress. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the progress of a device -**Access**: public -**Fulfil**: Number\|Null - device progress -**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field. - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getProgress('7cf02a6').then(function(progress) { - console.log(progress); -}); -``` -**Example** -```js -balena.models.device.getProgress(123).then(function(progress) { - console.log(progress); -}); -``` - - -##### device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Grant support access to a device until a specified time -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| expiryTimestamp | Number | a timestamp in ms for when the support access will expire | - -**Example** -```js -balena.models.device.grantSupportAccess('7cf02a6', Date.now() + 3600 * 1000); -``` -**Example** -```js -balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000); -``` - - -##### device.revokeSupportAccess(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Revoke support access to a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.revokeSupportAccess('7cf02a6'); -``` -**Example** -```js -balena.models.device.revokeSupportAccess(123); -``` - - -##### device.lastOnline(device) ⇒ String -If the device has never been online this method returns the string `Connecting...`. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a string showing when a device was last set as online -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - balena.models.device.lastOnline(device); -}) -``` - - -##### device.getOsVersion(device) ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the OS version (version number and variant combined) running on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - console.log(device.os_version); // => 'balenaOS 2.26.0+rev1' - console.log(device.os_variant); // => 'prod' - balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod' -}) -``` - - -##### device.isTrackingApplicationRelease(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get whether the device is configured to track the current application release -**Access**: public -**Fulfil**: Boolean - is tracking the current application release - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isTrackingApplicationRelease('7cf02a6').then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### device.getTargetReleaseHash(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the hash of the currently tracked release for a specific device -**Access**: public -**Fulfil**: String - The release hash of the currently tracked release - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getTargetReleaseHash('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.device.getTargetReleaseHash('7cf02a6', function(release) { - console.log(release); -}); -``` - - -##### device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ Promise -Configures the device to run a particular release -and not get updated when the current application release changes. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a specific device to run a particular release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| fullReleaseHashOrId | String \| Number | the hash of a successful release (string) or id (number) | - -**Example** -```js -balena.models.device.pinToRelease('7cf02a6', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` - - -##### device.trackApplicationRelease(uuidOrIdOrArray) ⇒ Promise -The device's current release will be updated with each new successfully built release. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Configure a specific device to track the current application release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.trackApplicationRelease('7cf02a6').then(function() { - ... -}); -``` - - -##### device.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ Promise -Configures the device to run a particular supervisor release. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a specific device to run a particular supervisor release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| supervisorVersionOrId | String \| Number | the raw version of a supervisor release (string) or id (number) | - -**Example** -```js -balena.models.device.setSupervisorRelease('7cf02a6', '10.8.0').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.setSupervisorRelease(123, '11.4.14').then(function() { - ... -}); -``` - - -##### device.startOsUpdate(uuidOrUuids, targetOsVersion, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start an OS update on a device -**Access**: public -**Fulfil**: Object - action response - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrUuids | String \| Array.<String> | full device uuid or array of full uuids | -| targetOsVersion | String | semver-compatible version for the target device Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number, a "prod" variant and greater than the one running on the device. To resolve the semver-compatible range use `balena.model.os.getMaxSatisfyingVersion`. | -| [options] | Object | options | -| [options.runDetached] | Boolean | run the update in detached mode. True by default | - -**Example** -```js -balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { - console.log(result.status); -}); -``` - - -##### device.ping(uuidOrId) ⇒ Promise -This is useful to signal that the supervisor is alive and responding. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Ping a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.ping('7cf02a6'); -``` -**Example** -```js -balena.models.device.ping(123); -``` - - -##### device.identify(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Identify device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.identify('7cf02a6'); -``` -**Example** -```js -balena.models.device.identify(123); -``` - - -##### device.restartApplication(uuidOrId) ⇒ Promise -This function restarts the Docker container running -the application on the device, but doesn't reboot -the device itself. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Restart application on device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.restartApplication('7cf02a6'); -``` -**Example** -```js -balena.models.device.restartApplication(123); -``` - - -##### device.reboot(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Reboot device -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.reboot('7cf02a6'); -``` -**Example** -```js -balena.models.device.reboot(123); -``` - - -##### device.shutdown(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Shutdown device -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.shutdown('7cf02a6'); -``` -**Example** -```js -balena.models.device.shutdown(123); -``` - - -##### device.purge(uuidOrId) ⇒ Promise -This function clears the user application's `/data` directory. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Purge device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.purge('7cf02a6'); -``` -**Example** -```js -balena.models.device.purge(123); -``` - - -##### device.update(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Trigger an update check on the supervisor -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.update('7cf02a6', { - force: true -}); -``` -**Example** -```js -balena.models.device.update(123, { - force: true -}); -``` - - -##### device.getSupervisorState(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the supervisor state on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getSupervisorState('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorState(123).then(function(state) { - console.log(state); -}); -``` - - -##### device.startService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to start | - -**Example** -```js -balena.models.device.startService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.startService(1, 123).then(function() { - ... -}); -``` - - -##### device.stopService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Stop a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to stop | - -**Example** -```js -balena.models.device.stopService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.stopService(1, 123).then(function() { - ... -}); -``` - - -##### device.restartService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Restart a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to restart | - -**Example** -```js -balena.models.device.restartService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.restartService(1, 123).then(function() { - ... -}); -``` - - -#### models.deviceType : object -**Kind**: static namespace of [models](#balena.models) - -* [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - - - -##### deviceType.get(idOrSlug, [options]) ⇒ Promise -This method returns a single device type. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a single deviceType -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| idOrSlug | String \| Number | | device type slug (string) or alias (string) or id | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.get('raspberry-pi').then(function(deviceType) { - console.log(deviceType); -}); -``` -**Example** -```js -balena.models.deviceType.get('raspberrypi').then(function(deviceType) { - console.log('resolved alias:', deviceType); -}); -``` - - -##### deviceType.getAll([options]) ⇒ Promise -This method returns all device types. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get all deviceTypes -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.getAll().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` -**Example** -```js -balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) { - console.log(deviceTypes); -}) -``` - - -##### deviceType.getAllSupported([options]) ⇒ Promise -This method returns all supported device types. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get all supported deviceTypes -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.getAllSupported().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` -**Example** -```js -balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) { - console.log(deviceTypes); -}) -``` - - -##### deviceType.getBySlugOrName(slugOrName) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a deviceType by slug or name -**Access**: public -**Fulfil**: Object - device type - -| Param | Type | Description | -| --- | --- | --- | -| slugOrName | String | deviceType slug | - -**Example** -```js -balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { - console.log(deviceType); -}); -``` - - -##### deviceType.getName(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get display name for a device -**Access**: public -**Fulfil**: String - device display name - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { - console.log(deviceTypeName); - // Raspberry Pi -}); -``` - - -##### deviceType.getSlugByName(deviceTypeName) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get device slug -**Access**: public -**Fulfil**: String - device slug name - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeName | String | device type name | - -**Example** -```js -balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { - console.log(deviceTypeSlug); - // raspberry-pi -}); -``` - - -##### deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a contract with resolved partial templates -**Access**: public -**Fulfil**: Contract - device type contract with resolved partials - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { - for (const partial in contract.partials) { - console.log(`${partial}: ${contract.partials[partial]}`); - } - // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] -}); -``` - - -##### deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get instructions for installing a host OS on a given device type -**Access**: public -**Fulfil**: Object \| String[] - step by step instructions for installing the host OS to the device - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlugOrContract | String \| Object | device type slug or contract | - -**Example** -```js -balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { - for (let instruction of instructions.values()) { - console.log(instruction); - } - // Insert the sdcard to the host machine. - // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. - // Wait for writing of BalenaOS to complete. - // Remove the sdcard from the host machine. - // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). - // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. -}); -``` - - -##### deviceType.getInstallMethod(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get installation method on a given device type -**Access**: public -**Fulfil**: String - the installation method supported for the given device type slug - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { - console.log(method); - // externalBoot -}); -``` - - -#### models.apiKey : object -**Kind**: static namespace of [models](#balena.models) - -* [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - - - -##### apiKey.create(createApiKeyParams) ⇒ Promise -This method registers a new api key for the current user with the name given. - -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Creates a new user API key -**Access**: public -**Fulfil**: String - API key - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| createApiKeyParams | Object | | an object containing the parameters for the creation of an API key | -| createApiKeyParams.name | String | | the API key name | -| createApiKeyParams.expiryDate | String | | the API key expiry date | -| [createApiKeyParams.description] | String | | the API key description | - -**Example** -```js -balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12}).then(function(apiKey) { - console.log(apiKey); -}); -``` -**Example** -```js -balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12, description: apiKeyDescription}).then(function(apiKey) { - console.log(apiKey); -}); -``` - - -##### apiKey.getAll([options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all accessible API keys -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getAll().then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getAllNamedUserApiKeys([options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all named user API keys of the current user -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all provisioning API keys for an application -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getDeviceApiKeysByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all API keys for a device -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device, uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a6').then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.update(id, apiKeyInfo) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Update the details of an API key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | API key id | -| apiKeyInfo | Object | an object with the updated name|description|expiryDate | - -**Example** -```js -balena.models.apiKey.update(123, { name: 'updatedName' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { description: 'updated description' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { expiryDate: '2022-04-29' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' }); -``` - - -##### apiKey.revoke(id) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Revoke an API key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | API key id | - -**Example** -```js -balena.models.apiKey.revoke(123); -``` - - -#### models.key : object -**Kind**: static namespace of [models](#balena.models) - -* [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - - - -##### key.getAll([options]) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Get all ssh keys -**Access**: public -**Fulfil**: Object[] - ssh keys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.key.getAll().then(function(keys) { - console.log(keys); -}); -``` - - -##### key.get(id) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Get a single ssh key -**Access**: public -**Fulfil**: Object - ssh key - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | key id | - -**Example** -```js -balena.models.key.get(51).then(function(key) { - console.log(key); -}); -``` - - -##### key.remove(id) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Remove ssh key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | key id | - -**Example** -```js -balena.models.key.remove(51); -``` - - -##### key.create(title, key) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Create a ssh key -**Access**: public -**Fulfil**: Object - ssh key - -| Param | Type | Description | -| --- | --- | --- | -| title | String | key title | -| key | String | the public ssh key | - -**Example** -```js -balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) { - console.log(key); -}); -``` - - -#### models.organization : object -**Kind**: static namespace of [models](#balena.models) - -* [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - - - -##### organization.membership : object -**Kind**: static namespace of [organization](#balena.models.organization) - -* [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - - - -###### membership.get(membershipId, [options]) ⇒ Promise -This method returns a single organization membership. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get a single organization membership -**Access**: public -**Fulfil**: Object - organization membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| membershipId | number \| Object | | the id or an object with the unique `user` & `is_member_of__organization` numeric pair of the membership | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.get(5).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all organization memberships for a specific organization. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get all memberships by organization -**Access**: public -**Fulfil**: Object[] - organization memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByUser(usernameOrId, [options]) ⇒ Promise -This method returns all organization memberships for a specific user. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get all memberships by user -**Access**: public -**Fulfil**: Object[] - organization memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| usernameOrId | String \| Number | | the user's username (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.organization.membership.getAllByUser(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise -This method changes the role of an organization member. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Changes the role of an organization member -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__organization` numeric pair of the membership that will be changed | -| roleName | String | the role name to be granted to the membership | - -**Example** -```js -balena.models.organization.membership.changeRole(123, "member").then(function() { - console.log('OK'); -}); -``` -**Example** -```js -balena.models.organization.membership.changeRole({ - user: 123, - is_member_of__organization: 125, -}, "member").then(function() { - console.log('OK'); -}); -``` - - -###### membership.remove(id) ⇒ Promise -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Remove a membership -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | organization membership id | - -**Example** -```js -balena.models.organization.membership.remove(123); -``` -**Example** -```js -balena.models.organization.membership.remove({ - user: 123, - is_member_of__application: 125, -}); -``` - - -##### organization.invite : object -**Kind**: static namespace of [organization](#balena.models.organization) - -* [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - - - -###### invite.getAll([options]) ⇒ Promise -This method returns all invites. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Get all invites -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.invite.getAll().then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all invites for a specific organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Get all invites by organization -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string), or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) { - console.log(invites); -}); -``` -**Example** -```js -balena.models.organization.invite.getAllByOrganization(123).then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.create(handleOrId, options, [message]) ⇒ Promise -This method invites a user by their email to an organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Creates a new invite for an organization -**Access**: public -**Fulfil**: String - organization invite - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string), or id (number) | -| options | Object | | invite creation parameters | -| options.invitee | String | | the email of the invitee | -| [options.roleName] | String | "developer" | the role name to be granted to the invitee | -| [message] | String | | the message to send along with the invite | - -**Example** -```js -balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) { - console.log(invite); -}); -``` - - -###### invite.revoke(id) ⇒ Promise -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Revoke an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | organization invite id | - -**Example** -```js -balena.models.organization.invite.revoke(123); -``` - - -###### invite.accept(invitationToken) ⇒ Promise -This method adds the calling user to the organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Accepts an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| invitationToken | String | invite token | - -**Example** -```js -balena.models.organization.invite.accept("qwerty-invitation-token"); -``` - - -##### organization.create(options) ⇒ Promise -This method creates a new organization with the current user as an administrator. - -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Creates a new organization -**Access**: public -**Fulfil**: String - Organization - -| Param | Type | Description | -| --- | --- | --- | -| options | Object | Organization parameters to use. | -| options.name | String | Required: the name of the organization that will be created. | -| [options.handle] | String | The handle of the organization that will be created. | - -**Example** -```js -balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.create({ - name:'MyOrganization', - logo_image: new balena.utils.BalenaWebResourceFile( - [fs.readFileSync('./img.jpeg')], - 'img.jpeg' - ); -}) -.then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.create({ - name:'MyOrganization', - // Only in case File API is avaialable (most browsers and Node 20+) - logo_image: new File( - imageContent, - 'img.jpeg' - ); -}) -.then(function(organization) { - console.log(organization); -}); -``` - - -##### organization.getAll([options]) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Get all Organizations -**Access**: public -**Fulfil**: Object[] - organizations - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.getAll().then(function(organizations) { - console.log(organizations); -}); -``` - - -##### organization.get(handleOrId, [options]) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Get a single organization -**Access**: public -**Fulfil**: Object - organization - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.get('myorganization').then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.get(123).then(function(organization) { - console.log(organization); -}); -``` - - -##### organization.remove(handleOrId) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Remove an Organization -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| handleOrId | String \| Number | organization handle (string) or id (number). | - -**Example** -```js -balena.models.organization.remove(123); -``` - - -#### models.team : object -**Kind**: static namespace of [models](#balena.models) - -* [.team](#balena.models.team) : object - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - - - -##### team.applicationAccess : object -**Kind**: static namespace of [team](#balena.models.team) - -* [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - - - -###### applicationAccess.getAllByTeam(teamId, [options]) ⇒ Promise -This method get all team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Get all team applications access -**Access**: public -**Fulfil**: Object[] - team application access - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| teamId | Number | | Required: the team id. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.team.applicationAccess.getAllByTeam(1239948).then(function(teamApplicationAccesses) { - console.log(teamApplicationAccesses); -}); -``` - - -###### applicationAccess.get(teamApplicationAccessId, [options]) ⇒ Promise -This method get specific team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Get team applications access -**Access**: public -**Fulfil**: Object - TeamApplicationAccess - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| teamApplicationAccessId | Number | | Required: the team application access id. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.team.applicationAccess.get(1239948).then(function(teamApplicationAccess) { - console.log(teamApplicationAccess); -}); -``` - - -###### applicationAccess.update(teamApplicationAccessId, roleName) ⇒ Promise -This method update a team application access role. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Update team application access -**Access**: public -**Fulfil**: Object - TeamApplicationAccess - -| Param | Type | Description | -| --- | --- | --- | -| teamApplicationAccessId | Number | Required: the team application access id. | -| roleName | String | Required: The new role to assing (ApplicationMembershipRoles). | - -**Example** -```js -balena.models.team.update(123, 'developer').then(function(teamApplicationAccess) { - console.log(teamApplicationAccess); -}); -``` - - -###### applicationAccess.remove(teamApplicationAccessId) ⇒ Promise -This remove a team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Remove team application access -**Access**: public -**Fulfil**: void - -| Param | Type | Description | -| --- | --- | --- | -| teamApplicationAccessId | Number | Required: the team application access id. | - -**Example** -```js -balena.models.team.remove(123).then(function(teams) { - console.log(teams); -}); -``` - - -##### team.create(organizationSlugOrId, name) ⇒ Promise -This method creates a new team. - -**Kind**: static method of [team](#balena.models.team) -**Summary**: Creates a new Team -**Access**: public -**Fulfil**: Object - Team - -| Param | Type | Description | -| --- | --- | --- | -| organizationSlugOrId | Number | Required: the organization slug or id the team will be part of. | -| name | String | Required: the name of the team that will be created. | - -**Example** -```js -balena.models.team.create(1239948, 'MyTeam').then(function(team) { - console.log(team); -}); -``` -**Example** -```js -balena.models.team.create('myOrgHandle', 'MyTeam') -.then(function(team) { - console.log(team); -}); -``` - - -##### team.getAllByOrganization(organizationSlugOrId, [options]) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Get all Teams of a specific Organization -**Access**: public -**Fulfil**: Object[] - Teams - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| organizationSlugOrId | Number | | Required: the organization slug or id the team is part of. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.team.getAllByOrganization(123).then(function(teams) { - console.log(teams); -}); -``` -**Example** -```js -balena.models.team.getAllByOrganization('MyOrganizationHandle').then(function(teams) { - console.log(teams); -}); -``` - - -##### team.get(teamId, [options]) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Get a single Team -**Access**: public -**Fulfil**: Object - Team - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| teamId | Number | | team id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.team.get(123).then(function(team) { - console.log(team); -}); -``` - - -##### team.rename(teamId, newName) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Rename Team -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| teamId | Number | team id (number) | -| newName | String | new team name (string) | - -**Example** -```js -balena.models.team.rename(123, 'MyNewTeamName'); -``` - - -##### team.remove(teamId) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Remove a Team -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| teamId | Number | team id (number). | - -**Example** -```js -balena.models.team.remove(123); -``` - - -#### models.os : object -**Kind**: static namespace of [models](#balena.models) - -* [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.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> - - - -##### os.getAvailableOsVersions(deviceTypes, [options]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the supported OS versions for the provided device type(s) -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceTypes | String \| Array.<String> | | device type slug or array of slugs | -| [options] | Object | | Extra pine options & draft filter to use | -| [options.includeDraft] | Boolean | false | Whether pre-releases should be included in the results | - -**Example** -```js -balena.models.os.getAvailableOsVersions('raspberrypi3'); -``` -**Example** -```js -balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']); -``` - - -##### os.getAllOsVersions(deviceTypes, [options]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceTypes | String \| Array.<String> | | device type slug or array of slugs | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.os.getAllOsVersions('raspberrypi3'); -``` -**Example** -```js -balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']); -``` -**Example** -```js -balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } }); -``` - - -##### os.getDownloadSize(deviceType, [version]) ⇒ Promise -**Note!** Currently only the raw (uncompressed) size is reported. - -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get OS download size estimate -**Access**: public -**Fulfil**: Number - OS image download size, in bytes. - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | -| [version] | String | semver-compatible version or 'latest', defaults to 'latest'. The version **must** be the exact version number. | - -**Example** -```js -balena.models.os.getDownloadSize('raspberry-pi').then(function(size) { - console.log('The OS download size for raspberry-pi', size); -}); -``` - - -##### os.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the max OS version satisfying the given range -**Access**: public -**Fulfil**: String\|null - the version number, or `null` if no matching versions are found - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | -| versionOrRange | String | can be one of * the exact version number, in which case it is returned if the version is supported, or `null` is returned otherwise, * a [semver](https://www.npmjs.com/package/semver)-compatible range specification, in which case the most recent satisfying version is returned if it exists, or `null` is returned, * `'latest'/'default'` in which case the most recent version is returned, excluding pre-releases, Defaults to `'latest'`. | -| [osType] | String | can be one of 'default', 'esr' or null to include all types | - -**Example** -```js -balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) { - console.log(version); -}); -``` - - -##### os.download(options) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Download an OS image -**Access**: public -**Fulfil**: ReadableStream - download stream - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | OS image options to use. | -| options.deviceType | String | | device type slug | -| [options.version] | String | 'latest' | semver-compatible version or 'latest', defaults to 'latest' Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number. | -| [options.developmentMode] | Boolean | | controls development mode for unified balenaOS releases. | -| [options.appId] | Number | | the application ID (number). | -| [options.fileType] | String | | download file type. One of '.img' or '.zip' or '.gz'. | -| [options.imageType] | String | | download file type. One of 'raw' or 'flasher' | -| [options.appUpdatePollInterval] | Number | | how often the OS checks for updates, in minutes. | -| [options.network] | String | | the network type that the device will use, one of 'ethernet' or 'wifi'. | -| [options.wifiKey] | String | | the key for the wifi network the device will connect to if network is wifi. | -| [options.wifiSsid] | String | | the ssid for the wifi network the device will connect to if network is wifi. | - -**Example** -```js -balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) { - stream.pipe(fs.createWriteStream('foo/bar/image.img')); -}); -``` - - -##### os.getConfig(slugOrUuidOrId, options) ⇒ Promise -Builds the config.json for a device in the given application, with the given -options. - -Note that an OS version is required. For versions < 2.7.8, config -generation is only supported when using a session token, not an API key. - -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get an applications config.json -**Access**: public -**Fulfil**: Object - application configuration as a JSON object. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number). | -| options | Object | | OS configuration options to use. | -| options.version | String | | Required: the OS version of the image. | -| [options.network] | String | 'ethernet' | The network type that the device will use, one of 'ethernet' or 'wifi'. | -| [options.appUpdatePollInterval] | Number | | How often the OS checks for updates, in minutes. | -| [options.provisioningKeyName] | String | | Name assigned to API key | -| [options.provisioningKeyExpiryDate] | String | | Expiry Date assigned to API key | -| [options.developmentMode] | Boolean | | Controls development mode for unified balenaOS releases. | -| [options.wifiKey] | String | | The key for the wifi network the device will connect to. | -| [options.wifiSsid] | String | | The ssid for the wifi network the device will connect to. | -| [options.ip] | String | | static ip address. | -| [options.gateway] | String | | static ip gateway. | -| [options.netmask] | String | | static ip netmask. | - -**Example** -```js -balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) { - fs.writeFile('foo/bar/config.json', JSON.stringify(config)); -}); - -balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) { - fs.writeFile('foo/bar/config.json', JSON.stringify(config)); -}); -``` - - -##### os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions -**Access**: public -**Fulfil**: Boolean - whether upgrading the OS to the target version is supported - -| 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.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) { - 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 -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns the supported OS update targets for the provided device type -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. -**Fulfil**: Object - the versions information, of the following structure: -* versions - an array of strings, -containing exact version numbers that OS update is supported -* recommended - the recommended version, i.e. the most recent version -that is _not_ pre-release, can be `null` -* current - the provided current version after normalization - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceType | String | | device type slug | -| currentVersion | String | | semver-compatible version for the starting OS version | -| [options] | Object | | Extra options to filter the OS releases by | -| [options.includeDraft] | Boolean | false | Whether pre-releases should be included in the results | - -**Example** -```js -balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) { - console.log(isSupported); -}); -``` - - -##### os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ Boolean -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns whether the specified OS architecture is compatible with the target architecture -**Returns**: Boolean - - Whether the specified OS architecture is capable of running -applications build for the target architecture -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| osArchitecture | String | The OS's architecture as specified in its device type | -| applicationArchitecture | String | The application's architecture as specified in its device type | - -**Example** -```js -const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf'); -console.log(result1); - -const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64'); -console.log(result2); -``` - - -##### os.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options]) ⇒ Promise.<String> -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns the Releases of the supervisor for the CPU Architecture -**Returns**: Promise.<String> - - An array of Release objects that can be used to manage a device as supervisors. -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| cpuArchitectureSlugOrId | String \| Number | | The slug (string) or id (number) for the CPU Architecture | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64'); - -const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( - 'aarch64', - { $filter: { raw_version: '12.11.0' } }, -); - -const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( - 'aarch64', - { - $select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'], - $expand: { - release_image: { - $select: 'id', - $expand: { - image: { - $select: 'is_stored_at__image_location', - }, - }, - }, - }, - $filter: { raw_version: '12.11.0' } - }, -); -``` - - -#### models.config : object -**Kind**: static namespace of [models](#balena.models) - -* [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - - - -##### config.getAll() ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get all configuration -**Access**: public -**Fulfil**: Object - configuration -**Example** -```js -balena.models.config.getAll().then(function(config) { - console.log(config); -}); -``` - - -##### ~~config.getDeviceTypes() ⇒ Promise~~ -***use balena.models.deviceType.getAll*** - -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get device types -**Access**: public -**Fulfil**: Object[] - device types -**Example** -```js -balena.models.config.getDeviceTypes().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` - - -##### ~~config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise~~ -***use balena.models.deviceType.getBySlugOrName*** - -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get a device type manifest by slug -**Access**: public -**Fulfil**: Object - device type manifest - -| Param | Type | Description | -| --- | --- | --- | -| slugOrName | String | device type slug | - -**Example** -```js -balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) { - console.log(manifest); -}); -``` - - -##### config.getDeviceOptions(deviceType) ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get configuration/initialization options for a device type -**Access**: public -**Fulfil**: Object[] - configuration options - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | - -**Example** -```js -balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) { - console.log(options); -}); -``` - - -##### config.getConfigVarSchema(deviceType) ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get configuration variables schema for a device type -**Access**: public -**Fulfil**: Object[] - configuration options - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | - -**Example** -```js -balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) { - console.log(options); -}); -``` - - -#### models.release : object -**Kind**: static namespace of [models](#balena.models) - -* [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - - - -##### release.tags : object -**Kind**: static namespace of [release](#balena.models.release) - -* [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Get all release tags for an application -**Access**: public -**Fulfil**: Object[] - release tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Get all release tags for a release -**Access**: public -**Fulfil**: Object[] - release tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.tags.getAllByRelease(123).then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByRelease('7cf02a6').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Set a release tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.release.tags.set(123, 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.release.tags.set('7cf02a6', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim'); -``` - - -###### tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Remove a release tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| tagKey | String | tag key | - -**Example** -```js -balena.models.release.tags.remove(123, 'EDITOR'); -``` -**Example** -```js -balena.models.release.tags.remove('7cf02a6', 'EDITOR'); -``` -**Example** -```js -balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR'); -``` - - -##### release.get(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get a specific release -**Access**: public -**Fulfil**: Object - release - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.get(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.get('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log(release); -}); -``` - - -##### release.getWithImageDetails(commitOrIdOrRawVersion, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want significantly more control, or to see the -raw model directly, use `release.get(id, options)` instead. - -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get a specific release with the details of the images built -**Access**: public -**Fulfil**: Object - release with image details - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | a map of extra pine options | -| [options.release] | Boolean | {} | extra pine options for releases | -| [options.image] | Object | {} | extra pine options for images | - -**Example** -```js -balena.models.release.getWithImageDetails(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } }) -.then(function(release) { - console.log(release.images[0].build_log); -}); -``` - - -##### release.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get all releases from an application -**Access**: public -**Fulfil**: Object[] - releases - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) { - console.log(releases); -}); -``` -**Example** -```js -balena.models.release.getAllByApplication(123).then(function(releases) { - console.log(releases); -}); -``` - - -##### release.getLatestByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get the latest successful release for an application -**Access**: public -**Fulfil**: Object\|undefined - release - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) { - console.log(releases); -}); -``` -**Example** -```js -balena.models.release.getLatestByApplication(123).then(function(releases) { - console.log(releases); -}); -``` - - -##### release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Create a new release built from the source in the provided url -**Access**: public -**Fulfil**: number - release ID - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| urlDeployOptions | Object | | builder options | -| urlDeployOptions.url | String | | a url with a tarball of the project to build | -| [urlDeployOptions.shouldFlatten] | Boolean | true | Should be true when the tarball includes an extra root folder with all the content | - -**Example** -```js -balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { - console.log(releaseId); -}); -``` -**Example** -```js -balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { - console.log(releaseId); -}); -``` - - -##### release.finalize(commitOrIdOrRawVersion) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Finalizes a draft release -**Access**: public -**Fulfil**: void - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | - -**Example** -```js -balena.models.release.finalize(123).then(function() { - console.log('finalized!'); -}); -``` -**Example** -```js -balena.models.release.finalize('7cf02a6').then(function() { - console.log('finalized!'); -}); -``` -**Example** -```js -balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log('finalized!'); -}); -``` - - -##### release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Set the is_invalidated property of a release to true or false -**Access**: public -**Fulfil**: void - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| isInvalidated | Boolean | boolean value, true for invalidated, false for validated | - -**Example** -```js -balena.models.release.setIsInvalidated(123, true).then(function() { - console.log('invalidated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated('7cf02a6', true).then(function() { - console.log('invalidated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log('invalidated!); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated(123, false).then(function() { - console.log('validated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated('7cf02a6', false).then(function() { - console.log('validated!'); -}); -``` - - -##### release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Add a note to a release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| noteOrNull | String \| Null | the note | - -**Example** -```js -balena.models.release.setNote('7cf02a6', 'My useful note'); -``` -**Example** -```js -balena.models.release.setNote(123, 'My useful note'); -``` -**Example** -```js -balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note'); -``` - - -##### release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Add a known issue list to a release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| knownIssueListOrNull | String \| Null | the known issue list | - -**Example** -```js -balena.models.release.setKnownIssueList('7cf02a6', 'This is an issue'); -``` -**Example** -```js -balena.models.release.setKnownIssueList(123, 'This is an issue'); -``` -**Example** -```js -balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue'); -``` - - -#### models.service : object -**Kind**: static namespace of [models](#balena.models) - -* [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - - - -##### service.var : object -**Kind**: static namespace of [service](#balena.models.service) - -* [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - - - -###### var.getAllByService(serviceIdOrNaturalKey, [options]) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get all variables for a service -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | | service id (number) or appliation-service_name pair | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.var.getAllByService(999999).then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) { - console.log(vars); -}); -``` - - -###### var.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get all service variables by application -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.service.var.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### var.get(serviceIdOrNaturalKey, key) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get the value of a specific service variable -**Access**: public -**Fulfil**: String\|undefined - the variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | - -**Example** -```js -balena.models.service.var.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### var.set(serviceIdOrNaturalKey, key, value) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Set the value of a specific service variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | -| value | String | variable value | - -**Example** -```js -balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### var.remove(serviceIdOrNaturalKey, key) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Clear the value of a specific service variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | - -**Example** -```js -balena.models.service.var.remove(999999, 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() { - ... -}); -``` - - -##### service.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [service](#balena.models.service) -**Summary**: Get all services from an application -**Access**: public -**Fulfil**: Object[] - services - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) { - console.log(services); -}); -``` -**Example** -```js -balena.models.service.getAllByApplication(123).then(function(services) { - console.log(services); -}); -``` - - -#### models.image : object -**Kind**: static namespace of [models](#balena.models) - -* [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - - - -##### image.get(id, [options]) ⇒ Promise -**Kind**: static method of [image](#balena.models.image) -**Summary**: Get a specific image -**Access**: public -**Fulfil**: Object - image - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| id | Number | | image id | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.image.get(123).then(function(image) { - console.log(image); -}); -``` - - -##### image.getLogs(id) ⇒ Promise -**Kind**: static method of [image](#balena.models.image) -**Summary**: Get the logs for an image -**Access**: public -**Fulfil**: string \| null - logs - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | image id | - -**Example** -```js -balena.models.image.getLogs(123).then(function(logs) { - console.log(logs); -}); -``` - - -#### models.creditBundle : object -**Kind**: static namespace of [models](#balena.models) - -* [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - - - -##### creditBundle.getAllByOrg(organization, [options]) ⇒ Promise -**Kind**: static method of [creditBundle](#balena.models.creditBundle) -**Summary**: Get all of the credit bundles purchased by the given org -**Access**: public -**Fulfil**: Object[] - credit bundles - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| organization | String \| Number | | handle (string) or id (number) of the target organization. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) { - console.log(creditBundles); -}); -``` - - -##### creditBundle.create(organization, featureId, creditsToPurchase) ⇒ Promise -**Kind**: static method of [creditBundle](#balena.models.creditBundle) -**Summary**: Purchase a credit bundle for the given feature and org of the given quantity -**Access**: public -**Fulfil**: Object[] - credit bundles - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| featureId | Number | id (number) of the feature for which credits are being purchased. | -| creditsToPurchase | Number | number of credits being purchased. | - -**Example** -```js -balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) { - console.log(creditBundle); -}); -``` - - -#### models.billing : object -**Note!** The billing methods are available on Balena.io exclusively. - -**Kind**: static namespace of [models](#balena.models) - -* [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - - - -##### billing.getAccount(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the user's billing account -**Access**: public -**Fulfil**: Object - billing account - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getAccount(orgId).then(function(billingAccount) { - console.log(billingAccount); -}); -``` - - -##### billing.getPlan(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the current billing plan -**Access**: public -**Fulfil**: Object - billing plan - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getPlan(orgId).then(function(billingPlan) { - console.log(billingPlan); -}); -``` - - -##### billing.getBillingInfo(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the current billing information -**Access**: public -**Fulfil**: Object - billing information - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -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 -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Update the current billing information -**Access**: public -**Fulfil**: Object - billing information - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| 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 -balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) { - console.log(billingInfo); -}); -``` - - -##### billing.removeBillingInfo(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Remove an organization's billing information -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.removeBillingInfo(orgId).then(function() { - console.log("Success"); -}); -``` - - -##### billing.updateAccountInfo(organization, accountInfo) -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Update the current billing account information -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| accountInfo | AccountInfo | an object containing billing account info | - -**Example** -```js -balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) -``` -**Example** -```js -balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) -``` - - -##### billing.changePlan(organization, planChangeOptions) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Change the current billing plan -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| planChangeOptions | Object | an object containing the billing plan change options | -| billingInfo.tier | String | the code of the target billing plan | -| billingInfo.cycle | String | the billing cycle | -| [billingInfo.planChangeReason] | String | the reason for changing the current plan | - -**Example** -```js -balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() { - console.log('Plan changed!'); -}); -``` - - -##### billing.getInvoices(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the available invoices -**Access**: public -**Fulfil**: Object - invoices - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getInvoices(orgId).then(function(invoices) { - console.log(invoices); -}); -``` - - -##### billing.downloadInvoice(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Download a specific invoice -**Access**: public -**Fulfil**: Blob\|ReadableStream - blob on the browser, download stream on node - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| | String | an invoice number | - -**Example** -```js -# Browser -balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) { - console.log(blob); -}); -# Node -balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) { - stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf')); -}); -``` - - -### balena.auth : object -**Kind**: static namespace of [balena](#balena) - -* [.auth](#balena.auth) : object - * [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.whoami()](#balena.auth.whoami) ⇒ Promise - * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ Promise - * [.login(credentials)](#balena.auth.login) ⇒ Promise - * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ Promise - * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ Promise - * [.getToken()](#balena.auth.getToken) ⇒ Promise - * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ Promise - * [.getActorId()](#balena.auth.getActorId) ⇒ Promise - * [.logout()](#balena.auth.logout) ⇒ Promise - * [.register(credentials)](#balena.auth.register) ⇒ Promise - * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ Promise - * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ Promise - - - -#### auth.twoFactor : object -**Kind**: static namespace of [auth](#balena.auth) - -* [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - - - -##### twoFactor.isEnabled() ⇒ Promise -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Check if two factor authentication is enabled -**Access**: public -**Fulfil**: Boolean - whether 2fa is enabled -**Example** -```js -balena.auth.twoFactor.isEnabled().then(function(isEnabled) { - if (isEnabled) { - console.log('2FA is enabled for this account'); - } -}); -``` - - -##### twoFactor.isPassed() ⇒ Promise -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Check if two factor authentication challenge was passed -**Access**: public -**Fulfil**: Boolean - whether 2fa challenge was passed -**Example** -```js -balena.auth.twoFactor.isPassed().then(function(isPassed) { - if (isPassed) { - console.log('2FA challenge passed'); - } -}); -``` - - -##### twoFactor.verify(code) ⇒ Promise -Verifies two factor authentication. -Note that this method not update the token automatically. -You should use [challenge](#balena.auth.twoFactor.challenge) when possible, -as it takes care of that as well. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Verify two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -const token = balena.auth.twoFactor.verify('1234'); -balena.auth.loginWithToken(token); -``` - - -##### twoFactor.getSetupKey() ⇒ Promise -Retrieves a setup key for enabling two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Get two factor authentication setup key -**Access**: public -**Fulfil**: String - setup key -**Example** -```js -const setupKey = balena.auth.twoFactor.getSetupKey(); -console.log(setupKey); -``` - - -##### twoFactor.enable(code) ⇒ Promise -Enables two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Enable two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -const token = balena.auth.twoFactor.enable('1234'); -balena.auth.loginWithToken(token); -``` - - -##### twoFactor.challenge(code) ⇒ Promise -You should use [login](#balena.auth.login) when possible, -as it takes care of saving the token and email as well. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Challenge two factor authentication and complete login -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -balena.auth.twoFactor.challenge('1234'); -``` - - -##### twoFactor.disable(password) ⇒ Promise -Disables two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Disable two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| password | String | password | - -**Example** -```js -const token = balena.auth.twoFactor.disable('1234'); -balena.auth.loginWithToken(token); -``` - - -#### auth.whoami() ⇒ Promise -This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Return current logged in information -**Access**: public -**Fulfil**: (Object\|undefined) - actor information, if it exists -**Example** -```js -balena.auth.whoami().then(function(result) { - if (!result) { - console.log('I\'m not logged in!'); - } else { - console.log('My result is:', result); - } -}); -``` - - -#### auth.authenticate(credentials) ⇒ Promise -You should use [login](#balena.auth.login) when possible, -as it takes care of saving the token and email as well. - -Notice that if `credentials` contains extra keys, they'll be discarted -by the server automatically. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Authenticate with the server -**Access**: protected -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of email, password | -| credentials.email | String | the email | -| credentials.password | String | the password | - -**Example** -```js -balena.auth.authenticate(credentials).then(function(token) { - console.log('My token is:', token); -}); -``` - - -#### auth.login(credentials) ⇒ Promise -If the login is successful, the token is persisted between sessions. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Login -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of email, password | -| credentials.email | String | the email | -| credentials.password | String | the password | - -**Example** -```js -balena.auth.login(credentials); -``` - - -#### auth.loginWithToken(authToken) ⇒ Promise -Login to balena with a session token or api key instead of with credentials. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Login with a token or api key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| authToken | String | the auth token | - -**Example** -```js -balena.auth.loginWithToken(authToken); -``` - - -#### auth.isLoggedIn() ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Check if you're logged in -**Access**: public -**Fulfil**: Boolean - is logged in -**Example** -```js -balena.auth.isLoggedIn().then(function(isLoggedIn) { - if (isLoggedIn) { - console.log('I\'m in!'); - } else { - console.log('Too bad!'); - } -}); -``` - - -#### auth.getToken() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in user's raw API key or session token -**Access**: public -**Fulfil**: String - raw API key or session token -**Example** -```js -balena.auth.getToken().then(function(token) { - console.log(token); -}); -``` - - -#### auth.getUserInfo() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in user's info -**Access**: public -**Fulfil**: Object - user info -**Example** -```js -balena.auth.getUserInfo().then(function(userInfo) { - console.log(userInfo); -}); -``` - - -#### auth.getActorId() ⇒ Promise -This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in actor id -**Access**: public -**Fulfil**: Number - actor id -**Example** -```js -balena.auth.getActorId().then(function(actorId) { - console.log(actorId); -}); -``` - - -#### auth.logout() ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Logout -**Access**: public -**Example** -```js -balena.auth.logout(); -``` - - -#### auth.register(credentials) ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Register a user account -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of username, password and email | -| credentials.email | String | the email | -| credentials.password | String | the password | -| [credentials.'g-recaptcha-response'] | String \| undefined | the captcha response | - -**Example** -```js -balena.auth.register({ - email: 'johndoe@gmail.com', - password: 'secret' -}).then(function(token) { - console.log(token); -}); -``` - - -#### auth.verifyEmail(verificationPayload) ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Verifies an email -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| verificationPayload | Object | in the form of email, and token | -| verificationPayload.email | String | the email | -| verificationPayload.token | String | the verification token | - -**Example** -```js -balena.auth.verifyEmail({ - email: 'johndoe@gmail.com', - token: '5bb11d90eefb34a70318f06a43ef063f' -}).then(function(jwt) { - console.log(jwt); -}); -``` - - -#### auth.requestVerificationEmail() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Re-send verification email to the user -**Access**: public -**Example** -```js -balena.auth.requestVerificationEmail().then(function() { - console.log('Requesting verification email operation complete!'); -}) -``` - - -### balena.logs : object -**Kind**: static namespace of [balena](#balena) - -* [.logs](#balena.logs) : object - * [.subscribe(uuidOrId, [options])](#balena.logs.subscribe) ⇒ Promise.<LogSubscription> - * [.history(uuidOrId, [options])](#balena.logs.history) ⇒ Promise - * [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - - - -#### logs.subscribe(uuidOrId, [options]) ⇒ Promise.<LogSubscription> -Connects to the stream of devices logs, returning a LogSubscription, which -can be used to listen for logs as they appear, line by line. - -**Kind**: static method of [logs](#balena.logs) -**Summary**: Subscribe to device logs -**Access**: public -**Fulfil**: [LogSubscription](#balena.logs.LogSubscription) - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.count] | Number \| 'all' | 0 | number of historical messages to include (or 'all') | -| [options.start] | Number \| String | | the timestamp or ISO Date string after which to retrieve historical messages. When specified, the count parameter needs to also be provided. | - -**Example** -```js -balena.logs.subscribe('7cf02a6').then(function(logs) { - logs.on('line', function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -balena.logs.subscribe(123).then(function(logs) { - logs.on('line', function(line) { - console.log(line); - }); -}); -``` - - -#### logs.history(uuidOrId, [options]) ⇒ Promise -Get an array of the latest log messages for a given device. - -**Kind**: static method of [logs](#balena.logs) -**Summary**: Get device logs history -**Access**: public -**Fulfil**: Object[] - history lines - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.count] | Number \| 'all' | 1000 | number of log messages to return (or 'all') | -| [options.start] | Number \| String | | the timestamp or ISO Date string after which to retrieve historical messages | - -**Example** -```js -balena.logs.history('7cf02a6').then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -balena.logs.history(123).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -const oneDayAgoTimestamp = Date.now() - 24*60*60*1000; -balena.logs.history('7cf02a6', { start: oneDayAgoTimestamp }).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -const oneDayAgoIsoDateString = new Date(Date.now() - 24*60*60*1000).toISOString(); -balena.logs.history('7cf02a6', { start: oneDayAgoIsoDateString }).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` - - -#### logs.LogSubscription : EventEmitter -The log subscription emits events as log data arrives. -You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)` - -**Kind**: static typedef of [logs](#balena.logs) - -* [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - - - -##### LogSubscription.unsubscribe() -Disconnect from the logs feed and stop receiving any future events on this emitter. - -**Kind**: static method of [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Unsubscribe from device logs -**Access**: public -**Example** -```js -logs.unsubscribe(); -``` - - -##### "line" -**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Event fired when a new line of log output is available -**Example** -```js -logs.on('line', function(line) { - console.log(line); -}); -``` - - -##### "error" -**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Event fired when an error has occured reading the device logs -**Example** -```js -logs.on('error', function(error) { - console.error(error); -}); -``` - - -### balena.settings : object -**Kind**: static namespace of [balena](#balena) - -* [.settings](#balena.settings) : object - * [.get([key])](#balena.settings.get) ⇒ Promise - * [.getAll()](#balena.settings.getAll) ⇒ Promise - - - -#### settings.get([key]) ⇒ Promise -**Kind**: static method of [settings](#balena.settings) -**Summary**: Get a single setting. **Only implemented in Node.js** -**Access**: public -**Fulfil**: \* - setting value - -| Param | Type | Description | -| --- | --- | --- | -| [key] | String | setting key | - -**Example** -```js -balena.settings.get('apiUrl').then(function(apiUrl) { - console.log(apiUrl); -}); -``` - - -#### settings.getAll() ⇒ Promise -**Kind**: static method of [settings](#balena.settings) -**Summary**: Get all settings **Only implemented in Node.js** -**Access**: public -**Fulfil**: Object - settings -**Example** -```js -balena.settings.getAll().then(function(settings) { - console.log(settings); -}); -``` - - -### balena.utils : object -**Kind**: static namespace of [balena](#balena) - - -## listImagesFromTargetState(targetState) ⇒ -**Kind**: global function -**Returns**: array containing all images for all services for all releases for all apps for the device - -| Param | -| --- | -| targetState | - diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/README.md b/pages/external-docs/sdk/node-sdk/v21.7.4/README.md new file mode 100644 index 0000000000..5cd3cf79c1 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/README.md @@ -0,0 +1 @@ +# v21.7.4 \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/auth.md b/pages/external-docs/sdk/node-sdk/v21.7.4/auth.md new file mode 100644 index 0000000000..0011e51751 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/auth.md @@ -0,0 +1,497 @@ +# auth +balena.auth : object + +**Kind**: static namespace + +* * * + +## authenticate +balena.auth.authenticate(credentials) ⇒ Promise + +You should use [login](#balena.auth.login) when possible, +as it takes care of saving the token and email as well. + +Notice that if `credentials` contains extra keys, they'll be discarted +by the server automatically. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Authenticate with the server +**Access**: protected +**Fulfil**: String - session token + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of email, password

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
+ +**Example** +```js +balena.auth.authenticate(credentials).then(function(token) { + console.log('My token is:', token); +}); +``` + +* * * + +## getActorId +balena.auth.getActorId() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in actor id +**Access**: public +**Fulfil**: Number - actor id +**Example** +```js +balena.auth.getActorId().then(function(actorId) { + console.log(actorId); +}); +``` + +* * * + +## getToken +balena.auth.getToken() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in user's raw API key or session token +**Access**: public +**Fulfil**: String - raw API key or session token +**Example** +```js +balena.auth.getToken().then(function(token) { + console.log(token); +}); +``` + +* * * + +## getUserInfo +balena.auth.getUserInfo() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in user's info +**Access**: public +**Fulfil**: Object - user info +**Example** +```js +balena.auth.getUserInfo().then(function(userInfo) { + console.log(userInfo); +}); +``` + +* * * + +## isLoggedIn +balena.auth.isLoggedIn() ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Check if you're logged in +**Access**: public +**Fulfil**: Boolean - is logged in +**Example** +```js +balena.auth.isLoggedIn().then(function(isLoggedIn) { + if (isLoggedIn) { + console.log('I\'m in!'); + } else { + console.log('Too bad!'); + } +}); +``` + +* * * + +## login +balena.auth.login(credentials) ⇒ Promise + +If the login is successful, the token is persisted between sessions. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Login +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of email, password

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
+ +**Example** +```js +balena.auth.login(credentials); +``` + +* * * + +## loginWithToken +balena.auth.loginWithToken(authToken) ⇒ Promise + +Login to balena with a session token or api key instead of with credentials. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Login with a token or api key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
authTokenString

the auth token

+
+ +**Example** +```js +balena.auth.loginWithToken(authToken); +``` + +* * * + +## logout +balena.auth.logout() ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Logout +**Access**: public +**Example** +```js +balena.auth.logout(); +``` + +* * * + +## register +balena.auth.register(credentials) ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Register a user account +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of username, password and email

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
[credentials.'g-recaptcha-response']String | undefined

the captcha response

+
+ +**Example** +```js +balena.auth.register({ + email: 'johndoe@gmail.com', + password: 'secret' +}).then(function(token) { + console.log(token); +}); +``` + +* * * + +## requestVerificationEmail +balena.auth.requestVerificationEmail() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Re-send verification email to the user +**Access**: public +**Example** +```js +balena.auth.requestVerificationEmail().then(function() { + console.log('Requesting verification email operation complete!'); +}) +``` + +* * * + +## verifyEmail +balena.auth.verifyEmail(verificationPayload) ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Verifies an email +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + + + + + +
ParamTypeDescription
verificationPayloadObject

in the form of email, and token

+
verificationPayload.emailString

the email

+
verificationPayload.tokenString

the verification token

+
+ +**Example** +```js +balena.auth.verifyEmail({ + email: 'johndoe@gmail.com', + token: '5bb11d90eefb34a70318f06a43ef063f' +}).then(function(jwt) { + console.log(jwt); +}); +``` + +* * * + +## whoami +balena.auth.whoami() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Return current logged in information +**Access**: public +**Fulfil**: (Object\|undefined) - actor information, if it exists +**Example** +```js +balena.auth.whoami().then(function(result) { + if (!result) { + console.log('I\'m not logged in!'); + } else { + console.log('My result is:', result); + } +}); +``` + +* * * + +## twoFactor +balena.auth.twoFactor : object + +**Kind**: static namespace of [auth](#balena.auth) + +* * * + +### challenge +balena.auth.twoFactor.challenge(code) ⇒ Promise + +You should use [login](#balena.auth.login) when possible, +as it takes care of saving the token and email as well. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Challenge two factor authentication and complete login +**Access**: public + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +balena.auth.twoFactor.challenge('1234'); +``` + +* * * + +### disable +balena.auth.twoFactor.disable(password) ⇒ Promise + +Disables two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Disable two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
passwordString

password

+
+ +**Example** +```js +const token = balena.auth.twoFactor.disable('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + +### enable +balena.auth.twoFactor.enable(code) ⇒ Promise + +Enables two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Enable two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +const token = balena.auth.twoFactor.enable('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + +### getSetupKey +balena.auth.twoFactor.getSetupKey() ⇒ Promise + +Retrieves a setup key for enabling two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Get two factor authentication setup key +**Access**: public +**Fulfil**: String - setup key +**Example** +```js +const setupKey = balena.auth.twoFactor.getSetupKey(); +console.log(setupKey); +``` + +* * * + +### isEnabled +balena.auth.twoFactor.isEnabled() ⇒ Promise + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Check if two factor authentication is enabled +**Access**: public +**Fulfil**: Boolean - whether 2fa is enabled +**Example** +```js +balena.auth.twoFactor.isEnabled().then(function(isEnabled) { + if (isEnabled) { + console.log('2FA is enabled for this account'); + } +}); +``` + +* * * + +### isPassed +balena.auth.twoFactor.isPassed() ⇒ Promise + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Check if two factor authentication challenge was passed +**Access**: public +**Fulfil**: Boolean - whether 2fa challenge was passed +**Example** +```js +balena.auth.twoFactor.isPassed().then(function(isPassed) { + if (isPassed) { + console.log('2FA challenge passed'); + } +}); +``` + +* * * + +### verify +balena.auth.twoFactor.verify(code) ⇒ Promise + +Verifies two factor authentication. +Note that this method not update the token automatically. +You should use [challenge](#balena.auth.twoFactor.challenge) when possible, +as it takes care of that as well. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Verify two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +const token = balena.auth.twoFactor.verify('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/errors.md b/pages/external-docs/sdk/node-sdk/v21.7.4/errors.md new file mode 100644 index 0000000000..132e5c1184 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/errors.md @@ -0,0 +1,24 @@ +# errors +balena.errors : Object + +The balena-errors module used internally. This is provided primarily for +convenience, and to avoid the necessity for separate balena-errors +dependencies. You'll want to use this if you need to match on the specific +type of error thrown by the SDK. + +**Kind**: static member +**Summary**: Balena errors module +**Access**: public +**Example** +```js +balena.models.device.get(123).catch(function (error) { + if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) { + ... + } else if (error.code === balena.errors.BalenaRequestError.prototype.code) { + ... + } +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/fromSharedOptions.md b/pages/external-docs/sdk/node-sdk/v21.7.4/fromSharedOptions.md new file mode 100644 index 0000000000..73f0097d6d --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/fromSharedOptions.md @@ -0,0 +1,18 @@ +# fromSharedOptions +module:balena-sdk~fromSharedOptions() + +Create an SDK instance using shared default options set using the `setSharedOptions()` method. +If options have not been set using this method, then this method will use the +same defaults as the main SDK factory function. + +**Kind**: inner function +**Summary**: Create an SDK instance using shared default options +**Access**: public +**Example** +```js +import { fromSharedOptions } from 'balena-sdk'; +const sdk = fromSharedOptions(); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/getSdk.md b/pages/external-docs/sdk/node-sdk/v21.7.4/getSdk.md new file mode 100644 index 0000000000..dff2249899 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/getSdk.md @@ -0,0 +1,22 @@ +# getSdk +module:balena-sdk~getSdk() + +The module exports a single factory function. + +**Kind**: inner function +**Summary**: Creates a new SDK instance using the default or the provided options. +**Example** +```js +// with es6 imports +import { getSdk } from 'balena-sdk'; +// or with node require +const { getSdk } = require('balena-sdk'); + +const balena = getSdk({ + apiUrl: "https://api.balena-cloud.com/", + dataDirectory: "/opt/local/balena" +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/interceptors.md b/pages/external-docs/sdk/node-sdk/v21.7.4/interceptors.md new file mode 100644 index 0000000000..0da46482a3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/interceptors.md @@ -0,0 +1,68 @@ +# interceptors +balena.interceptors : Array.<Interceptor> + +The current array of interceptors to use. Interceptors intercept requests made +internally and are executed in the order they appear in this array for requests, +and in the reverse order for responses. + +**Kind**: static member +**Summary**: Array of interceptors +**Access**: public +**Example** +```js +balena.interceptors.push({ + responseError: function (error) { + console.log(error); + throw error; + }) +}); +``` + +* * * + +## Interceptor +balena.interceptors.Interceptor : object + +An interceptor implements some set of the four interception hook callbacks. +To continue processing, each function should return a value or a promise that +successfully resolves to a value. + +To halt processing, each function should throw an error or return a promise that +rejects with an error. + +**Kind**: static typedef of [interceptors](#balena.interceptors) +**Properties** + + + + + + + + + + + + + + + + + +
NameTypeDescription
[request]function

Callback invoked before requests are made. Called with +the request options, should return (or resolve to) new request options, or throw/reject.

+
[response]function

Callback invoked before responses are returned. Called with +the response, should return (or resolve to) a new response, or throw/reject.

+
[requestError]function

Callback invoked if an error happens before a request. +Called with the error itself, caused by a preceeding request interceptor rejecting/throwing +an error for the request, or a failing in preflight token validation. Should return (or resolve +to) new request options, or throw/reject.

+
[responseError]function

Callback invoked if an error happens in the response. +Called with the error itself, caused by a preceeding response interceptor rejecting/throwing +an error for the request, a network error, or an error response from the server. Should return +(or resolve to) a new response, or throw/reject.

+
+ + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/introduction.md b/pages/external-docs/sdk/node-sdk/v21.7.4/introduction.md new file mode 100644 index 0000000000..1220aa46ef --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/introduction.md @@ -0,0 +1,59 @@ +# Introduction + +Welcome to the balena Node SDK documentation. These pages aim to describe all the functions supported by the SDK, as well as showing examples of their expected usage. + +## Installation + +Install the balena SDK by running: + +```sh +$ npm install --save balena-sdk +``` + +### Bundling for browsers + +If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. + +If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: + +* fs +* path +* balena-settings-client +* node-localstorage +* fs/promises +* mime + +### Bundling with pkg + +The balena SDK includes builds for various ECMAScript versions that are +dynamically selected at runtime (using +[@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). +For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not +able to automatically detect which assets to include in the output package. The +following sample `pkg` section should be added to your application's +`package.json` file to instruct `pkg` to bundle the required assets: + +```json + "pkg": { + "scripts": [ + "node_modules/balena-sdk/**/*.js" + ], + "assets": [ + "node_modules/pinejs-client-core/**/*" + ] + } +``` + +For more information, please refer to the respective +[documentation from the `pkg` project](https://github.com/vercel/pkg#config). + +## Trying balenaSDK in the browser + +BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. +To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries. + +![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png) + + +If you feel something is missing, not clear or could be improved, please don't hesitate to open an +[issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help. \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/logs.md b/pages/external-docs/sdk/node-sdk/v21.7.4/logs.md new file mode 100644 index 0000000000..47357db4ba --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/logs.md @@ -0,0 +1,179 @@ +# logs +balena.logs : object + +**Kind**: static namespace + +* * * + +## history +balena.logs.history(uuidOrId, [options]) ⇒ Promise + +Get an array of the latest log messages for a given device. + +**Kind**: static method of [logs](#balena.logs) +**Summary**: Get device logs history +**Access**: public +**Fulfil**: Object[] - history lines + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.count]Number | 'all'1000

number of log messages to return (or 'all')

+
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages

+
+ +**Example** +```js +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd').then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +balena.logs.history(123).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +const oneDayAgoTimestamp = Date.now() - 24*60*60*1000; +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoTimestamp }).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +const oneDayAgoIsoDateString = new Date(Date.now() - 24*60*60*1000).toISOString(); +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoIsoDateString }).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` + +* * * + +## subscribe +balena.logs.subscribe(uuidOrId, [options]) ⇒ Promise.<LogSubscription> + +Connects to the stream of devices logs, returning a LogSubscription, which +can be used to listen for logs as they appear, line by line. + +**Kind**: static method of [logs](#balena.logs) +**Summary**: Subscribe to device logs +**Access**: public +**Fulfil**: [LogSubscription](#balena.logs.LogSubscription) + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.count]Number | 'all'0

number of historical messages to include (or 'all')

+
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages. When specified, the count parameter needs to also be provided.

+
+ +**Example** +```js +balena.logs.subscribe('7cf02a69e4d34c9da573914963cf54fd').then(function(logs) { + logs.on('line', function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +balena.logs.subscribe(123).then(function(logs) { + logs.on('line', function(line) { + console.log(line); + }); +}); +``` + +* * * + +## LogSubscription +balena.logs.LogSubscription : EventEmitter + +The log subscription emits events as log data arrives. +You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)` + +**Kind**: static typedef of [logs](#balena.logs) + +* * * + +### unsubscribe +balena.logs.LogSubscription.unsubscribe() + +Disconnect from the logs feed and stop receiving any future events on this emitter. + +**Kind**: static method of [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Unsubscribe from device logs +**Access**: public +**Example** +```js +logs.unsubscribe(); +``` + +* * * + +### error +balena.logs.LogSubscription.event:error + +**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Event fired when an error has occured reading the device logs +**Example** +```js +logs.on('error', function(error) { + console.error(error); +}); +``` + +* * * + +### line +balena.logs.LogSubscription.event:line + +**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Event fired when a new line of log output is available +**Example** +```js +logs.on('line', function(line) { + console.log(line); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/README.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/README.md new file mode 100644 index 0000000000..e89b5f2b2b --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/README.md @@ -0,0 +1 @@ +# Models \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/apiKey.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/apiKey.md new file mode 100644 index 0000000000..3e118ba1c1 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/apiKey.md @@ -0,0 +1,242 @@ +# apiKey +balena.models.apiKey : object + +**Kind**: static namespace + +* * * + +## create +balena.models.apiKey.create(createApiKeyParams) ⇒ Promise + +This method registers a new api key for the current user with the name given. + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Creates a new user API key +**Access**: public +**Fulfil**: String - API key + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
createApiKeyParamsObject

an object containing the parameters for the creation of an API key

+
createApiKeyParams.nameString

the API key name

+
createApiKeyParams.expiryDateString

the API key expiry date

+
[createApiKeyParams.description]String

the API key description

+
+ +**Example** +```js +balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12}).then(function(apiKey) { + console.log(apiKey); +}); +``` +**Example** +```js +balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12, description: apiKeyDescription}).then(function(apiKey) { + console.log(apiKey); +}); +``` + +* * * + +## getAll +balena.models.apiKey.getAll([options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all accessible API keys +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getAll().then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getAllNamedUserApiKeys +balena.models.apiKey.getAllNamedUserApiKeys([options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all named user API keys of the current user +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getDeviceApiKeysByDevice +balena.models.apiKey.getDeviceApiKeysByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all API keys for a device +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device, uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getProvisioningApiKeysByApplication +balena.models.apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all provisioning API keys for an application +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## revoke +balena.models.apiKey.revoke(id) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Revoke an API key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

API key id

+
+ +**Example** +```js +balena.models.apiKey.revoke(123); +``` + +* * * + +## update +balena.models.apiKey.update(id, apiKeyInfo) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Update the details of an API key +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idNumber

API key id

+
apiKeyInfoObject

an object with the updated name|description|expiryDate

+
+ +**Example** +```js +balena.models.apiKey.update(123, { name: 'updatedName' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { description: 'updated description' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { expiryDate: '2022-04-29' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' }); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/application.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/application.md new file mode 100644 index 0000000000..1f405f01f4 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/application.md @@ -0,0 +1,1956 @@ +# application +balena.models.application : object + +**Kind**: static namespace + +* * * + +## create +balena.models.application.create(options) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Create an application +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
optionsObject

application creation parameters

+
options.nameString

application name

+
options.organizationString | Number

handle (string) or id (number) of the organization that the application will belong to or null

+
[options.uuid]String

application uuid

+
[options.applicationClass]String

application class: 'app' | 'fleet' | 'block'

+
options.deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.application.create({ name: 'My App', organization: 'myorganization', deviceType: 'raspberry-pi' }).then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.create({ name: 'My Block', organization: 'myorganization', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) { + console.log(application); +}); +``` + +* * * + +## disableDeviceUrls +balena.models.application.disableDeviceUrls(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Disable device urls for all devices that belong to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.disableDeviceUrls('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.disableDeviceUrls(123); +``` + +* * * + +## enableDeviceUrls +balena.models.application.enableDeviceUrls(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Enable device urls for all devices that belong to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.enableDeviceUrls('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.enableDeviceUrls(123); +``` + +* * * + +## generateProvisioningKey +balena.models.application.generateProvisioningKey(generateProvisioningKeyParams) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Generate a device provisioning key for a specific application +**Access**: public +**Fulfil**: String - device provisioning key + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
generateProvisioningKeyParamsObject

an object containing the parameters for the provisioning key generation

+
generateProvisioningKeyParams.slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
generateProvisioningKeyParams.keyExpiryDateString

Expiry Date for provisioning key

+
[generateProvisioningKeyParams.keyName]String

Provisioning key name

+
[generateProvisioningKeyParams.keyDescription]String

Description for provisioning key

+
+ +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 'myorganization/myapp', keyExpiryDate: '2030-10-12'}).then(function(key) { + console.log(key); +}); +``` +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12'}).then(function(key) { + console.log(key); +}); +``` +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12', keyName: 'api key name', keyDescription: 'api key long description'}).then(function(key) { + console.log(key); +}); +``` + +* * * + +## get +balena.models.application.get(slugOrUuidOrId, [options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.get('myorganization/myapp').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.get(123).then(function(application) { + console.log(application); +}); +``` + +* * * + +## getAll +balena.models.application.getAll([options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.getAll().then(function(applications) { + console.log(applications); +}); +``` + +* * * + +## getAllByOrganization +balena.models.application.getAllByOrganization(orgHandleOrId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications of an organization +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + + + +
ParamTypeDefaultDescription
orgHandleOrIdNumber | String

organization handle (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getAllByOrganization('myorganization').then(function(applications) { + console.log(applications); +}); +``` +**Example** +```js +const applications = await sdk.models.application.getAllByOrganization('myorganization', { + $select: ['app_name', 'slug'], + $expand: { + owns__device: { + $select: ['uuid', 'overall_status', 'is_connected_to_vpn', 'api_heartbeat_state'], + }, + }, + }); +``` + +* * * + +## getAllDirectlyAccessible +balena.models.application.getAllDirectlyAccessible([options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications directly accessible by the user +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getAllDirectlyAccessible().then(function(applications) { + console.log(applications); +}); +``` + +* * * + +## getAppByName +balena.models.application.getAppByName(appName, [options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application using the appname and the handle of the owning organization +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appNameString

application name

+
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.getAppByName('MyApp').then(function(application) { + console.log(application); +}); +``` + +* * * + +## getDashboardUrl +balena.models.application.getDashboardUrl(id) ⇒ String + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get Dashboard URL for a specific application +**Returns**: String - - Dashboard URL for the specific application +**Throws**: + +- Exception if the id is not a finite number + + + + + + + + + + + +
ParamTypeDescription
idNumber

Application id

+
+ +**Example** +```js +balena.models.application.get('myorganization/myapp').then(function(application) { + const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); + console.log(dashboardApplicationUrl); +}); +``` + +* * * + +## getDirectlyAccessible +balena.models.application.getDirectlyAccessible(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application directly accessible by the user +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.getDirectlyAccessible(123).then(function(application) { + console.log(application); +}); +``` + +* * * + +## getTargetReleaseHash +balena.models.application.getTargetReleaseHash(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get the hash of the current release for a specific application +**Access**: public +**Fulfil**: String\|undefined - The release hash of the current release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.application.getTargetReleaseHash(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) { + console.log(release); +}); +``` + +* * * + +## getWithDeviceServiceDetails +balena.models.application.getWithDeviceServiceDetails(slugOrUuidOrId, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want more control, or to see the raw model +directly, use `application.get(uuidOrId, options)` instead. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application and its devices, along with each device's +associated services' essential details +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.application.getWithDeviceServiceDetails(123).then(function(device) { + console.log(device); +}) +``` + +* * * + +## grantSupportAccess +balena.models.application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Grant support access to an application until a specified time +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
expiryTimestampNumber

a timestamp in ms for when the support access will expire

+
+ +**Example** +```js +balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000); +``` +**Example** +```js +balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000); +``` + +* * * + +## has +balena.models.application.has(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Check if an application exists +**Access**: public +**Fulfil**: Boolean - has application + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.has('myorganization/myapp').then(function(hasApp) { + console.log(hasApp); +}); +``` +**Example** +```js +balena.models.application.has(123).then(function(hasApp) { + console.log(hasApp); +}); +``` + +* * * + +## hasAny +balena.models.application.hasAny() ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Check if the user has access to any applications +**Access**: public +**Fulfil**: Boolean - has any applications +**Example** +```js +balena.models.application.hasAny().then(function(hasAny) { + console.log('Has any?', hasAny); +}); +``` + +* * * + +## isTrackingLatestRelease +balena.models.application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates +**Access**: public +**Fulfil**: Boolean - is tracking the latest release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) { + console.log(isEnabled); +}); +``` +**Example** +```js +balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## pinToRelease +balena.models.application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ Promise + +Configures the application to run a particular release +and not get updated when the latest release changes. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Set a specific application to run a particular release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
fullReleaseHashString

the hash of a successful release (string)

+
+ +**Example** +```js +balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` + +* * * + +## purge +balena.models.application.purge(appId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Purge devices by application id +**Access**: public + + + + + + + + + + +
ParamTypeDescription
appIdNumber

application id

+
+ +**Example** +```js +balena.models.application.purge(123); +``` + +* * * + +## reboot +balena.models.application.reboot(appId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Reboot devices by application id +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appIdNumber

application id

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.application.reboot(123); +``` + +* * * + +## remove +balena.models.application.remove(slugOrUuidOrIdOrIds) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Remove application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdOrIdsString | Number | Array.<Number>

application slug (string), uuid (string) or id (number) or array of ids

+
+ +**Example** +```js +balena.models.application.remove('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.remove(123); +``` + +* * * + +## rename +balena.models.application.rename(slugOrUuidOrId, newName) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Rename application +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
newNameString

new application name (string)

+
+ +**Example** +```js +balena.models.application.rename('myorganization/myapp', 'MyRenamedApp'); +``` +**Example** +```js +balena.models.application.rename(123, 'MyRenamedApp'); +``` + +* * * + +## restart +balena.models.application.restart(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Restart application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.restart('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.restart(123); +``` + +* * * + +## revokeSupportAccess +balena.models.application.revokeSupportAccess(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Revoke support access to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.revokeSupportAccess('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.revokeSupportAccess(123); +``` + +* * * + +## shutdown +balena.models.application.shutdown(appId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Shutdown devices by application id +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appIdNumber

application id

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.application.shutdown(123); +``` + +* * * + +## trackLatestRelease +balena.models.application.trackLatestRelease(slugOrUuidOrId) ⇒ Promise + +The application's current release will be updated with each new successfully built release. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Configure a specific application to track the latest finalized available release +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.trackLatestRelease('myorganization/myapp').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.trackLatestRelease(123).then(function() { + ... +}); +``` + +* * * + +## willTrackNewReleases +balena.models.application.willTrackNewReleases(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get whether the application is configured to receive updates whenever a new release is available +**Access**: public +**Fulfil**: Boolean - is tracking the latest release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) { + console.log(isEnabled); +}); +``` +**Example** +```js +balena.models.application.willTrackNewReleases(123).then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## buildVar +balena.models.application.buildVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.buildVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Get the value of a specific build environment variable +**Access**: public +**Fulfil**: String\|undefined - the build environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
+ +**Example** +```js +balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.buildVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.buildVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Get all build environment variables for an application +**Access**: public +**Fulfil**: Object[] - application build environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.buildVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Clear the value of a specific build environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
+ +**Example** +```js +balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.buildVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.buildVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Set the value of a specific build environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
valueString

build environment variable value

+
+ +**Example** +```js +balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## configVar +balena.models.application.configVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.configVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Get the value of a specific config variable +**Access**: public +**Fulfil**: String\|undefined - the config variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Get all config variables for an application +**Access**: public +**Fulfil**: Object[] - application config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.configVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.configVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Clear the value of a specific config variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.configVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Set the value of a specific config variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
valueString

config variable value

+
+ +**Example** +```js +balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## envVar +balena.models.application.envVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.envVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Get the value of a specific environment variable +**Access**: public +**Fulfil**: String\|undefined - the environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.envVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Get all environment variables for an application +**Access**: public +**Fulfil**: Object[] - application environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.envVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.envVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Clear the value of a specific environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.envVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.envVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Set the value of a specific environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
valueString

environment variable value

+
+ +**Example** +```js +balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## invite +balena.models.application.invite : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### accept +balena.models.application.invite.accept(invitationToken) ⇒ Promise + +This method adds the calling user to the application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Accepts an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
invitationTokenString

invite token

+
+ +**Example** +```js +balena.models.application.invite.accept("qwerty-invitation-token"); +``` + +* * * + +### create +balena.models.application.invite.create(slugOrUuidOrId, options, [message]) ⇒ Promise + +This method invites a user by their email to an application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Creates a new invite for an application +**Access**: public +**Fulfil**: String - application invite + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
optionsObject

invite creation parameters

+
options.inviteeString

the email of the invitee

+
[options.roleName]String"developer"

the role name to be granted to the invitee

+
[message]String

the message to send along with the invite

+
+ +**Example** +```js +balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) { + console.log(invite); +}); +``` + +* * * + +### getAll +balena.models.application.invite.getAll([options]) ⇒ Promise + +This method returns all invites. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Get all invites +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.invite.getAll().then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.invite.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all invites for a specific application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Get all invites by application +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) { + console.log(invites); +}); +``` +**Example** +```js +balena.models.application.invite.getAllByApplication(123).then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### revoke +balena.models.application.invite.revoke(id) ⇒ Promise + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Revoke an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

application invite id

+
+ +**Example** +```js +balena.models.application.invite.revoke(123); +``` + +* * * + +## membership +balena.models.application.membership : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### changeRole +balena.models.application.membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise + +This method changes the role of an application member. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Changes the role of an application member +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be changed

+
roleNameString

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.application.membership.changeRole(123, "member").then(function() { + console.log('OK'); +}); +``` +**Example** +```js +balena.models.application.membership.changeRole({ + user: 123, + is_member_of__application: 125, +}, "member").then(function() { + console.log('OK'); +}); +``` + +* * * + +### create +balena.models.application.membership.create(options) ⇒ Promise + +This method adds a user to an application by their username if they are a member of the organization. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Creates a new membership for an application +**Access**: public +**Fulfil**: Object - application membership + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

membership creation parameters

+
options.applicationString | Number

application handle (string), or id (number)

+
options.usernameString

the username of the balena user that will become a member

+
[options.roleName]String"member"

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { + console.log(membership); +}); +``` + +* * * + +### get +balena.models.application.membership.get(membershipId, [options]) ⇒ Promise + +This method returns a single application membership. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get a single application membership +**Access**: public +**Fulfil**: Object - application membership + + + + + + + + + + + + +
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.get(5).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.membership.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all application memberships for a specific application. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get all memberships by application +**Access**: public +**Fulfil**: Object[] - application memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.application.membership.getAllByApplication(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByUser +balena.models.application.membership.getAllByUser(usernameOrId, [options]) ⇒ Promise + +This method returns all application memberships for a specific user. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get all memberships by user +**Access**: public +**Fulfil**: Object[] - application memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.application.membership.getAllByUser(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### remove +balena.models.application.membership.remove(idOrUniqueKey) ⇒ Promise + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Remove a membership +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be removed

+
+ +**Example** +```js +balena.models.application.membership.remove(123); +``` +**Example** +```js +balena.models.application.membership.remove({ + user: 123, + is_member_of__application: 125, +}); +``` + +* * * + +## tags +balena.models.application.tags : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### getAllByApplication +balena.models.application.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Get all application tags for an application +**Access**: public +**Fulfil**: Object[] - application tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.application.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.application.tags.remove(slugOrUuidOrId, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Remove an application tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.application.tags.remove('myorganization/myapp', 'EDITOR'); +``` + +* * * + +### set +balena.models.application.tags.set(slugOrUuidOrId, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Set an application tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.application.tags.set(123, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/billing.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/billing.md new file mode 100644 index 0000000000..fd9bdf75a2 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/billing.md @@ -0,0 +1,339 @@ +# billing +balena.models.billing : object + +**Note!** The billing methods are available on Balena.io exclusively. + +**Kind**: static namespace + +* * * + +## changePlan +balena.models.billing.changePlan(organization, planChangeOptions) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Change the current billing plan +**Access**: public + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
planChangeOptionsObject

an object containing the billing plan change options

+
billingInfo.tierString

the code of the target billing plan

+
billingInfo.cycleString

the billing cycle

+
[billingInfo.planChangeReason]String

the reason for changing the current plan

+
+ +**Example** +```js +balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() { + console.log('Plan changed!'); +}); +``` + +* * * + +## createSetupIntent +balena.models.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 + + + + + + + + + + + + + + +
ParamTypeDescription
setupIntentParamsObject

an object containing the parameters for the setup intent creation

+
extraParams.organizationString | 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); +}); +``` + +* * * + +## downloadInvoice +balena.models.billing.downloadInvoice(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Download a specific invoice +**Access**: public +**Fulfil**: Blob\|ReadableStream - blob on the browser, download stream on node + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
String

an invoice number

+
+ +**Example** +```js +# Browser +balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) { + console.log(blob); +}); +# Node +balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) { + stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf')); +}); +``` + +* * * + +## getAccount +balena.models.billing.getAccount(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the user's billing account +**Access**: public +**Fulfil**: Object - billing account + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getAccount(orgId).then(function(billingAccount) { + console.log(billingAccount); +}); +``` + +* * * + +## getBillingInfo +balena.models.billing.getBillingInfo(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the current billing information +**Access**: public +**Fulfil**: Object - billing information + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getBillingInfo(orgId).then(function(billingInfo) { + console.log(billingInfo); +}); +``` + +* * * + +## getInvoices +balena.models.billing.getInvoices(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the available invoices +**Access**: public +**Fulfil**: Object - invoices + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getInvoices(orgId).then(function(invoices) { + console.log(invoices); +}); +``` + +* * * + +## getPlan +balena.models.billing.getPlan(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the current billing plan +**Access**: public +**Fulfil**: Object - billing plan + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getPlan(orgId).then(function(billingPlan) { + console.log(billingPlan); +}); +``` + +* * * + +## removeBillingInfo +balena.models.billing.removeBillingInfo(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Remove an organization's billing information +**Access**: public + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.removeBillingInfo(orgId).then(function() { + console.log("Success"); +}); +``` + +* * * + +## updateAccountInfo +balena.models.billing.updateAccountInfo(organization, accountInfo) + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Update the current billing account information +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
accountInfoAccountInfo

an object containing billing account info

+
+ +**Example** +```js +balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) +``` +**Example** +```js +balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) +``` + +* * * + +## updateBillingInfo +balena.models.billing.updateBillingInfo(organization, billingInfo) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Update the current billing information +**Access**: public +**Fulfil**: Object - billing information + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
billingInfoObject

an object containing a billing info token_id

+
billingInfo.token_idString

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 +balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) { + console.log(billingInfo); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/config.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/config.md new file mode 100644 index 0000000000..676ca030aa --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/config.md @@ -0,0 +1,130 @@ +# config +balena.models.config : object + +**Kind**: static namespace + +* * * + +## getAll +balena.models.config.getAll() ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get all configuration +**Access**: public +**Fulfil**: Object - configuration +**Example** +```js +balena.models.config.getAll().then(function(config) { + console.log(config); +}); +``` + +* * * + +## getConfigVarSchema +balena.models.config.getConfigVarSchema(deviceType) ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get configuration variables schema for a device type +**Access**: public +**Fulfil**: Object[] - configuration options + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) { + console.log(options); +}); +``` + +* * * + +## getDeviceOptions +balena.models.config.getDeviceOptions(deviceType) ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get configuration/initialization options for a device type +**Access**: public +**Fulfil**: Object[] - configuration options + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) { + console.log(options); +}); +``` + +* * * + +## getDeviceTypeManifestBySlug +balena.models.config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise + +***use balena.models.deviceType.getBySlugOrName*** + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get a device type manifest by slug +**Access**: public +**Fulfil**: Object - device type manifest + + + + + + + + + + +
ParamTypeDescription
slugOrNameString

device type slug

+
+ +**Example** +```js +balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) { + console.log(manifest); +}); +``` + +* * * + +## getDeviceTypes +balena.models.config.getDeviceTypes() ⇒ Promise + +***use balena.models.deviceType.getAll*** + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get device types +**Access**: public +**Fulfil**: Object[] - device types +**Example** +```js +balena.models.config.getDeviceTypes().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/creditBundle.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/creditBundle.md new file mode 100644 index 0000000000..9b3025c4e4 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/creditBundle.md @@ -0,0 +1,74 @@ +# creditBundle +balena.models.creditBundle : object + +**Kind**: static namespace + +* * * + +## create +balena.models.creditBundle.create(organization, featureId, creditsToPurchase) ⇒ Promise + +**Kind**: static method of [creditBundle](#balena.models.creditBundle) +**Summary**: Purchase a credit bundle for the given feature and org of the given quantity +**Access**: public +**Fulfil**: Object[] - credit bundles + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
featureIdNumber

id (number) of the feature for which credits are being purchased.

+
creditsToPurchaseNumber

number of credits being purchased.

+
+ +**Example** +```js +balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) { + console.log(creditBundle); +}); +``` + +* * * + +## getAllByOrg +balena.models.creditBundle.getAllByOrg(organization, [options]) ⇒ Promise + +**Kind**: static method of [creditBundle](#balena.models.creditBundle) +**Summary**: Get all of the credit bundles purchased by the given org +**Access**: public +**Fulfil**: Object[] - credit bundles + + + + + + + + + + + + +
ParamTypeDefaultDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) { + console.log(creditBundles); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/device.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/device.md new file mode 100644 index 0000000000..49a47aeac3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/device.md @@ -0,0 +1,2986 @@ +# device +balena.models.device : object + +**Kind**: static namespace + +* * * + +## deactivate +balena.models.device.deactivate(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Deactivate device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.deactivate('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.deactivate(123); +``` + +* * * + +## disableDeviceUrl +balena.models.device.disableDeviceUrl(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable device url for a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.disableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableDeviceUrl(123); +``` + +* * * + +## disableLocalMode +balena.models.device.disableLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable local mode +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.disableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableLocalMode(123); +``` + +* * * + +## disableLockOverride +balena.models.device.disableLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable lock override +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.disableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableLockOverride(123); +``` + +* * * + +## enableDeviceUrl +balena.models.device.enableDeviceUrl(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable device url for a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.enableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableDeviceUrl(123); +``` + +* * * + +## enableLocalMode +balena.models.device.enableLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable local mode +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.enableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableLocalMode(123); +``` + +* * * + +## enableLockOverride +balena.models.device.enableLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable lock override +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.enableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableLockOverride(123); +``` + +* * * + +## generateDeviceKey +balena.models.device.generateDeviceKey(uuidOrId, [keyName], [keyDescription]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Generate a device key +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[keyName]String

Device key name

+
[keyDescription]String

Description for device key

+
+ +**Example** +```js +balena.models.device.generateDeviceKey('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceApiKey) { + console.log(deviceApiKey); +}); +``` +**Example** +```js +balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) { + console.log(deviceApiKey); +}); +``` + +* * * + +## generateUniqueKey +balena.models.device.generateUniqueKey() ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Generate a random key, useful for both uuid and api key. +**Returns**: String - A generated key +**Access**: public +**Example** +```js +randomKey = balena.models.device.generateUniqueKey(); +// randomKey is a randomly generated key that can be used as either a uuid or an api key +console.log(randomKey); +``` + +* * * + +## get +balena.models.device.get(uuidOrId, [options]) ⇒ Promise + +This method returns a single device by id or uuid. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a single device +**Access**: public +**Fulfil**: Object - device + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.get(123).then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getAllByApplication +balena.models.device.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all devices of a specific application. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get all devices by application +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByApplication(123).then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getAllByOrganization +balena.models.device.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all devices of a specific application. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get all devices by organization +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getAllByOrganization('myorganization').then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByOrganization(123).then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getApplicationName +balena.models.device.getApplicationName(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get application name +**Access**: public +**Fulfil**: String - application name + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getApplicationName('7cf02a69e4d34c9da573914963cf54fd').then(function(applicationName) { + console.log(applicationName); +}); +``` +**Example** +```js +balena.models.device.getApplicationName(123).then(function(applicationName) { + console.log(applicationName); +}); +``` + +* * * + +## getByName +balena.models.device.getByName(name) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get devices by name +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + +
ParamTypeDescription
nameString

device name

+
+ +**Example** +```js +balena.models.device.getByName('MyDevice').then(function(devices) { + console.log(devices); +}); +``` + +* * * + +## getDashboardUrl +balena.models.device.getDashboardUrl(uuid) ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get Dashboard URL for a specific device +**Returns**: String - - Dashboard URL for the specific device +**Throws**: + +- Exception if the uuid is empty + + + + + + + + + + + +
ParamTypeDescription
uuidString

Device uuid

+
+ +**Example** +```js +dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8') +``` + +* * * + +## getDeviceUrl +balena.models.device.getDeviceUrl(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a device url +**Access**: public +**Fulfil**: String - device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(url) { + console.log(url); +}); +``` +**Example** +```js +balena.models.device.getDeviceUrl(123).then(function(url) { + console.log(url); +}); +``` + +* * * + +## getLocalIPAddresses +balena.models.device.getLocalIPAddresses(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the local IP addresses of a device +**Access**: public +**Fulfil**: String[] - local ip addresses +**Reject**: Error Will reject if the device is offline + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getLocalIPAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(localIPAddresses) { + localIPAddresses.forEach(function(localIP) { + console.log(localIP); + }); +}); +``` +**Example** +```js +balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) { + localIPAddresses.forEach(function(localIP) { + console.log(localIP); + }); +}); +``` + +* * * + +## getLocalModeSupport +balena.models.device.getLocalModeSupport(device) ⇒ Object + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported. +**Returns**: Object - Local mode support info ({ supported: true/false, message: "..." }) +**Access**: public + + + + + + + + + + +
ParamTypeDescription
deviceObject

A device object

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + balena.models.device.getLocalModeSupport(device); +}) +``` + +* * * + +## getMACAddresses +balena.models.device.getMACAddresses(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the MAC addresses of a device +**Access**: public +**Fulfil**: String[] - mac addresses + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getMACAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(macAddresses) { + macAddresses.forEach(function(mac) { + console.log(mac); + }); +}); +``` +**Example** +```js +balena.models.device.getMACAddresses(123).then(function(macAddresses) { + macAddresses.forEach(function(mac) { + console.log(mac); + }); +}); +``` + +* * * + +## getMetrics +balena.models.device.getMetrics(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the metrics related information for a device +**Access**: public +**Fulfil**: Object - device metrics + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getMetrics('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceMetrics) { + console.log(deviceMetrics); +}); +``` +**Example** +```js +balena.models.device.getMetrics(123).then(function(deviceMetrics) { + console.log(deviceMetrics); +}); +``` + +* * * + +## getName +balena.models.device.getName(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the name of a device +**Access**: public +**Fulfil**: String - device name + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getName('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceName) { + console.log(deviceName); +}); +``` +**Example** +```js +balena.models.device.getName(123).then(function(deviceName) { + console.log(deviceName); +}); +``` + +* * * + +## getOsVersion +balena.models.device.getOsVersion(device) ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the OS version (version number and variant combined) running on a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
deviceObject

A device object

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device.os_version); // => 'balenaOS 2.26.0+rev1' + console.log(device.os_variant); // => 'prod' + balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod' +}) +``` + +* * * + +## getProgress +balena.models.device.getProgress(uuidOrId) ⇒ Promise + +Convenience method for getting the overall progress of a device. +It's recommended to use `balena.models.device.get()` instead, +in case that you need to retrieve more device fields than just the progress. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the progress of a device +**Access**: public +**Fulfil**: Number\|null - device progress +**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field. + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getProgress('7cf02a69e4d34c9da573914963cf54fd').then(function(progress) { + console.log(progress); +}); +``` +**Example** +```js +balena.models.device.getProgress(123).then(function(progress) { + console.log(progress); +}); +``` + +* * * + +## getStatus +balena.models.device.getStatus(uuidOrId) ⇒ Promise + +Convenience method for getting the overall status of a device. +It's recommended to use `balena.models.device.get()` instead, +in case that you need to retrieve more device fields than just the status. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the status of a device +**Access**: public +**Fulfil**: String - device status +**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field. + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getStatus('7cf02a69e4d34c9da573914963cf54fd').then(function(status) { + console.log(status); +}); +``` +**Example** +```js +balena.models.device.getStatus(123).then(function(status) { + console.log(status); +}); +``` + +* * * + +## getSupervisorState +balena.models.device.getSupervisorState(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the supervisor state on a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getSupervisorState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorState(123).then(function(state) { + console.log(state); +}); +``` + +* * * + +## getSupervisorTargetState +balena.models.device.getSupervisorTargetState(uuidOrId, version) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the target supervisor state on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
versionNumber

(optional) target state version (2 or 3), default to 2

+
+ +**Example** +```js +balena.models.device.getSupervisorTargetState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetState(123).then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetState(123, 3).then(function(state) { + console.log(state); +}); +``` + +* * * + +## getSupervisorTargetStateForApp +balena.models.device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the target supervisor state on a "generic" device on a fleet +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

fleet uuid (string) or id (number)

+
releaseString

(optional) release uuid (default tracked)

+
+ +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` + +* * * + +## getTargetReleaseHash +balena.models.device.getTargetReleaseHash(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the hash of the currently tracked release for a specific device +**Access**: public +**Fulfil**: String - The release hash of the currently tracked release + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd', function(release) { + console.log(release); +}); +``` + +* * * + +## getWithServiceDetails +balena.models.device.getWithServiceDetails(uuidOrId, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want more control, or to see the raw model +directly, use `device.get(uuidOrId, options)` instead. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a single device along with its associated services' details, +including their associated commit +**Access**: public +**Fulfil**: Object - device with service details + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getWithServiceDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.getWithServiceDetails(123).then(function(device) { + console.log(device); +}) +``` + +* * * + +## grantSupportAccess +balena.models.device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Grant support access to a device until a specified time +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
expiryTimestampNumber

a timestamp in ms for when the support access will expire

+
+ +**Example** +```js +balena.models.device.grantSupportAccess('7cf02a69e4d34c9da573914963cf54fd', Date.now() + 3600 * 1000); +``` +**Example** +```js +balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000); +``` + +* * * + +## has +balena.models.device.has(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device exists +**Access**: public +**Fulfil**: Boolean - has device + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.has('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDevice) { + console.log(hasDevice); +}); +``` +**Example** +```js +balena.models.device.has(123).then(function(hasDevice) { + console.log(hasDevice); +}); +``` + +* * * + +## hasDeviceUrl +balena.models.device.hasDeviceUrl(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device is web accessible with device utls +**Access**: public +**Fulfil**: Boolean - has device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.hasDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDeviceUrl) { + if (hasDeviceUrl) { + console.log('The device has device URL enabled'); + } +}); +``` +**Example** +```js +balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) { + if (hasDeviceUrl) { + console.log('The device has device URL enabled'); + } +}); +``` + +* * * + +## hasLockOverride +balena.models.device.hasLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device has the lock override enabled +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.hasLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.hasLockOverride(123); +``` + +* * * + +## identify +balena.models.device.identify(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Identify device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.identify('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.identify(123); +``` + +* * * + +## isInLocalMode +balena.models.device.isInLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if local mode is enabled on the device +**Access**: public +**Fulfil**: Boolean - has device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isInLocalMode('7cf02a69e4d34c9da573914963cf54fd').then(function(isInLocalMode) { + if (isInLocalMode) { + console.log('The device has local mode enabled'); + } +}); +``` +**Example** +```js +balena.models.device.isInLocalMode(123).then(function(isInLocalMode) { + if (isInLocalMode) { + console.log('The device has local mode enabled'); + } +}); +``` + +* * * + +## isOnline +balena.models.device.isOnline(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device is online +**Access**: public +**Fulfil**: Boolean - is device online + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isOnline('7cf02a69e4d34c9da573914963cf54fd').then(function(isOnline) { + console.log('Is device online?', isOnline); +}); +``` +**Example** +```js +balena.models.device.isOnline(123).then(function(isOnline) { + console.log('Is device online?', isOnline); +}); +``` + +* * * + +## isTrackingApplicationRelease +balena.models.device.isTrackingApplicationRelease(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get whether the device is configured to track the current application release +**Access**: public +**Fulfil**: Boolean - is tracking the current application release + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isTrackingApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## move +balena.models.device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Move a device to another application +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.move('7cf02a69e4d34c9da573914963cf54fd', 'myorganization/myapp'); +``` +**Example** +```js +balena.models.device.move(123, 'myorganization/myapp'); +``` +**Example** +```js +balena.models.device.move(123, 456); +``` + +* * * + +## ping +balena.models.device.ping(uuidOrId) ⇒ Promise + +This is useful to signal that the supervisor is alive and responding. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Ping a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.ping('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.ping(123); +``` + +* * * + +## pinToOsRelease +balena.models.device.pinToOsRelease(uuidOrIdOrArray, osVersionOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Mark a specific device to be updated to a particular OS release +**Access**: public +**Experimental**: + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
osVersionOrIdString

the raw version of a OS release (string) or id (number) +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number, a "prod" variant and greater than or equal to the one running on the device. +To resolve compatible update targets for a device use balena.models.os.getSupportedOsUpdateVersions.

+
+ +**Example** +```js +await balena.models.device.pinToOsRelease('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod'); +``` + +* * * + +## pinToRelease +balena.models.device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ Promise + +Configures the device to run a particular release +and not get updated when the current application release changes. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a specific device to run a particular release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
fullReleaseHashOrIdString | Number

the hash of a successful release (string) or id (number)

+
+ +**Example** +```js +balena.models.device.pinToRelease('7cf02a69e4d34c9da573914963cf54fd', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` + +* * * + +## pinToSupervisorRelease +balena.models.device.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ Promise + +Configures the device to run a particular supervisor release. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a specific device to run a particular supervisor release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
supervisorVersionOrIdString | Number

the raw version of a supervisor release (string) or id (number)

+
+ +**Example** +```js +balena.models.device.pinToSupervisorRelease('7cf02a69e4d34c9da573914963cf54fd', '10.8.0').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.pinToSupervisorRelease(123, '11.4.14').then(function() { + ... +}); +``` + +* * * + +## purge +balena.models.device.purge(uuidOrId) ⇒ Promise + +This function clears the user application's `/data` directory. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Purge device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.purge('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.purge(123); +``` + +* * * + +## reboot +balena.models.device.reboot(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Reboot device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.reboot('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.reboot(123); +``` + +* * * + +## register +balena.models.device.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Register a new device with a Balena application. +**Access**: public +**Fulfil**: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." }) + + + + + + + + + + + + + + +
ParamTypeDescription
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
uuidString

device uuid

+
[deviceTypeSlug]String

device type slug (string) or alias (string)

+
+ +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register(123, uuid).then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` + +* * * + +## remove +balena.models.device.remove(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Remove device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.remove('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.remove(123); +``` + +* * * + +## rename +balena.models.device.rename(uuidOrId, newName) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Rename device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
newNameString

the device new name

+
+ +**Example** +```js +balena.models.device.rename('7cf02a69e4d34c9da573914963cf54fd', 'NewName'); +``` +**Example** +```js +balena.models.device.rename(123, 'NewName'); +``` + +* * * + +## restartApplication +balena.models.device.restartApplication(uuidOrId) ⇒ Promise + +This function restarts the Docker container running +the application on the device, but doesn't reboot +the device itself. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Restart application on device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.restartApplication('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.restartApplication(123); +``` + +* * * + +## restartService +balena.models.device.restartService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Restart a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to restart

+
+ +**Example** +```js +balena.models.device.restartService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.restartService(1, 123).then(function() { + ... +}); +``` + +* * * + +## revokeSupportAccess +balena.models.device.revokeSupportAccess(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Revoke support access to a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.revokeSupportAccess('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.revokeSupportAccess(123); +``` + +* * * + +## setCustomLocation +balena.models.device.setCustomLocation(uuidOrIdOrArray, location) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a custom location for a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
locationObject

the location ({ latitude: 123, longitude: 456 })

+
+ +**Example** +```js +balena.models.device.setCustomLocation('7cf02a69e4d34c9da573914963cf54fd', { latitude: 123, longitude: 456 }); +``` +**Example** +```js +balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 }); +``` + +* * * + +## setNote +balena.models.device.setNote(uuidOrIdOrArray, note) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Note a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
noteString

the note

+
+ +**Example** +```js +balena.models.device.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); +``` +**Example** +```js +balena.models.device.setNote(123, 'My useful note'); +``` + +* * * + +## shutdown +balena.models.device.shutdown(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Shutdown device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.shutdown('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.shutdown(123); +``` + +* * * + +## startOsUpdate +balena.models.device.startOsUpdate(uuidOrUuids, targetOsVersion, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Start an OS update on a device +**Access**: public +**Fulfil**: Object - action response + + + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrUuidsString | Array.<String>

full device uuid or array of full uuids

+
targetOsVersionString

semver-compatible version for the target device +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number, a "prod" variant and greater than the one running on the device. +To resolve the semver-compatible range use balena.model.os.getMaxSatisfyingVersion.

+
[options]Object

options

+
[options.runDetached]Boolean

run the update in detached mode. True by default

+
+ +**Example** +```js +balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { + console.log(result.status); +}); +``` + +* * * + +## startService +balena.models.device.startService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Start a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to start

+
+ +**Example** +```js +balena.models.device.startService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.startService(1, 123).then(function() { + ... +}); +``` + +* * * + +## stopService +balena.models.device.stopService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Stop a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to stop

+
+ +**Example** +```js +balena.models.device.stopService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.stopService(1, 123).then(function() { + ... +}); +``` + +* * * + +## trackApplicationRelease +balena.models.device.trackApplicationRelease(uuidOrIdOrArray) ⇒ Promise + +The device's current release will be updated with each new successfully built release. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Configure a specific device to track the current application release +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.trackApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function() { + ... +}); +``` + +* * * + +## unsetCustomLocation +balena.models.device.unsetCustomLocation(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Clear the custom location of a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.unsetCustomLocation('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.unsetCustomLocation(123); +``` + +* * * + +## update +balena.models.device.update(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Trigger an update check on the supervisor +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.update('7cf02a69e4d34c9da573914963cf54fd', { + force: true +}); +``` +**Example** +```js +balena.models.device.update(123, { + force: true +}); +``` + +* * * + +## configVar +balena.models.device.configVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.configVar.get(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get the value of a specific config variable +**Access**: public +**Fulfil**: String\|undefined - the config variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.device.configVar.get('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get all device config variables by application +**Access**: public +**Fulfil**: Object[] - device config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.configVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.configVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get all config variables for a device +**Access**: public +**Fulfil**: Object[] - device config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.configVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.configVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.configVar.remove(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Clear the value of a specific config variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.device.configVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.configVar.set(uuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Set the value of a specific config variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
valueString

config variable value

+
+ +**Example** +```js +balena.models.device.configVar.set('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## envVar +balena.models.device.envVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.envVar.get(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get the value of a specific environment variable +**Access**: public +**Fulfil**: String\|undefined - the environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.device.envVar.get('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.envVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get all device environment variables by application +**Access**: public +**Fulfil**: Object[] - device environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.envVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.envVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get all environment variables for a device +**Access**: public +**Fulfil**: Object[] - device environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.envVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.envVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.envVar.remove(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Clear the value of a specific environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.device.envVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.envVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.envVar.set(uuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Set the value of a specific environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
valueString

environment variable value

+
+ +**Example** +```js +balena.models.device.envVar.set('7cf02a69e4d34c9da573914963cf54fd', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## history +balena.models.device.history : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### getAllByApplication +balena.models.device.history.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [history](#balena.models.device.history) +**Summary**: Get all device history entries by application with time frame +**Access**: public +**Fulfil**: Object[] - device history + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

+
[dateFilter.toDate]Date

history entries younger or equal to this date

+
[options]Object

extra pine options to use

+
+ +**Example** +```js +balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +balena.models.device.history.getAllByApplication(999999).then(function(entries) { + console.log(entries); +}); + + +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByApplication( + 999999, + { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10), + { $top: 10, $orderby: { id: 'desc' }} +}); +``` + +* * * + +### getAllByDevice +balena.models.device.history.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [history](#balena.models.device.history) +**Summary**: Get all history entries for a device +**Access**: public +**Fulfil**: Object[] - device history + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (32 / 62 digits string) or id (number)

+
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

+
[dateFilter.toDate]Date

history entries younger or equal to this date

+
[options]Object

extra pine options to use

+
+ +**Example** +```js +balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +balena.models.device.history.getAllByDevice(999999).then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByDevice( + 999999, + { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}, + { $top: 10, $orderby: { id: 'desc' }} +) +``` + +* * * + +## serviceVar +balena.models.device.serviceVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get the overriden value of a service variable on a device +**Access**: public +**Fulfil**: String\|undefined - the variable value (or undefined) + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
+ +**Example** +```js +balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.serviceVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get all device service variable overrides by application +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.serviceVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get all service variable overrides for a device +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.serviceVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Clear the overridden value of a service variable on a device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
+ +**Example** +```js +balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Set the overriden value of a service variable on a device +**Access**: public + + + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
valueString

variable value

+
+ +**Example** +```js +balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR', 'override').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR', 'override').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() { + ... +}); +``` + +* * * + +## tags +balena.models.device.tags : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### getAllByApplication +balena.models.device.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Get all device tags for an application +**Access**: public +**Fulfil**: Object[] - device tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.device.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.tags.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Get all device tags for a device +**Access**: public +**Fulfil**: Object[] - device tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.tags.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.device.tags.getAllByDevice(123).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.device.tags.remove(uuidOrId, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Remove a device tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.device.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); +``` + +* * * + +### set +balena.models.device.tags.set(uuidOrId, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Set a device tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.device.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.device.tags.set(123, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/deviceType.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/deviceType.md new file mode 100644 index 0000000000..d5057f98ff --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/deviceType.md @@ -0,0 +1,309 @@ +# deviceType +balena.models.deviceType : object + +**Kind**: static namespace + +* * * + +## get +balena.models.deviceType.get(idOrSlug, [options]) ⇒ Promise + +This method returns a single device type. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a single deviceType +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + + + +
ParamTypeDefaultDescription
idOrSlugString | Number

device type slug (string) or alias (string) or id

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.get('raspberry-pi').then(function(deviceType) { + console.log(deviceType); +}); +``` +**Example** +```js +balena.models.deviceType.get('raspberrypi').then(function(deviceType) { + console.log('resolved alias:', deviceType); +}); +``` + +* * * + +## getAll +balena.models.deviceType.getAll([options]) ⇒ Promise + +This method returns all device types. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get all deviceTypes +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.getAll().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` +**Example** +```js +balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) { + console.log(deviceTypes); +}) +``` + +* * * + +## getAllSupported +balena.models.deviceType.getAllSupported([options]) ⇒ Promise + +This method returns all supported device types. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get all supported deviceTypes +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.getAllSupported().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` +**Example** +```js +balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) { + console.log(deviceTypes); +}) +``` + +* * * + +## getBySlugOrName +balena.models.deviceType.getBySlugOrName(slugOrName) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a deviceType by slug or name +**Access**: public +**Fulfil**: Object - device type + + + + + + + + + + +
ParamTypeDescription
slugOrNameString

deviceType slug

+
+ +**Example** +```js +balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { + console.log(deviceType); +}); +``` + +* * * + +## getInstallMethod +balena.models.deviceType.getInstallMethod(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get installation method on a given device type +**Access**: public +**Fulfil**: String - the installation method supported for the given device type slug + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { + console.log(method); + // externalBoot +}); +``` + +* * * + +## getInstructions +balena.models.deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get instructions for installing a host OS on a given device type +**Access**: public +**Fulfil**: Object \| String[] - step by step instructions for installing the host OS to the device + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugOrContractString | Object

device type slug or contract

+
+ +**Example** +```js +balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { + for (let instruction of instructions.values()) { + console.log(instruction); + } + // Insert the sdcard to the host machine. + // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. + // Wait for writing of BalenaOS to complete. + // Remove the sdcard from the host machine. + // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). + // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. +}); +``` + +* * * + +## getInterpolatedPartials +balena.models.deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a contract with resolved partial templates +**Access**: public +**Fulfil**: Contract - device type contract with resolved partials + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { + for (const partial in contract.partials) { + console.log(`${partial}: ${contract.partials[partial]}`); + } + // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] +}); +``` + +* * * + +## getName +balena.models.deviceType.getName(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get display name for a device +**Access**: public +**Fulfil**: String - device display name + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { + console.log(deviceTypeName); + // Raspberry Pi +}); +``` + +* * * + +## getSlugByName +balena.models.deviceType.getSlugByName(deviceTypeName) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get device slug +**Access**: public +**Fulfil**: String - device slug name + + + + + + + + + + +
ParamTypeDescription
deviceTypeNameString

device type name

+
+ +**Example** +```js +balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { + console.log(deviceTypeSlug); + // raspberry-pi +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/image.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/image.md new file mode 100644 index 0000000000..7e3a9e6e82 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/image.md @@ -0,0 +1,68 @@ +# image +balena.models.image : object + +**Kind**: static namespace + +* * * + +## get +balena.models.image.get(id, [options]) ⇒ Promise + +**Kind**: static method of [image](#balena.models.image) +**Summary**: Get a specific image +**Access**: public +**Fulfil**: Object - image + + + + + + + + + + + + +
ParamTypeDefaultDescription
idNumber

image id

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.image.get(123).then(function(image) { + console.log(image); +}); +``` + +* * * + +## getLogs +balena.models.image.getLogs(id) ⇒ Promise + +**Kind**: static method of [image](#balena.models.image) +**Summary**: Get the logs for an image +**Access**: public +**Fulfil**: string \| null - logs + + + + + + + + + + +
ParamTypeDescription
idNumber

image id

+
+ +**Example** +```js +balena.models.image.getLogs(123).then(function(logs) { + console.log(logs); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/key.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/key.md new file mode 100644 index 0000000000..9d4db96169 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/key.md @@ -0,0 +1,123 @@ +# key +balena.models.key : object + +**Kind**: static namespace + +* * * + +## create +balena.models.key.create(title, key) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Create a ssh key +**Access**: public +**Fulfil**: Object - ssh key + + + + + + + + + + + + +
ParamTypeDescription
titleString

key title

+
keyString

the public ssh key

+
+ +**Example** +```js +balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) { + console.log(key); +}); +``` + +* * * + +## get +balena.models.key.get(id) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Get a single ssh key +**Access**: public +**Fulfil**: Object - ssh key + + + + + + + + + + +
ParamTypeDescription
idNumber

key id

+
+ +**Example** +```js +balena.models.key.get(51).then(function(key) { + console.log(key); +}); +``` + +* * * + +## getAll +balena.models.key.getAll([options]) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Get all ssh keys +**Access**: public +**Fulfil**: Object[] - ssh keys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.key.getAll().then(function(keys) { + console.log(keys); +}); +``` + +* * * + +## remove +balena.models.key.remove(id) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Remove ssh key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

key id

+
+ +**Example** +```js +balena.models.key.remove(51); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/organization.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/organization.md new file mode 100644 index 0000000000..e195cd08f6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/organization.md @@ -0,0 +1,521 @@ +# organization +balena.models.organization : object + +**Kind**: static namespace + +* * * + +## create +balena.models.organization.create(options) ⇒ Promise + +This method creates a new organization with the current user as an administrator. + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Creates a new organization +**Access**: public +**Fulfil**: String - Organization + + + + + + + + + + + + + + +
ParamTypeDescription
optionsObject

Organization parameters to use.

+
options.nameString

Required: the name of the organization that will be created.

+
[options.handle]String

The handle of the organization that will be created.

+
+ +**Example** +```js +balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) { + console.log(organization); +}); +``` +**Example** +```js +balena.models.organization.create({ + name:'MyOrganization', + logo_image: new File( + imageContent, + 'img.jpeg' + ); +}) +.then(function(organization) { + console.log(organization); +}); +``` + +* * * + +## get +balena.models.organization.get(handleOrId, [options]) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Get a single organization +**Access**: public +**Fulfil**: Object - organization + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.get('myorganization').then(function(organization) { + console.log(organization); +}); +``` +**Example** +```js +balena.models.organization.get(123).then(function(organization) { + console.log(organization); +}); +``` + +* * * + +## getAll +balena.models.organization.getAll([options]) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Get all Organizations +**Access**: public +**Fulfil**: Object[] - organizations + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.getAll().then(function(organizations) { + console.log(organizations); +}); +``` + +* * * + +## remove +balena.models.organization.remove(handleOrId) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Remove an Organization +**Access**: public + + + + + + + + + + +
ParamTypeDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
+ +**Example** +```js +balena.models.organization.remove(123); +``` + +* * * + +## invite +balena.models.organization.invite : object + +**Kind**: static namespace of [organization](#balena.models.organization) + +* * * + +### accept +balena.models.organization.invite.accept(invitationToken) ⇒ Promise + +This method adds the calling user to the organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Accepts an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
invitationTokenString

invite token

+
+ +**Example** +```js +balena.models.organization.invite.accept("qwerty-invitation-token"); +``` + +* * * + +### create +balena.models.organization.invite.create(handleOrId, options, [message]) ⇒ Promise + +This method invites a user by their email to an organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Creates a new invite for an organization +**Access**: public +**Fulfil**: String - organization invite + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

+
optionsObject

invite creation parameters

+
options.inviteeString

the email of the invitee

+
[options.roleName]String"developer"

the role name to be granted to the invitee

+
[message]String

the message to send along with the invite

+
+ +**Example** +```js +balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) { + console.log(invite); +}); +``` + +* * * + +### getAll +balena.models.organization.invite.getAll([options]) ⇒ Promise + +This method returns all invites. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Get all invites +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.invite.getAll().then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### getAllByOrganization +balena.models.organization.invite.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all invites for a specific organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Get all invites by organization +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) { + console.log(invites); +}); +``` +**Example** +```js +balena.models.organization.invite.getAllByOrganization(123).then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### revoke +balena.models.organization.invite.revoke(id) ⇒ Promise + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Revoke an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

organization invite id

+
+ +**Example** +```js +balena.models.organization.invite.revoke(123); +``` + +* * * + +## membership +balena.models.organization.membership : object + +**Kind**: static namespace of [organization](#balena.models.organization) + +* * * + +### changeRole +balena.models.organization.membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise + +This method changes the role of an organization member. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Changes the role of an organization member +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership that will be changed

+
roleNameString

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.organization.membership.changeRole(123, "member").then(function() { + console.log('OK'); +}); +``` +**Example** +```js +balena.models.organization.membership.changeRole({ + user: 123, + is_member_of__organization: 125, +}, "member").then(function() { + console.log('OK'); +}); +``` + +* * * + +### get +balena.models.organization.membership.get(membershipId, [options]) ⇒ Promise + +This method returns a single organization membership. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get a single organization membership +**Access**: public +**Fulfil**: Object - organization membership + + + + + + + + + + + + +
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.get(5).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByOrganization +balena.models.organization.membership.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all organization memberships for a specific organization. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get all memberships by organization +**Access**: public +**Fulfil**: Object[] - organization memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByUser +balena.models.organization.membership.getAllByUser(usernameOrId, [options]) ⇒ Promise + +This method returns all organization memberships for a specific user. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get all memberships by user +**Access**: public +**Fulfil**: Object[] - organization memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.organization.membership.getAllByUser(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### remove +balena.models.organization.membership.remove(id) ⇒ Promise + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Remove a membership +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

organization membership id

+
+ +**Example** +```js +balena.models.organization.membership.remove(123); +``` +**Example** +```js +balena.models.organization.membership.remove({ + user: 123, + is_member_of__application: 125, +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/os.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/os.md new file mode 100644 index 0000000000..e9e7ac87f6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/os.md @@ -0,0 +1,523 @@ +# os +balena.models.os : object + +**Kind**: static namespace + +* * * + +## download +balena.models.os.download(options) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Download an OS image +**Access**: public +**Fulfil**: ReadableStream - download stream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

OS image options to use.

+
options.deviceTypeString

device type slug

+
[options.version]String'latest'

semver-compatible version or 'latest', defaults to 'latest' +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number.

+
[options.developmentMode]Boolean

controls development mode for unified balenaOS releases.

+
[options.appId]Number

the application ID (number).

+
[options.fileType]String

download file type. One of '.img' or '.zip' or '.gz'.

+
[options.imageType]String

download file type. One of 'raw' or 'flasher'

+
[options.appUpdatePollInterval]Number

how often the OS checks for updates, in minutes.

+
[options.network]String

the network type that the device will use, one of 'ethernet' or 'wifi'.

+
[options.wifiKey]String

the key for the wifi network the device will connect to if network is wifi.

+
[options.wifiSsid]String

the ssid for the wifi network the device will connect to if network is wifi.

+
+ +**Example** +```js +balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) { + stream.pipe(fs.createWriteStream('foo/bar/image.img')); +}); +``` + +* * * + +## getAllOsVersions +balena.models.os.getAllOsVersions(deviceTypes, [options]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.os.getAllOsVersions('raspberrypi3'); +``` +**Example** +```js +balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']); +``` +**Example** +```js +balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } }); +``` + +* * * + +## getAvailableOsVersions +balena.models.os.getAvailableOsVersions(deviceTypes, [pineOptions], [extraOptions]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get the supported OS versions for the provided device type(s) +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

+
[pineOptions]Object

Extra pine options to use

+
[extraOptions]Object

Extra convenience options to use

+
[extraOptions.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

+
+ +**Example** +```js +balena.models.os.getAvailableOsVersions('raspberrypi3'); +``` +**Example** +```js +balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']); +``` + +* * * + +## getConfig +balena.models.os.getConfig(slugOrUuidOrId, options) ⇒ Promise + +Builds the config.json for a device in the given application, with the given +options. + +Note that an OS version is required. For versions < 2.7.8, config +generation is only supported when using a session token, not an API key. + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get an applications config.json +**Access**: public +**Fulfil**: Object - application configuration as a JSON object. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number).

+
optionsObject

OS configuration options to use.

+
options.versionString

Required: the OS version of the image.

+
[options.network]String'ethernet'

The network type that +the device will use, one of 'ethernet' or 'wifi'.

+
[options.appUpdatePollInterval]Number

How often the OS checks +for updates, in minutes.

+
[options.provisioningKeyName]String

Name assigned to API key

+
[options.provisioningKeyExpiryDate]String

Expiry Date assigned to API key

+
[options.developmentMode]Boolean

Controls development mode for unified balenaOS releases.

+
[options.wifiKey]String

The key for the wifi network the +device will connect to.

+
[options.wifiSsid]String

The ssid for the wifi network the +device will connect to.

+
[options.ip]String

static ip address.

+
[options.gateway]String

static ip gateway.

+
[options.netmask]String

static ip netmask.

+
+ +**Example** +```js +balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) { + fs.writeFile('foo/bar/config.json', JSON.stringify(config)); +}); + +balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) { + fs.writeFile('foo/bar/config.json', JSON.stringify(config)); +}); +``` + +* * * + +## getDownloadSize +balena.models.os.getDownloadSize(deviceType, [version]) ⇒ Promise + +**Note!** Currently only the raw (uncompressed) size is reported. + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get OS download size estimate +**Access**: public +**Fulfil**: Number - OS image download size, in bytes. + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
[version]String

semver-compatible version or 'latest', defaults to 'latest'. +The version must be the exact version number.

+
+ +**Example** +```js +balena.models.os.getDownloadSize('raspberry-pi').then(function(size) { + console.log('The OS download size for raspberry-pi', size); +}); +``` + +* * * + +## getMaxSatisfyingVersion +balena.models.os.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get the max OS version satisfying the given range +**Access**: public +**Fulfil**: String\|null - the version number, or `null` if no matching versions are found + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
versionOrRangeString

can be one of

+
    +
  • the exact version number, +in which case it is returned if the version is supported, +or null is returned otherwise,
  • +
  • a semver-compatible +range specification, in which case the most recent satisfying version is returned +if it exists, or null is returned,
  • +
  • 'latest' in which case the most recent version is returned, excluding pre-releases, +Defaults to 'latest'.
  • +
+
[osType]String

can be one of 'default', 'esr' or null to include all types

+
+ +**Example** +```js +balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) { + console.log(version); +}); +``` + +* * * + +## getOsUpdateType +balena.models.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 + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
targetVersionString

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); +}); +``` + +* * * + +## getSupervisorReleasesForCpuArchitecture +balena.models.os.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options]) ⇒ Promise.<String> + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns the Releases of the supervisor for the CPU Architecture +**Returns**: Promise.<String> - - An array of Release objects that can be used to manage a device as supervisors. +**Access**: public + + + + + + + + + + + + +
ParamTypeDefaultDescription
cpuArchitectureSlugOrIdString | Number

The slug (string) or id (number) for the CPU Architecture

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64'); + +const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( + 'aarch64', + { $filter: { raw_version: '12.11.0' } }, +); + +const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( + 'aarch64', + { + $select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'], + $expand: { + release_image: { + $select: 'id', + $expand: { + image: { + $select: 'is_stored_at__image_location', + }, + }, + }, + }, + $filter: { raw_version: '12.11.0' } + }, +); +``` + +* * * + +## getSupportedOsUpdateVersions +balena.models.os.getSupportedOsUpdateVersions(deviceType, currentVersion, [options]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns the supported OS update targets for the provided device type +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. +**Fulfil**: Object - the versions information, of the following structure: +* versions - an array of strings, +containing exact version numbers that OS update is supported +* recommended - the recommended version, i.e. the most recent version +that is _not_ pre-release, can be `null` +* current - the provided current version after normalization + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
[options]Object

Extra options to filter the OS releases by

+
[options.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

+
[options.osType]String | null

Can be one of 'default', 'esr' or null which includes all types

+
+ +**Example** +```js +balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) { + console.log(isSupported); +}); +``` + +* * * + +## isArchitectureCompatibleWith +balena.models.os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ Boolean + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns whether the specified OS architecture is compatible with the target architecture +**Returns**: Boolean - - Whether the specified OS architecture is capable of running +applications build for the target architecture +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
osArchitectureString

The OS's architecture as specified in its device type

+
applicationArchitectureString

The application's architecture as specified in its device type

+
+ +**Example** +```js +const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf'); +console.log(result1); + +const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64'); +console.log(result2); +``` + +* * * + +## isSupportedOsUpdate +balena.models.os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions +**Access**: public +**Fulfil**: Boolean - whether upgrading the OS to the target version is supported + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
targetVersionString

semver-compatible version for the target OS version

+
+ +**Example** +```js +balena.models.os.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) { + console.log(isSupported); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/release.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/release.md new file mode 100644 index 0000000000..d4e3a33717 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/release.md @@ -0,0 +1,853 @@ +# release +balena.models.release : object + +**Kind**: static namespace + +* * * + +## createFromUrl +balena.models.release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Create a new release built from the source in the provided url +**Access**: public +**Fulfil**: number - release ID + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
urlDeployOptionsObject

builder options

+
urlDeployOptions.urlString

a url with a tarball of the project to build

+
[urlDeployOptions.shouldFlatten]Booleantrue

Should be true when the tarball includes an extra root folder with all the content

+
+ +**Example** +```js +balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { + console.log(releaseId); +}); +``` +**Example** +```js +balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { + console.log(releaseId); +}); +``` + +* * * + +## finalize +balena.models.release.finalize(commitOrIdOrRawVersion) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Finalizes a draft release +**Access**: public +**Fulfil**: void + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
+ +**Example** +```js +balena.models.release.finalize(123).then(function() { + console.log('finalized!'); +}); +``` +**Example** +```js +balena.models.release.finalize('7cf02a69e4d34c9da573914963cf54fd').then(function() { + console.log('finalized!'); +}); +``` +**Example** +```js +balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log('finalized!'); +}); +``` + +* * * + +## get +balena.models.release.get(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get a specific release +**Access**: public +**Fulfil**: Object - release + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.get(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.get('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log(release); +}); +``` + +* * * + +## getAllByApplication +balena.models.release.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get all releases from an application +**Access**: public +**Fulfil**: Object[] - releases + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) { + console.log(releases); +}); +``` +**Example** +```js +balena.models.release.getAllByApplication(123).then(function(releases) { + console.log(releases); +}); +``` + +* * * + +## getLatestByApplication +balena.models.release.getLatestByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get the latest successful release for an application +**Access**: public +**Fulfil**: Object\|undefined - release + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) { + console.log(releases); +}); +``` +**Example** +```js +balena.models.release.getLatestByApplication(123).then(function(releases) { + console.log(releases); +}); +``` + +* * * + +## getWithImageDetails +balena.models.release.getWithImageDetails(commitOrIdOrRawVersion, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want significantly more control, or to see the +raw model directly, use `release.get(id, options)` instead. + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get a specific release with the details of the images built +**Access**: public +**Fulfil**: Object - release with image details + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

a map of extra pine options

+
[options.release]Boolean{}

extra pine options for releases

+
[options.image]Object{}

extra pine options for images

+
+ +**Example** +```js +balena.models.release.getWithImageDetails(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } }) +.then(function(release) { + console.log(release.images[0].build_log); +}); +``` + +* * * + +## setIsInvalidated +balena.models.release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Set the is_invalidated property of a release to true or false +**Access**: public +**Fulfil**: void + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
isInvalidatedBoolean

boolean value, true for invalidated, false for validated

+
+ +**Example** +```js +balena.models.release.setIsInvalidated(123, true).then(function() { + console.log('invalidated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', true).then(function() { + console.log('invalidated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log('invalidated!); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated(123, false).then(function() { + console.log('validated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', false).then(function() { + console.log('validated!'); +}); +``` + +* * * + +## setKnownIssueList +balena.models.release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Add a known issue list to a release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
knownIssueListOrNullString | null

the known issue list

+
+ +**Example** +```js +balena.models.release.setKnownIssueList('7cf02a69e4d34c9da573914963cf54fd', 'This is an issue'); +``` +**Example** +```js +balena.models.release.setKnownIssueList(123, 'This is an issue'); +``` +**Example** +```js +balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue'); +``` + +* * * + +## setNote +balena.models.release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Add a note to a release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
noteOrNullString | null

the note

+
+ +**Example** +```js +balena.models.release.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); +``` +**Example** +```js +balena.models.release.setNote(123, 'My useful note'); +``` +**Example** +```js +balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note'); +``` + +* * * + +## asset +balena.models.release.asset : object + +**Kind**: static namespace of [release](#balena.models.release) + +* * * + +### download +balena.models.release.asset.download(id) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Download a release asset +**Access**: public +**Fulfil**: NodeJS.ReadableStream - download stream + + + + + + + + + + +
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
+ +**Example** +```js +balena.models.release.asset.download(123).then(function(stream) { + stream.pipe(fs.createWriteStream('logo.png')); +}); +``` +**Example** +```js +balena.models.release.asset.download({ + asset_key: 'logo.png', + release: 123 +}).then(function(stream) { + stream.pipe(fs.createWriteStream('logo.png')); +}); +``` + +* * * + +### get +balena.models.release.asset.get(id, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Get a specific release asset +**Access**: public +**Fulfil**: Object - release asset + + + + + + + + + + + + +
ParamTypeDefaultDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.asset.get(123).then(function(asset) { + console.log(asset); +}); +``` +**Example** +```js +balena.models.release.asset.get({ + asset_key: 'logo.png', + release: 123 +}).then(function(asset) { + console.log(asset); +}); +``` + +* * * + +### getAllByRelease +balena.models.release.asset.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Get all release assets for a release +**Access**: public +**Fulfil**: Object[] - release assets + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.asset.getAllByRelease(123).then(function(assets) { + console.log(assets); +}); +``` +**Example** +```js +balena.models.release.asset.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(assets) { + console.log(assets); +}); +``` +**Example** +```js +balena.models.release.asset.getAllByRelease({ application: 456, raw_version: '1.2.3' }).then(function(assets) { + console.log(assets); +}); +``` + +* * * + +### remove +balena.models.release.asset.remove(id) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Remove a release asset +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
+ +**Example** +```js +balena.models.release.asset.remove(123); +``` +**Example** +```js +balena.models.release.asset.remove({ + asset_key: 'logo.png', + release: 123 +}); +``` + +* * * + +### upload +balena.models.release.asset.upload(uploadParams, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Upload a release asset +**Access**: public +**Fulfil**: Object - uploaded release asset + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uploadParamsObject

upload parameters

+
uploadParams.assetString | File

asset file path (string, Node.js only) or File object (Node.js & browser). For File objects, use new File([content], filename, {type: mimeType})

+
uploadParams.asset_keyString

unique key for the asset within the release

+
uploadParams.releaseNumber

release ID

+
[options]Object{}

upload options

+
[options.chunkSize]Number5242880

chunk size for multipart uploads (5MiB default)

+
[options.parallelUploads]Number5

number of parallel uploads for multipart

+
[options.overwrite]Booleanfalse

whether to overwrite existing asset

+
[options.onUploadProgress]function

callback for upload progress

+
+ +**Example** +```js +// Upload from file path (Node.js) +balena.models.release.asset.upload({ + asset: '/path/to/logo.png', + asset_key: 'logo.png', + release: 123 +}).then(function(asset) { + console.log('Asset uploaded:', asset); +}); +``` +**Example** +```js +// Upload with File API (Node.js and browser) +const content = Buffer.from('Hello, World!', 'utf-8'); +const file = new File([content], 'readme.txt', { type: 'text/plain' }); + +balena.models.release.asset.upload({ + asset: file, + asset_key: 'readme.txt', + release: 123 +}).then(function(asset) { + console.log('Asset uploaded:', asset); +}); +``` +**Example** +```js +// Upload large file with File API and progress tracking +const largeContent = new Uint8Array(10 * 1024 * 1024); // 10MB +const largeFile = new File([largeContent], 'data.bin', { type: 'application/octet-stream' }); + +balena.models.release.asset.upload({ + asset: largeFile, + asset_key: 'data.bin', + release: 123 +}, { + chunkSize: 5 * 1024 * 1024, // 5MB chunks + parallelUploads: 3, + onUploadProgress: function(progress) { + const percent = (progress.uploaded / progress.total * 100).toFixed(2); + console.log(`Upload progress: ${percent}%`); + } +}).then(function(asset) { + console.log('Large file uploaded:', asset); +}); +``` +**Example** +```js +// Browser: Upload file from input element +const fileInput = document.getElementById('fileInput'); +const file = fileInput.files[0]; // File object from input + +balena.models.release.asset.upload({ + asset: file, + asset_key: file.name, + release: 123 +}).then(function(asset) { + console.log('File uploaded from browser:', asset); +}); +``` +**Example** +```js +// Upload with overwrite option +balena.models.release.asset.upload({ + asset: '/path/to/logo.png', + asset_key: 'logo.png', + release: 123 +}, { + overwrite: true +}).then(function(asset) { + console.log('Asset uploaded/updated:', asset); +}); +``` + +* * * + +## tags +balena.models.release.tags : object + +**Kind**: static namespace of [release](#balena.models.release) + +* * * + +### getAllByApplication +balena.models.release.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Get all release tags for an application +**Access**: public +**Fulfil**: Object[] - release tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### getAllByRelease +balena.models.release.tags.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Get all release tags for a release +**Access**: public +**Fulfil**: Object[] - release tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.tags.getAllByRelease(123).then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.release.tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Remove a release tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.release.tags.remove(123, 'EDITOR'); +``` +**Example** +```js +balena.models.release.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); +``` +**Example** +```js +balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR'); +``` + +* * * + +### set +balena.models.release.tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Set a release tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.release.tags.set(123, 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.release.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/service.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/service.md new file mode 100644 index 0000000000..03d4f527e3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/service.md @@ -0,0 +1,243 @@ +# service +balena.models.service : object + +**Kind**: static namespace + +* * * + +## getAllByApplication +balena.models.service.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [service](#balena.models.service) +**Summary**: Get all services from an application +**Access**: public +**Fulfil**: Object[] - services + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) { + console.log(services); +}); +``` +**Example** +```js +balena.models.service.getAllByApplication(123).then(function(services) { + console.log(services); +}); +``` + +* * * + +## var +balena.models.service.var : object + +**Kind**: static namespace of [service](#balena.models.service) + +* * * + +### get +balena.models.service.var.get(serviceIdOrNaturalKey, key) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get the value of a specific service variable +**Access**: public +**Fulfil**: String\|undefined - the variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
+ +**Example** +```js +balena.models.service.var.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.service.var.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get all service variables by application +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.service.var.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByService +balena.models.service.var.getAllByService(serviceIdOrNaturalKey, [options]) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get all variables for a service +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.var.getAllByService(999999).then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.service.var.remove(serviceIdOrNaturalKey, key) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Clear the value of a specific service variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
+ +**Example** +```js +balena.models.service.var.remove(999999, 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.service.var.set(serviceIdOrNaturalKey, key, value) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Set the value of a specific service variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
valueString

variable value

+
+ +**Example** +```js +balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/models/team.md b/pages/external-docs/sdk/node-sdk/v21.7.4/models/team.md new file mode 100644 index 0000000000..882fd8c89b --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/models/team.md @@ -0,0 +1,313 @@ +# team +balena.models.team : object + +**Kind**: static namespace + +* * * + +## create +balena.models.team.create(organizationSlugOrId, name) ⇒ Promise + +This method creates a new team. + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Creates a new Team +**Access**: public +**Fulfil**: Object - Team + + + + + + + + + + + + +
ParamTypeDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team will be part of.

+
nameString

Required: the name of the team that will be created.

+
+ +**Example** +```js +balena.models.team.create(1239948, 'MyTeam').then(function(team) { + console.log(team); +}); +``` +**Example** +```js +balena.models.team.create('myOrgHandle', 'MyTeam') +.then(function(team) { + console.log(team); +}); +``` + +* * * + +## get +balena.models.team.get(teamId, [options]) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Get a single Team +**Access**: public +**Fulfil**: Object - Team + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamIdNumber

team id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.get(123).then(function(team) { + console.log(team); +}); +``` + +* * * + +## getAllByOrganization +balena.models.team.getAllByOrganization(organizationSlugOrId, [options]) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Get all Teams of a specific Organization +**Access**: public +**Fulfil**: Object[] - Teams + + + + + + + + + + + + +
ParamTypeDefaultDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team is part of.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.getAllByOrganization(123).then(function(teams) { + console.log(teams); +}); +``` +**Example** +```js +balena.models.team.getAllByOrganization('MyOrganizationHandle').then(function(teams) { + console.log(teams); +}); +``` + +* * * + +## remove +balena.models.team.remove(teamId) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Remove a Team +**Access**: public + + + + + + + + + + +
ParamTypeDescription
teamIdNumber

team id (number).

+
+ +**Example** +```js +balena.models.team.remove(123); +``` + +* * * + +## rename +balena.models.team.rename(teamId, newName) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Rename Team +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
teamIdNumber

team id (number)

+
newNameString

new team name (string)

+
+ +**Example** +```js +balena.models.team.rename(123, 'MyNewTeamName'); +``` + +* * * + +## applicationAccess +balena.models.team.applicationAccess : object + +**Kind**: static namespace of [team](#balena.models.team) + +* * * + +### get +balena.models.team.applicationAccess.get(teamApplicationAccessId, [options]) ⇒ Promise + +This method get specific team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Get team applications access +**Access**: public +**Fulfil**: Object - TeamApplicationAccess + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.applicationAccess.get(1239948).then(function(teamApplicationAccess) { + console.log(teamApplicationAccess); +}); +``` + +* * * + +### getAllByTeam +balena.models.team.applicationAccess.getAllByTeam(teamId, [options]) ⇒ Promise + +This method get all team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Get all team applications access +**Access**: public +**Fulfil**: Object[] - team application access + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamIdNumber

Required: the team id.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.applicationAccess.getAllByTeam(1239948).then(function(teamApplicationAccesses) { + console.log(teamApplicationAccesses); +}); +``` + +* * * + +### remove +balena.models.team.applicationAccess.remove(teamApplicationAccessId) ⇒ Promise + +This remove a team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Remove team application access +**Access**: public +**Fulfil**: void + + + + + + + + + + +
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
+ +**Example** +```js +balena.models.team.remove(123).then(function(teams) { + console.log(teams); +}); +``` + +* * * + +### update +balena.models.team.applicationAccess.update(teamApplicationAccessId, roleName) ⇒ Promise + +This method update a team application access role. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Update team application access +**Access**: public +**Fulfil**: Object - TeamApplicationAccess + + + + + + + + + + + + +
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
roleNameString

Required: The new role to assing (ApplicationMembershipRoles).

+
+ +**Example** +```js +balena.models.team.update(123, 'developer').then(function(teamApplicationAccess) { + console.log(teamApplicationAccess); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/pine.md b/pages/external-docs/sdk/node-sdk/v21.7.4/pine.md new file mode 100644 index 0000000000..edb6c4bdfc --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/pine.md @@ -0,0 +1,25 @@ +# pine +balena.pine : Object + +The pinejs-client instance used internally. This should not be necessary +in normal usage, but can be useful if you want to directly make pine +queries to the api for some resource that isn't directly supported +in the SDK. + +**Kind**: static member +**Summary**: Balena pine instance +**Access**: public +**Example** +```js +balena.pine.get({ + resource: 'release', + options: { + $count: { + $filter: { belongs_to__application: applicationId } + } + } +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/request.md b/pages/external-docs/sdk/node-sdk/v21.7.4/request.md new file mode 100644 index 0000000000..0ba55a90d6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/request.md @@ -0,0 +1,17 @@ +# request +balena.request : Object + +The balena-request instance used internally. This should not be necessary +in normal usage, but can be useful if you want to make an API request directly, +using the same token and hooks as the SDK. + +**Kind**: static member +**Summary**: Balena request instance +**Access**: public +**Example** +```js +balena.request.send({ url: 'http://api.balena-cloud.com/ping' }); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/setSharedOptions.md b/pages/external-docs/sdk/node-sdk/v21.7.4/setSharedOptions.md new file mode 100644 index 0000000000..f2e444fc97 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/setSharedOptions.md @@ -0,0 +1,68 @@ +# setSharedOptions +module:balena-sdk~setSharedOptions(options) + +Set options that are used by calls to `fromSharedOptions()`. +The options accepted are the same as those used in the main SDK factory function. +If you use this method, it should be called as soon as possible during app +startup and before any calls to `fromSharedOptions()` are made. + +**Kind**: inner function +**Summary**: Set shared default options +**Access**: public + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

The shared default options

+
[options.apiUrl]String'https://api.balena-cloud.com/'

the balena API url to use.

+
[options.builderUrl]String'https://builder.balena-cloud.com/'

the balena builder url to use.

+
[options.deviceUrlsBase]String'balena-devices.com'

the base balena device API url to use.

+
[options.requestLimit]Number

the number of requests per requestLimitInterval that the SDK should respect.

+
[options.requestLimitInterval]Number60000

the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute).

+
[options.retryRateLimitedRequests]Boolean | functionfalse

Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header.

+
    +
  • If false, rate-limited requests will not be retried, and the rate limit error will be propagated.
  • +
  • If true, all rate-limited requests will be retried after the duration specified by the Retry-After header.
  • +
  • If a function (retryAfterMs: number) => boolean is provided, it will be called with the retry duration in ms and the request will be retried only when true is returned.
  • +
+
[options.dataDirectory]String | False'$HOME/.balena'

ignored in the browser unless false, the directory where the user settings are stored, normally retrieved like require('balena-settings-client').get('dataDirectory'). Providing false creates an isolated in-memory instance.

+
[options.isBrowser]Boolean

the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global window value.

+
[options.debug]Boolean

when set will print some extra debug information.

+
+ +**Example** +```js +import { setSharedOptions } from 'balena-sdk'; +setSharedOptions({ + apiUrl: 'https://api.balena-cloud.com/', + builderUrl: 'https://builder.balena-cloud.com/', + isBrowser: true, +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/settings.md b/pages/external-docs/sdk/node-sdk/v21.7.4/settings.md new file mode 100644 index 0000000000..1bbc80552d --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/settings.md @@ -0,0 +1,52 @@ +# settings +balena.settings : object + +**Kind**: static namespace + +* * * + +## get +balena.settings.get([key]) ⇒ Promise + +**Kind**: static method of [settings](#balena.settings) +**Summary**: Get a single setting. **Only implemented in Node.js** +**Access**: public +**Fulfil**: \* - setting value + + + + + + + + + + +
ParamTypeDescription
[key]String

setting key

+
+ +**Example** +```js +balena.settings.get('apiUrl').then(function(apiUrl) { + console.log(apiUrl); +}); +``` + +* * * + +## getAll +balena.settings.getAll() ⇒ Promise + +**Kind**: static method of [settings](#balena.settings) +**Summary**: Get all settings **Only implemented in Node.js** +**Access**: public +**Fulfil**: Object - settings +**Example** +```js +balena.settings.getAll().then(function(settings) { + console.log(settings); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v21.7.4/utils.md b/pages/external-docs/sdk/node-sdk/v21.7.4/utils.md new file mode 100644 index 0000000000..c8a5d1720c --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v21.7.4/utils.md @@ -0,0 +1,18 @@ +# utils +balena.utils : Object + +The utils instance offers some convenient features for clients. + +**Kind**: static member +**Summary**: Balena utils instance +**Access**: public +**Example** +```js +balena.utils.mergePineOptions( + { $expand: { device: { $select: ['id'] } } }, + { $expand: { device: { $select: ['name'] } } }, +); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9.md b/pages/external-docs/sdk/node-sdk/v22.4.9.md deleted file mode 100644 index 4c8c3cf369..0000000000 --- a/pages/external-docs/sdk/node-sdk/v22.4.9.md +++ /dev/null @@ -1,7431 +0,0 @@ - -## Installation - -Install the balena SDK by running: - -```sh -$ npm install --save balena-sdk -``` - -### Bundling for browsers - -If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. - -If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: - -* fs -* path -* balena-settings-client -* node-localstorage -* fs/promises -* mime - -### Bundling with pkg - -The balena SDK includes builds for various ECMAScript versions that are -dynamically selected at runtime (using -[@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). -For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not -able to automatically detect which assets to include in the output package. The -following sample `pkg` section should be added to your application's -`package.json` file to instruct `pkg` to bundle the required assets: - -```json - "pkg": { - "scripts": [ - "node_modules/balena-sdk/**/*.js" - ], - "assets": [ - "node_modules/pinejs-client-core/**/*" - ] - } -``` - -For more information, please refer to the respective -[documentation from the `pkg` project](https://github.com/vercel/pkg#config). - -## Trying balenaSDK in the browser - -BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. -To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries. - -![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png) - - -If you feel something is missing, not clear or could be improved, please don't hesitate to open an -[issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help. - - -## Modules - -
-
balena-sdk
-
-
- -## Objects - -
-
balena : object
-
-
- -## Functions - -
-
listImagesFromTargetState(targetState)
-
-
- - - -## balena-sdk - -* [balena-sdk](#module_balena-sdk) - * [~getSdk()](#module_balena-sdk..getSdk) - * [~setSharedOptions(options)](#module_balena-sdk..setSharedOptions) - * [~fromSharedOptions()](#module_balena-sdk..fromSharedOptions) - - - -### balena-sdk~getSdk() -The module exports a single factory function. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Creates a new SDK instance using the default or the provided options. -**Example** -```js -// with es6 imports -import { getSdk } from 'balena-sdk'; -// or with node require -const { getSdk } = require('balena-sdk'); - -const balena = getSdk({ - apiUrl: "https://api.balena-cloud.com/", - dataDirectory: "/opt/local/balena" -}); -``` - - -### balena-sdk~setSharedOptions(options) -Set options that are used by calls to `fromSharedOptions()`. -The options accepted are the same as those used in the main SDK factory function. -If you use this method, it should be called as soon as possible during app -startup and before any calls to `fromSharedOptions()` are made. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Set shared default options -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | The shared default options | -| [options.apiUrl] | String | 'https://api.balena-cloud.com/' | the balena API url to use. | -| [options.builderUrl] | String | 'https://builder.balena-cloud.com/' | the balena builder url to use. | -| [options.deviceUrlsBase] | String | 'balena-devices.com' | the base balena device API url to use. | -| [options.requestLimit] | Number | | the number of requests per requestLimitInterval that the SDK should respect. | -| [options.requestLimitInterval] | Number | 60000 | the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute). | -| [options.retryRateLimitedRequests] | Boolean \| function | false | Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header. - If `false`, rate-limited requests will not be retried, and the rate limit error will be propagated. - If `true`, all rate-limited requests will be retried after the duration specified by the `Retry-After` header. - If a function `(retryAfterMs: number) => boolean` is provided, it will be called with the retry duration in ms and the request will be retried only when `true` is returned. | -| [options.dataDirectory] | String \| False | '$HOME/.balena' | *ignored in the browser unless false*, the directory where the user settings are stored, normally retrieved like `require('balena-settings-client').get('dataDirectory')`. Providing `false` creates an isolated in-memory instance. | -| [options.isBrowser] | Boolean | | the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global `window` value. | -| [options.debug] | Boolean | | when set will print some extra debug information. | - -**Example** -```js -import { setSharedOptions } from 'balena-sdk'; -setSharedOptions({ - apiUrl: 'https://api.balena-cloud.com/', - builderUrl: 'https://builder.balena-cloud.com/', - isBrowser: true, -}); -``` - - -### balena-sdk~fromSharedOptions() -Create an SDK instance using shared default options set using the `setSharedOptions()` method. -If options have not been set using this method, then this method will use the -same defaults as the main SDK factory function. - -**Kind**: inner method of [balena-sdk](#module_balena-sdk) -**Summary**: Create an SDK instance using shared default options -**Access**: public -**Example** -```js -import { fromSharedOptions } from 'balena-sdk'; -const sdk = fromSharedOptions(); -``` - - -## balena : object -**Kind**: global namespace - -* [balena](#balena) : object - * [.interceptors](#balena.interceptors) : Array.<Interceptor> - * [.Interceptor](#balena.interceptors.Interceptor) : object - * [.utils](#balena.utils) : Object - * [.request](#balena.request) : Object - * [.pine](#balena.pine) : Object - * [.errors](#balena.errors) : Object - * [.models](#balena.models) : object - * [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * ~~[.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String~~ - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.team](#balena.models.team) : object - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - * [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.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> - * [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.asset](#balena.models.release.asset) : object - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.asset.getAllByRelease) ⇒ Promise - * [.get(id, [options])](#balena.models.release.asset.get) ⇒ Promise - * [.download(id)](#balena.models.release.asset.download) ⇒ Promise - * [.upload(uploadParams, [options])](#balena.models.release.asset.upload) ⇒ Promise - * [.remove(id)](#balena.models.release.asset.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - * [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - * [.auth](#balena.auth) : object - * [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.whoami()](#balena.auth.whoami) ⇒ Promise - * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ Promise - * [.login(credentials)](#balena.auth.login) ⇒ Promise - * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ Promise - * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ Promise - * [.getToken()](#balena.auth.getToken) ⇒ Promise - * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ Promise - * [.getActorId()](#balena.auth.getActorId) ⇒ Promise - * [.logout()](#balena.auth.logout) ⇒ Promise - * [.register(credentials)](#balena.auth.register) ⇒ Promise - * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ Promise - * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ Promise - * [.logs](#balena.logs) : object - * [.subscribe(uuidOrId, [options])](#balena.logs.subscribe) ⇒ Promise.<LogSubscription> - * [.history(uuidOrId, [options])](#balena.logs.history) ⇒ Promise - * [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - * [.settings](#balena.settings) : object - * [.get([key])](#balena.settings.get) ⇒ Promise - * [.getAll()](#balena.settings.getAll) ⇒ Promise - * [.utils](#balena.utils) : object - - - -### balena.interceptors : Array.<Interceptor> -The current array of interceptors to use. Interceptors intercept requests made -internally and are executed in the order they appear in this array for requests, -and in the reverse order for responses. - -**Kind**: static property of [balena](#balena) -**Summary**: Array of interceptors -**Access**: public -**Example** -```js -balena.interceptors.push({ - responseError: function (error) { - console.log(error); - throw error; - }) -}); -``` - - -#### interceptors.Interceptor : object -An interceptor implements some set of the four interception hook callbacks. -To continue processing, each function should return a value or a promise that -successfully resolves to a value. - -To halt processing, each function should throw an error or return a promise that -rejects with an error. - -**Kind**: static typedef of [interceptors](#balena.interceptors) -**Properties** - -| Name | Type | Description | -| --- | --- | --- | -| [request] | function | Callback invoked before requests are made. Called with the request options, should return (or resolve to) new request options, or throw/reject. | -| [response] | function | Callback invoked before responses are returned. Called with the response, should return (or resolve to) a new response, or throw/reject. | -| [requestError] | function | Callback invoked if an error happens before a request. Called with the error itself, caused by a preceeding request interceptor rejecting/throwing an error for the request, or a failing in preflight token validation. Should return (or resolve to) new request options, or throw/reject. | -| [responseError] | function | Callback invoked if an error happens in the response. Called with the error itself, caused by a preceeding response interceptor rejecting/throwing an error for the request, a network error, or an error response from the server. Should return (or resolve to) a new response, or throw/reject. | - - - -### balena.utils : Object -The utils instance offers some convenient features for clients. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena utils instance -**Access**: public -**Example** -```js -balena.utils.mergePineOptions( - { $expand: { device: { $select: ['id'] } } }, - { $expand: { device: { $select: ['name'] } } }, -); -``` - - -### balena.request : Object -The balena-request instance used internally. This should not be necessary -in normal usage, but can be useful if you want to make an API request directly, -using the same token and hooks as the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena request instance -**Access**: public -**Example** -```js -balena.request.send({ url: 'http://api.balena-cloud.com/ping' }); -``` - - -### balena.pine : Object -The pinejs-client instance used internally. This should not be necessary -in normal usage, but can be useful if you want to directly make pine -queries to the api for some resource that isn't directly supported -in the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena pine instance -**Access**: public -**Example** -```js -balena.pine.get({ - resource: 'release', - options: { - $count: { - $filter: { belongs_to__application: applicationId } - } - } -}); -``` - - -### balena.errors : Object -The balena-errors module used internally. This is provided primarily for -convenience, and to avoid the necessity for separate balena-errors -dependencies. You'll want to use this if you need to match on the specific -type of error thrown by the SDK. - -**Kind**: static property of [balena](#balena) -**Summary**: Balena errors module -**Access**: public -**Example** -```js -balena.models.device.get(123).catch(function (error) { - if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) { - ... - } else if (error.code === balena.errors.BalenaRequestError.prototype.code) { - ... - } -}); -``` - - -### balena.models : object -**Kind**: static namespace of [balena](#balena) - -* [.models](#balena.models) : object - * [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - * [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * ~~[.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String~~ - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - * [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - * [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - * [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - * [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - * [.team](#balena.models.team) : object - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - * [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.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> - * [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - * [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.asset](#balena.models.release.asset) : object - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.asset.getAllByRelease) ⇒ Promise - * [.get(id, [options])](#balena.models.release.asset.get) ⇒ Promise - * [.download(id)](#balena.models.release.asset.download) ⇒ Promise - * [.upload(uploadParams, [options])](#balena.models.release.asset.upload) ⇒ Promise - * [.remove(id)](#balena.models.release.asset.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - * [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - * [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - * [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - * [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - - - -#### models.application : object -**Kind**: static namespace of [models](#balena.models) - -* [.application](#balena.models.application) : object - * [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - * [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - * [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - * [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - * [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ String - * [.getAll([options], [context])](#balena.models.application.getAll) ⇒ Promise - * [.getAllDirectlyAccessible([options])](#balena.models.application.getAllDirectlyAccessible) ⇒ Promise - * [.getAllByOrganization(orgHandleOrId, [options])](#balena.models.application.getAllByOrganization) ⇒ Promise - * [.get(slugOrUuidOrId, [options], [context])](#balena.models.application.get) ⇒ Promise - * [.getDirectlyAccessible(slugOrUuidOrId, [options])](#balena.models.application.getDirectlyAccessible) ⇒ Promise - * [.getWithDeviceServiceDetails(slugOrUuidOrId, [options])](#balena.models.application.getWithDeviceServiceDetails) ⇒ Promise - * [.getAppByName(appName, [options], [context])](#balena.models.application.getAppByName) ⇒ Promise - * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ Promise - * [.hasAny()](#balena.models.application.hasAny) ⇒ Promise - * [.create(options)](#balena.models.application.create) ⇒ Promise - * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ Promise - * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ Promise - * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ Promise - * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ Promise - * [.purge(appId)](#balena.models.application.purge) ⇒ Promise - * [.shutdown(appId, [options])](#balena.models.application.shutdown) ⇒ Promise - * [.reboot(appId, [options])](#balena.models.application.reboot) ⇒ Promise - * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ Promise - * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ Promise - * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ Promise - * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ Promise - * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ Promise - * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ Promise - * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ Promise - * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ Promise - - - -##### application.tags : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.tags](#balena.models.application.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.tags.getAllByApplication) ⇒ Promise - * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ Promise - * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Get all application tags for an application -**Access**: public -**Fulfil**: Object[] - application tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.application.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(slugOrUuidOrId, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Set an application tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.application.tags.set(123, 'EDITOR', 'vim'); -``` - - -###### tags.remove(slugOrUuidOrId, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.application.tags) -**Summary**: Remove an application tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| tagKey | String | tag key | - -**Example** -```js -balena.models.application.tags.remove('myorganization/myapp', 'EDITOR'); -``` - - -##### application.configVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.configVar](#balena.models.application.configVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.configVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ Promise - - - -###### configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Get all config variables for an application -**Access**: public -**Fulfil**: Object[] - application config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.configVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Get the value of a specific config variable -**Access**: public -**Fulfil**: String\|undefined - the config variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` - - -###### configVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Set the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | -| value | String | config variable value | - -**Example** -```js -balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### configVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.application.configVar) -**Summary**: Clear the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() { - ... -}); -``` - - -##### application.envVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.envVar](#balena.models.application.envVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.envVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ Promise - - - -###### envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Get all environment variables for an application -**Access**: public -**Fulfil**: Object[] - application environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.envVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Get the value of a specific environment variable -**Access**: public -**Fulfil**: String\|undefined - the environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.envVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### envVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Set the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | -| value | String | environment variable value | - -**Example** -```js -balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### envVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.application.envVar) -**Summary**: Clear the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.envVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### application.buildVar : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.buildVar](#balena.models.application.buildVar) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.buildVar.getAllByApplication) ⇒ Promise - * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ Promise - * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ Promise - * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ Promise - - - -###### buildVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Get all build environment variables for an application -**Access**: public -**Fulfil**: Object[] - application build environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### buildVar.get(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Get the value of a specific build environment variable -**Access**: public -**Fulfil**: String\|undefined - the build environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | - -**Example** -```js -balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.application.buildVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### buildVar.set(slugOrUuidOrId, key, value) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Set the value of a specific build environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | -| value | String | build environment variable value | - -**Example** -```js -balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### buildVar.remove(slugOrUuidOrId, key) ⇒ Promise -**Kind**: static method of [buildVar](#balena.models.application.buildVar) -**Summary**: Clear the value of a specific build environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| key | String | build environment variable name | - -**Example** -```js -balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.buildVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### application.membership : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.membership](#balena.models.application.membership) : object - * [.get(membershipId, [options])](#balena.models.application.membership.get) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.membership.getAllByApplication) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.application.membership.getAllByUser) ⇒ Promise - * [.create(options)](#balena.models.application.membership.create) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ Promise - * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ Promise - - - -###### membership.get(membershipId, [options]) ⇒ Promise -This method returns a single application membership. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get a single application membership -**Access**: public -**Fulfil**: Object - application membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| membershipId | number \| Object | | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.get(5).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all application memberships for a specific application. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get all memberships by application -**Access**: public -**Fulfil**: Object[] - application memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.application.membership.getAllByApplication(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByUser(usernameOrId, [options]) ⇒ Promise -This method returns all application memberships for a specific user. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Get all memberships by user -**Access**: public -**Fulfil**: Object[] - application memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| usernameOrId | String \| Number | | the user's username (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.application.membership.getAllByUser(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.create(options) ⇒ Promise -This method adds a user to an application by their username if they are a member of the organization. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Creates a new membership for an application -**Access**: public -**Fulfil**: Object - application membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | membership creation parameters | -| options.application | String \| Number | | application handle (string), or id (number) | -| options.username | String | | the username of the balena user that will become a member | -| [options.roleName] | String | "member" | the role name to be granted to the membership | - -**Example** -```js -balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { - console.log(membership); -}); -``` - - -###### membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise -This method changes the role of an application member. - -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Changes the role of an application member -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be changed | -| roleName | String | the role name to be granted to the membership | - -**Example** -```js -balena.models.application.membership.changeRole(123, "member").then(function() { - console.log('OK'); -}); -``` -**Example** -```js -balena.models.application.membership.changeRole({ - user: 123, - is_member_of__application: 125, -}, "member").then(function() { - console.log('OK'); -}); -``` - - -###### membership.remove(idOrUniqueKey) ⇒ Promise -**Kind**: static method of [membership](#balena.models.application.membership) -**Summary**: Remove a membership -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be removed | - -**Example** -```js -balena.models.application.membership.remove(123); -``` -**Example** -```js -balena.models.application.membership.remove({ - user: 123, - is_member_of__application: 125, -}); -``` - - -##### application.invite : object -**Kind**: static namespace of [application](#balena.models.application) - -* [.invite](#balena.models.application.invite) : object - * [.getAll([options])](#balena.models.application.invite.getAll) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.application.invite.getAllByApplication) ⇒ Promise - * [.create(slugOrUuidOrId, options, [message])](#balena.models.application.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ Promise - - - -###### invite.getAll([options]) ⇒ Promise -This method returns all invites. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Get all invites -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.invite.getAll().then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all invites for a specific application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Get all invites by application -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) { - console.log(invites); -}); -``` -**Example** -```js -balena.models.application.invite.getAllByApplication(123).then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.create(slugOrUuidOrId, options, [message]) ⇒ Promise -This method invites a user by their email to an application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Creates a new invite for an application -**Access**: public -**Fulfil**: String - application invite - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| options | Object | | invite creation parameters | -| options.invitee | String | | the email of the invitee | -| [options.roleName] | String | "developer" | the role name to be granted to the invitee | -| [message] | String | | the message to send along with the invite | - -**Example** -```js -balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) { - console.log(invite); -}); -``` - - -###### invite.revoke(id) ⇒ Promise -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Revoke an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | application invite id | - -**Example** -```js -balena.models.application.invite.revoke(123); -``` - - -###### invite.accept(invitationToken) ⇒ Promise -This method adds the calling user to the application. - -**Kind**: static method of [invite](#balena.models.application.invite) -**Summary**: Accepts an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| invitationToken | String | invite token | - -**Example** -```js -balena.models.application.invite.accept("qwerty-invitation-token"); -``` - - -##### application.getDashboardUrl(id) ⇒ String -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get Dashboard URL for a specific application -**Returns**: String - - Dashboard URL for the specific application -**Throws**: - -- Exception if the id is not a finite number - - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | Application id | - -**Example** -```js -balena.models.application.get('myorganization/myapp').then(function(application) { - const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); - console.log(dashboardApplicationUrl); -}); -``` - - -##### application.getAll([options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.getAll().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.getAllDirectlyAccessible([options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications directly accessible by the user -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getAllDirectlyAccessible().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.getAllByOrganization(orgHandleOrId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get all applications of an organization -**Access**: public -**Fulfil**: Object[] - applications - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| orgHandleOrId | Number \| String | | organization handle (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getAllByOrganization().then(function(applications) { - console.log(applications); -}); -``` - - -##### application.get(slugOrUuidOrId, [options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.get('myorganization/myapp').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.get(123).then(function(application) { - console.log(application); -}); -``` - - -##### application.getDirectlyAccessible(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application directly accessible by the user -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.getDirectlyAccessible(123).then(function(application) { - console.log(application); -}); -``` - - -##### application.getWithDeviceServiceDetails(slugOrUuidOrId, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want more control, or to see the raw model -directly, use `application.get(uuidOrId, options)` instead. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application and its devices, along with each device's -associated services' essential details -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.application.getWithDeviceServiceDetails(123).then(function(device) { - console.log(device); -}) -``` - - -##### application.getAppByName(appName, [options], [context]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get a single application using the appname and the handle of the owning organization -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appName | String | | application name | -| [options] | Object | {} | extra pine options to use | -| [context] | String | | extra access filters, undefined or 'directly_accessible' | - -**Example** -```js -balena.models.application.getAppByName('MyApp').then(function(application) { - console.log(application); -}); -``` - - -##### application.has(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Check if an application exists -**Access**: public -**Fulfil**: Boolean - has application - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.has('myorganization/myapp').then(function(hasApp) { - console.log(hasApp); -}); -``` -**Example** -```js -balena.models.application.has(123).then(function(hasApp) { - console.log(hasApp); -}); -``` - - -##### application.hasAny() ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Check if the user has access to any applications -**Access**: public -**Fulfil**: Boolean - has any applications -**Example** -```js -balena.models.application.hasAny().then(function(hasAny) { - console.log('Has any?', hasAny); -}); -``` - - -##### application.create(options) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Create an application -**Access**: public -**Fulfil**: Object - application - -| Param | Type | Description | -| --- | --- | --- | -| options | Object | application creation parameters | -| options.name | String | application name | -| [options.uuid] | String | application uuid | -| [options.applicationClass] | String | application class: 'app' | 'fleet' | 'block' | -| options.deviceType | String | device type slug | -| options.organization | String \| Number | handle (string) or id (number) of the organization that the application will belong to or null | - -**Example** -```js -balena.models.application.create({ name: 'My App', deviceType: 'raspberry-pi' }).then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.create({ name: 'My Block', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) { - console.log(application); -}); -``` -**Example** -```js -balena.models.application.create({ name: 'My App', deviceType: 'raspberry-pi', parent: 'ParentApp' }).then(function(application) { - console.log(application); -}); -``` - - -##### application.remove(slugOrUuidOrIdOrIds) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Remove application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrIdOrIds | String \| Number \| Array.<Number> | application slug (string), uuid (string) or id (number) or array of ids | - -**Example** -```js -balena.models.application.remove('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.remove(123); -``` - - -##### application.rename(slugOrUuidOrId, newName) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Rename application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| newName | String | new application name (string) | - -**Example** -```js -balena.models.application.rename('myorganization/myapp', 'MyRenamedApp'); -``` -**Example** -```js -balena.models.application.rename(123, 'MyRenamedApp'); -``` - - -##### application.restart(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Restart application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.restart('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.restart(123); -``` - - -##### application.generateProvisioningKey(generateProvisioningKeyParams) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Generate a device provisioning key for a specific application -**Access**: public -**Fulfil**: String - device provisioning key - -| Param | Type | Description | -| --- | --- | --- | -| generateProvisioningKeyParams | Object | an object containing the parameters for the provisioning key generation | -| generateProvisioningKeyParams.slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| generateProvisioningKeyParams.keyExpiryDate | String | Expiry Date for provisioning key | -| [generateProvisioningKeyParams.keyName] | String | Provisioning key name | -| [generateProvisioningKeyParams.keyDescription] | String | Description for provisioning key | - -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 'myorganization/myapp', keyExpiryDate: '2030-10-12'}).then(function(key) { - console.log(key); -}); -``` -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12'}).then(function(key) { - console.log(key); -}); -``` -**Example** -```js -balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12', keyName: 'api key name', keyDescription: 'api key long description'}).then(function(key) { - console.log(key); -}); -``` - - -##### application.purge(appId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Purge devices by application id -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| appId | Number | application id | - -**Example** -```js -balena.models.application.purge(123); -``` - - -##### application.shutdown(appId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Shutdown devices by application id -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appId | Number | | application id | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.application.shutdown(123); -``` - - -##### application.reboot(appId, [options]) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Reboot devices by application id -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| appId | Number | | application id | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.application.reboot(123); -``` - - -##### application.willTrackNewReleases(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get whether the application is configured to receive updates whenever a new release is available -**Access**: public -**Fulfil**: Boolean - is tracking the latest release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) { - console.log(isEnabled); -}); -``` -**Example** -```js -balena.models.application.willTrackNewReleases(123).then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates -**Access**: public -**Fulfil**: Boolean - is tracking the latest release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) { - console.log(isEnabled); -}); -``` -**Example** -```js -balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ Promise -Configures the application to run a particular release -and not get updated when the latest release changes. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Set a specific application to run a particular release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| fullReleaseHash | String | the hash of a successful release (string) | - -**Example** -```js -balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` - - -##### application.getTargetReleaseHash(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Get the hash of the current release for a specific application -**Access**: public -**Fulfil**: String\|undefined - The release hash of the current release - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.application.getTargetReleaseHash(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) { - console.log(release); -}); -``` - - -##### application.trackLatestRelease(slugOrUuidOrId) ⇒ Promise -The application's current release will be updated with each new successfully built release. - -**Kind**: static method of [application](#balena.models.application) -**Summary**: Configure a specific application to track the latest finalized available release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.trackLatestRelease('myorganization/myapp').then(function() { - ... -}); -``` -**Example** -```js -balena.models.application.trackLatestRelease(123).then(function() { - ... -}); -``` - - -##### application.enableDeviceUrls(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Enable device urls for all devices that belong to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.enableDeviceUrls('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.enableDeviceUrls(123); -``` - - -##### application.disableDeviceUrls(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Disable device urls for all devices that belong to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.disableDeviceUrls('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.disableDeviceUrls(123); -``` - - -##### application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Grant support access to an application until a specified time -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| expiryTimestamp | Number | a timestamp in ms for when the support access will expire | - -**Example** -```js -balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000); -``` -**Example** -```js -balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000); -``` - - -##### application.revokeSupportAccess(slugOrUuidOrId) ⇒ Promise -**Kind**: static method of [application](#balena.models.application) -**Summary**: Revoke support access to an application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| slugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.application.revokeSupportAccess('myorganization/myapp'); -``` -**Example** -```js -balena.models.application.revokeSupportAccess(123); -``` - - -#### models.device : object -**Kind**: static namespace of [models](#balena.models) - -* [.device](#balena.models.device) : object - * [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - * [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - * [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - * [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - * [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ String - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.getAllByApplication) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.device.getAllByOrganization) ⇒ Promise - * [.get(uuidOrId, [options])](#balena.models.device.get) ⇒ Promise - * [.getWithServiceDetails(uuidOrId, [options])](#balena.models.device.getWithServiceDetails) ⇒ Promise - * [.getByName(name)](#balena.models.device.getByName) ⇒ Promise - * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ Promise - * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ Promise - * [.has(uuidOrId)](#balena.models.device.has) ⇒ Promise - * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ Promise - * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ Promise - * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ Promise - * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ Promise - * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ Promise - * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ Promise - * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ Promise - * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ Promise - * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ Promise - * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ Promise - * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ Promise - * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ Promise - * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ Promise - * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ String - * [.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug])](#balena.models.device.register) ⇒ Promise - * [.generateDeviceKey(uuidOrId, [keyName], [keyDescription])](#balena.models.device.generateDeviceKey) ⇒ Promise - * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ Promise - * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ Promise - * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ Promise - * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ Promise - * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ Promise - * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ Promise - * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ Promise - * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ Object - * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ Promise - * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ Promise - * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ Promise - * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ Promise - * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ Promise - * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ Promise - * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ Promise - * ~~[.lastOnline(device)](#balena.models.device.lastOnline) ⇒ String~~ - * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ String - * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ Promise - * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ Promise - * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ Promise - * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ Promise - * [.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.setSupervisorRelease) ⇒ Promise - * [.startOsUpdate(uuidOrUuids, targetOsVersion, [options])](#balena.models.device.startOsUpdate) ⇒ Promise - * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ Promise - * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ Promise - * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ Promise - * [.reboot(uuidOrId, [options])](#balena.models.device.reboot) ⇒ Promise - * [.shutdown(uuidOrId, [options])](#balena.models.device.shutdown) ⇒ Promise - * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ Promise - * [.update(uuidOrId, [options])](#balena.models.device.update) ⇒ Promise - * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ Promise - * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ Promise - * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ Promise - * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ Promise - - - -##### device.tags : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.tags](#balena.models.device.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.tags.getAllByApplication) ⇒ Promise - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.tags.getAllByDevice) ⇒ Promise - * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ Promise - * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Get all device tags for an application -**Access**: public -**Fulfil**: Object[] - device tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.device.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Get all device tags for a device -**Access**: public -**Fulfil**: Object[] - device tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.tags.getAllByDevice('7cf02a6').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.device.tags.getAllByDevice(123).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(uuidOrId, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Set a device tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.device.tags.set('7cf02a6', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.device.tags.set(123, 'EDITOR', 'vim'); -``` - - -###### tags.remove(uuidOrId, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.device.tags) -**Summary**: Remove a device tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| tagKey | String | tag key | - -**Example** -```js -balena.models.device.tags.remove('7cf02a6', 'EDITOR'); -``` - - -##### device.configVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.configVar](#balena.models.device.configVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.configVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.configVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ Promise - - - -###### configVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get all config variables for a device -**Access**: public -**Fulfil**: Object[] - device config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.configVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.configVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get all device config variables by application -**Access**: public -**Fulfil**: Object[] - device config variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.configVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### configVar.get(uuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Get the value of a specific config variable -**Access**: public -**Fulfil**: String\|undefined - the config variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.device.configVar.get('7cf02a6', 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) { - console.log(value); -}); -``` - - -###### configVar.set(uuidOrId, key, value) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Set the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | -| value | String | config variable value | - -**Example** -```js -balena.models.device.configVar.set('7cf02a6', 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### configVar.remove(uuidOrId, key) ⇒ Promise -**Kind**: static method of [configVar](#balena.models.device.configVar) -**Summary**: Clear the value of a specific config variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | config variable name | - -**Example** -```js -balena.models.device.configVar.remove('7cf02a6', 'BALENA_VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() { - ... -}); -``` - - -##### device.envVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.envVar](#balena.models.device.envVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.envVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.envVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ Promise - * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ Promise - * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ Promise - - - -###### envVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get all environment variables for a device -**Access**: public -**Fulfil**: Object[] - device environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.envVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.envVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get all device environment variables by application -**Access**: public -**Fulfil**: Object[] - device environment variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.envVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### envVar.get(uuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Get the value of a specific environment variable -**Access**: public -**Fulfil**: String\|undefined - the environment variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.device.envVar.get('7cf02a6', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.envVar.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### envVar.set(uuidOrId, key, value) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Set the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | -| value | String | environment variable value | - -**Example** -```js -balena.models.device.envVar.set('7cf02a6', 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### envVar.remove(uuidOrId, key) ⇒ Promise -**Kind**: static method of [envVar](#balena.models.device.envVar) -**Summary**: Clear the value of a specific environment variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| key | String | environment variable name | - -**Example** -```js -balena.models.device.envVar.remove('7cf02a6', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.envVar.remove(999999, 'VAR').then(function() { - ... -}); -``` - - -##### device.serviceVar : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.serviceVar](#balena.models.device.serviceVar) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.serviceVar.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.serviceVar.getAllByApplication) ⇒ Promise - * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ Promise - * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ Promise - * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ Promise - - - -###### serviceVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get all service variable overrides for a device -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.serviceVar.getAllByDevice('7cf02a6').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### serviceVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get all device service variable overrides by application -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Get the overriden value of a service variable on a device -**Access**: public -**Fulfil**: String\|undefined - the variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | - -**Example** -```js -balena.models.device.serviceVar.get('7cf02a6', 123, 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.serviceVar.get('7cf02a6', 'myservice', 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Set the overriden value of a service variable on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | -| value | String | variable value | - -**Example** -```js -balena.models.device.serviceVar.set('7cf02a6', 123, 'VAR', 'override').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.set('7cf02a6', 'myservice', 'VAR', 'override').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() { - ... -}); -``` - - -###### serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ Promise -**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) -**Summary**: Clear the overridden value of a service variable on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| serviceNameOrId | String \| Number | service name (string) or id (number) | -| key | String | variable name | - -**Example** -```js -balena.models.device.serviceVar.remove('7cf02a6', 123, 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.remove('7cf02a6', 'myservice', 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() { - ... -}); -``` - - -##### device.history : object -**Kind**: static namespace of [device](#balena.models.device) - -* [.history](#balena.models.device.history) : object - * [.getAllByDevice(uuidOrId, [options])](#balena.models.device.history.getAllByDevice) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.device.history.getAllByApplication) ⇒ Promise - - - -###### history.getAllByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [history](#balena.models.device.history) -**Summary**: Get all history entries for a device -**Access**: public -**Fulfil**: Object[] - device history - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (32 / 62 digits string) or id (number) | -| [dateFilter.fromDate] | Date | subDays(new Date(), 7) | history entries older or equal to this date - default now() - 7 days | -| [dateFilter.toDate] | Date | | history entries younger or equal to this date | -| [options] | Object | | extra pine options to use | - -**Example** -```js -balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -balena.models.device.history.getAllByDevice(999999).then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByDevice( - 999999, - { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}, - { $top: 10, $orderby: { id: 'desc' }} -) -``` - - -###### history.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [history](#balena.models.device.history) -**Summary**: Get all device history entries by application with time frame -**Access**: public -**Fulfil**: Object[] - device history - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [dateFilter.fromDate] | Date | subDays(new Date(), 7) | history entries older or equal to this date - default now() - 7 days | -| [dateFilter.toDate] | Date | | history entries younger or equal to this date | -| [options] | Object | | extra pine options to use | - -**Example** -```js -balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) { - console.log(entries); -}); -``` -**Example** -```js -balena.models.device.history.getAllByApplication(999999).then(function(entries) { - console.log(entries); -}); - - -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) -``` -**Example** -```js -// get all device history entries between now - 20 days and now - 10 days -balena.models.device.history.getAllByApplication( - 999999, - { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10), - { $top: 10, $orderby: { id: 'desc' }} -}); -``` - - -##### device.getDashboardUrl(uuid) ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get Dashboard URL for a specific device -**Returns**: String - - Dashboard URL for the specific device -**Throws**: - -- Exception if the uuid is empty - - -| Param | Type | Description | -| --- | --- | --- | -| uuid | String | Device uuid | - -**Example** -```js -dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8') -``` - - -##### device.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -This method returns all devices of a specific application. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get all devices by application -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByApplication(123).then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all devices of a specific application. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get all devices by organization -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getAllByOrganization('myorganization').then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByOrganization(123).then(function(devices) { - console.log(devices); -}); -``` -**Example** -```js -balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.get(uuidOrId, [options]) ⇒ Promise -This method returns a single device by id or uuid. -In order to have the following computed properties in the result -you have to explicitly define them in a `$select` in the extra options: -* `overall_status` -* `overall_progress` -* `should_be_running__release` - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a single device -**Access**: public -**Fulfil**: Object - device - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.get(123).then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.get('7cf02a6', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { - console.log(device); -}) -``` - - -##### device.getWithServiceDetails(uuidOrId, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want more control, or to see the raw model -directly, use `device.get(uuidOrId, options)` instead. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a single device along with its associated services' details, -including their associated commit -**Access**: public -**Fulfil**: Object - device with service details - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.device.getWithServiceDetails('7cf02a6').then(function(device) { - console.log(device); -}) -``` -**Example** -```js -balena.models.device.getWithServiceDetails(123).then(function(device) { - console.log(device); -}) -``` - - -##### device.getByName(name) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get devices by name -**Access**: public -**Fulfil**: Object[] - devices - -| Param | Type | Description | -| --- | --- | --- | -| name | String | device name | - -**Example** -```js -balena.models.device.getByName('MyDevice').then(function(devices) { - console.log(devices); -}); -``` - - -##### device.getName(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the name of a device -**Access**: public -**Fulfil**: String - device name - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getName('7cf02a6').then(function(deviceName) { - console.log(deviceName); -}); -``` -**Example** -```js -balena.models.device.getName(123).then(function(deviceName) { - console.log(deviceName); -}); -``` - - -##### device.getApplicationName(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get application name -**Access**: public -**Fulfil**: String - application name - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getApplicationName('7cf02a6').then(function(applicationName) { - console.log(applicationName); -}); -``` -**Example** -```js -balena.models.device.getApplicationName(123).then(function(applicationName) { - console.log(applicationName); -}); -``` - - -##### device.has(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device exists -**Access**: public -**Fulfil**: Boolean - has device - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.has('7cf02a6').then(function(hasDevice) { - console.log(hasDevice); -}); -``` -**Example** -```js -balena.models.device.has(123).then(function(hasDevice) { - console.log(hasDevice); -}); -``` - - -##### device.isOnline(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device is online -**Access**: public -**Fulfil**: Boolean - is device online - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isOnline('7cf02a6').then(function(isOnline) { - console.log('Is device online?', isOnline); -}); -``` -**Example** -```js -balena.models.device.isOnline(123).then(function(isOnline) { - console.log('Is device online?', isOnline); -}); -``` - - -##### device.getLocalIPAddresses(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the local IP addresses of a device -**Access**: public -**Fulfil**: String[] - local ip addresses -**Reject**: Error Will reject if the device is offline - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getLocalIPAddresses('7cf02a6').then(function(localIPAddresses) { - localIPAddresses.forEach(function(localIP) { - console.log(localIP); - }); -}); -``` -**Example** -```js -balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) { - localIPAddresses.forEach(function(localIP) { - console.log(localIP); - }); -}); -``` - - -##### device.getMACAddresses(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the MAC addresses of a device -**Access**: public -**Fulfil**: String[] - mac addresses - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getMACAddresses('7cf02a6').then(function(macAddresses) { - macAddresses.forEach(function(mac) { - console.log(mac); - }); -}); -``` -**Example** -```js -balena.models.device.getMACAddresses(123).then(function(macAddresses) { - macAddresses.forEach(function(mac) { - console.log(mac); - }); -}); -``` - - -##### device.getMetrics(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the metrics related information for a device -**Access**: public -**Fulfil**: Object - device metrics - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getMetrics('7cf02a6').then(function(deviceMetrics) { - console.log(deviceMetrics); -}); -``` -**Example** -```js -balena.models.device.getMetrics(123).then(function(deviceMetrics) { - console.log(deviceMetrics); -}); -``` - - -##### device.remove(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Remove device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.remove('7cf02a6'); -``` -**Example** -```js -balena.models.device.remove(123); -``` - - -##### device.deactivate(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Deactivate device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.deactivate('7cf02a6'); -``` -**Example** -```js -balena.models.device.deactivate(123); -``` - - -##### device.rename(uuidOrId, newName) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Rename device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| newName | String | the device new name | - -**Example** -```js -balena.models.device.rename('7cf02a6', 'NewName'); -``` -**Example** -```js -balena.models.device.rename(123, 'NewName'); -``` - - -##### device.setNote(uuidOrIdOrArray, note) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Note a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| note | String | the note | - -**Example** -```js -balena.models.device.setNote('7cf02a6', 'My useful note'); -``` -**Example** -```js -balena.models.device.setNote(123, 'My useful note'); -``` - - -##### device.setCustomLocation(uuidOrIdOrArray, location) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a custom location for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| location | Object | the location ({ latitude: 123, longitude: 456 }) | - -**Example** -```js -balena.models.device.setCustomLocation('7cf02a6', { latitude: 123, longitude: 456 }); -``` -**Example** -```js -balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 }); -``` - - -##### device.unsetCustomLocation(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Clear the custom location of a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.unsetCustomLocation('7cf02a6'); -``` -**Example** -```js -balena.models.device.unsetCustomLocation(123); -``` - - -##### device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Move a device to another application -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| applicationSlugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | - -**Example** -```js -balena.models.device.move('7cf02a6', 'myorganization/myapp'); -``` -**Example** -```js -balena.models.device.move(123, 'myorganization/myapp'); -``` -**Example** -```js -balena.models.device.move(123, 456); -``` - - -##### device.getSupervisorTargetState(uuidOrId, version) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the target supervisor state on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| version | Number | (optional) target state version (2 or 3), default to 2 | - -**Example** -```js -balena.models.device.getSupervisorTargetState('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetState(123).then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetState(123, 3).then(function(state) { - console.log(state); -}); -``` - - -##### device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the target supervisor state on a "generic" device on a fleet -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | fleet uuid (string) or id (number) | -| release | String | (optional) release uuid (default tracked) | - -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a6').then(function(state) { - console.log(state); -}); -``` - - -##### device.generateUniqueKey() ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Generate a random key, useful for both uuid and api key. -**Returns**: String - A generated key -**Access**: public -**Example** -```js -randomKey = balena.models.device.generateUniqueKey(); -// randomKey is a randomly generated key that can be used as either a uuid or an api key -console.log(randomKey); -``` - - -##### device.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Register a new device with a Balena application. -**Access**: public -**Fulfil**: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." }) - -| Param | Type | Description | -| --- | --- | --- | -| applicationSlugOrUuidOrId | String \| Number | application slug (string), uuid (string) or id (number) | -| uuid | String | device uuid | -| [deviceTypeSlug] | String | device type slug (string) or alias (string) | - -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` -**Example** -```js -var uuid = balena.models.device.generateUniqueKey(); -balena.models.device.register(123, uuid).then(function(registrationInfo) { - console.log(registrationInfo); -}); -``` - - -##### device.generateDeviceKey(uuidOrId, [keyName], [keyDescription]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Generate a device key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| [keyName] | String | Device key name | -| [keyDescription] | String | Description for device key | - -**Example** -```js -balena.models.device.generateDeviceKey('7cf02a6').then(function(deviceApiKey) { - console.log(deviceApiKey); -}); -``` -**Example** -```js -balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) { - console.log(deviceApiKey); -}); -``` - - -##### device.hasDeviceUrl(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device is web accessible with device utls -**Access**: public -**Fulfil**: Boolean - has device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.hasDeviceUrl('7cf02a6').then(function(hasDeviceUrl) { - if (hasDeviceUrl) { - console.log('The device has device URL enabled'); - } -}); -``` -**Example** -```js -balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) { - if (hasDeviceUrl) { - console.log('The device has device URL enabled'); - } -}); -``` - - -##### device.getDeviceUrl(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a device url -**Access**: public -**Fulfil**: String - device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getDeviceUrl('7cf02a6').then(function(url) { - console.log(url); -}); -``` -**Example** -```js -balena.models.device.getDeviceUrl(123).then(function(url) { - console.log(url); -}); -``` - - -##### device.enableDeviceUrl(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable device url for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.enableDeviceUrl('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableDeviceUrl(123); -``` - - -##### device.disableDeviceUrl(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable device url for a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.disableDeviceUrl('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableDeviceUrl(123); -``` - - -##### device.enableLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable local mode -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.enableLocalMode('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableLocalMode(123); -``` - - -##### device.disableLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable local mode -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.disableLocalMode('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableLocalMode(123); -``` - - -##### device.isInLocalMode(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if local mode is enabled on the device -**Access**: public -**Fulfil**: Boolean - has device url - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isInLocalMode('7cf02a6').then(function(isInLocalMode) { - if (isInLocalMode) { - console.log('The device has local mode enabled'); - } -}); -``` -**Example** -```js -balena.models.device.isInLocalMode(123).then(function(isInLocalMode) { - if (isInLocalMode) { - console.log('The device has local mode enabled'); - } -}); -``` - - -##### device.getLocalModeSupport(device) ⇒ Object -**Kind**: static method of [device](#balena.models.device) -**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported. -**Returns**: Object - Local mode support info ({ supported: true/false, message: "..." }) -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - balena.models.device.getLocalModeSupport(device); -}) -``` - - -##### device.enableLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Enable lock override -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.enableLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.enableLockOverride(123); -``` - - -##### device.disableLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Disable lock override -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.disableLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.disableLockOverride(123); -``` - - -##### device.hasLockOverride(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Check if a device has the lock override enabled -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.hasLockOverride('7cf02a6'); -``` -**Example** -```js -balena.models.device.hasLockOverride(123); -``` - - -##### device.getStatus(uuidOrId) ⇒ Promise -Convenience method for getting the overall status of a device. -It's recommended to use `balena.models.device.get()` instead, -in case that you need to retrieve more device fields than just the status. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the status of a device -**Access**: public -**Fulfil**: String - device status -**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field. - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getStatus('7cf02a6').then(function(status) { - console.log(status); -}); -``` -**Example** -```js -balena.models.device.getStatus(123).then(function(status) { - console.log(status); -}); -``` - - -##### device.getProgress(uuidOrId) ⇒ Promise -Convenience method for getting the overall progress of a device. -It's recommended to use `balena.models.device.get()` instead, -in case that you need to retrieve more device fields than just the progress. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the progress of a device -**Access**: public -**Fulfil**: Number\|Null - device progress -**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field. - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getProgress('7cf02a6').then(function(progress) { - console.log(progress); -}); -``` -**Example** -```js -balena.models.device.getProgress(123).then(function(progress) { - console.log(progress); -}); -``` - - -##### device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Grant support access to a device until a specified time -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| expiryTimestamp | Number | a timestamp in ms for when the support access will expire | - -**Example** -```js -balena.models.device.grantSupportAccess('7cf02a6', Date.now() + 3600 * 1000); -``` -**Example** -```js -balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000); -``` - - -##### device.revokeSupportAccess(uuidOrIdOrArray) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Revoke support access to a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.revokeSupportAccess('7cf02a6'); -``` -**Example** -```js -balena.models.device.revokeSupportAccess(123); -``` - - -##### ~~device.lastOnline(device) ⇒ String~~ -***Will be dropped in the next major*** - -If the device has never been online this method returns the string `Connecting...`. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get a string showing when a device was last set as online -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - balena.models.device.lastOnline(device); -}) -``` - - -##### device.getOsVersion(device) ⇒ String -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the OS version (version number and variant combined) running on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| device | Object | A device object | - -**Example** -```js -balena.models.device.get('7cf02a6').then(function(device) { - console.log(device.os_version); // => 'balenaOS 2.26.0+rev1' - console.log(device.os_variant); // => 'prod' - balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod' -}) -``` - - -##### device.isTrackingApplicationRelease(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get whether the device is configured to track the current application release -**Access**: public -**Fulfil**: Boolean - is tracking the current application release - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.isTrackingApplicationRelease('7cf02a6').then(function(isEnabled) { - console.log(isEnabled); -}); -``` - - -##### device.getTargetReleaseHash(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the hash of the currently tracked release for a specific device -**Access**: public -**Fulfil**: String - The release hash of the currently tracked release - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getTargetReleaseHash('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.device.getTargetReleaseHash('7cf02a6', function(release) { - console.log(release); -}); -``` - - -##### device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ Promise -Configures the device to run a particular release -and not get updated when the current application release changes. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a specific device to run a particular release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| fullReleaseHashOrId | String \| Number | the hash of a successful release (string) or id (number) | - -**Example** -```js -balena.models.device.pinToRelease('7cf02a6', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { - ... -}); -``` - - -##### device.trackApplicationRelease(uuidOrIdOrArray) ⇒ Promise -The device's current release will be updated with each new successfully built release. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Configure a specific device to track the current application release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | - -**Example** -```js -balena.models.device.trackApplicationRelease('7cf02a6').then(function() { - ... -}); -``` - - -##### device.setSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ Promise -Configures the device to run a particular supervisor release. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Set a specific device to run a particular supervisor release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrIdOrArray | String \| Array.<String> \| Number \| Array.<Number> | device uuid (string) or id (number) or array of full uuids or ids | -| supervisorVersionOrId | String \| Number | the raw version of a supervisor release (string) or id (number) | - -**Example** -```js -balena.models.device.setSupervisorRelease('7cf02a6', '10.8.0').then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.setSupervisorRelease(123, '11.4.14').then(function() { - ... -}); -``` - - -##### device.startOsUpdate(uuidOrUuids, targetOsVersion, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start an OS update on a device -**Access**: public -**Fulfil**: Object - action response - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrUuids | String \| Array.<String> | full device uuid or array of full uuids | -| targetOsVersion | String | semver-compatible version for the target device Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number, a "prod" variant and greater than the one running on the device. To resolve the semver-compatible range use `balena.model.os.getMaxSatisfyingVersion`. | -| [options] | Object | options | -| [options.runDetached] | Boolean | run the update in detached mode. True by default | - -**Example** -```js -balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { - console.log(result.status); -}); -``` - - -##### device.ping(uuidOrId) ⇒ Promise -This is useful to signal that the supervisor is alive and responding. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Ping a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.ping('7cf02a6'); -``` -**Example** -```js -balena.models.device.ping(123); -``` - - -##### device.identify(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Identify device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.identify('7cf02a6'); -``` -**Example** -```js -balena.models.device.identify(123); -``` - - -##### device.restartApplication(uuidOrId) ⇒ Promise -This function restarts the Docker container running -the application on the device, but doesn't reboot -the device itself. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Restart application on device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.restartApplication('7cf02a6'); -``` -**Example** -```js -balena.models.device.restartApplication(123); -``` - - -##### device.reboot(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Reboot device -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.reboot('7cf02a6'); -``` -**Example** -```js -balena.models.device.reboot(123); -``` - - -##### device.shutdown(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Shutdown device -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.shutdown('7cf02a6'); -``` -**Example** -```js -balena.models.device.shutdown(123); -``` - - -##### device.purge(uuidOrId) ⇒ Promise -This function clears the user application's `/data` directory. - -**Kind**: static method of [device](#balena.models.device) -**Summary**: Purge device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.purge('7cf02a6'); -``` -**Example** -```js -balena.models.device.purge(123); -``` - - -##### device.update(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Trigger an update check on the supervisor -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.force] | Boolean | false | override update lock | - -**Example** -```js -balena.models.device.update('7cf02a6', { - force: true -}); -``` -**Example** -```js -balena.models.device.update(123, { - force: true -}); -``` - - -##### device.getSupervisorState(uuidOrId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Get the supervisor state on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | - -**Example** -```js -balena.models.device.getSupervisorState('7cf02a6').then(function(state) { - console.log(state); -}); -``` -**Example** -```js -balena.models.device.getSupervisorState(123).then(function(state) { - console.log(state); -}); -``` - - -##### device.startService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Start a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to start | - -**Example** -```js -balena.models.device.startService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.startService(1, 123).then(function() { - ... -}); -``` - - -##### device.stopService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Stop a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to stop | - -**Example** -```js -balena.models.device.stopService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.stopService(1, 123).then(function() { - ... -}); -``` - - -##### device.restartService(uuidOrId, imageId) ⇒ Promise -**Kind**: static method of [device](#balena.models.device) -**Summary**: Restart a service on a device -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| uuidOrId | String \| Number | device uuid (string) or id (number) | -| imageId | Number | id of the image to restart | - -**Example** -```js -balena.models.device.restartService('7cf02a6', 123).then(function() { - ... -}); -``` -**Example** -```js -balena.models.device.restartService(1, 123).then(function() { - ... -}); -``` - - -#### models.deviceType : object -**Kind**: static namespace of [models](#balena.models) - -* [.deviceType](#balena.models.deviceType) : object - * [.get(idOrSlug, [options])](#balena.models.deviceType.get) ⇒ Promise - * [.getAll([options])](#balena.models.deviceType.getAll) ⇒ Promise - * [.getAllSupported([options])](#balena.models.deviceType.getAllSupported) ⇒ Promise - * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ Promise - * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ Promise - * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ Promise - * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ Promise - * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ Promise - * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ Promise - - - -##### deviceType.get(idOrSlug, [options]) ⇒ Promise -This method returns a single device type. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a single deviceType -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| idOrSlug | String \| Number | | device type slug (string) or alias (string) or id | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.get('raspberry-pi').then(function(deviceType) { - console.log(deviceType); -}); -``` -**Example** -```js -balena.models.deviceType.get('raspberrypi').then(function(deviceType) { - console.log('resolved alias:', deviceType); -}); -``` - - -##### deviceType.getAll([options]) ⇒ Promise -This method returns all device types. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get all deviceTypes -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.getAll().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` -**Example** -```js -balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) { - console.log(deviceTypes); -}) -``` - - -##### deviceType.getAllSupported([options]) ⇒ Promise -This method returns all supported device types. - -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get all supported deviceTypes -**Access**: public -**Fulfil**: Object[] - device types - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.deviceType.getAllSupported().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` -**Example** -```js -balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) { - console.log(deviceTypes); -}) -``` - - -##### deviceType.getBySlugOrName(slugOrName) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a deviceType by slug or name -**Access**: public -**Fulfil**: Object - device type - -| Param | Type | Description | -| --- | --- | --- | -| slugOrName | String | deviceType slug | - -**Example** -```js -balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { - console.log(deviceType); -}); -``` - - -##### deviceType.getName(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get display name for a device -**Access**: public -**Fulfil**: String - device display name - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { - console.log(deviceTypeName); - // Raspberry Pi -}); -``` - - -##### deviceType.getSlugByName(deviceTypeName) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get device slug -**Access**: public -**Fulfil**: String - device slug name - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeName | String | device type name | - -**Example** -```js -balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { - console.log(deviceTypeSlug); - // raspberry-pi -}); -``` - - -##### deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get a contract with resolved partial templates -**Access**: public -**Fulfil**: Contract - device type contract with resolved partials - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { - for (const partial in contract.partials) { - console.log(`${partial}: ${contract.partials[partial]}`); - } - // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] -}); -``` - - -##### deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get instructions for installing a host OS on a given device type -**Access**: public -**Fulfil**: Object \| String[] - step by step instructions for installing the host OS to the device - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlugOrContract | String \| Object | device type slug or contract | - -**Example** -```js -balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { - for (let instruction of instructions.values()) { - console.log(instruction); - } - // Insert the sdcard to the host machine. - // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. - // Wait for writing of BalenaOS to complete. - // Remove the sdcard from the host machine. - // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). - // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. -}); -``` - - -##### deviceType.getInstallMethod(deviceTypeSlug) ⇒ Promise -**Kind**: static method of [deviceType](#balena.models.deviceType) -**Summary**: Get installation method on a given device type -**Access**: public -**Fulfil**: String - the installation method supported for the given device type slug - -| Param | Type | Description | -| --- | --- | --- | -| deviceTypeSlug | String | device type slug | - -**Example** -```js -balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { - console.log(method); - // externalBoot -}); -``` - - -#### models.apiKey : object -**Kind**: static namespace of [models](#balena.models) - -* [.apiKey](#balena.models.apiKey) : object - * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ Promise - * [.getAll([options])](#balena.models.apiKey.getAll) ⇒ Promise - * [.getAllNamedUserApiKeys([options])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ Promise - * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ Promise - * [.getDeviceApiKeysByDevice(uuidOrId, [options])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ Promise - * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ Promise - * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ Promise - - - -##### apiKey.create(createApiKeyParams) ⇒ Promise -This method registers a new api key for the current user with the name given. - -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Creates a new user API key -**Access**: public -**Fulfil**: String - API key - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| createApiKeyParams | Object | | an object containing the parameters for the creation of an API key | -| createApiKeyParams.name | String | | the API key name | -| createApiKeyParams.expiryDate | String | | the API key expiry date | -| [createApiKeyParams.description] | String | | the API key description | - -**Example** -```js -balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12}).then(function(apiKey) { - console.log(apiKey); -}); -``` -**Example** -```js -balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12, description: apiKeyDescription}).then(function(apiKey) { - console.log(apiKey); -}); -``` - - -##### apiKey.getAll([options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all accessible API keys -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getAll().then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getAllNamedUserApiKeys([options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all named user API keys of the current user -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all provisioning API keys for an application -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.getDeviceApiKeysByDevice(uuidOrId, [options]) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Get all API keys for a device -**Access**: public -**Fulfil**: Object[] - apiKeys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device, uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a6').then(function(apiKeys) { - console.log(apiKeys); -}); -``` - - -##### apiKey.update(id, apiKeyInfo) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Update the details of an API key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | API key id | -| apiKeyInfo | Object | an object with the updated name|description|expiryDate | - -**Example** -```js -balena.models.apiKey.update(123, { name: 'updatedName' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { description: 'updated description' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { expiryDate: '2022-04-29' }); -``` -**Example** -```js -balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' }); -``` - - -##### apiKey.revoke(id) ⇒ Promise -**Kind**: static method of [apiKey](#balena.models.apiKey) -**Summary**: Revoke an API key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | API key id | - -**Example** -```js -balena.models.apiKey.revoke(123); -``` - - -#### models.key : object -**Kind**: static namespace of [models](#balena.models) - -* [.key](#balena.models.key) : object - * [.getAll([options])](#balena.models.key.getAll) ⇒ Promise - * [.get(id)](#balena.models.key.get) ⇒ Promise - * [.remove(id)](#balena.models.key.remove) ⇒ Promise - * [.create(title, key)](#balena.models.key.create) ⇒ Promise - - - -##### key.getAll([options]) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Get all ssh keys -**Access**: public -**Fulfil**: Object[] - ssh keys - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.key.getAll().then(function(keys) { - console.log(keys); -}); -``` - - -##### key.get(id) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Get a single ssh key -**Access**: public -**Fulfil**: Object - ssh key - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | key id | - -**Example** -```js -balena.models.key.get(51).then(function(key) { - console.log(key); -}); -``` - - -##### key.remove(id) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Remove ssh key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | key id | - -**Example** -```js -balena.models.key.remove(51); -``` - - -##### key.create(title, key) ⇒ Promise -**Kind**: static method of [key](#balena.models.key) -**Summary**: Create a ssh key -**Access**: public -**Fulfil**: Object - ssh key - -| Param | Type | Description | -| --- | --- | --- | -| title | String | key title | -| key | String | the public ssh key | - -**Example** -```js -balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) { - console.log(key); -}); -``` - - -#### models.organization : object -**Kind**: static namespace of [models](#balena.models) - -* [.organization](#balena.models.organization) : object - * [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - * [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - * [.create(options)](#balena.models.organization.create) ⇒ Promise - * [.getAll([options])](#balena.models.organization.getAll) ⇒ Promise - * [.get(handleOrId, [options])](#balena.models.organization.get) ⇒ Promise - * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ Promise - - - -##### organization.membership : object -**Kind**: static namespace of [organization](#balena.models.organization) - -* [.membership](#balena.models.organization.membership) : object - * [.get(membershipId, [options])](#balena.models.organization.membership.get) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.membership.getAllByOrganization) ⇒ Promise - * [.getAllByUser(usernameOrId, [options])](#balena.models.organization.membership.getAllByUser) ⇒ Promise - * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ Promise - * [.remove(id)](#balena.models.organization.membership.remove) ⇒ Promise - - - -###### membership.get(membershipId, [options]) ⇒ Promise -This method returns a single organization membership. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get a single organization membership -**Access**: public -**Fulfil**: Object - organization membership - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| membershipId | number \| Object | | the id or an object with the unique `user` & `is_member_of__organization` numeric pair of the membership | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.get(5).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all organization memberships for a specific organization. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get all memberships by organization -**Access**: public -**Fulfil**: Object[] - organization memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.getAllByUser(usernameOrId, [options]) ⇒ Promise -This method returns all organization memberships for a specific user. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Get all memberships by user -**Access**: public -**Fulfil**: Object[] - organization memberships - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| usernameOrId | String \| Number | | the user's username (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) { - console.log(memberships); -}); -``` -**Example** -```js -balena.models.organization.membership.getAllByUser(123).then(function(memberships) { - console.log(memberships); -}); -``` - - -###### membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise -This method changes the role of an organization member. - -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Changes the role of an organization member -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| idOrUniqueKey | Number \| Object | the id or an object with the unique `user` & `is_member_of__organization` numeric pair of the membership that will be changed | -| roleName | String | the role name to be granted to the membership | - -**Example** -```js -balena.models.organization.membership.changeRole(123, "member").then(function() { - console.log('OK'); -}); -``` -**Example** -```js -balena.models.organization.membership.changeRole({ - user: 123, - is_member_of__organization: 125, -}, "member").then(function() { - console.log('OK'); -}); -``` - - -###### membership.remove(id) ⇒ Promise -**Kind**: static method of [membership](#balena.models.organization.membership) -**Summary**: Remove a membership -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | organization membership id | - -**Example** -```js -balena.models.organization.membership.remove(123); -``` -**Example** -```js -balena.models.organization.membership.remove({ - user: 123, - is_member_of__application: 125, -}); -``` - - -##### organization.invite : object -**Kind**: static namespace of [organization](#balena.models.organization) - -* [.invite](#balena.models.organization.invite) : object - * [.getAll([options])](#balena.models.organization.invite.getAll) ⇒ Promise - * [.getAllByOrganization(handleOrId, [options])](#balena.models.organization.invite.getAllByOrganization) ⇒ Promise - * [.create(handleOrId, options, [message])](#balena.models.organization.invite.create) ⇒ Promise - * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ Promise - * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ Promise - - - -###### invite.getAll([options]) ⇒ Promise -This method returns all invites. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Get all invites -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.invite.getAll().then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.getAllByOrganization(handleOrId, [options]) ⇒ Promise -This method returns all invites for a specific organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Get all invites by organization -**Access**: public -**Fulfil**: Object[] - invites - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string), or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) { - console.log(invites); -}); -``` -**Example** -```js -balena.models.organization.invite.getAllByOrganization(123).then(function(invites) { - console.log(invites); -}); -``` - - -###### invite.create(handleOrId, options, [message]) ⇒ Promise -This method invites a user by their email to an organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Creates a new invite for an organization -**Access**: public -**Fulfil**: String - organization invite - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string), or id (number) | -| options | Object | | invite creation parameters | -| options.invitee | String | | the email of the invitee | -| [options.roleName] | String | "developer" | the role name to be granted to the invitee | -| [message] | String | | the message to send along with the invite | - -**Example** -```js -balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) { - console.log(invite); -}); -``` - - -###### invite.revoke(id) ⇒ Promise -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Revoke an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | organization invite id | - -**Example** -```js -balena.models.organization.invite.revoke(123); -``` - - -###### invite.accept(invitationToken) ⇒ Promise -This method adds the calling user to the organization. - -**Kind**: static method of [invite](#balena.models.organization.invite) -**Summary**: Accepts an invite -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| invitationToken | String | invite token | - -**Example** -```js -balena.models.organization.invite.accept("qwerty-invitation-token"); -``` - - -##### organization.create(options) ⇒ Promise -This method creates a new organization with the current user as an administrator. - -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Creates a new organization -**Access**: public -**Fulfil**: String - Organization - -| Param | Type | Description | -| --- | --- | --- | -| options | Object | Organization parameters to use. | -| options.name | String | Required: the name of the organization that will be created. | -| [options.handle] | String | The handle of the organization that will be created. | - -**Example** -```js -balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.create({ - name:'MyOrganization', - logo_image: new File( - imageContent, - 'img.jpeg' - ); -}) -.then(function(organization) { - console.log(organization); -}); -``` - - -##### organization.getAll([options]) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Get all Organizations -**Access**: public -**Fulfil**: Object[] - organizations - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.getAll().then(function(organizations) { - console.log(organizations); -}); -``` - - -##### organization.get(handleOrId, [options]) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Get a single organization -**Access**: public -**Fulfil**: Object - organization - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| handleOrId | String \| Number | | organization handle (string) or id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.organization.get('myorganization').then(function(organization) { - console.log(organization); -}); -``` -**Example** -```js -balena.models.organization.get(123).then(function(organization) { - console.log(organization); -}); -``` - - -##### organization.remove(handleOrId) ⇒ Promise -**Kind**: static method of [organization](#balena.models.organization) -**Summary**: Remove an Organization -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| handleOrId | String \| Number | organization handle (string) or id (number). | - -**Example** -```js -balena.models.organization.remove(123); -``` - - -#### models.team : object -**Kind**: static namespace of [models](#balena.models) - -* [.team](#balena.models.team) : object - * [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ Promise - * [.getAllByOrganization(organizationSlugOrId, [options])](#balena.models.team.getAllByOrganization) ⇒ Promise - * [.get(teamId, [options])](#balena.models.team.get) ⇒ Promise - * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ Promise - * [.remove(teamId)](#balena.models.team.remove) ⇒ Promise - - - -##### team.applicationAccess : object -**Kind**: static namespace of [team](#balena.models.team) - -* [.applicationAccess](#balena.models.team.applicationAccess) : object - * [.getAllByTeam(teamId, [options])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ Promise - * [.get(teamApplicationAccessId, [options])](#balena.models.team.applicationAccess.get) ⇒ Promise - * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ Promise - * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ Promise - - - -###### applicationAccess.getAllByTeam(teamId, [options]) ⇒ Promise -This method get all team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Get all team applications access -**Access**: public -**Fulfil**: Object[] - team application access - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| teamId | Number | | Required: the team id. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.team.applicationAccess.getAllByTeam(1239948).then(function(teamApplicationAccesses) { - console.log(teamApplicationAccesses); -}); -``` - - -###### applicationAccess.get(teamApplicationAccessId, [options]) ⇒ Promise -This method get specific team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Get team applications access -**Access**: public -**Fulfil**: Object - TeamApplicationAccess - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| teamApplicationAccessId | Number | | Required: the team application access id. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.team.applicationAccess.get(1239948).then(function(teamApplicationAccess) { - console.log(teamApplicationAccess); -}); -``` - - -###### applicationAccess.update(teamApplicationAccessId, roleName) ⇒ Promise -This method update a team application access role. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Update team application access -**Access**: public -**Fulfil**: Object - TeamApplicationAccess - -| Param | Type | Description | -| --- | --- | --- | -| teamApplicationAccessId | Number | Required: the team application access id. | -| roleName | String | Required: The new role to assing (ApplicationMembershipRoles). | - -**Example** -```js -balena.models.team.update(123, 'developer').then(function(teamApplicationAccess) { - console.log(teamApplicationAccess); -}); -``` - - -###### applicationAccess.remove(teamApplicationAccessId) ⇒ Promise -This remove a team application access. - -**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) -**Summary**: Remove team application access -**Access**: public -**Fulfil**: void - -| Param | Type | Description | -| --- | --- | --- | -| teamApplicationAccessId | Number | Required: the team application access id. | - -**Example** -```js -balena.models.team.remove(123).then(function(teams) { - console.log(teams); -}); -``` - - -##### team.create(organizationSlugOrId, name) ⇒ Promise -This method creates a new team. - -**Kind**: static method of [team](#balena.models.team) -**Summary**: Creates a new Team -**Access**: public -**Fulfil**: Object - Team - -| Param | Type | Description | -| --- | --- | --- | -| organizationSlugOrId | Number | Required: the organization slug or id the team will be part of. | -| name | String | Required: the name of the team that will be created. | - -**Example** -```js -balena.models.team.create(1239948, 'MyTeam').then(function(team) { - console.log(team); -}); -``` -**Example** -```js -balena.models.team.create('myOrgHandle', 'MyTeam') -.then(function(team) { - console.log(team); -}); -``` - - -##### team.getAllByOrganization(organizationSlugOrId, [options]) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Get all Teams of a specific Organization -**Access**: public -**Fulfil**: Object[] - Teams - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| organizationSlugOrId | Number | | Required: the organization slug or id the team is part of. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.team.getAllByOrganization(123).then(function(teams) { - console.log(teams); -}); -``` -**Example** -```js -balena.models.team.getAllByOrganization('MyOrganizationHandle').then(function(teams) { - console.log(teams); -}); -``` - - -##### team.get(teamId, [options]) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Get a single Team -**Access**: public -**Fulfil**: Object - Team - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| teamId | Number | | team id (number). | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.team.get(123).then(function(team) { - console.log(team); -}); -``` - - -##### team.rename(teamId, newName) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Rename Team -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| teamId | Number | team id (number) | -| newName | String | new team name (string) | - -**Example** -```js -balena.models.team.rename(123, 'MyNewTeamName'); -``` - - -##### team.remove(teamId) ⇒ Promise -**Kind**: static method of [team](#balena.models.team) -**Summary**: Remove a Team -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| teamId | Number | team id (number). | - -**Example** -```js -balena.models.team.remove(123); -``` - - -#### models.os : object -**Kind**: static namespace of [models](#balena.models) - -* [.os](#balena.models.os) : object - * [.getAvailableOsVersions(deviceTypes, [options])](#balena.models.os.getAvailableOsVersions) ⇒ Promise - * [.getAllOsVersions(deviceTypes, [options])](#balena.models.os.getAllOsVersions) ⇒ Promise - * [.getDownloadSize(deviceType, [version])](#balena.models.os.getDownloadSize) ⇒ Promise - * [.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType])](#balena.models.os.getMaxSatisfyingVersion) ⇒ Promise - * [.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> - - - -##### os.getAvailableOsVersions(deviceTypes, [options]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the supported OS versions for the provided device type(s) -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceTypes | String \| Array.<String> | | device type slug or array of slugs | -| [options] | Object | | Extra pine options & draft filter to use | -| [options.includeDraft] | Boolean | false | Whether pre-releases should be included in the results | - -**Example** -```js -balena.models.os.getAvailableOsVersions('raspberrypi3'); -``` -**Example** -```js -balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']); -``` - - -##### os.getAllOsVersions(deviceTypes, [options]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceTypes | String \| Array.<String> | | device type slug or array of slugs | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.os.getAllOsVersions('raspberrypi3'); -``` -**Example** -```js -balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']); -``` -**Example** -```js -balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } }); -``` - - -##### os.getDownloadSize(deviceType, [version]) ⇒ Promise -**Note!** Currently only the raw (uncompressed) size is reported. - -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get OS download size estimate -**Access**: public -**Fulfil**: Number - OS image download size, in bytes. - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | -| [version] | String | semver-compatible version or 'latest', defaults to 'latest'. The version **must** be the exact version number. | - -**Example** -```js -balena.models.os.getDownloadSize('raspberry-pi').then(function(size) { - console.log('The OS download size for raspberry-pi', size); -}); -``` - - -##### os.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType]) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get the max OS version satisfying the given range -**Access**: public -**Fulfil**: String\|null - the version number, or `null` if no matching versions are found - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | -| versionOrRange | String | can be one of * the exact version number, in which case it is returned if the version is supported, or `null` is returned otherwise, * a [semver](https://www.npmjs.com/package/semver)-compatible range specification, in which case the most recent satisfying version is returned if it exists, or `null` is returned, * `'latest'/'default'` in which case the most recent version is returned, excluding pre-releases, Defaults to `'latest'`. | -| [osType] | String | can be one of 'default', 'esr' or null to include all types | - -**Example** -```js -balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) { - console.log(version); -}); -``` - - -##### os.download(options) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Download an OS image -**Access**: public -**Fulfil**: ReadableStream - download stream - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| options | Object | | OS image options to use. | -| options.deviceType | String | | device type slug | -| [options.version] | String | 'latest' | semver-compatible version or 'latest', defaults to 'latest' Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number. | -| [options.developmentMode] | Boolean | | controls development mode for unified balenaOS releases. | -| [options.appId] | Number | | the application ID (number). | -| [options.fileType] | String | | download file type. One of '.img' or '.zip' or '.gz'. | -| [options.imageType] | String | | download file type. One of 'raw' or 'flasher' | -| [options.appUpdatePollInterval] | Number | | how often the OS checks for updates, in minutes. | -| [options.network] | String | | the network type that the device will use, one of 'ethernet' or 'wifi'. | -| [options.wifiKey] | String | | the key for the wifi network the device will connect to if network is wifi. | -| [options.wifiSsid] | String | | the ssid for the wifi network the device will connect to if network is wifi. | - -**Example** -```js -balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) { - stream.pipe(fs.createWriteStream('foo/bar/image.img')); -}); -``` - - -##### os.getConfig(slugOrUuidOrId, options) ⇒ Promise -Builds the config.json for a device in the given application, with the given -options. - -Note that an OS version is required. For versions < 2.7.8, config -generation is only supported when using a session token, not an API key. - -**Kind**: static method of [os](#balena.models.os) -**Summary**: Get an applications config.json -**Access**: public -**Fulfil**: Object - application configuration as a JSON object. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number). | -| options | Object | | OS configuration options to use. | -| options.version | String | | Required: the OS version of the image. | -| [options.network] | String | 'ethernet' | The network type that the device will use, one of 'ethernet' or 'wifi'. | -| [options.appUpdatePollInterval] | Number | | How often the OS checks for updates, in minutes. | -| [options.provisioningKeyName] | String | | Name assigned to API key | -| [options.provisioningKeyExpiryDate] | String | | Expiry Date assigned to API key | -| [options.developmentMode] | Boolean | | Controls development mode for unified balenaOS releases. | -| [options.wifiKey] | String | | The key for the wifi network the device will connect to. | -| [options.wifiSsid] | String | | The ssid for the wifi network the device will connect to. | -| [options.ip] | String | | static ip address. | -| [options.gateway] | String | | static ip gateway. | -| [options.netmask] | String | | static ip netmask. | - -**Example** -```js -balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) { - fs.writeFile('foo/bar/config.json', JSON.stringify(config)); -}); - -balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) { - fs.writeFile('foo/bar/config.json', JSON.stringify(config)); -}); -``` - - -##### os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ Promise -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions -**Access**: public -**Fulfil**: Boolean - whether upgrading the OS to the target version is supported - -| 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.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) { - 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 -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns the supported OS update targets for the provided device type -**Access**: public -**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, -or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. -**Fulfil**: Object - the versions information, of the following structure: -* versions - an array of strings, -containing exact version numbers that OS update is supported -* recommended - the recommended version, i.e. the most recent version -that is _not_ pre-release, can be `null` -* current - the provided current version after normalization - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| deviceType | String | | device type slug | -| currentVersion | String | | semver-compatible version for the starting OS version | -| [options] | Object | | Extra options to filter the OS releases by | -| [options.includeDraft] | Boolean | false | Whether pre-releases should be included in the results | -| [options.osType] | String \| Null | 'default' | Can be one of 'default', 'esr' or null to include all types | - -**Example** -```js -balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) { - console.log(isSupported); -}); -``` - - -##### os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ Boolean -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns whether the specified OS architecture is compatible with the target architecture -**Returns**: Boolean - - Whether the specified OS architecture is capable of running -applications build for the target architecture -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| osArchitecture | String | The OS's architecture as specified in its device type | -| applicationArchitecture | String | The application's architecture as specified in its device type | - -**Example** -```js -const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf'); -console.log(result1); - -const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64'); -console.log(result2); -``` - - -##### os.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options]) ⇒ Promise.<String> -**Kind**: static method of [os](#balena.models.os) -**Summary**: Returns the Releases of the supervisor for the CPU Architecture -**Returns**: Promise.<String> - - An array of Release objects that can be used to manage a device as supervisors. -**Access**: public - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| cpuArchitectureSlugOrId | String \| Number | | The slug (string) or id (number) for the CPU Architecture | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64'); - -const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( - 'aarch64', - { $filter: { raw_version: '12.11.0' } }, -); - -const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( - 'aarch64', - { - $select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'], - $expand: { - release_image: { - $select: 'id', - $expand: { - image: { - $select: 'is_stored_at__image_location', - }, - }, - }, - }, - $filter: { raw_version: '12.11.0' } - }, -); -``` - - -#### models.config : object -**Kind**: static namespace of [models](#balena.models) - -* [.config](#balena.models.config) : object - * [.getAll()](#balena.models.config.getAll) ⇒ Promise - * ~~[.getDeviceTypes()](#balena.models.config.getDeviceTypes) ⇒ Promise~~ - * ~~[.getDeviceTypeManifestBySlug(slugOrName)](#balena.models.config.getDeviceTypeManifestBySlug) ⇒ Promise~~ - * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ Promise - * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ Promise - - - -##### config.getAll() ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get all configuration -**Access**: public -**Fulfil**: Object - configuration -**Example** -```js -balena.models.config.getAll().then(function(config) { - console.log(config); -}); -``` - - -##### ~~config.getDeviceTypes() ⇒ Promise~~ -***use balena.models.deviceType.getAll*** - -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get device types -**Access**: public -**Fulfil**: Object[] - device types -**Example** -```js -balena.models.config.getDeviceTypes().then(function(deviceTypes) { - console.log(deviceTypes); -}); -``` - - -##### ~~config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise~~ -***use balena.models.deviceType.getBySlugOrName*** - -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get a device type manifest by slug -**Access**: public -**Fulfil**: Object - device type manifest - -| Param | Type | Description | -| --- | --- | --- | -| slugOrName | String | device type slug | - -**Example** -```js -balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) { - console.log(manifest); -}); -``` - - -##### config.getDeviceOptions(deviceType) ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get configuration/initialization options for a device type -**Access**: public -**Fulfil**: Object[] - configuration options - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | - -**Example** -```js -balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) { - console.log(options); -}); -``` - - -##### config.getConfigVarSchema(deviceType) ⇒ Promise -**Kind**: static method of [config](#balena.models.config) -**Summary**: Get configuration variables schema for a device type -**Access**: public -**Fulfil**: Object[] - configuration options - -| Param | Type | Description | -| --- | --- | --- | -| deviceType | String | device type slug | - -**Example** -```js -balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) { - console.log(options); -}); -``` - - -#### models.release : object -**Kind**: static namespace of [models](#balena.models) - -* [.release](#balena.models.release) : object - * [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - * [.asset](#balena.models.release.asset) : object - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.asset.getAllByRelease) ⇒ Promise - * [.get(id, [options])](#balena.models.release.asset.get) ⇒ Promise - * [.download(id)](#balena.models.release.asset.download) ⇒ Promise - * [.upload(uploadParams, [options])](#balena.models.release.asset.upload) ⇒ Promise - * [.remove(id)](#balena.models.release.asset.remove) ⇒ Promise - * [.get(commitOrIdOrRawVersion, [options])](#balena.models.release.get) ⇒ Promise - * [.getWithImageDetails(commitOrIdOrRawVersion, [options])](#balena.models.release.getWithImageDetails) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.getAllByApplication) ⇒ Promise - * [.getLatestByApplication(slugOrUuidOrId, [options])](#balena.models.release.getLatestByApplication) ⇒ Promise - * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ Promise - * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ Promise - * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ Promise - * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ Promise - * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ Promise - - - -##### release.tags : object -**Kind**: static namespace of [release](#balena.models.release) - -* [.tags](#balena.models.release.tags) : object - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.release.tags.getAllByApplication) ⇒ Promise - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.tags.getAllByRelease) ⇒ Promise - * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ Promise - * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ Promise - - - -###### tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Get all release tags for an application -**Access**: public -**Fulfil**: Object[] - release tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByApplication(999999).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Get all release tags for a release -**Access**: public -**Fulfil**: Object[] - release tags - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.tags.getAllByRelease(123).then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByRelease('7cf02a6').then(function(tags) { - console.log(tags); -}); -``` -**Example** -```js -balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) { - console.log(tags); -}); -``` - - -###### tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Set a release tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| tagKey | String | tag key | -| value | String \| undefined | tag value | - -**Example** -```js -balena.models.release.tags.set(123, 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.release.tags.set('7cf02a6', 'EDITOR', 'vim'); -``` -**Example** -```js -balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim'); -``` - - -###### tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ Promise -**Kind**: static method of [tags](#balena.models.release.tags) -**Summary**: Remove a release tag -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| tagKey | String | tag key | - -**Example** -```js -balena.models.release.tags.remove(123, 'EDITOR'); -``` -**Example** -```js -balena.models.release.tags.remove('7cf02a6', 'EDITOR'); -``` -**Example** -```js -balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR'); -``` - - -##### release.asset : object -**Kind**: static namespace of [release](#balena.models.release) - -* [.asset](#balena.models.release.asset) : object - * [.getAllByRelease(commitOrIdOrRawVersion, [options])](#balena.models.release.asset.getAllByRelease) ⇒ Promise - * [.get(id, [options])](#balena.models.release.asset.get) ⇒ Promise - * [.download(id)](#balena.models.release.asset.download) ⇒ Promise - * [.upload(uploadParams, [options])](#balena.models.release.asset.upload) ⇒ Promise - * [.remove(id)](#balena.models.release.asset.remove) ⇒ Promise - - - -###### asset.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Get all release assets for a release -**Access**: public -**Fulfil**: Object[] - release assets - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.asset.getAllByRelease(123).then(function(assets) { - console.log(assets); -}); -``` -**Example** -```js -balena.models.release.asset.getAllByRelease('7cf02a6').then(function(assets) { - console.log(assets); -}); -``` -**Example** -```js -balena.models.release.asset.getAllByRelease({ application: 456, raw_version: '1.2.3' }).then(function(assets) { - console.log(assets); -}); -``` - - -###### asset.get(id, [options]) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Get a specific release asset -**Access**: public -**Fulfil**: Object - release asset - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| id | Number \| Object | | release asset ID or object specifying the unique release & asset_key pair | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.asset.get(123).then(function(asset) { - console.log(asset); -}); -``` -**Example** -```js -balena.models.release.asset.get({ - asset_key: 'logo.png', - release: 123 -}).then(function(asset) { - console.log(asset); -}); -``` - - -###### asset.download(id) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Download a release asset -**Access**: public -**Fulfil**: NodeJS.ReadableStream - download stream - -| Param | Type | Description | -| --- | --- | --- | -| id | Number \| Object | release asset ID or object specifying the unique release & asset_key pair | - -**Example** -```js -balena.models.release.asset.download(123).then(function(stream) { - stream.pipe(fs.createWriteStream('logo.png')); -}); -``` -**Example** -```js -balena.models.release.asset.download({ - asset_key: 'logo.png', - release: 123 -}).then(function(stream) { - stream.pipe(fs.createWriteStream('logo.png')); -}); -``` - - -###### asset.upload(uploadParams, [options]) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Upload a release asset -**Access**: public -**Fulfil**: Object - uploaded release asset - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uploadParams | Object | | upload parameters | -| uploadParams.asset | String \| File | | asset file path (string, Node.js only) or File object (Node.js & browser). For File objects, use new File([content], filename, {type: mimeType}) | -| uploadParams.asset_key | String | | unique key for the asset within the release | -| uploadParams.release | Number | | release ID | -| [options] | Object | {} | upload options | -| [options.chunkSize] | Number | 5242880 | chunk size for multipart uploads (5MiB default) | -| [options.parallelUploads] | Number | 5 | number of parallel uploads for multipart | -| [options.overwrite] | Boolean | false | whether to overwrite existing asset | -| [options.onUploadProgress] | function | | callback for upload progress | - -**Example** -```js -// Upload from file path (Node.js) -balena.models.release.asset.upload({ - asset: '/path/to/logo.png', - asset_key: 'logo.png', - release: 123 -}).then(function(asset) { - console.log('Asset uploaded:', asset); -}); -``` -**Example** -```js -// Upload with File API (Node.js and browser) -const content = Buffer.from('Hello, World!', 'utf-8'); -const file = new File([content], 'readme.txt', { type: 'text/plain' }); - -balena.models.release.asset.upload({ - asset: file, - asset_key: 'readme.txt', - release: 123 -}).then(function(asset) { - console.log('Asset uploaded:', asset); -}); -``` -**Example** -```js -// Upload large file with File API and progress tracking -const largeContent = new Uint8Array(10 * 1024 * 1024); // 10MB -const largeFile = new File([largeContent], 'data.bin', { type: 'application/octet-stream' }); - -balena.models.release.asset.upload({ - asset: largeFile, - asset_key: 'data.bin', - release: 123 -}, { - chunkSize: 5 * 1024 * 1024, // 5MB chunks - parallelUploads: 3, - onUploadProgress: function(progress) { - const percent = (progress.uploaded / progress.total * 100).toFixed(2); - console.log(`Upload progress: ${percent}%`); - } -}).then(function(asset) { - console.log('Large file uploaded:', asset); -}); -``` -**Example** -```js -// Browser: Upload file from input element -const fileInput = document.getElementById('fileInput'); -const file = fileInput.files[0]; // File object from input - -balena.models.release.asset.upload({ - asset: file, - asset_key: file.name, - release: 123 -}).then(function(asset) { - console.log('File uploaded from browser:', asset); -}); -``` -**Example** -```js -// Upload with overwrite option -balena.models.release.asset.upload({ - asset: '/path/to/logo.png', - asset_key: 'logo.png', - release: 123 -}, { - overwrite: true -}).then(function(asset) { - console.log('Asset uploaded/updated:', asset); -}); -``` - - -###### asset.remove(id) ⇒ Promise -**Kind**: static method of [asset](#balena.models.release.asset) -**Summary**: Remove a release asset -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| id | Number \| Object | release asset ID or object specifying the unique release & asset_key pair | - -**Example** -```js -balena.models.release.asset.remove(123); -``` -**Example** -```js -balena.models.release.asset.remove({ - asset_key: 'logo.png', - release: 123 -}); -``` - - -##### release.get(commitOrIdOrRawVersion, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get a specific release -**Access**: public -**Fulfil**: Object - release - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.get(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.get('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log(release); -}); -``` - - -##### release.getWithImageDetails(commitOrIdOrRawVersion, [options]) ⇒ Promise -This method does not map exactly to the underlying model: it runs a -larger prebuilt query, and reformats it into an easy to use and -understand format. If you want significantly more control, or to see the -raw model directly, use `release.get(id, options)` instead. - -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get a specific release with the details of the images built -**Access**: public -**Fulfil**: Object - release with image details - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| [options] | Object | {} | a map of extra pine options | -| [options.release] | Boolean | {} | extra pine options for releases | -| [options.image] | Object | {} | extra pine options for images | - -**Example** -```js -balena.models.release.getWithImageDetails(123).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails('7cf02a6').then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log(release); -}); -``` -**Example** -```js -balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } }) -.then(function(release) { - console.log(release.images[0].build_log); -}); -``` - - -##### release.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get all releases from an application -**Access**: public -**Fulfil**: Object[] - releases - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) { - console.log(releases); -}); -``` -**Example** -```js -balena.models.release.getAllByApplication(123).then(function(releases) { - console.log(releases); -}); -``` - - -##### release.getLatestByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Get the latest successful release for an application -**Access**: public -**Fulfil**: Object\|undefined - release - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) { - console.log(releases); -}); -``` -**Example** -```js -balena.models.release.getLatestByApplication(123).then(function(releases) { - console.log(releases); -}); -``` - - -##### release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Create a new release built from the source in the provided url -**Access**: public -**Fulfil**: number - release ID - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| urlDeployOptions | Object | | builder options | -| urlDeployOptions.url | String | | a url with a tarball of the project to build | -| [urlDeployOptions.shouldFlatten] | Boolean | true | Should be true when the tarball includes an extra root folder with all the content | - -**Example** -```js -balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { - console.log(releaseId); -}); -``` -**Example** -```js -balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { - console.log(releaseId); -}); -``` - - -##### release.finalize(commitOrIdOrRawVersion) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Finalizes a draft release -**Access**: public -**Fulfil**: void - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | - -**Example** -```js -balena.models.release.finalize(123).then(function() { - console.log('finalized!'); -}); -``` -**Example** -```js -balena.models.release.finalize('7cf02a6').then(function() { - console.log('finalized!'); -}); -``` -**Example** -```js -balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log('finalized!'); -}); -``` - - -##### release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Set the is_invalidated property of a release to true or false -**Access**: public -**Fulfil**: void - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| isInvalidated | Boolean | boolean value, true for invalidated, false for validated | - -**Example** -```js -balena.models.release.setIsInvalidated(123, true).then(function() { - console.log('invalidated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated('7cf02a6', true).then(function() { - console.log('invalidated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) { - console.log('invalidated!); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated(123, false).then(function() { - console.log('validated!'); -}); -``` -**Example** -```js -balena.models.release.setIsInvalidated('7cf02a6', false).then(function() { - console.log('validated!'); -}); -``` - - -##### release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Add a note to a release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| noteOrNull | String \| Null | the note | - -**Example** -```js -balena.models.release.setNote('7cf02a6', 'My useful note'); -``` -**Example** -```js -balena.models.release.setNote(123, 'My useful note'); -``` -**Example** -```js -balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note'); -``` - - -##### release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ Promise -**Kind**: static method of [release](#balena.models.release) -**Summary**: Add a known issue list to a release -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| commitOrIdOrRawVersion | String \| Number \| Object | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release | -| knownIssueListOrNull | String \| Null | the known issue list | - -**Example** -```js -balena.models.release.setKnownIssueList('7cf02a6', 'This is an issue'); -``` -**Example** -```js -balena.models.release.setKnownIssueList(123, 'This is an issue'); -``` -**Example** -```js -balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue'); -``` - - -#### models.service : object -**Kind**: static namespace of [models](#balena.models) - -* [.service](#balena.models.service) : object - * [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.getAllByApplication) ⇒ Promise - - - -##### service.var : object -**Kind**: static namespace of [service](#balena.models.service) - -* [.var](#balena.models.service.var) : object - * [.getAllByService(serviceIdOrNaturalKey, [options])](#balena.models.service.var.getAllByService) ⇒ Promise - * [.getAllByApplication(slugOrUuidOrId, [options])](#balena.models.service.var.getAllByApplication) ⇒ Promise - * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ Promise - * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ Promise - * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ Promise - - - -###### var.getAllByService(serviceIdOrNaturalKey, [options]) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get all variables for a service -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | | service id (number) or appliation-service_name pair | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.var.getAllByService(999999).then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) { - console.log(vars); -}); -``` - - -###### var.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get all service variables by application -**Access**: public -**Fulfil**: Object[] - service variables - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) { - console.log(vars); -}); -``` -**Example** -```js -balena.models.service.var.getAllByApplication(999999).then(function(vars) { - console.log(vars); -}); -``` - - -###### var.get(serviceIdOrNaturalKey, key) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Get the value of a specific service variable -**Access**: public -**Fulfil**: String\|undefined - the variable value (or undefined) - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | - -**Example** -```js -balena.models.service.var.get(999999, 'VAR').then(function(value) { - console.log(value); -}); -``` -**Example** -```js -balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) { - console.log(value); -}); -``` - - -###### var.set(serviceIdOrNaturalKey, key, value) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Set the value of a specific service variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | -| value | String | variable value | - -**Example** -```js -balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() { - ... -}); -``` -**Example** -```js -balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() { - ... -}); -``` - - -###### var.remove(serviceIdOrNaturalKey, key) ⇒ Promise -**Kind**: static method of [var](#balena.models.service.var) -**Summary**: Clear the value of a specific service variable -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| serviceIdOrNaturalKey | Number \| Object | service id (number) or appliation-service_name pair | -| key | String | variable name | - -**Example** -```js -balena.models.service.var.remove(999999, 'VAR').then(function() { - ... -}); -``` -**Example** -```js -balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() { - ... -}); -``` - - -##### service.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise -**Kind**: static method of [service](#balena.models.service) -**Summary**: Get all services from an application -**Access**: public -**Fulfil**: Object[] - services - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| slugOrUuidOrId | String \| Number | | application slug (string), uuid (string) or id (number) | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) { - console.log(services); -}); -``` -**Example** -```js -balena.models.service.getAllByApplication(123).then(function(services) { - console.log(services); -}); -``` - - -#### models.image : object -**Kind**: static namespace of [models](#balena.models) - -* [.image](#balena.models.image) : object - * [.get(id, [options])](#balena.models.image.get) ⇒ Promise - * [.getLogs(id)](#balena.models.image.getLogs) ⇒ Promise - - - -##### image.get(id, [options]) ⇒ Promise -**Kind**: static method of [image](#balena.models.image) -**Summary**: Get a specific image -**Access**: public -**Fulfil**: Object - image - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| id | Number | | image id | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.image.get(123).then(function(image) { - console.log(image); -}); -``` - - -##### image.getLogs(id) ⇒ Promise -**Kind**: static method of [image](#balena.models.image) -**Summary**: Get the logs for an image -**Access**: public -**Fulfil**: string \| null - logs - -| Param | Type | Description | -| --- | --- | --- | -| id | Number | image id | - -**Example** -```js -balena.models.image.getLogs(123).then(function(logs) { - console.log(logs); -}); -``` - - -#### models.creditBundle : object -**Kind**: static namespace of [models](#balena.models) - -* [.creditBundle](#balena.models.creditBundle) : object - * [.getAllByOrg(organization, [options])](#balena.models.creditBundle.getAllByOrg) ⇒ Promise - * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ Promise - - - -##### creditBundle.getAllByOrg(organization, [options]) ⇒ Promise -**Kind**: static method of [creditBundle](#balena.models.creditBundle) -**Summary**: Get all of the credit bundles purchased by the given org -**Access**: public -**Fulfil**: Object[] - credit bundles - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| organization | String \| Number | | handle (string) or id (number) of the target organization. | -| [options] | Object | {} | extra pine options to use | - -**Example** -```js -balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) { - console.log(creditBundles); -}); -``` - - -##### creditBundle.create(organization, featureId, creditsToPurchase) ⇒ Promise -**Kind**: static method of [creditBundle](#balena.models.creditBundle) -**Summary**: Purchase a credit bundle for the given feature and org of the given quantity -**Access**: public -**Fulfil**: Object[] - credit bundles - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| featureId | Number | id (number) of the feature for which credits are being purchased. | -| creditsToPurchase | Number | number of credits being purchased. | - -**Example** -```js -balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) { - console.log(creditBundle); -}); -``` - - -#### models.billing : object -**Note!** The billing methods are available on Balena.io exclusively. - -**Kind**: static namespace of [models](#balena.models) - -* [.billing](#balena.models.billing) : object - * [.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) - * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ Promise - * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ Promise - * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ Promise - - - -##### billing.getAccount(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the user's billing account -**Access**: public -**Fulfil**: Object - billing account - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getAccount(orgId).then(function(billingAccount) { - console.log(billingAccount); -}); -``` - - -##### billing.getPlan(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the current billing plan -**Access**: public -**Fulfil**: Object - billing plan - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getPlan(orgId).then(function(billingPlan) { - console.log(billingPlan); -}); -``` - - -##### billing.getBillingInfo(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the current billing information -**Access**: public -**Fulfil**: Object - billing information - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -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 -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Update the current billing information -**Access**: public -**Fulfil**: Object - billing information - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| 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 -balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) { - console.log(billingInfo); -}); -``` - - -##### billing.removeBillingInfo(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Remove an organization's billing information -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.removeBillingInfo(orgId).then(function() { - console.log("Success"); -}); -``` - - -##### billing.updateAccountInfo(organization, accountInfo) -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Update the current billing account information -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| accountInfo | AccountInfo | an object containing billing account info | - -**Example** -```js -balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) -``` -**Example** -```js -balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) -``` - - -##### billing.changePlan(organization, planChangeOptions) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Change the current billing plan -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| planChangeOptions | Object | an object containing the billing plan change options | -| billingInfo.tier | String | the code of the target billing plan | -| billingInfo.cycle | String | the billing cycle | -| [billingInfo.planChangeReason] | String | the reason for changing the current plan | - -**Example** -```js -balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() { - console.log('Plan changed!'); -}); -``` - - -##### billing.getInvoices(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Get the available invoices -**Access**: public -**Fulfil**: Object - invoices - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | - -**Example** -```js -balena.models.billing.getInvoices(orgId).then(function(invoices) { - console.log(invoices); -}); -``` - - -##### billing.downloadInvoice(organization) ⇒ Promise -**Kind**: static method of [billing](#balena.models.billing) -**Summary**: Download a specific invoice -**Access**: public -**Fulfil**: Blob\|ReadableStream - blob on the browser, download stream on node - -| Param | Type | Description | -| --- | --- | --- | -| organization | String \| Number | handle (string) or id (number) of the target organization. | -| | String | an invoice number | - -**Example** -```js -# Browser -balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) { - console.log(blob); -}); -# Node -balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) { - stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf')); -}); -``` - - -### balena.auth : object -**Kind**: static namespace of [balena](#balena) - -* [.auth](#balena.auth) : object - * [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - * [.whoami()](#balena.auth.whoami) ⇒ Promise - * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ Promise - * [.login(credentials)](#balena.auth.login) ⇒ Promise - * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ Promise - * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ Promise - * [.getToken()](#balena.auth.getToken) ⇒ Promise - * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ Promise - * [.getActorId()](#balena.auth.getActorId) ⇒ Promise - * [.logout()](#balena.auth.logout) ⇒ Promise - * [.register(credentials)](#balena.auth.register) ⇒ Promise - * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ Promise - * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ Promise - - - -#### auth.twoFactor : object -**Kind**: static namespace of [auth](#balena.auth) - -* [.twoFactor](#balena.auth.twoFactor) : object - * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ Promise - * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ Promise - * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ Promise - * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ Promise - * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ Promise - * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ Promise - * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ Promise - - - -##### twoFactor.isEnabled() ⇒ Promise -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Check if two factor authentication is enabled -**Access**: public -**Fulfil**: Boolean - whether 2fa is enabled -**Example** -```js -balena.auth.twoFactor.isEnabled().then(function(isEnabled) { - if (isEnabled) { - console.log('2FA is enabled for this account'); - } -}); -``` - - -##### twoFactor.isPassed() ⇒ Promise -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Check if two factor authentication challenge was passed -**Access**: public -**Fulfil**: Boolean - whether 2fa challenge was passed -**Example** -```js -balena.auth.twoFactor.isPassed().then(function(isPassed) { - if (isPassed) { - console.log('2FA challenge passed'); - } -}); -``` - - -##### twoFactor.verify(code) ⇒ Promise -Verifies two factor authentication. -Note that this method not update the token automatically. -You should use [challenge](#balena.auth.twoFactor.challenge) when possible, -as it takes care of that as well. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Verify two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -const token = balena.auth.twoFactor.verify('1234'); -balena.auth.loginWithToken(token); -``` - - -##### twoFactor.getSetupKey() ⇒ Promise -Retrieves a setup key for enabling two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Get two factor authentication setup key -**Access**: public -**Fulfil**: String - setup key -**Example** -```js -const setupKey = balena.auth.twoFactor.getSetupKey(); -console.log(setupKey); -``` - - -##### twoFactor.enable(code) ⇒ Promise -Enables two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Enable two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -const token = balena.auth.twoFactor.enable('1234'); -balena.auth.loginWithToken(token); -``` - - -##### twoFactor.challenge(code) ⇒ Promise -You should use [login](#balena.auth.login) when possible, -as it takes care of saving the token and email as well. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Challenge two factor authentication and complete login -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| code | String | code | - -**Example** -```js -balena.auth.twoFactor.challenge('1234'); -``` - - -##### twoFactor.disable(password) ⇒ Promise -Disables two factor authentication. - -**Kind**: static method of [twoFactor](#balena.auth.twoFactor) -**Summary**: Disable two factor authentication -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| password | String | password | - -**Example** -```js -const token = balena.auth.twoFactor.disable('1234'); -balena.auth.loginWithToken(token); -``` - - -#### auth.whoami() ⇒ Promise -This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Return current logged in information -**Access**: public -**Fulfil**: (Object\|undefined) - actor information, if it exists -**Example** -```js -balena.auth.whoami().then(function(result) { - if (!result) { - console.log('I\'m not logged in!'); - } else { - console.log('My result is:', result); - } -}); -``` - - -#### auth.authenticate(credentials) ⇒ Promise -You should use [login](#balena.auth.login) when possible, -as it takes care of saving the token and email as well. - -Notice that if `credentials` contains extra keys, they'll be discarted -by the server automatically. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Authenticate with the server -**Access**: protected -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of email, password | -| credentials.email | String | the email | -| credentials.password | String | the password | - -**Example** -```js -balena.auth.authenticate(credentials).then(function(token) { - console.log('My token is:', token); -}); -``` - - -#### auth.login(credentials) ⇒ Promise -If the login is successful, the token is persisted between sessions. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Login -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of email, password | -| credentials.email | String | the email | -| credentials.password | String | the password | - -**Example** -```js -balena.auth.login(credentials); -``` - - -#### auth.loginWithToken(authToken) ⇒ Promise -Login to balena with a session token or api key instead of with credentials. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Login with a token or api key -**Access**: public - -| Param | Type | Description | -| --- | --- | --- | -| authToken | String | the auth token | - -**Example** -```js -balena.auth.loginWithToken(authToken); -``` - - -#### auth.isLoggedIn() ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Check if you're logged in -**Access**: public -**Fulfil**: Boolean - is logged in -**Example** -```js -balena.auth.isLoggedIn().then(function(isLoggedIn) { - if (isLoggedIn) { - console.log('I\'m in!'); - } else { - console.log('Too bad!'); - } -}); -``` - - -#### auth.getToken() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in user's raw API key or session token -**Access**: public -**Fulfil**: String - raw API key or session token -**Example** -```js -balena.auth.getToken().then(function(token) { - console.log(token); -}); -``` - - -#### auth.getUserInfo() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in user's info -**Access**: public -**Fulfil**: Object - user info -**Example** -```js -balena.auth.getUserInfo().then(function(userInfo) { - console.log(userInfo); -}); -``` - - -#### auth.getActorId() ⇒ Promise -This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Get current logged in actor id -**Access**: public -**Fulfil**: Number - actor id -**Example** -```js -balena.auth.getActorId().then(function(actorId) { - console.log(actorId); -}); -``` - - -#### auth.logout() ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Logout -**Access**: public -**Example** -```js -balena.auth.logout(); -``` - - -#### auth.register(credentials) ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Register a user account -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| credentials | Object | in the form of username, password and email | -| credentials.email | String | the email | -| credentials.password | String | the password | -| [credentials.'g-recaptcha-response'] | String \| undefined | the captcha response | - -**Example** -```js -balena.auth.register({ - email: 'johndoe@gmail.com', - password: 'secret' -}).then(function(token) { - console.log(token); -}); -``` - - -#### auth.verifyEmail(verificationPayload) ⇒ Promise -**Kind**: static method of [auth](#balena.auth) -**Summary**: Verifies an email -**Access**: public -**Fulfil**: String - session token - -| Param | Type | Description | -| --- | --- | --- | -| verificationPayload | Object | in the form of email, and token | -| verificationPayload.email | String | the email | -| verificationPayload.token | String | the verification token | - -**Example** -```js -balena.auth.verifyEmail({ - email: 'johndoe@gmail.com', - token: '5bb11d90eefb34a70318f06a43ef063f' -}).then(function(jwt) { - console.log(jwt); -}); -``` - - -#### auth.requestVerificationEmail() ⇒ Promise -This will only work if you used [login](#balena.auth.login) to log in. - -**Kind**: static method of [auth](#balena.auth) -**Summary**: Re-send verification email to the user -**Access**: public -**Example** -```js -balena.auth.requestVerificationEmail().then(function() { - console.log('Requesting verification email operation complete!'); -}) -``` - - -### balena.logs : object -**Kind**: static namespace of [balena](#balena) - -* [.logs](#balena.logs) : object - * [.subscribe(uuidOrId, [options])](#balena.logs.subscribe) ⇒ Promise.<LogSubscription> - * [.history(uuidOrId, [options])](#balena.logs.history) ⇒ Promise - * [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - - - -#### logs.subscribe(uuidOrId, [options]) ⇒ Promise.<LogSubscription> -Connects to the stream of devices logs, returning a LogSubscription, which -can be used to listen for logs as they appear, line by line. - -**Kind**: static method of [logs](#balena.logs) -**Summary**: Subscribe to device logs -**Access**: public -**Fulfil**: [LogSubscription](#balena.logs.LogSubscription) - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.count] | Number \| 'all' | 0 | number of historical messages to include (or 'all') | -| [options.start] | Number \| String | | the timestamp or ISO Date string after which to retrieve historical messages. When specified, the count parameter needs to also be provided. | - -**Example** -```js -balena.logs.subscribe('7cf02a6').then(function(logs) { - logs.on('line', function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -balena.logs.subscribe(123).then(function(logs) { - logs.on('line', function(line) { - console.log(line); - }); -}); -``` - - -#### logs.history(uuidOrId, [options]) ⇒ Promise -Get an array of the latest log messages for a given device. - -**Kind**: static method of [logs](#balena.logs) -**Summary**: Get device logs history -**Access**: public -**Fulfil**: Object[] - history lines - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| uuidOrId | String \| Number | | device uuid (string) or id (number) | -| [options] | Object | | options | -| [options.count] | Number \| 'all' | 1000 | number of log messages to return (or 'all') | -| [options.start] | Number \| String | | the timestamp or ISO Date string after which to retrieve historical messages | - -**Example** -```js -balena.logs.history('7cf02a6').then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -balena.logs.history(123).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -const oneDayAgoTimestamp = Date.now() - 24*60*60*1000; -balena.logs.history('7cf02a6', { start: oneDayAgoTimestamp }).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` -**Example** -```js -const oneDayAgoIsoDateString = new Date(Date.now() - 24*60*60*1000).toISOString(); -balena.logs.history('7cf02a6', { start: oneDayAgoIsoDateString }).then(function(lines) { - lines.forEach(function(line) { - console.log(line); - }); -}); -``` - - -#### logs.LogSubscription : EventEmitter -The log subscription emits events as log data arrives. -You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)` - -**Kind**: static typedef of [logs](#balena.logs) - -* [.LogSubscription](#balena.logs.LogSubscription) : EventEmitter - * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe) - * ["line"](#balena.logs.LogSubscription.event_line) - * ["error"](#balena.logs.LogSubscription.event_error) - - - -##### LogSubscription.unsubscribe() -Disconnect from the logs feed and stop receiving any future events on this emitter. - -**Kind**: static method of [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Unsubscribe from device logs -**Access**: public -**Example** -```js -logs.unsubscribe(); -``` - - -##### "line" -**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Event fired when a new line of log output is available -**Example** -```js -logs.on('line', function(line) { - console.log(line); -}); -``` - - -##### "error" -**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) -**Summary**: Event fired when an error has occured reading the device logs -**Example** -```js -logs.on('error', function(error) { - console.error(error); -}); -``` - - -### balena.settings : object -**Kind**: static namespace of [balena](#balena) - -* [.settings](#balena.settings) : object - * [.get([key])](#balena.settings.get) ⇒ Promise - * [.getAll()](#balena.settings.getAll) ⇒ Promise - - - -#### settings.get([key]) ⇒ Promise -**Kind**: static method of [settings](#balena.settings) -**Summary**: Get a single setting. **Only implemented in Node.js** -**Access**: public -**Fulfil**: \* - setting value - -| Param | Type | Description | -| --- | --- | --- | -| [key] | String | setting key | - -**Example** -```js -balena.settings.get('apiUrl').then(function(apiUrl) { - console.log(apiUrl); -}); -``` - - -#### settings.getAll() ⇒ Promise -**Kind**: static method of [settings](#balena.settings) -**Summary**: Get all settings **Only implemented in Node.js** -**Access**: public -**Fulfil**: Object - settings -**Example** -```js -balena.settings.getAll().then(function(settings) { - console.log(settings); -}); -``` - - -### balena.utils : object -**Kind**: static namespace of [balena](#balena) - - -## listImagesFromTargetState(targetState) ⇒ -**Kind**: global function -**Returns**: array containing all images for all services for all releases for all apps for the device - -| Param | -| --- | -| targetState | - diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/README.md b/pages/external-docs/sdk/node-sdk/v22.4.9/README.md new file mode 100644 index 0000000000..30996e3dea --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/README.md @@ -0,0 +1 @@ +# v22.4.9 \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/auth.md b/pages/external-docs/sdk/node-sdk/v22.4.9/auth.md new file mode 100644 index 0000000000..0011e51751 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/auth.md @@ -0,0 +1,497 @@ +# auth +balena.auth : object + +**Kind**: static namespace + +* * * + +## authenticate +balena.auth.authenticate(credentials) ⇒ Promise + +You should use [login](#balena.auth.login) when possible, +as it takes care of saving the token and email as well. + +Notice that if `credentials` contains extra keys, they'll be discarted +by the server automatically. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Authenticate with the server +**Access**: protected +**Fulfil**: String - session token + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of email, password

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
+ +**Example** +```js +balena.auth.authenticate(credentials).then(function(token) { + console.log('My token is:', token); +}); +``` + +* * * + +## getActorId +balena.auth.getActorId() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in actor id +**Access**: public +**Fulfil**: Number - actor id +**Example** +```js +balena.auth.getActorId().then(function(actorId) { + console.log(actorId); +}); +``` + +* * * + +## getToken +balena.auth.getToken() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in user's raw API key or session token +**Access**: public +**Fulfil**: String - raw API key or session token +**Example** +```js +balena.auth.getToken().then(function(token) { + console.log(token); +}); +``` + +* * * + +## getUserInfo +balena.auth.getUserInfo() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Get current logged in user's info +**Access**: public +**Fulfil**: Object - user info +**Example** +```js +balena.auth.getUserInfo().then(function(userInfo) { + console.log(userInfo); +}); +``` + +* * * + +## isLoggedIn +balena.auth.isLoggedIn() ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Check if you're logged in +**Access**: public +**Fulfil**: Boolean - is logged in +**Example** +```js +balena.auth.isLoggedIn().then(function(isLoggedIn) { + if (isLoggedIn) { + console.log('I\'m in!'); + } else { + console.log('Too bad!'); + } +}); +``` + +* * * + +## login +balena.auth.login(credentials) ⇒ Promise + +If the login is successful, the token is persisted between sessions. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Login +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of email, password

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
+ +**Example** +```js +balena.auth.login(credentials); +``` + +* * * + +## loginWithToken +balena.auth.loginWithToken(authToken) ⇒ Promise + +Login to balena with a session token or api key instead of with credentials. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Login with a token or api key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
authTokenString

the auth token

+
+ +**Example** +```js +balena.auth.loginWithToken(authToken); +``` + +* * * + +## logout +balena.auth.logout() ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Logout +**Access**: public +**Example** +```js +balena.auth.logout(); +``` + +* * * + +## register +balena.auth.register(credentials) ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Register a user account +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + + + + + + + +
ParamTypeDescription
credentialsObject

in the form of username, password and email

+
credentials.emailString

the email

+
credentials.passwordString

the password

+
[credentials.'g-recaptcha-response']String | undefined

the captcha response

+
+ +**Example** +```js +balena.auth.register({ + email: 'johndoe@gmail.com', + password: 'secret' +}).then(function(token) { + console.log(token); +}); +``` + +* * * + +## requestVerificationEmail +balena.auth.requestVerificationEmail() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Re-send verification email to the user +**Access**: public +**Example** +```js +balena.auth.requestVerificationEmail().then(function() { + console.log('Requesting verification email operation complete!'); +}) +``` + +* * * + +## verifyEmail +balena.auth.verifyEmail(verificationPayload) ⇒ Promise + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Verifies an email +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + + + + + +
ParamTypeDescription
verificationPayloadObject

in the form of email, and token

+
verificationPayload.emailString

the email

+
verificationPayload.tokenString

the verification token

+
+ +**Example** +```js +balena.auth.verifyEmail({ + email: 'johndoe@gmail.com', + token: '5bb11d90eefb34a70318f06a43ef063f' +}).then(function(jwt) { + console.log(jwt); +}); +``` + +* * * + +## whoami +balena.auth.whoami() ⇒ Promise + +This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in. + +**Kind**: static method of [auth](#balena.auth) +**Summary**: Return current logged in information +**Access**: public +**Fulfil**: (Object\|undefined) - actor information, if it exists +**Example** +```js +balena.auth.whoami().then(function(result) { + if (!result) { + console.log('I\'m not logged in!'); + } else { + console.log('My result is:', result); + } +}); +``` + +* * * + +## twoFactor +balena.auth.twoFactor : object + +**Kind**: static namespace of [auth](#balena.auth) + +* * * + +### challenge +balena.auth.twoFactor.challenge(code) ⇒ Promise + +You should use [login](#balena.auth.login) when possible, +as it takes care of saving the token and email as well. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Challenge two factor authentication and complete login +**Access**: public + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +balena.auth.twoFactor.challenge('1234'); +``` + +* * * + +### disable +balena.auth.twoFactor.disable(password) ⇒ Promise + +Disables two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Disable two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
passwordString

password

+
+ +**Example** +```js +const token = balena.auth.twoFactor.disable('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + +### enable +balena.auth.twoFactor.enable(code) ⇒ Promise + +Enables two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Enable two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +const token = balena.auth.twoFactor.enable('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + +### getSetupKey +balena.auth.twoFactor.getSetupKey() ⇒ Promise + +Retrieves a setup key for enabling two factor authentication. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Get two factor authentication setup key +**Access**: public +**Fulfil**: String - setup key +**Example** +```js +const setupKey = balena.auth.twoFactor.getSetupKey(); +console.log(setupKey); +``` + +* * * + +### isEnabled +balena.auth.twoFactor.isEnabled() ⇒ Promise + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Check if two factor authentication is enabled +**Access**: public +**Fulfil**: Boolean - whether 2fa is enabled +**Example** +```js +balena.auth.twoFactor.isEnabled().then(function(isEnabled) { + if (isEnabled) { + console.log('2FA is enabled for this account'); + } +}); +``` + +* * * + +### isPassed +balena.auth.twoFactor.isPassed() ⇒ Promise + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Check if two factor authentication challenge was passed +**Access**: public +**Fulfil**: Boolean - whether 2fa challenge was passed +**Example** +```js +balena.auth.twoFactor.isPassed().then(function(isPassed) { + if (isPassed) { + console.log('2FA challenge passed'); + } +}); +``` + +* * * + +### verify +balena.auth.twoFactor.verify(code) ⇒ Promise + +Verifies two factor authentication. +Note that this method not update the token automatically. +You should use [challenge](#balena.auth.twoFactor.challenge) when possible, +as it takes care of that as well. + +**Kind**: static method of [twoFactor](#balena.auth.twoFactor) +**Summary**: Verify two factor authentication +**Access**: public +**Fulfil**: String - session token + + + + + + + + + + +
ParamTypeDescription
codeString

code

+
+ +**Example** +```js +const token = balena.auth.twoFactor.verify('1234'); +balena.auth.loginWithToken(token); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/errors.md b/pages/external-docs/sdk/node-sdk/v22.4.9/errors.md new file mode 100644 index 0000000000..132e5c1184 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/errors.md @@ -0,0 +1,24 @@ +# errors +balena.errors : Object + +The balena-errors module used internally. This is provided primarily for +convenience, and to avoid the necessity for separate balena-errors +dependencies. You'll want to use this if you need to match on the specific +type of error thrown by the SDK. + +**Kind**: static member +**Summary**: Balena errors module +**Access**: public +**Example** +```js +balena.models.device.get(123).catch(function (error) { + if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) { + ... + } else if (error.code === balena.errors.BalenaRequestError.prototype.code) { + ... + } +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/fromSharedOptions.md b/pages/external-docs/sdk/node-sdk/v22.4.9/fromSharedOptions.md new file mode 100644 index 0000000000..73f0097d6d --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/fromSharedOptions.md @@ -0,0 +1,18 @@ +# fromSharedOptions +module:balena-sdk~fromSharedOptions() + +Create an SDK instance using shared default options set using the `setSharedOptions()` method. +If options have not been set using this method, then this method will use the +same defaults as the main SDK factory function. + +**Kind**: inner function +**Summary**: Create an SDK instance using shared default options +**Access**: public +**Example** +```js +import { fromSharedOptions } from 'balena-sdk'; +const sdk = fromSharedOptions(); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/getSdk.md b/pages/external-docs/sdk/node-sdk/v22.4.9/getSdk.md new file mode 100644 index 0000000000..dff2249899 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/getSdk.md @@ -0,0 +1,22 @@ +# getSdk +module:balena-sdk~getSdk() + +The module exports a single factory function. + +**Kind**: inner function +**Summary**: Creates a new SDK instance using the default or the provided options. +**Example** +```js +// with es6 imports +import { getSdk } from 'balena-sdk'; +// or with node require +const { getSdk } = require('balena-sdk'); + +const balena = getSdk({ + apiUrl: "https://api.balena-cloud.com/", + dataDirectory: "/opt/local/balena" +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/interceptors.md b/pages/external-docs/sdk/node-sdk/v22.4.9/interceptors.md new file mode 100644 index 0000000000..0da46482a3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/interceptors.md @@ -0,0 +1,68 @@ +# interceptors +balena.interceptors : Array.<Interceptor> + +The current array of interceptors to use. Interceptors intercept requests made +internally and are executed in the order they appear in this array for requests, +and in the reverse order for responses. + +**Kind**: static member +**Summary**: Array of interceptors +**Access**: public +**Example** +```js +balena.interceptors.push({ + responseError: function (error) { + console.log(error); + throw error; + }) +}); +``` + +* * * + +## Interceptor +balena.interceptors.Interceptor : object + +An interceptor implements some set of the four interception hook callbacks. +To continue processing, each function should return a value or a promise that +successfully resolves to a value. + +To halt processing, each function should throw an error or return a promise that +rejects with an error. + +**Kind**: static typedef of [interceptors](#balena.interceptors) +**Properties** + + + + + + + + + + + + + + + + + +
NameTypeDescription
[request]function

Callback invoked before requests are made. Called with +the request options, should return (or resolve to) new request options, or throw/reject.

+
[response]function

Callback invoked before responses are returned. Called with +the response, should return (or resolve to) a new response, or throw/reject.

+
[requestError]function

Callback invoked if an error happens before a request. +Called with the error itself, caused by a preceeding request interceptor rejecting/throwing +an error for the request, or a failing in preflight token validation. Should return (or resolve +to) new request options, or throw/reject.

+
[responseError]function

Callback invoked if an error happens in the response. +Called with the error itself, caused by a preceeding response interceptor rejecting/throwing +an error for the request, a network error, or an error response from the server. Should return +(or resolve to) a new response, or throw/reject.

+
+ + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/introduction.md b/pages/external-docs/sdk/node-sdk/v22.4.9/introduction.md new file mode 100644 index 0000000000..1220aa46ef --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/introduction.md @@ -0,0 +1,59 @@ +# Introduction + +Welcome to the balena Node SDK documentation. These pages aim to describe all the functions supported by the SDK, as well as showing examples of their expected usage. + +## Installation + +Install the balena SDK by running: + +```sh +$ npm install --save balena-sdk +``` + +### Bundling for browsers + +If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle. + +If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle: + +* fs +* path +* balena-settings-client +* node-localstorage +* fs/promises +* mime + +### Bundling with pkg + +The balena SDK includes builds for various ECMAScript versions that are +dynamically selected at runtime (using +[@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). +For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not +able to automatically detect which assets to include in the output package. The +following sample `pkg` section should be added to your application's +`package.json` file to instruct `pkg` to bundle the required assets: + +```json + "pkg": { + "scripts": [ + "node_modules/balena-sdk/**/*.js" + ], + "assets": [ + "node_modules/pinejs-client-core/**/*" + ] + } +``` + +For more information, please refer to the respective +[documentation from the `pkg` project](https://github.com/vercel/pkg#config). + +## Trying balenaSDK in the browser + +BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. +To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries. + +![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png) + + +If you feel something is missing, not clear or could be improved, please don't hesitate to open an +[issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help. \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/logs.md b/pages/external-docs/sdk/node-sdk/v22.4.9/logs.md new file mode 100644 index 0000000000..47357db4ba --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/logs.md @@ -0,0 +1,179 @@ +# logs +balena.logs : object + +**Kind**: static namespace + +* * * + +## history +balena.logs.history(uuidOrId, [options]) ⇒ Promise + +Get an array of the latest log messages for a given device. + +**Kind**: static method of [logs](#balena.logs) +**Summary**: Get device logs history +**Access**: public +**Fulfil**: Object[] - history lines + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.count]Number | 'all'1000

number of log messages to return (or 'all')

+
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages

+
+ +**Example** +```js +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd').then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +balena.logs.history(123).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +const oneDayAgoTimestamp = Date.now() - 24*60*60*1000; +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoTimestamp }).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +const oneDayAgoIsoDateString = new Date(Date.now() - 24*60*60*1000).toISOString(); +balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoIsoDateString }).then(function(lines) { + lines.forEach(function(line) { + console.log(line); + }); +}); +``` + +* * * + +## subscribe +balena.logs.subscribe(uuidOrId, [options]) ⇒ Promise.<LogSubscription> + +Connects to the stream of devices logs, returning a LogSubscription, which +can be used to listen for logs as they appear, line by line. + +**Kind**: static method of [logs](#balena.logs) +**Summary**: Subscribe to device logs +**Access**: public +**Fulfil**: [LogSubscription](#balena.logs.LogSubscription) + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.count]Number | 'all'0

number of historical messages to include (or 'all')

+
[options.start]Number | String

the timestamp or ISO Date string after which to retrieve historical messages. When specified, the count parameter needs to also be provided.

+
+ +**Example** +```js +balena.logs.subscribe('7cf02a69e4d34c9da573914963cf54fd').then(function(logs) { + logs.on('line', function(line) { + console.log(line); + }); +}); +``` +**Example** +```js +balena.logs.subscribe(123).then(function(logs) { + logs.on('line', function(line) { + console.log(line); + }); +}); +``` + +* * * + +## LogSubscription +balena.logs.LogSubscription : EventEmitter + +The log subscription emits events as log data arrives. +You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)` + +**Kind**: static typedef of [logs](#balena.logs) + +* * * + +### unsubscribe +balena.logs.LogSubscription.unsubscribe() + +Disconnect from the logs feed and stop receiving any future events on this emitter. + +**Kind**: static method of [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Unsubscribe from device logs +**Access**: public +**Example** +```js +logs.unsubscribe(); +``` + +* * * + +### error +balena.logs.LogSubscription.event:error + +**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Event fired when an error has occured reading the device logs +**Example** +```js +logs.on('error', function(error) { + console.error(error); +}); +``` + +* * * + +### line +balena.logs.LogSubscription.event:line + +**Kind**: event emitted by [LogSubscription](#balena.logs.LogSubscription) +**Summary**: Event fired when a new line of log output is available +**Example** +```js +logs.on('line', function(line) { + console.log(line); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/README.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/README.md new file mode 100644 index 0000000000..e89b5f2b2b --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/README.md @@ -0,0 +1 @@ +# Models \ No newline at end of file diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/apiKey.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/apiKey.md new file mode 100644 index 0000000000..3e118ba1c1 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/apiKey.md @@ -0,0 +1,242 @@ +# apiKey +balena.models.apiKey : object + +**Kind**: static namespace + +* * * + +## create +balena.models.apiKey.create(createApiKeyParams) ⇒ Promise + +This method registers a new api key for the current user with the name given. + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Creates a new user API key +**Access**: public +**Fulfil**: String - API key + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
createApiKeyParamsObject

an object containing the parameters for the creation of an API key

+
createApiKeyParams.nameString

the API key name

+
createApiKeyParams.expiryDateString

the API key expiry date

+
[createApiKeyParams.description]String

the API key description

+
+ +**Example** +```js +balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12}).then(function(apiKey) { + console.log(apiKey); +}); +``` +**Example** +```js +balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12, description: apiKeyDescription}).then(function(apiKey) { + console.log(apiKey); +}); +``` + +* * * + +## getAll +balena.models.apiKey.getAll([options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all accessible API keys +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getAll().then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getAllNamedUserApiKeys +balena.models.apiKey.getAllNamedUserApiKeys([options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all named user API keys of the current user +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getDeviceApiKeysByDevice +balena.models.apiKey.getDeviceApiKeysByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all API keys for a device +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device, uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## getProvisioningApiKeysByApplication +balena.models.apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Get all provisioning API keys for an application +**Access**: public +**Fulfil**: Object[] - apiKeys + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) { + console.log(apiKeys); +}); +``` + +* * * + +## revoke +balena.models.apiKey.revoke(id) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Revoke an API key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

API key id

+
+ +**Example** +```js +balena.models.apiKey.revoke(123); +``` + +* * * + +## update +balena.models.apiKey.update(id, apiKeyInfo) ⇒ Promise + +**Kind**: static method of [apiKey](#balena.models.apiKey) +**Summary**: Update the details of an API key +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idNumber

API key id

+
apiKeyInfoObject

an object with the updated name|description|expiryDate

+
+ +**Example** +```js +balena.models.apiKey.update(123, { name: 'updatedName' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { description: 'updated description' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { expiryDate: '2022-04-29' }); +``` +**Example** +```js +balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' }); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/application.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/application.md new file mode 100644 index 0000000000..1f405f01f4 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/application.md @@ -0,0 +1,1956 @@ +# application +balena.models.application : object + +**Kind**: static namespace + +* * * + +## create +balena.models.application.create(options) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Create an application +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
optionsObject

application creation parameters

+
options.nameString

application name

+
options.organizationString | Number

handle (string) or id (number) of the organization that the application will belong to or null

+
[options.uuid]String

application uuid

+
[options.applicationClass]String

application class: 'app' | 'fleet' | 'block'

+
options.deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.application.create({ name: 'My App', organization: 'myorganization', deviceType: 'raspberry-pi' }).then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.create({ name: 'My Block', organization: 'myorganization', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) { + console.log(application); +}); +``` + +* * * + +## disableDeviceUrls +balena.models.application.disableDeviceUrls(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Disable device urls for all devices that belong to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.disableDeviceUrls('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.disableDeviceUrls(123); +``` + +* * * + +## enableDeviceUrls +balena.models.application.enableDeviceUrls(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Enable device urls for all devices that belong to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.enableDeviceUrls('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.enableDeviceUrls(123); +``` + +* * * + +## generateProvisioningKey +balena.models.application.generateProvisioningKey(generateProvisioningKeyParams) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Generate a device provisioning key for a specific application +**Access**: public +**Fulfil**: String - device provisioning key + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
generateProvisioningKeyParamsObject

an object containing the parameters for the provisioning key generation

+
generateProvisioningKeyParams.slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
generateProvisioningKeyParams.keyExpiryDateString

Expiry Date for provisioning key

+
[generateProvisioningKeyParams.keyName]String

Provisioning key name

+
[generateProvisioningKeyParams.keyDescription]String

Description for provisioning key

+
+ +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 'myorganization/myapp', keyExpiryDate: '2030-10-12'}).then(function(key) { + console.log(key); +}); +``` +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12'}).then(function(key) { + console.log(key); +}); +``` +**Example** +```js +balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12', keyName: 'api key name', keyDescription: 'api key long description'}).then(function(key) { + console.log(key); +}); +``` + +* * * + +## get +balena.models.application.get(slugOrUuidOrId, [options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.get('myorganization/myapp').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.get(123).then(function(application) { + console.log(application); +}); +``` + +* * * + +## getAll +balena.models.application.getAll([options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.getAll().then(function(applications) { + console.log(applications); +}); +``` + +* * * + +## getAllByOrganization +balena.models.application.getAllByOrganization(orgHandleOrId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications of an organization +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + + + +
ParamTypeDefaultDescription
orgHandleOrIdNumber | String

organization handle (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getAllByOrganization('myorganization').then(function(applications) { + console.log(applications); +}); +``` +**Example** +```js +const applications = await sdk.models.application.getAllByOrganization('myorganization', { + $select: ['app_name', 'slug'], + $expand: { + owns__device: { + $select: ['uuid', 'overall_status', 'is_connected_to_vpn', 'api_heartbeat_state'], + }, + }, + }); +``` + +* * * + +## getAllDirectlyAccessible +balena.models.application.getAllDirectlyAccessible([options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get all applications directly accessible by the user +**Access**: public +**Fulfil**: Object[] - applications + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getAllDirectlyAccessible().then(function(applications) { + console.log(applications); +}); +``` + +* * * + +## getAppByName +balena.models.application.getAppByName(appName, [options], [context]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application using the appname and the handle of the owning organization +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appNameString

application name

+
[options]Object{}

extra pine options to use

+
[context]String

extra access filters, undefined or 'directly_accessible'

+
+ +**Example** +```js +balena.models.application.getAppByName('MyApp').then(function(application) { + console.log(application); +}); +``` + +* * * + +## getDashboardUrl +balena.models.application.getDashboardUrl(id) ⇒ String + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get Dashboard URL for a specific application +**Returns**: String - - Dashboard URL for the specific application +**Throws**: + +- Exception if the id is not a finite number + + + + + + + + + + + +
ParamTypeDescription
idNumber

Application id

+
+ +**Example** +```js +balena.models.application.get('myorganization/myapp').then(function(application) { + const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); + console.log(dashboardApplicationUrl); +}); +``` + +* * * + +## getDirectlyAccessible +balena.models.application.getDirectlyAccessible(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application directly accessible by the user +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) { + console.log(application); +}); +``` +**Example** +```js +balena.models.application.getDirectlyAccessible(123).then(function(application) { + console.log(application); +}); +``` + +* * * + +## getTargetReleaseHash +balena.models.application.getTargetReleaseHash(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get the hash of the current release for a specific application +**Access**: public +**Fulfil**: String\|undefined - The release hash of the current release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.application.getTargetReleaseHash(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) { + console.log(release); +}); +``` + +* * * + +## getWithDeviceServiceDetails +balena.models.application.getWithDeviceServiceDetails(slugOrUuidOrId, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want more control, or to see the raw model +directly, use `application.get(uuidOrId, options)` instead. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get a single application and its devices, along with each device's +associated services' essential details +**Access**: public +**Fulfil**: Object - application + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.application.getWithDeviceServiceDetails(123).then(function(device) { + console.log(device); +}) +``` + +* * * + +## grantSupportAccess +balena.models.application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Grant support access to an application until a specified time +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
expiryTimestampNumber

a timestamp in ms for when the support access will expire

+
+ +**Example** +```js +balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000); +``` +**Example** +```js +balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000); +``` + +* * * + +## has +balena.models.application.has(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Check if an application exists +**Access**: public +**Fulfil**: Boolean - has application + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.has('myorganization/myapp').then(function(hasApp) { + console.log(hasApp); +}); +``` +**Example** +```js +balena.models.application.has(123).then(function(hasApp) { + console.log(hasApp); +}); +``` + +* * * + +## hasAny +balena.models.application.hasAny() ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Check if the user has access to any applications +**Access**: public +**Fulfil**: Boolean - has any applications +**Example** +```js +balena.models.application.hasAny().then(function(hasAny) { + console.log('Has any?', hasAny); +}); +``` + +* * * + +## isTrackingLatestRelease +balena.models.application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates +**Access**: public +**Fulfil**: Boolean - is tracking the latest release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) { + console.log(isEnabled); +}); +``` +**Example** +```js +balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## pinToRelease +balena.models.application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ Promise + +Configures the application to run a particular release +and not get updated when the latest release changes. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Set a specific application to run a particular release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
fullReleaseHashString

the hash of a successful release (string)

+
+ +**Example** +```js +balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` + +* * * + +## purge +balena.models.application.purge(appId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Purge devices by application id +**Access**: public + + + + + + + + + + +
ParamTypeDescription
appIdNumber

application id

+
+ +**Example** +```js +balena.models.application.purge(123); +``` + +* * * + +## reboot +balena.models.application.reboot(appId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Reboot devices by application id +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appIdNumber

application id

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.application.reboot(123); +``` + +* * * + +## remove +balena.models.application.remove(slugOrUuidOrIdOrIds) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Remove application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdOrIdsString | Number | Array.<Number>

application slug (string), uuid (string) or id (number) or array of ids

+
+ +**Example** +```js +balena.models.application.remove('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.remove(123); +``` + +* * * + +## rename +balena.models.application.rename(slugOrUuidOrId, newName) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Rename application +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
newNameString

new application name (string)

+
+ +**Example** +```js +balena.models.application.rename('myorganization/myapp', 'MyRenamedApp'); +``` +**Example** +```js +balena.models.application.rename(123, 'MyRenamedApp'); +``` + +* * * + +## restart +balena.models.application.restart(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Restart application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.restart('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.restart(123); +``` + +* * * + +## revokeSupportAccess +balena.models.application.revokeSupportAccess(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Revoke support access to an application +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.revokeSupportAccess('myorganization/myapp'); +``` +**Example** +```js +balena.models.application.revokeSupportAccess(123); +``` + +* * * + +## shutdown +balena.models.application.shutdown(appId, [options]) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Shutdown devices by application id +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
appIdNumber

application id

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.application.shutdown(123); +``` + +* * * + +## trackLatestRelease +balena.models.application.trackLatestRelease(slugOrUuidOrId) ⇒ Promise + +The application's current release will be updated with each new successfully built release. + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Configure a specific application to track the latest finalized available release +**Access**: public + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.trackLatestRelease('myorganization/myapp').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.trackLatestRelease(123).then(function() { + ... +}); +``` + +* * * + +## willTrackNewReleases +balena.models.application.willTrackNewReleases(slugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [application](#balena.models.application) +**Summary**: Get whether the application is configured to receive updates whenever a new release is available +**Access**: public +**Fulfil**: Boolean - is tracking the latest release + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) { + console.log(isEnabled); +}); +``` +**Example** +```js +balena.models.application.willTrackNewReleases(123).then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## buildVar +balena.models.application.buildVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.buildVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Get the value of a specific build environment variable +**Access**: public +**Fulfil**: String\|undefined - the build environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
+ +**Example** +```js +balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.buildVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.buildVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Get all build environment variables for an application +**Access**: public +**Fulfil**: Object[] - application build environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.buildVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Clear the value of a specific build environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
+ +**Example** +```js +balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.buildVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.buildVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [buildVar](#balena.models.application.buildVar) +**Summary**: Set the value of a specific build environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

build environment variable name

+
valueString

build environment variable value

+
+ +**Example** +```js +balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## configVar +balena.models.application.configVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.configVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Get the value of a specific config variable +**Access**: public +**Fulfil**: String\|undefined - the config variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Get all config variables for an application +**Access**: public +**Fulfil**: Object[] - application config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.configVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.configVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Clear the value of a specific config variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.configVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.application.configVar) +**Summary**: Set the value of a specific config variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

config variable name

+
valueString

config variable value

+
+ +**Example** +```js +balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## envVar +balena.models.application.envVar : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### get +balena.models.application.envVar.get(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Get the value of a specific environment variable +**Access**: public +**Fulfil**: String\|undefined - the environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.application.envVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Get all environment variables for an application +**Access**: public +**Fulfil**: Object[] - application environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.application.envVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.application.envVar.remove(slugOrUuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Clear the value of a specific environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.envVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.application.envVar.set(slugOrUuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.application.envVar) +**Summary**: Set the value of a specific environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
keyString

environment variable name

+
valueString

environment variable value

+
+ +**Example** +```js +balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## invite +balena.models.application.invite : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### accept +balena.models.application.invite.accept(invitationToken) ⇒ Promise + +This method adds the calling user to the application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Accepts an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
invitationTokenString

invite token

+
+ +**Example** +```js +balena.models.application.invite.accept("qwerty-invitation-token"); +``` + +* * * + +### create +balena.models.application.invite.create(slugOrUuidOrId, options, [message]) ⇒ Promise + +This method invites a user by their email to an application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Creates a new invite for an application +**Access**: public +**Fulfil**: String - application invite + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
optionsObject

invite creation parameters

+
options.inviteeString

the email of the invitee

+
[options.roleName]String"developer"

the role name to be granted to the invitee

+
[message]String

the message to send along with the invite

+
+ +**Example** +```js +balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) { + console.log(invite); +}); +``` + +* * * + +### getAll +balena.models.application.invite.getAll([options]) ⇒ Promise + +This method returns all invites. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Get all invites +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.invite.getAll().then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.invite.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all invites for a specific application. + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Get all invites by application +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) { + console.log(invites); +}); +``` +**Example** +```js +balena.models.application.invite.getAllByApplication(123).then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### revoke +balena.models.application.invite.revoke(id) ⇒ Promise + +**Kind**: static method of [invite](#balena.models.application.invite) +**Summary**: Revoke an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

application invite id

+
+ +**Example** +```js +balena.models.application.invite.revoke(123); +``` + +* * * + +## membership +balena.models.application.membership : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### changeRole +balena.models.application.membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise + +This method changes the role of an application member. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Changes the role of an application member +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be changed

+
roleNameString

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.application.membership.changeRole(123, "member").then(function() { + console.log('OK'); +}); +``` +**Example** +```js +balena.models.application.membership.changeRole({ + user: 123, + is_member_of__application: 125, +}, "member").then(function() { + console.log('OK'); +}); +``` + +* * * + +### create +balena.models.application.membership.create(options) ⇒ Promise + +This method adds a user to an application by their username if they are a member of the organization. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Creates a new membership for an application +**Access**: public +**Fulfil**: Object - application membership + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

membership creation parameters

+
options.applicationString | Number

application handle (string), or id (number)

+
options.usernameString

the username of the balena user that will become a member

+
[options.roleName]String"member"

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) { + console.log(membership); +}); +``` + +* * * + +### get +balena.models.application.membership.get(membershipId, [options]) ⇒ Promise + +This method returns a single application membership. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get a single application membership +**Access**: public +**Fulfil**: Object - application membership + + + + + + + + + + + + +
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.get(5).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByApplication +balena.models.application.membership.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all application memberships for a specific application. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get all memberships by application +**Access**: public +**Fulfil**: Object[] - application memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.application.membership.getAllByApplication(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByUser +balena.models.application.membership.getAllByUser(usernameOrId, [options]) ⇒ Promise + +This method returns all application memberships for a specific user. + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Get all memberships by user +**Access**: public +**Fulfil**: Object[] - application memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.application.membership.getAllByUser(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### remove +balena.models.application.membership.remove(idOrUniqueKey) ⇒ Promise + +**Kind**: static method of [membership](#balena.models.application.membership) +**Summary**: Remove a membership +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__application numeric pair of the membership that will be removed

+
+ +**Example** +```js +balena.models.application.membership.remove(123); +``` +**Example** +```js +balena.models.application.membership.remove({ + user: 123, + is_member_of__application: 125, +}); +``` + +* * * + +## tags +balena.models.application.tags : object + +**Kind**: static namespace of [application](#balena.models.application) + +* * * + +### getAllByApplication +balena.models.application.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Get all application tags for an application +**Access**: public +**Fulfil**: Object[] - application tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.application.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.application.tags.remove(slugOrUuidOrId, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Remove an application tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.application.tags.remove('myorganization/myapp', 'EDITOR'); +``` + +* * * + +### set +balena.models.application.tags.set(slugOrUuidOrId, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.application.tags) +**Summary**: Set an application tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.application.tags.set(123, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/billing.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/billing.md new file mode 100644 index 0000000000..fd9bdf75a2 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/billing.md @@ -0,0 +1,339 @@ +# billing +balena.models.billing : object + +**Note!** The billing methods are available on Balena.io exclusively. + +**Kind**: static namespace + +* * * + +## changePlan +balena.models.billing.changePlan(organization, planChangeOptions) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Change the current billing plan +**Access**: public + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
planChangeOptionsObject

an object containing the billing plan change options

+
billingInfo.tierString

the code of the target billing plan

+
billingInfo.cycleString

the billing cycle

+
[billingInfo.planChangeReason]String

the reason for changing the current plan

+
+ +**Example** +```js +balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() { + console.log('Plan changed!'); +}); +``` + +* * * + +## createSetupIntent +balena.models.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 + + + + + + + + + + + + + + +
ParamTypeDescription
setupIntentParamsObject

an object containing the parameters for the setup intent creation

+
extraParams.organizationString | 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); +}); +``` + +* * * + +## downloadInvoice +balena.models.billing.downloadInvoice(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Download a specific invoice +**Access**: public +**Fulfil**: Blob\|ReadableStream - blob on the browser, download stream on node + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
String

an invoice number

+
+ +**Example** +```js +# Browser +balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) { + console.log(blob); +}); +# Node +balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) { + stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf')); +}); +``` + +* * * + +## getAccount +balena.models.billing.getAccount(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the user's billing account +**Access**: public +**Fulfil**: Object - billing account + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getAccount(orgId).then(function(billingAccount) { + console.log(billingAccount); +}); +``` + +* * * + +## getBillingInfo +balena.models.billing.getBillingInfo(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the current billing information +**Access**: public +**Fulfil**: Object - billing information + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getBillingInfo(orgId).then(function(billingInfo) { + console.log(billingInfo); +}); +``` + +* * * + +## getInvoices +balena.models.billing.getInvoices(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the available invoices +**Access**: public +**Fulfil**: Object - invoices + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getInvoices(orgId).then(function(invoices) { + console.log(invoices); +}); +``` + +* * * + +## getPlan +balena.models.billing.getPlan(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Get the current billing plan +**Access**: public +**Fulfil**: Object - billing plan + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.getPlan(orgId).then(function(billingPlan) { + console.log(billingPlan); +}); +``` + +* * * + +## removeBillingInfo +balena.models.billing.removeBillingInfo(organization) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Remove an organization's billing information +**Access**: public + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
+ +**Example** +```js +balena.models.billing.removeBillingInfo(orgId).then(function() { + console.log("Success"); +}); +``` + +* * * + +## updateAccountInfo +balena.models.billing.updateAccountInfo(organization, accountInfo) + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Update the current billing account information +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
accountInfoAccountInfo

an object containing billing account info

+
+ +**Example** +```js +balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) +``` +**Example** +```js +balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' }) +``` + +* * * + +## updateBillingInfo +balena.models.billing.updateBillingInfo(organization, billingInfo) ⇒ Promise + +**Kind**: static method of [billing](#balena.models.billing) +**Summary**: Update the current billing information +**Access**: public +**Fulfil**: Object - billing information + + + + + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
billingInfoObject

an object containing a billing info token_id

+
billingInfo.token_idString

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 +balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) { + console.log(billingInfo); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/config.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/config.md new file mode 100644 index 0000000000..676ca030aa --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/config.md @@ -0,0 +1,130 @@ +# config +balena.models.config : object + +**Kind**: static namespace + +* * * + +## getAll +balena.models.config.getAll() ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get all configuration +**Access**: public +**Fulfil**: Object - configuration +**Example** +```js +balena.models.config.getAll().then(function(config) { + console.log(config); +}); +``` + +* * * + +## getConfigVarSchema +balena.models.config.getConfigVarSchema(deviceType) ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get configuration variables schema for a device type +**Access**: public +**Fulfil**: Object[] - configuration options + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) { + console.log(options); +}); +``` + +* * * + +## getDeviceOptions +balena.models.config.getDeviceOptions(deviceType) ⇒ Promise + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get configuration/initialization options for a device type +**Access**: public +**Fulfil**: Object[] - configuration options + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
+ +**Example** +```js +balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) { + console.log(options); +}); +``` + +* * * + +## getDeviceTypeManifestBySlug +balena.models.config.getDeviceTypeManifestBySlug(slugOrName) ⇒ Promise + +***use balena.models.deviceType.getBySlugOrName*** + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get a device type manifest by slug +**Access**: public +**Fulfil**: Object - device type manifest + + + + + + + + + + +
ParamTypeDescription
slugOrNameString

device type slug

+
+ +**Example** +```js +balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) { + console.log(manifest); +}); +``` + +* * * + +## getDeviceTypes +balena.models.config.getDeviceTypes() ⇒ Promise + +***use balena.models.deviceType.getAll*** + +**Kind**: static method of [config](#balena.models.config) +**Summary**: Get device types +**Access**: public +**Fulfil**: Object[] - device types +**Example** +```js +balena.models.config.getDeviceTypes().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/creditBundle.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/creditBundle.md new file mode 100644 index 0000000000..9b3025c4e4 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/creditBundle.md @@ -0,0 +1,74 @@ +# creditBundle +balena.models.creditBundle : object + +**Kind**: static namespace + +* * * + +## create +balena.models.creditBundle.create(organization, featureId, creditsToPurchase) ⇒ Promise + +**Kind**: static method of [creditBundle](#balena.models.creditBundle) +**Summary**: Purchase a credit bundle for the given feature and org of the given quantity +**Access**: public +**Fulfil**: Object[] - credit bundles + + + + + + + + + + + + + + +
ParamTypeDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
featureIdNumber

id (number) of the feature for which credits are being purchased.

+
creditsToPurchaseNumber

number of credits being purchased.

+
+ +**Example** +```js +balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) { + console.log(creditBundle); +}); +``` + +* * * + +## getAllByOrg +balena.models.creditBundle.getAllByOrg(organization, [options]) ⇒ Promise + +**Kind**: static method of [creditBundle](#balena.models.creditBundle) +**Summary**: Get all of the credit bundles purchased by the given org +**Access**: public +**Fulfil**: Object[] - credit bundles + + + + + + + + + + + + +
ParamTypeDefaultDescription
organizationString | Number

handle (string) or id (number) of the target organization.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) { + console.log(creditBundles); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/device.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/device.md new file mode 100644 index 0000000000..49a47aeac3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/device.md @@ -0,0 +1,2986 @@ +# device +balena.models.device : object + +**Kind**: static namespace + +* * * + +## deactivate +balena.models.device.deactivate(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Deactivate device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.deactivate('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.deactivate(123); +``` + +* * * + +## disableDeviceUrl +balena.models.device.disableDeviceUrl(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable device url for a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.disableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableDeviceUrl(123); +``` + +* * * + +## disableLocalMode +balena.models.device.disableLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable local mode +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.disableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableLocalMode(123); +``` + +* * * + +## disableLockOverride +balena.models.device.disableLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Disable lock override +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.disableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.disableLockOverride(123); +``` + +* * * + +## enableDeviceUrl +balena.models.device.enableDeviceUrl(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable device url for a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.enableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableDeviceUrl(123); +``` + +* * * + +## enableLocalMode +balena.models.device.enableLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable local mode +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.enableLocalMode('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableLocalMode(123); +``` + +* * * + +## enableLockOverride +balena.models.device.enableLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Enable lock override +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.enableLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.enableLockOverride(123); +``` + +* * * + +## generateDeviceKey +balena.models.device.generateDeviceKey(uuidOrId, [keyName], [keyDescription]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Generate a device key +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[keyName]String

Device key name

+
[keyDescription]String

Description for device key

+
+ +**Example** +```js +balena.models.device.generateDeviceKey('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceApiKey) { + console.log(deviceApiKey); +}); +``` +**Example** +```js +balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) { + console.log(deviceApiKey); +}); +``` + +* * * + +## generateUniqueKey +balena.models.device.generateUniqueKey() ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Generate a random key, useful for both uuid and api key. +**Returns**: String - A generated key +**Access**: public +**Example** +```js +randomKey = balena.models.device.generateUniqueKey(); +// randomKey is a randomly generated key that can be used as either a uuid or an api key +console.log(randomKey); +``` + +* * * + +## get +balena.models.device.get(uuidOrId, [options]) ⇒ Promise + +This method returns a single device by id or uuid. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a single device +**Access**: public +**Fulfil**: Object - device + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.get(123).then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getAllByApplication +balena.models.device.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +This method returns all devices of a specific application. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get all devices by application +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByApplication(123).then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getAllByOrganization +balena.models.device.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all devices of a specific application. +In order to have the following computed properties in the result +you have to explicitly define them in a `$select` in the extra options: +* `overall_status` +* `overall_progress` +* `should_be_running__release` + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get all devices by organization +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getAllByOrganization('myorganization').then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByOrganization(123).then(function(devices) { + console.log(devices); +}); +``` +**Example** +```js +balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) { + console.log(device); +}) +``` + +* * * + +## getApplicationName +balena.models.device.getApplicationName(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get application name +**Access**: public +**Fulfil**: String - application name + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getApplicationName('7cf02a69e4d34c9da573914963cf54fd').then(function(applicationName) { + console.log(applicationName); +}); +``` +**Example** +```js +balena.models.device.getApplicationName(123).then(function(applicationName) { + console.log(applicationName); +}); +``` + +* * * + +## getByName +balena.models.device.getByName(name) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get devices by name +**Access**: public +**Fulfil**: Object[] - devices + + + + + + + + + + +
ParamTypeDescription
nameString

device name

+
+ +**Example** +```js +balena.models.device.getByName('MyDevice').then(function(devices) { + console.log(devices); +}); +``` + +* * * + +## getDashboardUrl +balena.models.device.getDashboardUrl(uuid) ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get Dashboard URL for a specific device +**Returns**: String - - Dashboard URL for the specific device +**Throws**: + +- Exception if the uuid is empty + + + + + + + + + + + +
ParamTypeDescription
uuidString

Device uuid

+
+ +**Example** +```js +dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8') +``` + +* * * + +## getDeviceUrl +balena.models.device.getDeviceUrl(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a device url +**Access**: public +**Fulfil**: String - device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(url) { + console.log(url); +}); +``` +**Example** +```js +balena.models.device.getDeviceUrl(123).then(function(url) { + console.log(url); +}); +``` + +* * * + +## getLocalIPAddresses +balena.models.device.getLocalIPAddresses(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the local IP addresses of a device +**Access**: public +**Fulfil**: String[] - local ip addresses +**Reject**: Error Will reject if the device is offline + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getLocalIPAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(localIPAddresses) { + localIPAddresses.forEach(function(localIP) { + console.log(localIP); + }); +}); +``` +**Example** +```js +balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) { + localIPAddresses.forEach(function(localIP) { + console.log(localIP); + }); +}); +``` + +* * * + +## getLocalModeSupport +balena.models.device.getLocalModeSupport(device) ⇒ Object + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported. +**Returns**: Object - Local mode support info ({ supported: true/false, message: "..." }) +**Access**: public + + + + + + + + + + +
ParamTypeDescription
deviceObject

A device object

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + balena.models.device.getLocalModeSupport(device); +}) +``` + +* * * + +## getMACAddresses +balena.models.device.getMACAddresses(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the MAC addresses of a device +**Access**: public +**Fulfil**: String[] - mac addresses + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getMACAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(macAddresses) { + macAddresses.forEach(function(mac) { + console.log(mac); + }); +}); +``` +**Example** +```js +balena.models.device.getMACAddresses(123).then(function(macAddresses) { + macAddresses.forEach(function(mac) { + console.log(mac); + }); +}); +``` + +* * * + +## getMetrics +balena.models.device.getMetrics(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the metrics related information for a device +**Access**: public +**Fulfil**: Object - device metrics + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getMetrics('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceMetrics) { + console.log(deviceMetrics); +}); +``` +**Example** +```js +balena.models.device.getMetrics(123).then(function(deviceMetrics) { + console.log(deviceMetrics); +}); +``` + +* * * + +## getName +balena.models.device.getName(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the name of a device +**Access**: public +**Fulfil**: String - device name + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getName('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceName) { + console.log(deviceName); +}); +``` +**Example** +```js +balena.models.device.getName(123).then(function(deviceName) { + console.log(deviceName); +}); +``` + +* * * + +## getOsVersion +balena.models.device.getOsVersion(device) ⇒ String + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the OS version (version number and variant combined) running on a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
deviceObject

A device object

+
+ +**Example** +```js +balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device.os_version); // => 'balenaOS 2.26.0+rev1' + console.log(device.os_variant); // => 'prod' + balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod' +}) +``` + +* * * + +## getProgress +balena.models.device.getProgress(uuidOrId) ⇒ Promise + +Convenience method for getting the overall progress of a device. +It's recommended to use `balena.models.device.get()` instead, +in case that you need to retrieve more device fields than just the progress. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the progress of a device +**Access**: public +**Fulfil**: Number\|null - device progress +**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field. + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getProgress('7cf02a69e4d34c9da573914963cf54fd').then(function(progress) { + console.log(progress); +}); +``` +**Example** +```js +balena.models.device.getProgress(123).then(function(progress) { + console.log(progress); +}); +``` + +* * * + +## getStatus +balena.models.device.getStatus(uuidOrId) ⇒ Promise + +Convenience method for getting the overall status of a device. +It's recommended to use `balena.models.device.get()` instead, +in case that you need to retrieve more device fields than just the status. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the status of a device +**Access**: public +**Fulfil**: String - device status +**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field. + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getStatus('7cf02a69e4d34c9da573914963cf54fd').then(function(status) { + console.log(status); +}); +``` +**Example** +```js +balena.models.device.getStatus(123).then(function(status) { + console.log(status); +}); +``` + +* * * + +## getSupervisorState +balena.models.device.getSupervisorState(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the supervisor state on a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getSupervisorState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorState(123).then(function(state) { + console.log(state); +}); +``` + +* * * + +## getSupervisorTargetState +balena.models.device.getSupervisorTargetState(uuidOrId, version) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the target supervisor state on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
versionNumber

(optional) target state version (2 or 3), default to 2

+
+ +**Example** +```js +balena.models.device.getSupervisorTargetState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetState(123).then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetState(123, 3).then(function(state) { + console.log(state); +}); +``` + +* * * + +## getSupervisorTargetStateForApp +balena.models.device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the target supervisor state on a "generic" device on a fleet +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

fleet uuid (string) or id (number)

+
releaseString

(optional) release uuid (default tracked)

+
+ +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp('7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) { + console.log(state); +}); +``` +**Example** +```js +balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a69e4d34c9da573914963cf54fd').then(function(state) { + console.log(state); +}); +``` + +* * * + +## getTargetReleaseHash +balena.models.device.getTargetReleaseHash(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get the hash of the currently tracked release for a specific device +**Access**: public +**Fulfil**: String - The release hash of the currently tracked release + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd', function(release) { + console.log(release); +}); +``` + +* * * + +## getWithServiceDetails +balena.models.device.getWithServiceDetails(uuidOrId, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want more control, or to see the raw model +directly, use `device.get(uuidOrId, options)` instead. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get a single device along with its associated services' details, +including their associated commit +**Access**: public +**Fulfil**: Object - device with service details + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.getWithServiceDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(device) { + console.log(device); +}) +``` +**Example** +```js +balena.models.device.getWithServiceDetails(123).then(function(device) { + console.log(device); +}) +``` + +* * * + +## grantSupportAccess +balena.models.device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Grant support access to a device until a specified time +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
expiryTimestampNumber

a timestamp in ms for when the support access will expire

+
+ +**Example** +```js +balena.models.device.grantSupportAccess('7cf02a69e4d34c9da573914963cf54fd', Date.now() + 3600 * 1000); +``` +**Example** +```js +balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000); +``` + +* * * + +## has +balena.models.device.has(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device exists +**Access**: public +**Fulfil**: Boolean - has device + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.has('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDevice) { + console.log(hasDevice); +}); +``` +**Example** +```js +balena.models.device.has(123).then(function(hasDevice) { + console.log(hasDevice); +}); +``` + +* * * + +## hasDeviceUrl +balena.models.device.hasDeviceUrl(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device is web accessible with device utls +**Access**: public +**Fulfil**: Boolean - has device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.hasDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDeviceUrl) { + if (hasDeviceUrl) { + console.log('The device has device URL enabled'); + } +}); +``` +**Example** +```js +balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) { + if (hasDeviceUrl) { + console.log('The device has device URL enabled'); + } +}); +``` + +* * * + +## hasLockOverride +balena.models.device.hasLockOverride(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device has the lock override enabled +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.hasLockOverride('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.hasLockOverride(123); +``` + +* * * + +## identify +balena.models.device.identify(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Identify device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.identify('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.identify(123); +``` + +* * * + +## isInLocalMode +balena.models.device.isInLocalMode(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if local mode is enabled on the device +**Access**: public +**Fulfil**: Boolean - has device url + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isInLocalMode('7cf02a69e4d34c9da573914963cf54fd').then(function(isInLocalMode) { + if (isInLocalMode) { + console.log('The device has local mode enabled'); + } +}); +``` +**Example** +```js +balena.models.device.isInLocalMode(123).then(function(isInLocalMode) { + if (isInLocalMode) { + console.log('The device has local mode enabled'); + } +}); +``` + +* * * + +## isOnline +balena.models.device.isOnline(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Check if a device is online +**Access**: public +**Fulfil**: Boolean - is device online + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isOnline('7cf02a69e4d34c9da573914963cf54fd').then(function(isOnline) { + console.log('Is device online?', isOnline); +}); +``` +**Example** +```js +balena.models.device.isOnline(123).then(function(isOnline) { + console.log('Is device online?', isOnline); +}); +``` + +* * * + +## isTrackingApplicationRelease +balena.models.device.isTrackingApplicationRelease(uuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Get whether the device is configured to track the current application release +**Access**: public +**Fulfil**: Boolean - is tracking the current application release + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.isTrackingApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(isEnabled) { + console.log(isEnabled); +}); +``` + +* * * + +## move +balena.models.device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Move a device to another application +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.move('7cf02a69e4d34c9da573914963cf54fd', 'myorganization/myapp'); +``` +**Example** +```js +balena.models.device.move(123, 'myorganization/myapp'); +``` +**Example** +```js +balena.models.device.move(123, 456); +``` + +* * * + +## ping +balena.models.device.ping(uuidOrId) ⇒ Promise + +This is useful to signal that the supervisor is alive and responding. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Ping a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.ping('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.ping(123); +``` + +* * * + +## pinToOsRelease +balena.models.device.pinToOsRelease(uuidOrIdOrArray, osVersionOrId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Mark a specific device to be updated to a particular OS release +**Access**: public +**Experimental**: + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
osVersionOrIdString

the raw version of a OS release (string) or id (number) +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number, a "prod" variant and greater than or equal to the one running on the device. +To resolve compatible update targets for a device use balena.models.os.getSupportedOsUpdateVersions.

+
+ +**Example** +```js +await balena.models.device.pinToOsRelease('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod'); +``` + +* * * + +## pinToRelease +balena.models.device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ Promise + +Configures the device to run a particular release +and not get updated when the current application release changes. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a specific device to run a particular release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
fullReleaseHashOrIdString | Number

the hash of a successful release (string) or id (number)

+
+ +**Example** +```js +balena.models.device.pinToRelease('7cf02a69e4d34c9da573914963cf54fd', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() { + ... +}); +``` + +* * * + +## pinToSupervisorRelease +balena.models.device.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ Promise + +Configures the device to run a particular supervisor release. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a specific device to run a particular supervisor release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
supervisorVersionOrIdString | Number

the raw version of a supervisor release (string) or id (number)

+
+ +**Example** +```js +balena.models.device.pinToSupervisorRelease('7cf02a69e4d34c9da573914963cf54fd', '10.8.0').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.pinToSupervisorRelease(123, '11.4.14').then(function() { + ... +}); +``` + +* * * + +## purge +balena.models.device.purge(uuidOrId) ⇒ Promise + +This function clears the user application's `/data` directory. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Purge device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.purge('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.purge(123); +``` + +* * * + +## reboot +balena.models.device.reboot(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Reboot device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.reboot('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.reboot(123); +``` + +* * * + +## register +balena.models.device.register(applicationSlugOrUuidOrId, uuid, [deviceTypeSlug]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Register a new device with a Balena application. +**Access**: public +**Fulfil**: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." }) + + + + + + + + + + + + + + +
ParamTypeDescription
applicationSlugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
uuidString

device uuid

+
[deviceTypeSlug]String

device type slug (string) or alias (string)

+
+ +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` +**Example** +```js +var uuid = balena.models.device.generateUniqueKey(); +balena.models.device.register(123, uuid).then(function(registrationInfo) { + console.log(registrationInfo); +}); +``` + +* * * + +## remove +balena.models.device.remove(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Remove device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.remove('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.remove(123); +``` + +* * * + +## rename +balena.models.device.rename(uuidOrId, newName) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Rename device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
newNameString

the device new name

+
+ +**Example** +```js +balena.models.device.rename('7cf02a69e4d34c9da573914963cf54fd', 'NewName'); +``` +**Example** +```js +balena.models.device.rename(123, 'NewName'); +``` + +* * * + +## restartApplication +balena.models.device.restartApplication(uuidOrId) ⇒ Promise + +This function restarts the Docker container running +the application on the device, but doesn't reboot +the device itself. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Restart application on device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
+ +**Example** +```js +balena.models.device.restartApplication('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.restartApplication(123); +``` + +* * * + +## restartService +balena.models.device.restartService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Restart a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to restart

+
+ +**Example** +```js +balena.models.device.restartService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.restartService(1, 123).then(function() { + ... +}); +``` + +* * * + +## revokeSupportAccess +balena.models.device.revokeSupportAccess(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Revoke support access to a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.revokeSupportAccess('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.revokeSupportAccess(123); +``` + +* * * + +## setCustomLocation +balena.models.device.setCustomLocation(uuidOrIdOrArray, location) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Set a custom location for a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
locationObject

the location ({ latitude: 123, longitude: 456 })

+
+ +**Example** +```js +balena.models.device.setCustomLocation('7cf02a69e4d34c9da573914963cf54fd', { latitude: 123, longitude: 456 }); +``` +**Example** +```js +balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 }); +``` + +* * * + +## setNote +balena.models.device.setNote(uuidOrIdOrArray, note) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Note a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
noteString

the note

+
+ +**Example** +```js +balena.models.device.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); +``` +**Example** +```js +balena.models.device.setNote(123, 'My useful note'); +``` + +* * * + +## shutdown +balena.models.device.shutdown(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Shutdown device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.shutdown('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.shutdown(123); +``` + +* * * + +## startOsUpdate +balena.models.device.startOsUpdate(uuidOrUuids, targetOsVersion, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Start an OS update on a device +**Access**: public +**Fulfil**: Object - action response + + + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrUuidsString | Array.<String>

full device uuid or array of full uuids

+
targetOsVersionString

semver-compatible version for the target device +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number, a "prod" variant and greater than the one running on the device. +To resolve the semver-compatible range use balena.model.os.getMaxSatisfyingVersion.

+
[options]Object

options

+
[options.runDetached]Boolean

run the update in detached mode. True by default

+
+ +**Example** +```js +balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { + console.log(result.status); +}); +``` + +* * * + +## startService +balena.models.device.startService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Start a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to start

+
+ +**Example** +```js +balena.models.device.startService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.startService(1, 123).then(function() { + ... +}); +``` + +* * * + +## stopService +balena.models.device.stopService(uuidOrId, imageId) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Stop a service on a device +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
imageIdNumber

id of the image to stop

+
+ +**Example** +```js +balena.models.device.stopService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.stopService(1, 123).then(function() { + ... +}); +``` + +* * * + +## trackApplicationRelease +balena.models.device.trackApplicationRelease(uuidOrIdOrArray) ⇒ Promise + +The device's current release will be updated with each new successfully built release. + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Configure a specific device to track the current application release +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.trackApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function() { + ... +}); +``` + +* * * + +## unsetCustomLocation +balena.models.device.unsetCustomLocation(uuidOrIdOrArray) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Clear the custom location of a device +**Access**: public + + + + + + + + + + +
ParamTypeDescription
uuidOrIdOrArrayString | Array.<String> | Number | Array.<Number>

device uuid (string) or id (number) or array of full uuids or ids

+
+ +**Example** +```js +balena.models.device.unsetCustomLocation('7cf02a69e4d34c9da573914963cf54fd'); +``` +**Example** +```js +balena.models.device.unsetCustomLocation(123); +``` + +* * * + +## update +balena.models.device.update(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [device](#balena.models.device) +**Summary**: Trigger an update check on the supervisor +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object

options

+
[options.force]Booleanfalse

override update lock

+
+ +**Example** +```js +balena.models.device.update('7cf02a69e4d34c9da573914963cf54fd', { + force: true +}); +``` +**Example** +```js +balena.models.device.update(123, { + force: true +}); +``` + +* * * + +## configVar +balena.models.device.configVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.configVar.get(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get the value of a specific config variable +**Access**: public +**Fulfil**: String\|undefined - the config variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.device.configVar.get('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.configVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get all device config variables by application +**Access**: public +**Fulfil**: Object[] - device config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.configVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.configVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Get all config variables for a device +**Access**: public +**Fulfil**: Object[] - device config variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.configVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.configVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.configVar.remove(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Clear the value of a specific config variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
+ +**Example** +```js +balena.models.device.configVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.configVar.set(uuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [configVar](#balena.models.device.configVar) +**Summary**: Set the value of a specific config variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

config variable name

+
valueString

config variable value

+
+ +**Example** +```js +balena.models.device.configVar.set('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## envVar +balena.models.device.envVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.envVar.get(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get the value of a specific environment variable +**Access**: public +**Fulfil**: String\|undefined - the environment variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.device.envVar.get('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.envVar.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.envVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get all device environment variables by application +**Access**: public +**Fulfil**: Object[] - device environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.envVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.envVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Get all environment variables for a device +**Access**: public +**Fulfil**: Object[] - device environment variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.envVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.envVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.envVar.remove(uuidOrId, key) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Clear the value of a specific environment variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
+ +**Example** +```js +balena.models.device.envVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.envVar.remove(999999, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.envVar.set(uuidOrId, key, value) ⇒ Promise + +**Kind**: static method of [envVar](#balena.models.device.envVar) +**Summary**: Set the value of a specific environment variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
keyString

environment variable name

+
valueString

environment variable value

+
+ +**Example** +```js +balena.models.device.envVar.set('7cf02a69e4d34c9da573914963cf54fd', 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + +## history +balena.models.device.history : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### getAllByApplication +balena.models.device.history.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [history](#balena.models.device.history) +**Summary**: Get all device history entries by application with time frame +**Access**: public +**Fulfil**: Object[] - device history + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

+
[dateFilter.toDate]Date

history entries younger or equal to this date

+
[options]Object

extra pine options to use

+
+ +**Example** +```js +balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +balena.models.device.history.getAllByApplication(999999).then(function(entries) { + console.log(entries); +}); + + +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByApplication( + 999999, + { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10), + { $top: 10, $orderby: { id: 'desc' }} +}); +``` + +* * * + +### getAllByDevice +balena.models.device.history.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [history](#balena.models.device.history) +**Summary**: Get all history entries for a device +**Access**: public +**Fulfil**: Object[] - device history + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (32 / 62 digits string) or id (number)

+
[dateFilter.fromDate]DatesubDays(new Date(), 7)

history entries older or equal to this date - default now() - 7 days

+
[dateFilter.toDate]Date

history entries younger or equal to this date

+
[options]Object

extra pine options to use

+
+ +**Example** +```js +balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +balena.models.device.history.getAllByDevice(999999).then(function(entries) { + console.log(entries); +}); +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}) +``` +**Example** +```js +// get all device history entries between now - 20 days and now - 10 days +balena.models.device.history.getAllByDevice( + 999999, + { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)}, + { $top: 10, $orderby: { id: 'desc' }} +) +``` + +* * * + +## serviceVar +balena.models.device.serviceVar : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### get +balena.models.device.serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get the overriden value of a service variable on a device +**Access**: public +**Fulfil**: String\|undefined - the variable value (or undefined) + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
+ +**Example** +```js +balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.device.serviceVar.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get all device service variable overrides by application +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.serviceVar.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Get all service variable overrides for a device +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.serviceVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.device.serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Clear the overridden value of a service variable on a device +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
+ +**Example** +```js +balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.device.serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ Promise + +**Kind**: static method of [serviceVar](#balena.models.device.serviceVar) +**Summary**: Set the overriden value of a service variable on a device +**Access**: public + + + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
serviceNameOrIdString | Number

service name (string) or id (number)

+
keyString

variable name

+
valueString

variable value

+
+ +**Example** +```js +balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR', 'override').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR', 'override').then(function() { + ... +}); +``` +**Example** +```js +balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() { + ... +}); +``` + +* * * + +## tags +balena.models.device.tags : object + +**Kind**: static namespace of [device](#balena.models.device) + +* * * + +### getAllByApplication +balena.models.device.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Get all device tags for an application +**Access**: public +**Fulfil**: Object[] - device tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.device.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### getAllByDevice +balena.models.device.tags.getAllByDevice(uuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Get all device tags for a device +**Access**: public +**Fulfil**: Object[] - device tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.device.tags.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.device.tags.getAllByDevice(123).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.device.tags.remove(uuidOrId, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Remove a device tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.device.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); +``` + +* * * + +### set +balena.models.device.tags.set(uuidOrId, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.device.tags) +**Summary**: Set a device tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
uuidOrIdString | Number

device uuid (string) or id (number)

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.device.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.device.tags.set(123, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/deviceType.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/deviceType.md new file mode 100644 index 0000000000..d5057f98ff --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/deviceType.md @@ -0,0 +1,309 @@ +# deviceType +balena.models.deviceType : object + +**Kind**: static namespace + +* * * + +## get +balena.models.deviceType.get(idOrSlug, [options]) ⇒ Promise + +This method returns a single device type. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a single deviceType +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + + + +
ParamTypeDefaultDescription
idOrSlugString | Number

device type slug (string) or alias (string) or id

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.get('raspberry-pi').then(function(deviceType) { + console.log(deviceType); +}); +``` +**Example** +```js +balena.models.deviceType.get('raspberrypi').then(function(deviceType) { + console.log('resolved alias:', deviceType); +}); +``` + +* * * + +## getAll +balena.models.deviceType.getAll([options]) ⇒ Promise + +This method returns all device types. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get all deviceTypes +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.getAll().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` +**Example** +```js +balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) { + console.log(deviceTypes); +}) +``` + +* * * + +## getAllSupported +balena.models.deviceType.getAllSupported([options]) ⇒ Promise + +This method returns all supported device types. + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get all supported deviceTypes +**Access**: public +**Fulfil**: Object[] - device types + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.deviceType.getAllSupported().then(function(deviceTypes) { + console.log(deviceTypes); +}); +``` +**Example** +```js +balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) { + console.log(deviceTypes); +}) +``` + +* * * + +## getBySlugOrName +balena.models.deviceType.getBySlugOrName(slugOrName) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a deviceType by slug or name +**Access**: public +**Fulfil**: Object - device type + + + + + + + + + + +
ParamTypeDescription
slugOrNameString

deviceType slug

+
+ +**Example** +```js +balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { + console.log(deviceType); +}); +``` + +* * * + +## getInstallMethod +balena.models.deviceType.getInstallMethod(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get installation method on a given device type +**Access**: public +**Fulfil**: String - the installation method supported for the given device type slug + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { + console.log(method); + // externalBoot +}); +``` + +* * * + +## getInstructions +balena.models.deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get instructions for installing a host OS on a given device type +**Access**: public +**Fulfil**: Object \| String[] - step by step instructions for installing the host OS to the device + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugOrContractString | Object

device type slug or contract

+
+ +**Example** +```js +balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { + for (let instruction of instructions.values()) { + console.log(instruction); + } + // Insert the sdcard to the host machine. + // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. + // Wait for writing of BalenaOS to complete. + // Remove the sdcard from the host machine. + // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). + // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. +}); +``` + +* * * + +## getInterpolatedPartials +balena.models.deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get a contract with resolved partial templates +**Access**: public +**Fulfil**: Contract - device type contract with resolved partials + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { + for (const partial in contract.partials) { + console.log(`${partial}: ${contract.partials[partial]}`); + } + // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] +}); +``` + +* * * + +## getName +balena.models.deviceType.getName(deviceTypeSlug) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get display name for a device +**Access**: public +**Fulfil**: String - device display name + + + + + + + + + + +
ParamTypeDescription
deviceTypeSlugString

device type slug

+
+ +**Example** +```js +balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { + console.log(deviceTypeName); + // Raspberry Pi +}); +``` + +* * * + +## getSlugByName +balena.models.deviceType.getSlugByName(deviceTypeName) ⇒ Promise + +**Kind**: static method of [deviceType](#balena.models.deviceType) +**Summary**: Get device slug +**Access**: public +**Fulfil**: String - device slug name + + + + + + + + + + +
ParamTypeDescription
deviceTypeNameString

device type name

+
+ +**Example** +```js +balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { + console.log(deviceTypeSlug); + // raspberry-pi +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/image.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/image.md new file mode 100644 index 0000000000..7e3a9e6e82 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/image.md @@ -0,0 +1,68 @@ +# image +balena.models.image : object + +**Kind**: static namespace + +* * * + +## get +balena.models.image.get(id, [options]) ⇒ Promise + +**Kind**: static method of [image](#balena.models.image) +**Summary**: Get a specific image +**Access**: public +**Fulfil**: Object - image + + + + + + + + + + + + +
ParamTypeDefaultDescription
idNumber

image id

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.image.get(123).then(function(image) { + console.log(image); +}); +``` + +* * * + +## getLogs +balena.models.image.getLogs(id) ⇒ Promise + +**Kind**: static method of [image](#balena.models.image) +**Summary**: Get the logs for an image +**Access**: public +**Fulfil**: string \| null - logs + + + + + + + + + + +
ParamTypeDescription
idNumber

image id

+
+ +**Example** +```js +balena.models.image.getLogs(123).then(function(logs) { + console.log(logs); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/key.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/key.md new file mode 100644 index 0000000000..9d4db96169 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/key.md @@ -0,0 +1,123 @@ +# key +balena.models.key : object + +**Kind**: static namespace + +* * * + +## create +balena.models.key.create(title, key) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Create a ssh key +**Access**: public +**Fulfil**: Object - ssh key + + + + + + + + + + + + +
ParamTypeDescription
titleString

key title

+
keyString

the public ssh key

+
+ +**Example** +```js +balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) { + console.log(key); +}); +``` + +* * * + +## get +balena.models.key.get(id) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Get a single ssh key +**Access**: public +**Fulfil**: Object - ssh key + + + + + + + + + + +
ParamTypeDescription
idNumber

key id

+
+ +**Example** +```js +balena.models.key.get(51).then(function(key) { + console.log(key); +}); +``` + +* * * + +## getAll +balena.models.key.getAll([options]) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Get all ssh keys +**Access**: public +**Fulfil**: Object[] - ssh keys + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.key.getAll().then(function(keys) { + console.log(keys); +}); +``` + +* * * + +## remove +balena.models.key.remove(id) ⇒ Promise + +**Kind**: static method of [key](#balena.models.key) +**Summary**: Remove ssh key +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

key id

+
+ +**Example** +```js +balena.models.key.remove(51); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/organization.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/organization.md new file mode 100644 index 0000000000..e195cd08f6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/organization.md @@ -0,0 +1,521 @@ +# organization +balena.models.organization : object + +**Kind**: static namespace + +* * * + +## create +balena.models.organization.create(options) ⇒ Promise + +This method creates a new organization with the current user as an administrator. + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Creates a new organization +**Access**: public +**Fulfil**: String - Organization + + + + + + + + + + + + + + +
ParamTypeDescription
optionsObject

Organization parameters to use.

+
options.nameString

Required: the name of the organization that will be created.

+
[options.handle]String

The handle of the organization that will be created.

+
+ +**Example** +```js +balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) { + console.log(organization); +}); +``` +**Example** +```js +balena.models.organization.create({ + name:'MyOrganization', + logo_image: new File( + imageContent, + 'img.jpeg' + ); +}) +.then(function(organization) { + console.log(organization); +}); +``` + +* * * + +## get +balena.models.organization.get(handleOrId, [options]) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Get a single organization +**Access**: public +**Fulfil**: Object - organization + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.get('myorganization').then(function(organization) { + console.log(organization); +}); +``` +**Example** +```js +balena.models.organization.get(123).then(function(organization) { + console.log(organization); +}); +``` + +* * * + +## getAll +balena.models.organization.getAll([options]) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Get all Organizations +**Access**: public +**Fulfil**: Object[] - organizations + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.getAll().then(function(organizations) { + console.log(organizations); +}); +``` + +* * * + +## remove +balena.models.organization.remove(handleOrId) ⇒ Promise + +**Kind**: static method of [organization](#balena.models.organization) +**Summary**: Remove an Organization +**Access**: public + + + + + + + + + + +
ParamTypeDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
+ +**Example** +```js +balena.models.organization.remove(123); +``` + +* * * + +## invite +balena.models.organization.invite : object + +**Kind**: static namespace of [organization](#balena.models.organization) + +* * * + +### accept +balena.models.organization.invite.accept(invitationToken) ⇒ Promise + +This method adds the calling user to the organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Accepts an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
invitationTokenString

invite token

+
+ +**Example** +```js +balena.models.organization.invite.accept("qwerty-invitation-token"); +``` + +* * * + +### create +balena.models.organization.invite.create(handleOrId, options, [message]) ⇒ Promise + +This method invites a user by their email to an organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Creates a new invite for an organization +**Access**: public +**Fulfil**: String - organization invite + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

+
optionsObject

invite creation parameters

+
options.inviteeString

the email of the invitee

+
[options.roleName]String"developer"

the role name to be granted to the invitee

+
[message]String

the message to send along with the invite

+
+ +**Example** +```js +balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) { + console.log(invite); +}); +``` + +* * * + +### getAll +balena.models.organization.invite.getAll([options]) ⇒ Promise + +This method returns all invites. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Get all invites +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + +
ParamTypeDefaultDescription
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.invite.getAll().then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### getAllByOrganization +balena.models.organization.invite.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all invites for a specific organization. + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Get all invites by organization +**Access**: public +**Fulfil**: Object[] - invites + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string), or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) { + console.log(invites); +}); +``` +**Example** +```js +balena.models.organization.invite.getAllByOrganization(123).then(function(invites) { + console.log(invites); +}); +``` + +* * * + +### revoke +balena.models.organization.invite.revoke(id) ⇒ Promise + +**Kind**: static method of [invite](#balena.models.organization.invite) +**Summary**: Revoke an invite +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

organization invite id

+
+ +**Example** +```js +balena.models.organization.invite.revoke(123); +``` + +* * * + +## membership +balena.models.organization.membership : object + +**Kind**: static namespace of [organization](#balena.models.organization) + +* * * + +### changeRole +balena.models.organization.membership.changeRole(idOrUniqueKey, roleName) ⇒ Promise + +This method changes the role of an organization member. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Changes the role of an organization member +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
idOrUniqueKeyNumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership that will be changed

+
roleNameString

the role name to be granted to the membership

+
+ +**Example** +```js +balena.models.organization.membership.changeRole(123, "member").then(function() { + console.log('OK'); +}); +``` +**Example** +```js +balena.models.organization.membership.changeRole({ + user: 123, + is_member_of__organization: 125, +}, "member").then(function() { + console.log('OK'); +}); +``` + +* * * + +### get +balena.models.organization.membership.get(membershipId, [options]) ⇒ Promise + +This method returns a single organization membership. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get a single organization membership +**Access**: public +**Fulfil**: Object - organization membership + + + + + + + + + + + + +
ParamTypeDefaultDescription
membershipIdnumber | Object

the id or an object with the unique user & is_member_of__organization numeric pair of the membership

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.get(5).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByOrganization +balena.models.organization.membership.getAllByOrganization(handleOrId, [options]) ⇒ Promise + +This method returns all organization memberships for a specific organization. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get all memberships by organization +**Access**: public +**Fulfil**: Object[] - organization memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
handleOrIdString | Number

organization handle (string) or id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### getAllByUser +balena.models.organization.membership.getAllByUser(usernameOrId, [options]) ⇒ Promise + +This method returns all organization memberships for a specific user. + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Get all memberships by user +**Access**: public +**Fulfil**: Object[] - organization memberships + + + + + + + + + + + + +
ParamTypeDefaultDescription
usernameOrIdString | Number

the user's username (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) { + console.log(memberships); +}); +``` +**Example** +```js +balena.models.organization.membership.getAllByUser(123).then(function(memberships) { + console.log(memberships); +}); +``` + +* * * + +### remove +balena.models.organization.membership.remove(id) ⇒ Promise + +**Kind**: static method of [membership](#balena.models.organization.membership) +**Summary**: Remove a membership +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber

organization membership id

+
+ +**Example** +```js +balena.models.organization.membership.remove(123); +``` +**Example** +```js +balena.models.organization.membership.remove({ + user: 123, + is_member_of__application: 125, +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/os.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/os.md new file mode 100644 index 0000000000..e9e7ac87f6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/os.md @@ -0,0 +1,523 @@ +# os +balena.models.os : object + +**Kind**: static namespace + +* * * + +## download +balena.models.os.download(options) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Download an OS image +**Access**: public +**Fulfil**: ReadableStream - download stream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

OS image options to use.

+
options.deviceTypeString

device type slug

+
[options.version]String'latest'

semver-compatible version or 'latest', defaults to 'latest' +Unsupported (unpublished) version will result in rejection. +The version must be the exact version number.

+
[options.developmentMode]Boolean

controls development mode for unified balenaOS releases.

+
[options.appId]Number

the application ID (number).

+
[options.fileType]String

download file type. One of '.img' or '.zip' or '.gz'.

+
[options.imageType]String

download file type. One of 'raw' or 'flasher'

+
[options.appUpdatePollInterval]Number

how often the OS checks for updates, in minutes.

+
[options.network]String

the network type that the device will use, one of 'ethernet' or 'wifi'.

+
[options.wifiKey]String

the key for the wifi network the device will connect to if network is wifi.

+
[options.wifiSsid]String

the ssid for the wifi network the device will connect to if network is wifi.

+
+ +**Example** +```js +balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) { + stream.pipe(fs.createWriteStream('foo/bar/image.img')); +}); +``` + +* * * + +## getAllOsVersions +balena.models.os.getAllOsVersions(deviceTypes, [options]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.os.getAllOsVersions('raspberrypi3'); +``` +**Example** +```js +balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']); +``` +**Example** +```js +balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } }); +``` + +* * * + +## getAvailableOsVersions +balena.models.os.getAvailableOsVersions(deviceTypes, [pineOptions], [extraOptions]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get the supported OS versions for the provided device type(s) +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypesString | Array.<String>

device type slug or array of slugs

+
[pineOptions]Object

Extra pine options to use

+
[extraOptions]Object

Extra convenience options to use

+
[extraOptions.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

+
+ +**Example** +```js +balena.models.os.getAvailableOsVersions('raspberrypi3'); +``` +**Example** +```js +balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']); +``` + +* * * + +## getConfig +balena.models.os.getConfig(slugOrUuidOrId, options) ⇒ Promise + +Builds the config.json for a device in the given application, with the given +options. + +Note that an OS version is required. For versions < 2.7.8, config +generation is only supported when using a session token, not an API key. + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get an applications config.json +**Access**: public +**Fulfil**: Object - application configuration as a JSON object. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number).

+
optionsObject

OS configuration options to use.

+
options.versionString

Required: the OS version of the image.

+
[options.network]String'ethernet'

The network type that +the device will use, one of 'ethernet' or 'wifi'.

+
[options.appUpdatePollInterval]Number

How often the OS checks +for updates, in minutes.

+
[options.provisioningKeyName]String

Name assigned to API key

+
[options.provisioningKeyExpiryDate]String

Expiry Date assigned to API key

+
[options.developmentMode]Boolean

Controls development mode for unified balenaOS releases.

+
[options.wifiKey]String

The key for the wifi network the +device will connect to.

+
[options.wifiSsid]String

The ssid for the wifi network the +device will connect to.

+
[options.ip]String

static ip address.

+
[options.gateway]String

static ip gateway.

+
[options.netmask]String

static ip netmask.

+
+ +**Example** +```js +balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) { + fs.writeFile('foo/bar/config.json', JSON.stringify(config)); +}); + +balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) { + fs.writeFile('foo/bar/config.json', JSON.stringify(config)); +}); +``` + +* * * + +## getDownloadSize +balena.models.os.getDownloadSize(deviceType, [version]) ⇒ Promise + +**Note!** Currently only the raw (uncompressed) size is reported. + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get OS download size estimate +**Access**: public +**Fulfil**: Number - OS image download size, in bytes. + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
[version]String

semver-compatible version or 'latest', defaults to 'latest'. +The version must be the exact version number.

+
+ +**Example** +```js +balena.models.os.getDownloadSize('raspberry-pi').then(function(size) { + console.log('The OS download size for raspberry-pi', size); +}); +``` + +* * * + +## getMaxSatisfyingVersion +balena.models.os.getMaxSatisfyingVersion(deviceType, versionOrRange, [osType]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Get the max OS version satisfying the given range +**Access**: public +**Fulfil**: String\|null - the version number, or `null` if no matching versions are found + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
versionOrRangeString

can be one of

+
    +
  • the exact version number, +in which case it is returned if the version is supported, +or null is returned otherwise,
  • +
  • a semver-compatible +range specification, in which case the most recent satisfying version is returned +if it exists, or null is returned,
  • +
  • 'latest' in which case the most recent version is returned, excluding pre-releases, +Defaults to 'latest'.
  • +
+
[osType]String

can be one of 'default', 'esr' or null to include all types

+
+ +**Example** +```js +balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) { + console.log(version); +}); +``` + +* * * + +## getOsUpdateType +balena.models.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 + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
targetVersionString

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); +}); +``` + +* * * + +## getSupervisorReleasesForCpuArchitecture +balena.models.os.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, [options]) ⇒ Promise.<String> + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns the Releases of the supervisor for the CPU Architecture +**Returns**: Promise.<String> - - An array of Release objects that can be used to manage a device as supervisors. +**Access**: public + + + + + + + + + + + + +
ParamTypeDefaultDescription
cpuArchitectureSlugOrIdString | Number

The slug (string) or id (number) for the CPU Architecture

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64'); + +const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( + 'aarch64', + { $filter: { raw_version: '12.11.0' } }, +); + +const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture( + 'aarch64', + { + $select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'], + $expand: { + release_image: { + $select: 'id', + $expand: { + image: { + $select: 'is_stored_at__image_location', + }, + }, + }, + }, + $filter: { raw_version: '12.11.0' } + }, +); +``` + +* * * + +## getSupportedOsUpdateVersions +balena.models.os.getSupportedOsUpdateVersions(deviceType, currentVersion, [options]) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns the supported OS update targets for the provided device type +**Access**: public +**Fulfil**: Object[]\|Object - An array of OsVersion objects when a single device type slug is provided, +or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided. +**Fulfil**: Object - the versions information, of the following structure: +* versions - an array of strings, +containing exact version numbers that OS update is supported +* recommended - the recommended version, i.e. the most recent version +that is _not_ pre-release, can be `null` +* current - the provided current version after normalization + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
[options]Object

Extra options to filter the OS releases by

+
[options.includeDraft]Booleanfalse

Whether pre-releases should be included in the results

+
[options.osType]String | null

Can be one of 'default', 'esr' or null which includes all types

+
+ +**Example** +```js +balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) { + console.log(isSupported); +}); +``` + +* * * + +## isArchitectureCompatibleWith +balena.models.os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ Boolean + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns whether the specified OS architecture is compatible with the target architecture +**Returns**: Boolean - - Whether the specified OS architecture is capable of running +applications build for the target architecture +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
osArchitectureString

The OS's architecture as specified in its device type

+
applicationArchitectureString

The application's architecture as specified in its device type

+
+ +**Example** +```js +const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf'); +console.log(result1); + +const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64'); +console.log(result2); +``` + +* * * + +## isSupportedOsUpdate +balena.models.os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ Promise + +**Kind**: static method of [os](#balena.models.os) +**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions +**Access**: public +**Fulfil**: Boolean - whether upgrading the OS to the target version is supported + + + + + + + + + + + + + + +
ParamTypeDescription
deviceTypeString

device type slug

+
currentVersionString

semver-compatible version for the starting OS version

+
targetVersionString

semver-compatible version for the target OS version

+
+ +**Example** +```js +balena.models.os.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) { + console.log(isSupported); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/release.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/release.md new file mode 100644 index 0000000000..d4e3a33717 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/release.md @@ -0,0 +1,853 @@ +# release +balena.models.release : object + +**Kind**: static namespace + +* * * + +## createFromUrl +balena.models.release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Create a new release built from the source in the provided url +**Access**: public +**Fulfil**: number - release ID + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
urlDeployOptionsObject

builder options

+
urlDeployOptions.urlString

a url with a tarball of the project to build

+
[urlDeployOptions.shouldFlatten]Booleantrue

Should be true when the tarball includes an extra root folder with all the content

+
+ +**Example** +```js +balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { + console.log(releaseId); +}); +``` +**Example** +```js +balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { + console.log(releaseId); +}); +``` + +* * * + +## finalize +balena.models.release.finalize(commitOrIdOrRawVersion) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Finalizes a draft release +**Access**: public +**Fulfil**: void + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
+ +**Example** +```js +balena.models.release.finalize(123).then(function() { + console.log('finalized!'); +}); +``` +**Example** +```js +balena.models.release.finalize('7cf02a69e4d34c9da573914963cf54fd').then(function() { + console.log('finalized!'); +}); +``` +**Example** +```js +balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log('finalized!'); +}); +``` + +* * * + +## get +balena.models.release.get(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get a specific release +**Access**: public +**Fulfil**: Object - release + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.get(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.get('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log(release); +}); +``` + +* * * + +## getAllByApplication +balena.models.release.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get all releases from an application +**Access**: public +**Fulfil**: Object[] - releases + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) { + console.log(releases); +}); +``` +**Example** +```js +balena.models.release.getAllByApplication(123).then(function(releases) { + console.log(releases); +}); +``` + +* * * + +## getLatestByApplication +balena.models.release.getLatestByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get the latest successful release for an application +**Access**: public +**Fulfil**: Object\|undefined - release + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) { + console.log(releases); +}); +``` +**Example** +```js +balena.models.release.getLatestByApplication(123).then(function(releases) { + console.log(releases); +}); +``` + +* * * + +## getWithImageDetails +balena.models.release.getWithImageDetails(commitOrIdOrRawVersion, [options]) ⇒ Promise + +This method does not map exactly to the underlying model: it runs a +larger prebuilt query, and reformats it into an easy to use and +understand format. If you want significantly more control, or to see the +raw model directly, use `release.get(id, options)` instead. + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Get a specific release with the details of the images built +**Access**: public +**Fulfil**: Object - release with image details + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

a map of extra pine options

+
[options.release]Boolean{}

extra pine options for releases

+
[options.image]Object{}

extra pine options for images

+
+ +**Example** +```js +balena.models.release.getWithImageDetails(123).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log(release); +}); +``` +**Example** +```js +balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } }) +.then(function(release) { + console.log(release.images[0].build_log); +}); +``` + +* * * + +## setIsInvalidated +balena.models.release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Set the is_invalidated property of a release to true or false +**Access**: public +**Fulfil**: void + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
isInvalidatedBoolean

boolean value, true for invalidated, false for validated

+
+ +**Example** +```js +balena.models.release.setIsInvalidated(123, true).then(function() { + console.log('invalidated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', true).then(function() { + console.log('invalidated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) { + console.log('invalidated!); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated(123, false).then(function() { + console.log('validated!'); +}); +``` +**Example** +```js +balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', false).then(function() { + console.log('validated!'); +}); +``` + +* * * + +## setKnownIssueList +balena.models.release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Add a known issue list to a release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
knownIssueListOrNullString | null

the known issue list

+
+ +**Example** +```js +balena.models.release.setKnownIssueList('7cf02a69e4d34c9da573914963cf54fd', 'This is an issue'); +``` +**Example** +```js +balena.models.release.setKnownIssueList(123, 'This is an issue'); +``` +**Example** +```js +balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue'); +``` + +* * * + +## setNote +balena.models.release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ Promise + +**Kind**: static method of [release](#balena.models.release) +**Summary**: Add a note to a release +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
noteOrNullString | null

the note

+
+ +**Example** +```js +balena.models.release.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note'); +``` +**Example** +```js +balena.models.release.setNote(123, 'My useful note'); +``` +**Example** +```js +balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note'); +``` + +* * * + +## asset +balena.models.release.asset : object + +**Kind**: static namespace of [release](#balena.models.release) + +* * * + +### download +balena.models.release.asset.download(id) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Download a release asset +**Access**: public +**Fulfil**: NodeJS.ReadableStream - download stream + + + + + + + + + + +
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
+ +**Example** +```js +balena.models.release.asset.download(123).then(function(stream) { + stream.pipe(fs.createWriteStream('logo.png')); +}); +``` +**Example** +```js +balena.models.release.asset.download({ + asset_key: 'logo.png', + release: 123 +}).then(function(stream) { + stream.pipe(fs.createWriteStream('logo.png')); +}); +``` + +* * * + +### get +balena.models.release.asset.get(id, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Get a specific release asset +**Access**: public +**Fulfil**: Object - release asset + + + + + + + + + + + + +
ParamTypeDefaultDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.asset.get(123).then(function(asset) { + console.log(asset); +}); +``` +**Example** +```js +balena.models.release.asset.get({ + asset_key: 'logo.png', + release: 123 +}).then(function(asset) { + console.log(asset); +}); +``` + +* * * + +### getAllByRelease +balena.models.release.asset.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Get all release assets for a release +**Access**: public +**Fulfil**: Object[] - release assets + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.asset.getAllByRelease(123).then(function(assets) { + console.log(assets); +}); +``` +**Example** +```js +balena.models.release.asset.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(assets) { + console.log(assets); +}); +``` +**Example** +```js +balena.models.release.asset.getAllByRelease({ application: 456, raw_version: '1.2.3' }).then(function(assets) { + console.log(assets); +}); +``` + +* * * + +### remove +balena.models.release.asset.remove(id) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Remove a release asset +**Access**: public + + + + + + + + + + +
ParamTypeDescription
idNumber | Object

release asset ID or object specifying the unique release & asset_key pair

+
+ +**Example** +```js +balena.models.release.asset.remove(123); +``` +**Example** +```js +balena.models.release.asset.remove({ + asset_key: 'logo.png', + release: 123 +}); +``` + +* * * + +### upload +balena.models.release.asset.upload(uploadParams, [options]) ⇒ Promise + +**Kind**: static method of [asset](#balena.models.release.asset) +**Summary**: Upload a release asset +**Access**: public +**Fulfil**: Object - uploaded release asset + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
uploadParamsObject

upload parameters

+
uploadParams.assetString | File

asset file path (string, Node.js only) or File object (Node.js & browser). For File objects, use new File([content], filename, {type: mimeType})

+
uploadParams.asset_keyString

unique key for the asset within the release

+
uploadParams.releaseNumber

release ID

+
[options]Object{}

upload options

+
[options.chunkSize]Number5242880

chunk size for multipart uploads (5MiB default)

+
[options.parallelUploads]Number5

number of parallel uploads for multipart

+
[options.overwrite]Booleanfalse

whether to overwrite existing asset

+
[options.onUploadProgress]function

callback for upload progress

+
+ +**Example** +```js +// Upload from file path (Node.js) +balena.models.release.asset.upload({ + asset: '/path/to/logo.png', + asset_key: 'logo.png', + release: 123 +}).then(function(asset) { + console.log('Asset uploaded:', asset); +}); +``` +**Example** +```js +// Upload with File API (Node.js and browser) +const content = Buffer.from('Hello, World!', 'utf-8'); +const file = new File([content], 'readme.txt', { type: 'text/plain' }); + +balena.models.release.asset.upload({ + asset: file, + asset_key: 'readme.txt', + release: 123 +}).then(function(asset) { + console.log('Asset uploaded:', asset); +}); +``` +**Example** +```js +// Upload large file with File API and progress tracking +const largeContent = new Uint8Array(10 * 1024 * 1024); // 10MB +const largeFile = new File([largeContent], 'data.bin', { type: 'application/octet-stream' }); + +balena.models.release.asset.upload({ + asset: largeFile, + asset_key: 'data.bin', + release: 123 +}, { + chunkSize: 5 * 1024 * 1024, // 5MB chunks + parallelUploads: 3, + onUploadProgress: function(progress) { + const percent = (progress.uploaded / progress.total * 100).toFixed(2); + console.log(`Upload progress: ${percent}%`); + } +}).then(function(asset) { + console.log('Large file uploaded:', asset); +}); +``` +**Example** +```js +// Browser: Upload file from input element +const fileInput = document.getElementById('fileInput'); +const file = fileInput.files[0]; // File object from input + +balena.models.release.asset.upload({ + asset: file, + asset_key: file.name, + release: 123 +}).then(function(asset) { + console.log('File uploaded from browser:', asset); +}); +``` +**Example** +```js +// Upload with overwrite option +balena.models.release.asset.upload({ + asset: '/path/to/logo.png', + asset_key: 'logo.png', + release: 123 +}, { + overwrite: true +}).then(function(asset) { + console.log('Asset uploaded/updated:', asset); +}); +``` + +* * * + +## tags +balena.models.release.tags : object + +**Kind**: static namespace of [release](#balena.models.release) + +* * * + +### getAllByApplication +balena.models.release.tags.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Get all release tags for an application +**Access**: public +**Fulfil**: Object[] - release tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByApplication(999999).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### getAllByRelease +balena.models.release.tags.getAllByRelease(commitOrIdOrRawVersion, [options]) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Get all release tags for a release +**Access**: public +**Fulfil**: Object[] - release tags + + + + + + + + + + + + +
ParamTypeDefaultDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.release.tags.getAllByRelease(123).then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) { + console.log(tags); +}); +``` +**Example** +```js +balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) { + console.log(tags); +}); +``` + +* * * + +### remove +balena.models.release.tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Remove a release tag +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
tagKeyString

tag key

+
+ +**Example** +```js +balena.models.release.tags.remove(123, 'EDITOR'); +``` +**Example** +```js +balena.models.release.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR'); +``` +**Example** +```js +balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR'); +``` + +* * * + +### set +balena.models.release.tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ Promise + +**Kind**: static method of [tags](#balena.models.release.tags) +**Summary**: Set a release tag +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
commitOrIdOrRawVersionString | Number | Object

release commit (string) or id (number) or an object with the unique application (number or string) & rawVersion (string) pair of the release

+
tagKeyString

tag key

+
valueString | undefined

tag value

+
+ +**Example** +```js +balena.models.release.tags.set(123, 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.release.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim'); +``` +**Example** +```js +balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim'); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/service.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/service.md new file mode 100644 index 0000000000..03d4f527e3 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/service.md @@ -0,0 +1,243 @@ +# service +balena.models.service : object + +**Kind**: static namespace + +* * * + +## getAllByApplication +balena.models.service.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [service](#balena.models.service) +**Summary**: Get all services from an application +**Access**: public +**Fulfil**: Object[] - services + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) { + console.log(services); +}); +``` +**Example** +```js +balena.models.service.getAllByApplication(123).then(function(services) { + console.log(services); +}); +``` + +* * * + +## var +balena.models.service.var : object + +**Kind**: static namespace of [service](#balena.models.service) + +* * * + +### get +balena.models.service.var.get(serviceIdOrNaturalKey, key) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get the value of a specific service variable +**Access**: public +**Fulfil**: String\|undefined - the variable value (or undefined) + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
+ +**Example** +```js +balena.models.service.var.get(999999, 'VAR').then(function(value) { + console.log(value); +}); +``` +**Example** +```js +balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) { + console.log(value); +}); +``` + +* * * + +### getAllByApplication +balena.models.service.var.getAllByApplication(slugOrUuidOrId, [options]) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get all service variables by application +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
slugOrUuidOrIdString | Number

application slug (string), uuid (string) or id (number)

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.service.var.getAllByApplication(999999).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### getAllByService +balena.models.service.var.getAllByService(serviceIdOrNaturalKey, [options]) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Get all variables for a service +**Access**: public +**Fulfil**: Object[] - service variables + + + + + + + + + + + + +
ParamTypeDefaultDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.service.var.getAllByService(999999).then(function(vars) { + console.log(vars); +}); +``` +**Example** +```js +balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) { + console.log(vars); +}); +``` + +* * * + +### remove +balena.models.service.var.remove(serviceIdOrNaturalKey, key) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Clear the value of a specific service variable +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
+ +**Example** +```js +balena.models.service.var.remove(999999, 'VAR').then(function() { + ... +}); +``` +**Example** +```js +balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() { + ... +}); +``` + +* * * + +### set +balena.models.service.var.set(serviceIdOrNaturalKey, key, value) ⇒ Promise + +**Kind**: static method of [var](#balena.models.service.var) +**Summary**: Set the value of a specific service variable +**Access**: public + + + + + + + + + + + + + + +
ParamTypeDescription
serviceIdOrNaturalKeyNumber | Object

service id (number) or appliation-service_name pair

+
keyString

variable name

+
valueString

variable value

+
+ +**Example** +```js +balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() { + ... +}); +``` +**Example** +```js +balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() { + ... +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/models/team.md b/pages/external-docs/sdk/node-sdk/v22.4.9/models/team.md new file mode 100644 index 0000000000..882fd8c89b --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/models/team.md @@ -0,0 +1,313 @@ +# team +balena.models.team : object + +**Kind**: static namespace + +* * * + +## create +balena.models.team.create(organizationSlugOrId, name) ⇒ Promise + +This method creates a new team. + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Creates a new Team +**Access**: public +**Fulfil**: Object - Team + + + + + + + + + + + + +
ParamTypeDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team will be part of.

+
nameString

Required: the name of the team that will be created.

+
+ +**Example** +```js +balena.models.team.create(1239948, 'MyTeam').then(function(team) { + console.log(team); +}); +``` +**Example** +```js +balena.models.team.create('myOrgHandle', 'MyTeam') +.then(function(team) { + console.log(team); +}); +``` + +* * * + +## get +balena.models.team.get(teamId, [options]) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Get a single Team +**Access**: public +**Fulfil**: Object - Team + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamIdNumber

team id (number).

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.get(123).then(function(team) { + console.log(team); +}); +``` + +* * * + +## getAllByOrganization +balena.models.team.getAllByOrganization(organizationSlugOrId, [options]) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Get all Teams of a specific Organization +**Access**: public +**Fulfil**: Object[] - Teams + + + + + + + + + + + + +
ParamTypeDefaultDescription
organizationSlugOrIdNumber

Required: the organization slug or id the team is part of.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.getAllByOrganization(123).then(function(teams) { + console.log(teams); +}); +``` +**Example** +```js +balena.models.team.getAllByOrganization('MyOrganizationHandle').then(function(teams) { + console.log(teams); +}); +``` + +* * * + +## remove +balena.models.team.remove(teamId) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Remove a Team +**Access**: public + + + + + + + + + + +
ParamTypeDescription
teamIdNumber

team id (number).

+
+ +**Example** +```js +balena.models.team.remove(123); +``` + +* * * + +## rename +balena.models.team.rename(teamId, newName) ⇒ Promise + +**Kind**: static method of [team](#balena.models.team) +**Summary**: Rename Team +**Access**: public + + + + + + + + + + + + +
ParamTypeDescription
teamIdNumber

team id (number)

+
newNameString

new team name (string)

+
+ +**Example** +```js +balena.models.team.rename(123, 'MyNewTeamName'); +``` + +* * * + +## applicationAccess +balena.models.team.applicationAccess : object + +**Kind**: static namespace of [team](#balena.models.team) + +* * * + +### get +balena.models.team.applicationAccess.get(teamApplicationAccessId, [options]) ⇒ Promise + +This method get specific team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Get team applications access +**Access**: public +**Fulfil**: Object - TeamApplicationAccess + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.applicationAccess.get(1239948).then(function(teamApplicationAccess) { + console.log(teamApplicationAccess); +}); +``` + +* * * + +### getAllByTeam +balena.models.team.applicationAccess.getAllByTeam(teamId, [options]) ⇒ Promise + +This method get all team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Get all team applications access +**Access**: public +**Fulfil**: Object[] - team application access + + + + + + + + + + + + +
ParamTypeDefaultDescription
teamIdNumber

Required: the team id.

+
[options]Object{}

extra pine options to use

+
+ +**Example** +```js +balena.models.team.applicationAccess.getAllByTeam(1239948).then(function(teamApplicationAccesses) { + console.log(teamApplicationAccesses); +}); +``` + +* * * + +### remove +balena.models.team.applicationAccess.remove(teamApplicationAccessId) ⇒ Promise + +This remove a team application access. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Remove team application access +**Access**: public +**Fulfil**: void + + + + + + + + + + +
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
+ +**Example** +```js +balena.models.team.remove(123).then(function(teams) { + console.log(teams); +}); +``` + +* * * + +### update +balena.models.team.applicationAccess.update(teamApplicationAccessId, roleName) ⇒ Promise + +This method update a team application access role. + +**Kind**: static method of [applicationAccess](#balena.models.team.applicationAccess) +**Summary**: Update team application access +**Access**: public +**Fulfil**: Object - TeamApplicationAccess + + + + + + + + + + + + +
ParamTypeDescription
teamApplicationAccessIdNumber

Required: the team application access id.

+
roleNameString

Required: The new role to assing (ApplicationMembershipRoles).

+
+ +**Example** +```js +balena.models.team.update(123, 'developer').then(function(teamApplicationAccess) { + console.log(teamApplicationAccess); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/pine.md b/pages/external-docs/sdk/node-sdk/v22.4.9/pine.md new file mode 100644 index 0000000000..edb6c4bdfc --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/pine.md @@ -0,0 +1,25 @@ +# pine +balena.pine : Object + +The pinejs-client instance used internally. This should not be necessary +in normal usage, but can be useful if you want to directly make pine +queries to the api for some resource that isn't directly supported +in the SDK. + +**Kind**: static member +**Summary**: Balena pine instance +**Access**: public +**Example** +```js +balena.pine.get({ + resource: 'release', + options: { + $count: { + $filter: { belongs_to__application: applicationId } + } + } +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/request.md b/pages/external-docs/sdk/node-sdk/v22.4.9/request.md new file mode 100644 index 0000000000..0ba55a90d6 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/request.md @@ -0,0 +1,17 @@ +# request +balena.request : Object + +The balena-request instance used internally. This should not be necessary +in normal usage, but can be useful if you want to make an API request directly, +using the same token and hooks as the SDK. + +**Kind**: static member +**Summary**: Balena request instance +**Access**: public +**Example** +```js +balena.request.send({ url: 'http://api.balena-cloud.com/ping' }); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/setSharedOptions.md b/pages/external-docs/sdk/node-sdk/v22.4.9/setSharedOptions.md new file mode 100644 index 0000000000..f2e444fc97 --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/setSharedOptions.md @@ -0,0 +1,68 @@ +# setSharedOptions +module:balena-sdk~setSharedOptions(options) + +Set options that are used by calls to `fromSharedOptions()`. +The options accepted are the same as those used in the main SDK factory function. +If you use this method, it should be called as soon as possible during app +startup and before any calls to `fromSharedOptions()` are made. + +**Kind**: inner function +**Summary**: Set shared default options +**Access**: public + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParamTypeDefaultDescription
optionsObject

The shared default options

+
[options.apiUrl]String'https://api.balena-cloud.com/'

the balena API url to use.

+
[options.builderUrl]String'https://builder.balena-cloud.com/'

the balena builder url to use.

+
[options.deviceUrlsBase]String'balena-devices.com'

the base balena device API url to use.

+
[options.requestLimit]Number

the number of requests per requestLimitInterval that the SDK should respect.

+
[options.requestLimitInterval]Number60000

the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute).

+
[options.retryRateLimitedRequests]Boolean | functionfalse

Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header.

+
    +
  • If false, rate-limited requests will not be retried, and the rate limit error will be propagated.
  • +
  • If true, all rate-limited requests will be retried after the duration specified by the Retry-After header.
  • +
  • If a function (retryAfterMs: number) => boolean is provided, it will be called with the retry duration in ms and the request will be retried only when true is returned.
  • +
+
[options.dataDirectory]String | False'$HOME/.balena'

ignored in the browser unless false, the directory where the user settings are stored, normally retrieved like require('balena-settings-client').get('dataDirectory'). Providing false creates an isolated in-memory instance.

+
[options.isBrowser]Boolean

the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global window value.

+
[options.debug]Boolean

when set will print some extra debug information.

+
+ +**Example** +```js +import { setSharedOptions } from 'balena-sdk'; +setSharedOptions({ + apiUrl: 'https://api.balena-cloud.com/', + builderUrl: 'https://builder.balena-cloud.com/', + isBrowser: true, +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/settings.md b/pages/external-docs/sdk/node-sdk/v22.4.9/settings.md new file mode 100644 index 0000000000..1bbc80552d --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/settings.md @@ -0,0 +1,52 @@ +# settings +balena.settings : object + +**Kind**: static namespace + +* * * + +## get +balena.settings.get([key]) ⇒ Promise + +**Kind**: static method of [settings](#balena.settings) +**Summary**: Get a single setting. **Only implemented in Node.js** +**Access**: public +**Fulfil**: \* - setting value + + + + + + + + + + +
ParamTypeDescription
[key]String

setting key

+
+ +**Example** +```js +balena.settings.get('apiUrl').then(function(apiUrl) { + console.log(apiUrl); +}); +``` + +* * * + +## getAll +balena.settings.getAll() ⇒ Promise + +**Kind**: static method of [settings](#balena.settings) +**Summary**: Get all settings **Only implemented in Node.js** +**Access**: public +**Fulfil**: Object - settings +**Example** +```js +balena.settings.getAll().then(function(settings) { + console.log(settings); +}); +``` + +* * * + diff --git a/pages/external-docs/sdk/node-sdk/v22.4.9/utils.md b/pages/external-docs/sdk/node-sdk/v22.4.9/utils.md new file mode 100644 index 0000000000..c8a5d1720c --- /dev/null +++ b/pages/external-docs/sdk/node-sdk/v22.4.9/utils.md @@ -0,0 +1,18 @@ +# utils +balena.utils : Object + +The utils instance offers some convenient features for clients. + +**Kind**: static member +**Summary**: Balena utils instance +**Access**: public +**Example** +```js +balena.utils.mergePineOptions( + { $expand: { device: { $select: ['id'] } } }, + { $expand: { device: { $select: ['name'] } } }, +); +``` + +* * * + diff --git a/tools/sync-external.js b/tools/sync-external.js index 253de55e37..24e8db3ae1 100755 --- a/tools/sync-external.js +++ b/tools/sync-external.js @@ -90,7 +90,7 @@ async function fetchContentFromGithub( // returns summary content for the files that were downloaded successfully async function downloadFolderFromGithub(repo, folderPath, ref, targetDir) { // Get the recursive tree manifest - const treeUrl = `https://api.github.com/repos/${repo}/git/trees/${ref}?recursive=1`; + const treeUrl = `https://api.github.com/repos/${repo}/git/trees/${encodeURIComponent('wikify-docs')}?recursive=1`; const response = await fetch(treeUrl, { headers: { @@ -174,7 +174,7 @@ async function downloadFolderFromGithub(repo, folderPath, ref, targetDir) { let summaryContent = ''; for (const file of files) { - const rawUrl = `https://raw.githubusercontent.com/${repo}/${ref}/${file.path}`; + const rawUrl = `https://raw.githubusercontent.com/${repo}/${encodeURIComponent('wikify-docs')}/${file.path}`; // These looks like `pages/foo/bar/fizz.md. They are the path within the repo but not the full path in the local directory const destLatter = file.path.split(folderPath)[1]; // This is the full local path, i.e. `/home/wsl/repos/docs/pages/foo/bar/fizz.md`