-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c625faf
commit bf1aed7
Showing
18 changed files
with
7,984 additions
and
0 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
...e-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/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,109 @@ | ||
# Azure MicrosoftAzureFleet client library for JavaScript | ||
|
||
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure MicrosoftAzureFleet client. | ||
|
||
|
||
|
||
[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/computefleet/arm-computefleet) | | ||
[Package (NPM)](https://www.npmjs.com/package/@azure/arm-computefleet) | | ||
[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-computefleet?view=azure-node-preview) | | ||
[Samples](https://github.com/Azure-Samples/azure-samples-js-management) | ||
|
||
## Getting started | ||
|
||
### Currently supported environments | ||
|
||
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) | ||
- Latest versions of Safari, Chrome, Edge and Firefox. | ||
|
||
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. | ||
|
||
### Prerequisites | ||
|
||
- An [Azure subscription][azure_sub]. | ||
|
||
### Install the `@azure/arm-computefleet` package | ||
|
||
Install the Azure MicrosoftAzureFleet client library for JavaScript with `npm`: | ||
|
||
```bash | ||
npm install @azure/arm-computefleet | ||
``` | ||
|
||
### Create and authenticate a `MicrosoftAzureFleet` | ||
|
||
To create a client object to access the Azure MicrosoftAzureFleet API, you will need the `endpoint` of your Azure MicrosoftAzureFleet resource and a `credential`. The Azure MicrosoftAzureFleet client can use Azure Active Directory credentials to authenticate. | ||
You can find the endpoint for your Azure MicrosoftAzureFleet resource in the [Azure Portal][azure_portal]. | ||
|
||
You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). | ||
|
||
To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: | ||
|
||
```bash | ||
npm install @azure/identity | ||
``` | ||
|
||
You will also need to **register a new AAD application and grant access to Azure MicrosoftAzureFleet** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). | ||
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`. | ||
|
||
For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). | ||
|
||
```javascript | ||
const { MicrosoftAzureFleet } = require("@azure/arm-computefleet"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. | ||
|
||
const subscriptionId = "00000000-0000-0000-0000-000000000000"; | ||
const client = new MicrosoftAzureFleet(new DefaultAzureCredential(), subscriptionId); | ||
|
||
// For client-side applications running in the browser, use this code instead: | ||
// const credential = new InteractiveBrowserCredential({ | ||
// tenantId: "<YOUR_TENANT_ID>", | ||
// clientId: "<YOUR_CLIENT_ID>" | ||
// }); | ||
// const client = new MicrosoftAzureFleet(credential, subscriptionId); | ||
``` | ||
|
||
|
||
### JavaScript Bundle | ||
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). | ||
|
||
## Key concepts | ||
|
||
### MicrosoftAzureFleet | ||
|
||
`MicrosoftAzureFleet` is the primary interface for developers using the Azure MicrosoftAzureFleet client library. Explore the methods on this client object to understand the different features of the Azure MicrosoftAzureFleet service that you can access. | ||
|
||
## 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). | ||
|
||
## Next steps | ||
|
||
Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library. | ||
|
||
## Contributing | ||
|
||
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. | ||
|
||
## Related projects | ||
|
||
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) | ||
|
||
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcomputefleet%2Farm-computefleet%2FREADME.png) | ||
|
||
[azure_cli]: https://docs.microsoft.com/cli/azure | ||
[azure_sub]: https://azure.microsoft.com/free/ | ||
[azure_sub]: https://azure.microsoft.com/free/ | ||
[azure_portal]: https://portal.azure.com | ||
[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity | ||
[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential |
18 changes: 18 additions & 0 deletions
18
...ce-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/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,18 @@ | ||
{ | ||
Check failure on line 1 in specification/azurefleet/resource-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/api-extractor.json Azure Pipelines / Swagger PrettierCheckspecification/azurefleet/resource-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/api-extractor.json#L1
|
||
"$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/arm-computefleet.d.ts" | ||
}, | ||
"messages": { | ||
"tsdocMessageReporting": { "default": { "logLevel": "none" } }, | ||
"extractorMessageReporting": { | ||
"ae-missing-release-tag": { "logLevel": "none" }, | ||
"ae-unresolved-link": { "logLevel": "none" } | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...resource-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/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,86 @@ | ||
{ | ||
Check failure on line 1 in specification/azurefleet/resource-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/package.json Azure Pipelines / Swagger PrettierCheckspecification/azurefleet/resource-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/package.json#L1
|
||
"name": "@azure/arm-computefleet", | ||
"sdk-type": "mgmt", | ||
"author": "Microsoft Corporation", | ||
"description": "A generated SDK for MicrosoftAzureFleet.", | ||
"version": "1.0.0-beta.1", | ||
"engines": { "node": ">=18.0.0" }, | ||
"dependencies": { | ||
"@azure/core-lro": "^2.5.4", | ||
"@azure/abort-controller": "^2.1.2", | ||
"@azure/core-paging": "^1.2.0", | ||
"@azure/core-client": "^1.7.0", | ||
"@azure/core-auth": "^1.6.0", | ||
"@azure/core-rest-pipeline": "^1.14.0", | ||
"tslib": "^2.2.0" | ||
}, | ||
"keywords": ["node", "azure", "typescript", "browser", "isomorphic"], | ||
"license": "MIT", | ||
"main": "./dist/index.js", | ||
"module": "./dist-esm/index.js", | ||
"types": "./types/arm-computefleet.d.ts", | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.31.1", | ||
"mkdirp": "^3.0.1", | ||
"typescript": "~5.5.3", | ||
"uglify-js": "^3.4.9", | ||
"rimraf": "^5.0.0", | ||
"dotenv": "^16.0.0", | ||
"@azure/dev-tool": "^1.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Azure/azure-sdk-for-js.git" | ||
}, | ||
"bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, | ||
"files": [ | ||
"dist/**/*.js", | ||
"dist/**/*.js.map", | ||
"dist/**/*.d.ts", | ||
"dist/**/*.d.ts.map", | ||
"dist-esm/**/*.js", | ||
"dist-esm/**/*.js.map", | ||
"dist-esm/**/*.d.ts", | ||
"dist-esm/**/*.d.ts.map", | ||
"src/**/*.ts", | ||
"README.md", | ||
"LICENSE", | ||
"tsconfig.json", | ||
"review/*", | ||
"CHANGELOG.md", | ||
"types/*" | ||
], | ||
"scripts": { | ||
"build": "npm run clean && tsc && dev-tool run bundle && npm run minify && mkdirp ./review && npm run extract-api", | ||
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", | ||
"prepack": "npm run build", | ||
"pack": "npm pack 2>&1", | ||
"extract-api": "dev-tool run extract-api", | ||
"lint": "echo skipped", | ||
"clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", | ||
"build:node": "echo skipped", | ||
"build:browser": "echo skipped", | ||
"build:test": "echo skipped", | ||
"build:samples": "echo skipped.", | ||
"check-format": "echo skipped", | ||
"execute:samples": "echo skipped", | ||
"format": "echo skipped", | ||
"test": "echo skipped", | ||
"test:node": "echo skipped", | ||
"test:browser": "echo skipped", | ||
"unit-test": "echo skipped", | ||
"unit-test:node": "echo skipped", | ||
"unit-test:browser": "echo skipped", | ||
"integration-test": "echo skipped", | ||
"integration-test:node": "echo skipped", | ||
"integration-test:browser": "echo skipped" | ||
}, | ||
"sideEffects": false, | ||
"//metadata": { | ||
"constantPaths": [ | ||
{ "path": "src/microsoftAzureFleet.ts", "prefix": "packageDetails" } | ||
] | ||
}, | ||
"autoPublish": true, | ||
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/computefleet/arm-computefleet" | ||
} |
5 changes: 5 additions & 0 deletions
5
...resource-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/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,5 @@ | ||
/// <reference lib="esnext.asynciterable" /> | ||
export { getContinuationToken } from "./pagingHelper"; | ||
export * from "./models"; | ||
export { MicrosoftAzureFleet } from "./microsoftAzureFleet"; | ||
export * from "./operationsInterfaces"; |
34 changes: 34 additions & 0 deletions
34
...source-manager/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/src/lroImpl.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 { AbortSignalLike } from "@azure/abort-controller"; | ||
import { LongRunningOperation, LroResponse } from "@azure/core-lro"; | ||
|
||
export function createLroSpec<T>(inputs: { | ||
sendOperationFn: (args: any, spec: any) => Promise<LroResponse<T>>; | ||
args: Record<string, unknown>; | ||
spec: { | ||
readonly requestBody?: unknown; | ||
readonly path?: string; | ||
readonly httpMethod: string; | ||
} & Record<string, any>; | ||
}): LongRunningOperation<T> { | ||
const { args, spec, sendOperationFn } = inputs; | ||
return { | ||
requestMethod: spec.httpMethod, | ||
requestPath: spec.path!, | ||
sendInitialRequest: () => sendOperationFn(args, spec), | ||
sendPollRequest: ( | ||
path: string, | ||
options?: { abortSignal?: AbortSignalLike }, | ||
) => { | ||
const { requestBody, ...restSpec } = spec; | ||
return sendOperationFn(args, { | ||
...restSpec, | ||
httpMethod: "GET", | ||
path, | ||
abortSignal: options?.abortSignal, | ||
}); | ||
}, | ||
}; | ||
} |
135 changes: 135 additions & 0 deletions
135
...er/$(typescript-sdks-folder)/sdk/computefleet/arm-computefleet/src/microsoftAzureFleet.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,135 @@ | ||
import * as coreClient from "@azure/core-client"; | ||
import * as coreRestPipeline from "@azure/core-rest-pipeline"; | ||
import { | ||
PipelineRequest, | ||
PipelineResponse, | ||
SendRequest, | ||
} from "@azure/core-rest-pipeline"; | ||
import * as coreAuth from "@azure/core-auth"; | ||
import { OperationsImpl, FleetsImpl } from "./operations"; | ||
import { Operations, Fleets } from "./operationsInterfaces"; | ||
import { MicrosoftAzureFleetOptionalParams } from "./models"; | ||
|
||
export class MicrosoftAzureFleet extends coreClient.ServiceClient { | ||
$host: string; | ||
apiVersion: string; | ||
subscriptionId: string; | ||
|
||
/** | ||
* Initializes a new instance of the MicrosoftAzureFleet class. | ||
* @param credentials Subscription credentials which uniquely identify client subscription. | ||
* @param subscriptionId The ID of the target subscription. The value must be an UUID. | ||
* @param options The parameter options | ||
*/ | ||
constructor( | ||
credentials: coreAuth.TokenCredential, | ||
subscriptionId: string, | ||
options?: MicrosoftAzureFleetOptionalParams, | ||
) { | ||
if (credentials === undefined) { | ||
throw new Error("'credentials' cannot be null"); | ||
} | ||
if (subscriptionId === undefined) { | ||
throw new Error("'subscriptionId' cannot be null"); | ||
} | ||
|
||
// Initializing default values for options | ||
if (!options) { | ||
options = {}; | ||
} | ||
const defaults: MicrosoftAzureFleetOptionalParams = { | ||
requestContentType: "application/json; charset=utf-8", | ||
credential: credentials, | ||
}; | ||
|
||
const packageDetails = `azsdk-js-arm-computefleet/1.0.0-beta.1`; | ||
const userAgentPrefix = | ||
options.userAgentOptions && options.userAgentOptions.userAgentPrefix | ||
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` | ||
: `${packageDetails}`; | ||
|
||
const optionsWithDefaults = { | ||
...defaults, | ||
...options, | ||
userAgentOptions: { | ||
userAgentPrefix, | ||
}, | ||
endpoint: | ||
options.endpoint ?? options.baseUri ?? "https://management.azure.com", | ||
}; | ||
super(optionsWithDefaults); | ||
|
||
let bearerTokenAuthenticationPolicyFound: boolean = false; | ||
if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { | ||
const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = | ||
options.pipeline.getOrderedPolicies(); | ||
bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( | ||
(pipelinePolicy) => | ||
pipelinePolicy.name === | ||
coreRestPipeline.bearerTokenAuthenticationPolicyName, | ||
); | ||
} | ||
if ( | ||
!options || | ||
!options.pipeline || | ||
options.pipeline.getOrderedPolicies().length == 0 || | ||
!bearerTokenAuthenticationPolicyFound | ||
) { | ||
this.pipeline.removePolicy({ | ||
name: coreRestPipeline.bearerTokenAuthenticationPolicyName, | ||
}); | ||
this.pipeline.addPolicy( | ||
coreRestPipeline.bearerTokenAuthenticationPolicy({ | ||
credential: credentials, | ||
scopes: | ||
optionsWithDefaults.credentialScopes ?? | ||
`${optionsWithDefaults.endpoint}/.default`, | ||
challengeCallbacks: { | ||
authorizeRequestOnChallenge: | ||
coreClient.authorizeRequestOnClaimChallenge, | ||
}, | ||
}), | ||
); | ||
} | ||
// Parameter assignments | ||
this.subscriptionId = subscriptionId; | ||
|
||
// Assigning values to Constant parameters | ||
this.$host = options.$host || "https://management.azure.com"; | ||
this.apiVersion = options.apiVersion || "2024-11-01"; | ||
this.operations = new OperationsImpl(this); | ||
this.fleets = new FleetsImpl(this); | ||
this.addCustomApiVersionPolicy(options.apiVersion); | ||
} | ||
|
||
/** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ | ||
private addCustomApiVersionPolicy(apiVersion?: string) { | ||
if (!apiVersion) { | ||
return; | ||
} | ||
const apiVersionPolicy = { | ||
name: "CustomApiVersionPolicy", | ||
async sendRequest( | ||
request: PipelineRequest, | ||
next: SendRequest, | ||
): Promise<PipelineResponse> { | ||
const param = request.url.split("?"); | ||
if (param.length > 1) { | ||
const newParams = param[1].split("&").map((item) => { | ||
if (item.indexOf("api-version") > -1) { | ||
return "api-version=" + apiVersion; | ||
} else { | ||
return item; | ||
} | ||
}); | ||
request.url = param[0] + "?" + newParams.join("&"); | ||
} | ||
return next(request); | ||
}, | ||
}; | ||
this.pipeline.addPolicy(apiVersionPolicy); | ||
} | ||
|
||
operations: Operations; | ||
fleets: Fleets; | ||
} |
Oops, something went wrong.