forked from Azure/azure-sdk-for-js
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CodeGen from PR 30768 in Azure/azure-rest-api-specs
Merge f857628ff2d7bfaaefb117ed52ddcd5f082fdad0 into 139840784c38414085b3d799cee5545f9b6e8dec
- Loading branch information
SDKAuto
committed
Sep 27, 2024
1 parent
537dc7d
commit d59a199
Showing
23 changed files
with
3,053 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2024 Microsoft | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
57 changes: 57 additions & 0 deletions
57
sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# AzureHealthInsights REST client library for JavaScript | ||
|
||
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. | ||
|
||
**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** | ||
|
||
Key links: | ||
|
||
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/health-insights-radiologyinsights) | ||
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/health-insights-radiologyinsights?view=azure-node-preview) | ||
|
||
## Getting started | ||
|
||
### Currently supported environments | ||
|
||
- LTS versions of Node.js | ||
|
||
### Prerequisites | ||
|
||
- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package. | ||
|
||
### Install the `@azure-rest/health-insights-radiologyinsights` package | ||
|
||
Install the AzureHealthInsights REST client REST client library for JavaScript with `npm`: | ||
|
||
```bash | ||
npm install @azure-rest/health-insights-radiologyinsights | ||
``` | ||
|
||
### Create and authenticate a `AzureHealthInsightsClient` | ||
|
||
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), | ||
provide an instance of the desired credential type obtained from the | ||
[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library. | ||
|
||
To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity) | ||
|
||
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. | ||
As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential) | ||
can be used to authenticate the client. | ||
|
||
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: | ||
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET | ||
|
||
## Troubleshooting | ||
|
||
### Logging | ||
|
||
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`: | ||
|
||
```javascript | ||
const { setLogLevel } = require("@azure/logger"); | ||
|
||
setLogLevel("info"); | ||
``` | ||
|
||
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). |
31 changes: 31 additions & 0 deletions
31
sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/api-extractor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"mainEntryPointFilePath": "./dist/esm/index.d.ts", | ||
"docModel": { | ||
"enabled": true | ||
}, | ||
"apiReport": { | ||
"enabled": true, | ||
"reportFolder": "./review" | ||
}, | ||
"dtsRollup": { | ||
"enabled": true, | ||
"untrimmedFilePath": "", | ||
"publicTrimmedFilePath": "./types/health-insights-radiologyinsights.d.ts" | ||
}, | ||
"messages": { | ||
"tsdocMessageReporting": { | ||
"default": { | ||
"logLevel": "none" | ||
} | ||
}, | ||
"extractorMessageReporting": { | ||
"ae-missing-release-tag": { | ||
"logLevel": "none" | ||
}, | ||
"ae-unresolved-link": { | ||
"logLevel": "none" | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/eslint.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; | ||
|
||
export default [ | ||
...azsdkEslint.configs.recommended, | ||
{ | ||
rules: { | ||
"@azure/azure-sdk/ts-modules-only-named": "warn", | ||
"@azure/azure-sdk/ts-apiextractor-json-types": "warn", | ||
"@azure/azure-sdk/ts-package-json-types": "warn", | ||
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn", | ||
"@azure/azure-sdk/ts-package-json-module": "off", | ||
"@azure/azure-sdk/ts-package-json-files-required": "off", | ||
"@azure/azure-sdk/ts-package-json-main-is-cjs": "off", | ||
"tsdoc/syntax": "warn" | ||
} | ||
} | ||
]; |
111 changes: 111 additions & 0 deletions
111
sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
{ | ||
"name": "@azure-rest/health-insights-radiologyinsights", | ||
"version": "1.0.0-beta.1", | ||
"description": "A generated SDK for AzureHealthInsightsClient.", | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
"sideEffects": false, | ||
"autoPublish": false, | ||
"tshy": { | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": "./src/index.ts" | ||
}, | ||
"dialects": [ | ||
"esm", | ||
"commonjs" | ||
], | ||
"esmDialects": [ | ||
"browser", | ||
"react-native" | ||
], | ||
"selfLink": false | ||
}, | ||
"type": "module", | ||
"keywords": [ | ||
"node", | ||
"azure", | ||
"cloud", | ||
"typescript", | ||
"browser", | ||
"isomorphic" | ||
], | ||
"author": "Microsoft Corporation", | ||
"license": "MIT", | ||
"files": [ | ||
"dist", | ||
"README.md", | ||
"LICENSE", | ||
"review/*", | ||
"CHANGELOG.md" | ||
], | ||
"sdk-type": "client", | ||
"repository": "github:Azure/azure-sdk-for-js", | ||
"bugs": { | ||
"url": "https://github.com/Azure/azure-sdk-for-js/issues" | ||
}, | ||
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", | ||
"//metadata": { | ||
"constantPaths": [ | ||
{ | ||
"path": "src/azureHealthInsightsClient.ts", | ||
"prefix": "userAgentInfo" | ||
} | ||
] | ||
}, | ||
"dependencies": { | ||
"@azure-rest/core-client": "^2.1.0", | ||
"@azure/core-auth": "^1.6.0", | ||
"@azure/core-rest-pipeline": "^1.5.0", | ||
"@azure/logger": "^1.0.0", | ||
"tslib": "^2.6.2", | ||
"@azure/core-lro": "^3.0.0", | ||
"@azure/abort-controller": "^2.1.2" | ||
}, | ||
"devDependencies": { | ||
"dotenv": "^16.0.0", | ||
"@microsoft/api-extractor": "^7.40.3", | ||
"@types/node": "^18.0.0", | ||
"eslint": "^8.55.0", | ||
"prettier": "^3.2.5", | ||
"rimraf": "^5.0.5", | ||
"mkdirp": "^3.0.1", | ||
"typescript": "~5.5.3", | ||
"tshy": "^1.11.1", | ||
"@azure/identity": "^4.2.1", | ||
"@vitest/browser": "^2.0.5", | ||
"@vitest/coverage-istanbul": "^2.0.5", | ||
"playwright": "^1.41.2", | ||
"vitest": "^2.0.5", | ||
"@azure-tools/test-credential": "^2.0.0", | ||
"@azure-tools/test-recorder": "^4.0.0", | ||
"@azure/dev-tool": "^1.0.0", | ||
"@azure/eslint-plugin-azure-sdk": "^3.0.0" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", | ||
"extract-api": "rimraf review && mkdirp ./review && dev-tool run extract-api", | ||
"pack": "npm pack 2>&1", | ||
"lint": "eslint package.json api-extractor.json src test", | ||
"lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", | ||
"unit-test": "npm run unit-test:node && npm run unit-test:browser", | ||
"unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser", | ||
"unit-test:node": "dev-tool run test:vitest", | ||
"integration-test": "npm run integration-test:node && npm run integration-test:browser", | ||
"integration-test:browser": "echo skipped", | ||
"integration-test:node": "echo skipped", | ||
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", | ||
"build:samples": "echo skipped", | ||
"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}\" ", | ||
"execute:samples": "echo skipped", | ||
"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}\" ", | ||
"generate:client": "echo skipped", | ||
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", | ||
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", | ||
"build:test": "npm run clean && tshy && dev-tool run build-test", | ||
"build": "npm run clean && tshy && mkdirp ./review && dev-tool run extract-api", | ||
"test:node": "npm run clean && tshy && npm run unit-test:node && npm run integration-test:node", | ||
"test": "npm run clean && tshy && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test" | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...healthinsights/azurehealthinsightsradiologyinsights-rest/src/azureHealthInsightsClient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { getClient, ClientOptions } from "@azure-rest/core-client"; | ||
import { logger } from "./logger.js"; | ||
import { TokenCredential, KeyCredential } from "@azure/core-auth"; | ||
import { AzureHealthInsightsClient } from "./clientDefinitions.js"; | ||
|
||
/** The optional parameters for the client */ | ||
export interface AzureHealthInsightsClientOptions extends ClientOptions { | ||
/** The api version option of the client */ | ||
apiVersion?: string; | ||
} | ||
|
||
/** | ||
* Initialize a new instance of `AzureHealthInsightsClient` | ||
* @param endpointParam - Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). | ||
* @param credentials - uniquely identify client credential | ||
* @param options - the parameter for all optional parameters | ||
*/ | ||
export default function createClient( | ||
endpointParam: string, | ||
credentials: TokenCredential | KeyCredential, | ||
{ | ||
apiVersion = "2024-04-01", | ||
...options | ||
}: AzureHealthInsightsClientOptions = {}, | ||
): AzureHealthInsightsClient { | ||
const endpointUrl = | ||
options.endpoint ?? options.baseUrl ?? `${endpointParam}/health-insights`; | ||
const userAgentInfo = `azsdk-js-health-insights-radiologyinsights-rest/1.0.0-beta.1`; | ||
const userAgentPrefix = | ||
options.userAgentOptions && options.userAgentOptions.userAgentPrefix | ||
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` | ||
: `${userAgentInfo}`; | ||
options = { | ||
...options, | ||
userAgentOptions: { | ||
userAgentPrefix, | ||
}, | ||
loggingOptions: { | ||
logger: options.loggingOptions?.logger ?? logger.info, | ||
}, | ||
credentials: { | ||
scopes: options.credentials?.scopes ?? [ | ||
"https://cognitiveservices.azure.com/.default", | ||
], | ||
apiKeyHeaderName: | ||
options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key", | ||
}, | ||
}; | ||
const client = getClient( | ||
endpointUrl, | ||
credentials, | ||
options, | ||
) as AzureHealthInsightsClient; | ||
|
||
client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); | ||
client.pipeline.addPolicy({ | ||
name: "ClientApiVersionPolicy", | ||
sendRequest: (req, next) => { | ||
// Use the apiVersion defined in request url directly | ||
// Append one if there is no apiVersion and we have one at client options | ||
const url = new URL(req.url); | ||
if (!url.searchParams.get("api-version") && apiVersion) { | ||
req.url = `${req.url}${ | ||
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" | ||
}api-version=${apiVersion}`; | ||
} | ||
|
||
return next(req); | ||
}, | ||
}); | ||
|
||
return client; | ||
} |
34 changes: 34 additions & 0 deletions
34
sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/clientDefinitions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { GetJobParameters, CreateJobParameters } from "./parameters.js"; | ||
import { | ||
GetJob200Response, | ||
GetJobDefaultResponse, | ||
CreateJob200Response, | ||
CreateJob201Response, | ||
CreateJobDefaultResponse, | ||
} from "./responses.js"; | ||
import { Client, StreamableMethod } from "@azure-rest/core-client"; | ||
|
||
export interface GetJob { | ||
/** Gets the status and details of the Radiology Insights job. */ | ||
get( | ||
options?: GetJobParameters, | ||
): StreamableMethod<GetJob200Response | GetJobDefaultResponse>; | ||
/** Creates a Radiology Insights job with the given request body. */ | ||
put( | ||
options: CreateJobParameters, | ||
): StreamableMethod< | ||
CreateJob200Response | CreateJob201Response | CreateJobDefaultResponse | ||
>; | ||
} | ||
|
||
export interface Routes { | ||
/** Resource for '/radiology-insights/jobs/\{id\}' has methods for the following verbs: get, put */ | ||
(path: "/radiology-insights/jobs/{id}", id: string): GetJob; | ||
} | ||
|
||
export type AzureHealthInsightsClient = Client & { | ||
path: Routes; | ||
}; |
16 changes: 16 additions & 0 deletions
16
sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import AzureHealthInsightsClient from "./azureHealthInsightsClient.js"; | ||
|
||
export * from "./azureHealthInsightsClient.js"; | ||
export * from "./parameters.js"; | ||
export * from "./responses.js"; | ||
export * from "./clientDefinitions.js"; | ||
export * from "./isUnexpected.js"; | ||
export * from "./models.js"; | ||
export * from "./outputModels.js"; | ||
export * from "./pollingHelper.js"; | ||
export * from "./serializeHelper.js"; | ||
|
||
export default AzureHealthInsightsClient; |
Oops, something went wrong.