Skip to content

Commit a95bf28

Browse files
authored
device update release (Azure#19728)
1 parent 99f2b37 commit a95bf28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+6049
-69
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 119 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rush.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This is the main configuration file for Rush.
33
* For full documentation, please see https://rushjs.io
4-
*/{
4+
*/ {
55
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json",
66
/**
77
* (Required) This specifies the version of the Rush engine to be used in this repo.
@@ -666,6 +666,11 @@
666666
"projectFolder": "sdk/synapse/synapse-access-control-rest",
667667
"versionPolicyName": "client"
668668
},
669+
{
670+
"packageName": "@azure-rest/iot-device-update",
671+
"projectFolder": "sdk/deviceupdate/iot-device-update-rest",
672+
"versionPolicyName": "client"
673+
},
669674
{
670675
"packageName": "@azure/synapse-artifacts",
671676
"projectFolder": "sdk/synapse/synapse-artifacts",

sdk/deviceupdate/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ pr:
2424
extends:
2525
template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml
2626
parameters:
27+
TestProxy: true
2728
ServiceDirectory: deviceupdate
2829
IncludeRelease: true
2930
Artifacts:
3031
- name: azure-iot-device-update
3132
safeName: azureiotdeviceupdate
33+
- name: azure-rest-iot-device-update
34+
safeName: azurerestiotdeviceupdate
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": ["@azure/azure-sdk"],
3+
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
4+
"rules": {
5+
"@azure/azure-sdk/ts-modules-only-named": "warn",
6+
"@azure/azure-sdk/ts-apiextractor-json-types": "warn",
7+
"@azure/azure-sdk/ts-package-json-types": "warn",
8+
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
9+
"tsdoc/syntax": "warn"
10+
}
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0-beta.1 (2022-1-10)
2+
3+
- Initial Release
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Microsoft
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Azure Device Update for IoT Hub Rest Client library for JavaScript
2+
3+
The library provides access to the Device Update for IoT Hub service that enables customers to publish updates for their IoT devices to the cloud, and then deploy these updates to their devices (approve updates to groups of devices managed and provisioned in IoT Hub).
4+
5+
**Please rely heavily on the [service's documentation][device_update_product_documentation] and our [REST client docs][rest_client] to use this library**
6+
7+
Key links:
8+
- [Source code][source_code]
9+
- [Package (NPM)][npm]
10+
- [API reference documentation][ref_docs]
11+
- [Product documentation][device_update_product_documentation]
12+
13+
## Getting started
14+
15+
### Currently supported environments
16+
17+
- Node.js version 14.x.x or higher
18+
19+
### Prerequisites
20+
21+
- Microsoft Azure Subscription: To call Microsoft Azure services, you need to create an [Azure subscription][azure_subscription]
22+
- Device Update for IoT Hub instance
23+
- Azure IoT Hub instance
24+
25+
### Install the `@azure-rest/iot-device-update` package
26+
27+
Install the Azure Iot Device Update client library for JavaScript with `npm`:
28+
29+
```bash
30+
npm install @azure-rest/iot-device-update
31+
```
32+
33+
### Create and authenticate a `DeviceUpdate`
34+
35+
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
36+
provide an instance of the desired credential type obtained from the
37+
[@azure/identity][azure_identity_credentials] library.
38+
39+
To authenticate with AAD, you must first `npm` install [`@azure/identity`][azure_identity_npm].
40+
41+
After installation, you can choose which type of [credential][azure_identity_credentials] from `@azure/identity` to use.
42+
As an example, [DefaultAzureCredential][default_azure_credential]
43+
can be used to authenticate the client:
44+
45+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
46+
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
47+
48+
Use the returned token credential to authenticate the client:
49+
50+
```typescript
51+
import DeviceUpdate from "@azure-rest/iot-device-update";
52+
import { DefaultAzureCredential } from "@azure/identity";
53+
const client = DeviceUpdate(
54+
"https://<my-instance-id>.api.adu.microsoft.com",
55+
new DefaultAzureCredential()
56+
);
57+
```
58+
59+
## Key concepts
60+
61+
### REST Client
62+
63+
This client is one of our REST clients. We highly recommend you read how to use a REST client [here][rest_client].
64+
65+
## Examples
66+
67+
The following section shows you how to initialize and authenticate your client, then get all devices.
68+
69+
- [Get All Devices](#get-all-devices "Get All Devices")
70+
71+
```typescript
72+
import DeviceUpdate from "@azure-rest/iot-device-update";
73+
import { DefaultAzureCredential } from "@azure/identity";
74+
75+
async function main() {
76+
console.log("== List devices ==");
77+
const client = DeviceUpdate(endpoint, new DefaultAzureCredential());
78+
79+
const result = await client
80+
.path("/deviceupdate/{instanceId}/management/devices", instanceId)
81+
.get();
82+
83+
console.log(result);
84+
}
85+
86+
main().catch(console.error);
87+
```
88+
89+
## Troubleshooting
90+
91+
### Logging
92+
93+
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
94+
95+
```javascript
96+
import { setLogLevel } from "@azure/logger";
97+
98+
setLogLevel("info");
99+
```
100+
101+
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
102+
103+
## Next steps
104+
105+
## Contributing
106+
107+
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
108+
109+
## Related projects
110+
111+
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
112+
113+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fdeviceupdate%2Fiot-device-update%2FREADME.png)
114+
115+
[device_update_product_documentation]: https://docs.microsoft.com/azure/iot-hub-device-update/
116+
[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md
117+
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/deviceupdate/iot-device-update-rest
118+
[npm]: https://www.npmjs.com/org/azure-rest
119+
[ref_docs]: https://azure.github.io/azure-sdk-for-js
120+
[azure_subscription]: https://azure.microsoft.com/free/
121+
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
122+
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials
123+
[azure_identity_npm]: https://www.npmjs.com/package/@azure/identity
124+
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
"mainEntryPointFilePath": "types/src/index.d.ts",
4+
"docModel": {
5+
"enabled": true
6+
},
7+
"apiReport": {
8+
"enabled": true,
9+
"reportFolder": "./review"
10+
},
11+
"dtsRollup": {
12+
"enabled": true,
13+
"untrimmedFilePath": "",
14+
"publicTrimmedFilePath": "./types/iot-device-update-rest.d.ts"
15+
},
16+
"messages": {
17+
"tsdocMessageReporting": {
18+
"default": {
19+
"logLevel": "none"
20+
}
21+
},
22+
"extractorMessageReporting": {
23+
"ae-missing-release-tag": {
24+
"logLevel": "none"
25+
},
26+
"ae-unresolved-link": {
27+
"logLevel": "none"
28+
}
29+
}
30+
}
31+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
4+
// https://github.com/karma-runner/karma-chrome-launcher
5+
process.env.CHROME_BIN = require("puppeteer").executablePath();
6+
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
7+
8+
require("dotenv").config();
9+
10+
module.exports = function (config) {
11+
config.set({
12+
// base path that will be used to resolve all patterns (eg. files, exclude)
13+
basePath: "./",
14+
15+
// frameworks to use
16+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
17+
frameworks: ["source-map-support", "mocha"],
18+
19+
plugins: [
20+
"karma-mocha",
21+
"karma-mocha-reporter",
22+
"karma-chrome-launcher",
23+
"karma-edge-launcher",
24+
"karma-firefox-launcher",
25+
"karma-ie-launcher",
26+
"karma-env-preprocessor",
27+
"karma-coverage",
28+
"karma-sourcemap-loader",
29+
"karma-junit-reporter",
30+
"karma-json-to-file-reporter",
31+
"karma-source-map-support",
32+
"karma-json-preprocessor",
33+
],
34+
35+
// list of files / patterns to load in the browser
36+
files: [
37+
"dist-test/index.browser.js",
38+
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
39+
],
40+
41+
// list of files / patterns to exclude
42+
exclude: [],
43+
44+
// preprocess matching files before serving them to the browser
45+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
46+
preprocessors: {
47+
"**/*.js": ["sourcemap", "env"],
48+
"recordings/browsers/**/*.json": ["json"],
49+
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
50+
// Preprocess source file to calculate code coverage, however this will make source file unreadable
51+
// "dist-test/index.js": ["coverage"]
52+
},
53+
54+
envPreprocessor: [
55+
"TEST_MODE",
56+
"ENDPOINT",
57+
"AZURE_CLIENT_SECRET",
58+
"AZURE_CLIENT_ID",
59+
"AZURE_TENANT_ID",
60+
"RECORDINGS_RELATIVE_PATH",
61+
],
62+
63+
// test results reporter to use
64+
// possible values: 'dots', 'progress'
65+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
66+
reporters: ["mocha", "coverage", "junit"],
67+
68+
coverageReporter: {
69+
// specify a common output directory
70+
dir: "coverage-browser/",
71+
reporters: [
72+
{ type: "json", subdir: ".", file: "coverage.json" },
73+
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
74+
{ type: "html", subdir: "html" },
75+
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
76+
],
77+
},
78+
79+
junitReporter: {
80+
outputDir: "", // results will be saved as $outputDir/$browserName.xml
81+
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
82+
suite: "", // suite will become the package name attribute in xml testsuite element
83+
useBrowserName: false, // add browser name to report and classes names
84+
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
85+
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
86+
properties: {}, // key value pair of properties to add to the <properties> section of the report
87+
},
88+
89+
// web server port
90+
port: 9876,
91+
92+
// enable / disable colors in the output (reporters and logs)
93+
colors: true,
94+
95+
// level of logging
96+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
97+
logLevel: config.LOG_INFO,
98+
99+
// enable / disable watching file and executing tests whenever any file changes
100+
autoWatch: false,
101+
102+
// --no-sandbox allows our tests to run in Linux without having to change the system.
103+
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
104+
browsers: ["ChromeHeadlessNoSandbox"],
105+
customLaunchers: {
106+
ChromeHeadlessNoSandbox: {
107+
base: "ChromeHeadless",
108+
flags: ["--no-sandbox", "--disable-web-security"],
109+
},
110+
},
111+
112+
// Continuous Integration mode
113+
// if true, Karma captures browsers, runs the tests and exits
114+
singleRun: false,
115+
116+
// Concurrency level
117+
// how many browser should be started simultaneous
118+
concurrency: 1,
119+
120+
browserNoActivityTimeout: 60000000,
121+
browserDisconnectTimeout: 10000,
122+
browserDisconnectTolerance: 3,
123+
124+
client: {
125+
mocha: {
126+
// change Karma's debug.html to the mocha web reporter
127+
reporter: "html",
128+
timeout: "600000",
129+
},
130+
},
131+
});
132+
};

0 commit comments

Comments
 (0)