Skip to content

Commit 25df857

Browse files
author
SDKAuto
committed
CodeGen from PR 3559 in test-repo-billy/azure-rest-api-specs
Merge 060e30d7a05928d0442267354fe4ccf0740e37ef into a1ece0d8092cbabd104c6a090519eb102db0c350
1 parent b90db00 commit 25df857

23 files changed

+3053
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2024 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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# AzureHealthInsights REST client library for JavaScript
2+
3+
Azure AI Health Insights provides an API that serves insight models, specific for Health & Life Sciences, that perform analysis and provide inferences to be used by a human.
4+
5+
**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
6+
7+
Key links:
8+
9+
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/health-insights-radiologyinsights)
10+
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/health-insights-radiologyinsights?view=azure-node-preview)
11+
12+
## Getting started
13+
14+
### Currently supported environments
15+
16+
- LTS versions of Node.js
17+
18+
### Prerequisites
19+
20+
- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package.
21+
22+
### Install the `@azure-rest/health-insights-radiologyinsights` package
23+
24+
Install the AzureHealthInsights REST client REST client library for JavaScript with `npm`:
25+
26+
```bash
27+
npm install @azure-rest/health-insights-radiologyinsights
28+
```
29+
30+
### Create and authenticate a `AzureHealthInsightsClient`
31+
32+
To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
33+
provide an instance of the desired credential type obtained from the
34+
[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
35+
36+
To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
37+
38+
After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use.
39+
As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
40+
can be used to authenticate the client.
41+
42+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
43+
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
44+
45+
## Troubleshooting
46+
47+
### Logging
48+
49+
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`:
50+
51+
```javascript
52+
const { setLogLevel } = require("@azure/logger");
53+
54+
setLogLevel("info");
55+
```
56+
57+
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).
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": "./dist/esm/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/health-insights-radiologyinsights.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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
2+
3+
export default [
4+
...azsdkEslint.configs.recommended,
5+
{
6+
rules: {
7+
"@azure/azure-sdk/ts-modules-only-named": "warn",
8+
"@azure/azure-sdk/ts-apiextractor-json-types": "warn",
9+
"@azure/azure-sdk/ts-package-json-types": "warn",
10+
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
11+
"@azure/azure-sdk/ts-package-json-module": "off",
12+
"@azure/azure-sdk/ts-package-json-files-required": "off",
13+
"@azure/azure-sdk/ts-package-json-main-is-cjs": "off",
14+
"tsdoc/syntax": "warn"
15+
}
16+
}
17+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"name": "@azure-rest/health-insights-radiologyinsights",
3+
"version": "1.0.0-beta.1",
4+
"description": "A generated SDK for AzureHealthInsightsClient.",
5+
"engines": {
6+
"node": ">=18.0.0"
7+
},
8+
"sideEffects": false,
9+
"autoPublish": false,
10+
"tshy": {
11+
"exports": {
12+
"./package.json": "./package.json",
13+
".": "./src/index.ts"
14+
},
15+
"dialects": [
16+
"esm",
17+
"commonjs"
18+
],
19+
"esmDialects": [
20+
"browser",
21+
"react-native"
22+
],
23+
"selfLink": false
24+
},
25+
"type": "module",
26+
"keywords": [
27+
"node",
28+
"azure",
29+
"cloud",
30+
"typescript",
31+
"browser",
32+
"isomorphic"
33+
],
34+
"author": "Microsoft Corporation",
35+
"license": "MIT",
36+
"files": [
37+
"dist",
38+
"README.md",
39+
"LICENSE",
40+
"review/*",
41+
"CHANGELOG.md"
42+
],
43+
"sdk-type": "client",
44+
"repository": "github:Azure/azure-sdk-for-js",
45+
"bugs": {
46+
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
47+
},
48+
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
49+
"//metadata": {
50+
"constantPaths": [
51+
{
52+
"path": "src/azureHealthInsightsClient.ts",
53+
"prefix": "userAgentInfo"
54+
}
55+
]
56+
},
57+
"dependencies": {
58+
"@azure-rest/core-client": "^2.1.0",
59+
"@azure/core-auth": "^1.6.0",
60+
"@azure/core-rest-pipeline": "^1.5.0",
61+
"@azure/logger": "^1.0.0",
62+
"tslib": "^2.6.2",
63+
"@azure/core-lro": "^3.0.0",
64+
"@azure/abort-controller": "^2.1.2"
65+
},
66+
"devDependencies": {
67+
"dotenv": "^16.0.0",
68+
"@microsoft/api-extractor": "^7.40.3",
69+
"@types/node": "^18.0.0",
70+
"eslint": "^8.55.0",
71+
"prettier": "^3.2.5",
72+
"rimraf": "^5.0.5",
73+
"mkdirp": "^3.0.1",
74+
"typescript": "~5.5.3",
75+
"tshy": "^1.11.1",
76+
"@azure/identity": "^4.2.1",
77+
"@vitest/browser": "^2.0.5",
78+
"@vitest/coverage-istanbul": "^2.0.5",
79+
"playwright": "^1.41.2",
80+
"vitest": "^2.0.5",
81+
"@azure-tools/test-credential": "^2.0.0",
82+
"@azure-tools/test-recorder": "^4.0.0",
83+
"@azure/dev-tool": "^1.0.0",
84+
"@azure/eslint-plugin-azure-sdk": "^3.0.0"
85+
},
86+
"scripts": {
87+
"clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
88+
"extract-api": "rimraf review && mkdirp ./review && dev-tool run extract-api",
89+
"pack": "npm pack 2>&1",
90+
"lint": "eslint package.json api-extractor.json src test",
91+
"lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]",
92+
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
93+
"unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser",
94+
"unit-test:node": "dev-tool run test:vitest",
95+
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
96+
"integration-test:browser": "echo skipped",
97+
"integration-test:node": "echo skipped",
98+
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
99+
"build:samples": "echo skipped",
100+
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ",
101+
"execute:samples": "echo skipped",
102+
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ",
103+
"generate:client": "echo skipped",
104+
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
105+
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js",
106+
"build:test": "npm run clean && tshy && dev-tool run build-test",
107+
"build": "npm run clean && tshy && mkdirp ./review && dev-tool run extract-api",
108+
"test:node": "npm run clean && tshy && npm run unit-test:node && npm run integration-test:node",
109+
"test": "npm run clean && tshy && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test"
110+
}
111+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
import { getClient, ClientOptions } from "@azure-rest/core-client";
5+
import { logger } from "./logger.js";
6+
import { TokenCredential, KeyCredential } from "@azure/core-auth";
7+
import { AzureHealthInsightsClient } from "./clientDefinitions.js";
8+
9+
/** The optional parameters for the client */
10+
export interface AzureHealthInsightsClientOptions extends ClientOptions {
11+
/** The api version option of the client */
12+
apiVersion?: string;
13+
}
14+
15+
/**
16+
* Initialize a new instance of `AzureHealthInsightsClient`
17+
* @param endpointParam - Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).
18+
* @param credentials - uniquely identify client credential
19+
* @param options - the parameter for all optional parameters
20+
*/
21+
export default function createClient(
22+
endpointParam: string,
23+
credentials: TokenCredential | KeyCredential,
24+
{
25+
apiVersion = "2024-08-01-preview",
26+
...options
27+
}: AzureHealthInsightsClientOptions = {},
28+
): AzureHealthInsightsClient {
29+
const endpointUrl =
30+
options.endpoint ?? options.baseUrl ?? `${endpointParam}/health-insights`;
31+
const userAgentInfo = `azsdk-js-health-insights-radiologyinsights-rest/1.0.0-beta.1`;
32+
const userAgentPrefix =
33+
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
34+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
35+
: `${userAgentInfo}`;
36+
options = {
37+
...options,
38+
userAgentOptions: {
39+
userAgentPrefix,
40+
},
41+
loggingOptions: {
42+
logger: options.loggingOptions?.logger ?? logger.info,
43+
},
44+
credentials: {
45+
scopes: options.credentials?.scopes ?? [
46+
"https://cognitiveservices.azure.com/.default",
47+
],
48+
apiKeyHeaderName:
49+
options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key",
50+
},
51+
};
52+
const client = getClient(
53+
endpointUrl,
54+
credentials,
55+
options,
56+
) as AzureHealthInsightsClient;
57+
58+
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
59+
client.pipeline.addPolicy({
60+
name: "ClientApiVersionPolicy",
61+
sendRequest: (req, next) => {
62+
// Use the apiVersion defined in request url directly
63+
// Append one if there is no apiVersion and we have one at client options
64+
const url = new URL(req.url);
65+
if (!url.searchParams.get("api-version") && apiVersion) {
66+
req.url = `${req.url}${
67+
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
68+
}api-version=${apiVersion}`;
69+
}
70+
71+
return next(req);
72+
},
73+
});
74+
75+
return client;
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
import { GetJobParameters, CreateJobParameters } from "./parameters.js";
5+
import {
6+
GetJob200Response,
7+
GetJobDefaultResponse,
8+
CreateJob200Response,
9+
CreateJob201Response,
10+
CreateJobDefaultResponse,
11+
} from "./responses.js";
12+
import { Client, StreamableMethod } from "@azure-rest/core-client";
13+
14+
export interface GetJob {
15+
/** Gets the status and details of the Radiology Insights job. */
16+
get(
17+
options?: GetJobParameters,
18+
): StreamableMethod<GetJob200Response | GetJobDefaultResponse>;
19+
/** Creates a Radiology Insights job with the given request body. */
20+
put(
21+
options: CreateJobParameters,
22+
): StreamableMethod<
23+
CreateJob200Response | CreateJob201Response | CreateJobDefaultResponse
24+
>;
25+
}
26+
27+
export interface Routes {
28+
/** Resource for '/radiology-insights/jobs/\{id\}' has methods for the following verbs: get, put */
29+
(path: "/radiology-insights/jobs/{id}", id: string): GetJob;
30+
}
31+
32+
export type AzureHealthInsightsClient = Client & {
33+
path: Routes;
34+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
import AzureHealthInsightsClient from "./azureHealthInsightsClient.js";
5+
6+
export * from "./azureHealthInsightsClient.js";
7+
export * from "./parameters.js";
8+
export * from "./responses.js";
9+
export * from "./clientDefinitions.js";
10+
export * from "./isUnexpected.js";
11+
export * from "./models.js";
12+
export * from "./outputModels.js";
13+
export * from "./pollingHelper.js";
14+
export * from "./serializeHelper.js";
15+
16+
export default AzureHealthInsightsClient;

0 commit comments

Comments
 (0)