diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 63826cc8e27d..70aa0be4a7b6 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -96,6 +96,7 @@ specifiers: '@rush-temp/arm-features': file:./projects/arm-features.tgz '@rush-temp/arm-fluidrelay': file:./projects/arm-fluidrelay.tgz '@rush-temp/arm-frontdoor': file:./projects/arm-frontdoor.tgz + '@rush-temp/arm-graphservices': file:./projects/arm-graphservices.tgz '@rush-temp/arm-hanaonazure': file:./projects/arm-hanaonazure.tgz '@rush-temp/arm-hardwaresecuritymodules': file:./projects/arm-hardwaresecuritymodules.tgz '@rush-temp/arm-hdinsight': file:./projects/arm-hdinsight.tgz @@ -427,6 +428,7 @@ dependencies: '@rush-temp/arm-features': file:projects/arm-features.tgz '@rush-temp/arm-fluidrelay': file:projects/arm-fluidrelay.tgz '@rush-temp/arm-frontdoor': file:projects/arm-frontdoor.tgz + '@rush-temp/arm-graphservices': file:projects/arm-graphservices.tgz '@rush-temp/arm-hanaonazure': file:projects/arm-hanaonazure.tgz '@rush-temp/arm-hardwaresecuritymodules': file:projects/arm-hardwaresecuritymodules.tgz '@rush-temp/arm-hdinsight': file:projects/arm-hdinsight.tgz @@ -3942,7 +3944,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.1.0-dev.20230306 + typescript: 5.1.0-dev.20230307 dev: false /ecdsa-sig-formatter/1.0.11: @@ -8659,8 +8661,8 @@ packages: hasBin: true dev: false - /typescript/5.1.0-dev.20230306: - resolution: {integrity: sha512-CqMT7nhnVNKfaT1giN+UjFUSqN2gBI17K8JoT+I1LgPU/G9oYypuG+91pz8Kjk/GW/BG685khZ0YfFrADj+KPQ==} + /typescript/5.1.0-dev.20230307: + resolution: {integrity: sha512-QoA4rJ5koT+JJk69FBwAF4vx446c5xPWlvgMrlz0E0SaGDpveCbK8DTpRmdxrZR4oVQ0VxMag1BGtZPtQtU+Jg==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -12092,6 +12094,36 @@ packages: - supports-color dev: false + file:projects/arm-graphservices.tgz: + resolution: {integrity: sha512-FGMQq6BOIpb01GiMS1PDpo/y17Bb9bxNSMVtLJRoORxpGlTgbpDWB+1o65n5kZ4P2Sda2DScSr+Oml3uXoC3kg==, tarball: file:projects/arm-graphservices.tgz} + name: '@rush-temp/arm-graphservices' + version: 0.0.0 + dependencies: + '@azure-tools/test-recorder': 2.0.0 + '@azure/identity': 2.1.0 + '@microsoft/api-extractor': 7.34.4_@types+node@14.18.37 + '@rollup/plugin-commonjs': 24.0.1_rollup@2.79.1 + '@rollup/plugin-json': 6.0.0_rollup@2.79.1 + '@rollup/plugin-multi-entry': 6.0.0_rollup@2.79.1 + '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.37 + chai: 4.3.7 + cross-env: 7.0.3 + dotenv: 16.0.3 + mkdirp: 2.1.5 + mocha: 7.2.0 + rimraf: 3.0.2 + rollup: 2.79.1 + rollup-plugin-sourcemaps: 0.6.3_uvqxrz6xmh6o32kxhfeqlqrt5q + tslib: 2.5.0 + typescript: 4.8.4 + uglify-js: 3.17.4 + transitivePeerDependencies: + - encoding + - supports-color + dev: false + file:projects/arm-hanaonazure.tgz: resolution: {integrity: sha512-1NSUUNIl576g7DAB1k8qytIsRfg6Cd9J239nnW50hrqt4i6cmLfj7Hn7eaiVgQ66GJ7iqCTUiKTMcowRm4lTDg==, tarball: file:projects/arm-hanaonazure.tgz} name: '@rush-temp/arm-hanaonazure' @@ -15210,7 +15242,7 @@ packages: dev: false file:projects/arm-voiceservices.tgz: - resolution: {integrity: sha512-UQzVM3QGOoF41oeKg9b+AVss67zUot4pmOyomomv5c8+fdG1UARwvbx2XHwgVrAMj9NtbvXrj/MDVkWcXZxYVQ==, tarball: file:projects/arm-voiceservices.tgz} + resolution: {integrity: sha512-DgQPVXmJi5u5/OroRBeaCgyimbuLN3qv2jxV6vLk3nYsPcGR6EYm/UgNrOTogjpMWyA+UOa7ZAi2KjMKld0NYA==, tarball: file:projects/arm-voiceservices.tgz} name: '@rush-temp/arm-voiceservices' version: 0.0.0 dependencies: @@ -15235,7 +15267,6 @@ packages: typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - encoding - supports-color dev: false diff --git a/rush.json b/rush.json index aae5d2cf38ac..6b5ce4b93172 100644 --- a/rush.json +++ b/rush.json @@ -1932,6 +1932,11 @@ "packageName": "@azure/arm-voiceservices", "projectFolder": "sdk/voiceservices/arm-voiceservices", "versionPolicyName": "management" + }, + { + "packageName": "@azure/arm-graphservices", + "projectFolder": "sdk/graphservices/arm-graphservices", + "versionPolicyName": "management" } ] } \ No newline at end of file diff --git a/sdk/graphservices/arm-graphservices/CHANGELOG.md b/sdk/graphservices/arm-graphservices/CHANGELOG.md new file mode 100644 index 000000000000..e126f3bf99d0 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2023-03-08) + +The package of @azure/arm-graphservices is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart). diff --git a/sdk/graphservices/arm-graphservices/LICENSE b/sdk/graphservices/arm-graphservices/LICENSE new file mode 100644 index 000000000000..3a1d9b6f24f7 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 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. \ No newline at end of file diff --git a/sdk/graphservices/arm-graphservices/README.md b/sdk/graphservices/arm-graphservices/README.md new file mode 100644 index 000000000000..81afb38d4d9e --- /dev/null +++ b/sdk/graphservices/arm-graphservices/README.md @@ -0,0 +1,109 @@ +# Azure GraphServices client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure GraphServices client. + +Self service experience for Microsoft Graph metered services + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/graphservices/arm-graphservices) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-graphservices) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-graphservices?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-graphservices` package + +Install the Azure GraphServices client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-graphservices +``` + +### Create and authenticate a `GraphServices` + +To create a client object to access the Azure GraphServices API, you will need the `endpoint` of your Azure GraphServices resource and a `credential`. The Azure GraphServices client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure GraphServices 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 GraphServices** 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 { GraphServices } = require("@azure/arm-graphservices"); +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 GraphServices(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new GraphServices(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 + +### GraphServices + +`GraphServices` is the primary interface for developers using the Azure GraphServices client library. Explore the methods on this client object to understand the different features of the Azure GraphServices 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%2Fgraphservices%2Farm-graphservices%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 diff --git a/sdk/graphservices/arm-graphservices/_meta.json b/sdk/graphservices/arm-graphservices/_meta.json new file mode 100644 index 000000000000..1a94fdfff01e --- /dev/null +++ b/sdk/graphservices/arm-graphservices/_meta.json @@ -0,0 +1,8 @@ +{ + "commit": "120c2910613641e64e4a4bdf2dcf0cd5af9c7664", + "readme": "specification/graphservicesprod/resource-manager/readme.md", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/graphservicesprod/resource-manager/readme.md --use=@autorest/typescript@6.0.0-rc.9", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "release_tool": "@azure-tools/js-sdk-release-tools@2.6.2", + "use": "@autorest/typescript@6.0.0-rc.9" +} \ No newline at end of file diff --git a/sdk/graphservices/arm-graphservices/api-extractor.json b/sdk/graphservices/arm-graphservices/api-extractor.json new file mode 100644 index 000000000000..914b64eac6c8 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/arm-graphservices.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} \ No newline at end of file diff --git a/sdk/graphservices/arm-graphservices/package.json b/sdk/graphservices/arm-graphservices/package.json new file mode 100644 index 000000000000..ecc4dd8d6e37 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/package.json @@ -0,0 +1,115 @@ +{ + "name": "@azure/arm-graphservices", + "sdk-type": "mgmt", + "author": "Microsoft Corporation", + "description": "A generated SDK for GraphServices.", + "version": "1.0.0-beta.1", + "engines": { + "node": ">=14.0.0" + }, + "dependencies": { + "@azure/core-lro": "^2.5.0", + "@azure/abort-controller": "^1.0.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-client": "^1.7.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.8.0", + "tslib": "^2.2.0" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/arm-graphservices.d.ts", + "devDependencies": { + "@microsoft/api-extractor": "^7.31.1", + "@rollup/plugin-commonjs": "^24.0.0", + "@rollup/plugin-json": "^6.0.0", + "@rollup/plugin-multi-entry": "^6.0.0", + "@rollup/plugin-node-resolve": "^13.1.3", + "mkdirp": "^2.1.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", + "typescript": "~4.8.0", + "uglify-js": "^3.4.9", + "rimraf": "^3.0.0", + "dotenv": "^16.0.0", + "@azure/identity": "^2.0.1", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", + "mocha": "^7.1.1", + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.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", + "rollup.config.js", + "tsconfig.json", + "review/*", + "CHANGELOG.md", + "types/*" + ], + "scripts": { + "build": "npm run clean && tsc && rollup -c 2>&1 && 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": "api-extractor run --local", + "lint": "echo skipped", + "audit": "echo skipped", + "clean": "rimraf 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": "npm run integration-test", + "test:node": "echo skipped", + "test:browser": "echo skipped", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", + "unit-test:browser": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" + }, + "sideEffects": false, + "//metadata": { + "constantPaths": [ + { + "path": "src/graphServices.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/graphservices/arm-graphservices" +} \ No newline at end of file diff --git a/sdk/graphservices/arm-graphservices/review/arm-graphservices.api.md b/sdk/graphservices/arm-graphservices/review/arm-graphservices.api.md new file mode 100644 index 000000000000..9eb04331cec9 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/review/arm-graphservices.api.md @@ -0,0 +1,264 @@ +## API Report File for "@azure/arm-graphservices" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import * as coreAuth from '@azure/core-auth'; +import * as coreClient from '@azure/core-client'; +import { OperationState } from '@azure/core-lro'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { SimplePollerLike } from '@azure/core-lro'; + +// @public +export interface Account { + beginCreateAndUpdate(resourceGroupName: string, resourceName: string, accountResource: AccountResource, options?: AccountCreateAndUpdateOptionalParams): Promise, AccountCreateAndUpdateResponse>>; + beginCreateAndUpdateAndWait(resourceGroupName: string, resourceName: string, accountResource: AccountResource, options?: AccountCreateAndUpdateOptionalParams): Promise; + delete(resourceGroupName: string, resourceName: string, options?: AccountDeleteOptionalParams): Promise; + get(resourceGroupName: string, resourceName: string, options?: AccountGetOptionalParams): Promise; + update(resourceGroupName: string, resourceName: string, accountResource: AccountPatchResource, options?: AccountUpdateOptionalParams): Promise; +} + +// @public +export interface AccountCreateAndUpdateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type AccountCreateAndUpdateResponse = AccountResource; + +// @public +export interface AccountDeleteOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface AccountGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AccountGetResponse = AccountResource; + +// @public +export interface AccountPatchResource extends TagUpdate { +} + +// @public +export interface AccountResource extends Resource { + properties: AccountResourceProperties; + readonly systemData?: SystemData; +} + +// @public +export interface AccountResourceList { + nextLink?: string; + value?: AccountResource[]; +} + +// @public +export interface AccountResourceProperties { + applicationId: string; + readonly billingPlanId?: string; + readonly provisioningState?: ProvisioningState; +} + +// @public +export interface Accounts { + listByResourceGroup(resourceGroupName: string, options?: AccountsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; + listBySubscription(options?: AccountsListBySubscriptionOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface AccountsListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AccountsListByResourceGroupNextResponse = AccountResourceList; + +// @public +export interface AccountsListByResourceGroupOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AccountsListByResourceGroupResponse = AccountResourceList; + +// @public +export interface AccountsListBySubscriptionNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AccountsListBySubscriptionNextResponse = AccountResourceList; + +// @public +export interface AccountsListBySubscriptionOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AccountsListBySubscriptionResponse = AccountResourceList; + +// @public +export interface AccountUpdateOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AccountUpdateResponse = AccountResource; + +// @public +export type ActionType = string; + +// @public +export type CreatedByType = string; + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export function getContinuationToken(page: unknown): string | undefined; + +// @public (undocumented) +export class GraphServices extends coreClient.ServiceClient { + // (undocumented) + $host: string; + constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: GraphServicesOptionalParams); + // (undocumented) + account: Account; + // (undocumented) + accounts: Accounts; + // (undocumented) + apiVersion: string; + // (undocumented) + operationOperations: OperationOperations; + // (undocumented) + subscriptionId: string; +} + +// @public +export interface GraphServicesOptionalParams extends coreClient.ServiceClientOptions { + $host?: string; + apiVersion?: string; + endpoint?: string; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export interface OperationListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationListNextResponse = OperationListResult; + +// @public +export interface OperationListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationListResponse = OperationListResult; + +// @public +export interface OperationListResult { + readonly nextLink?: string; + readonly value?: Operation[]; +} + +// @public +export interface OperationOperations { + list(options?: OperationListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export type Origin = string; + +// @public +export type ProvisioningState = string; + +// @public +export interface Resource { + readonly id?: string; + location?: string; + readonly name?: string; + tags?: { + [propertyName: string]: string; + }; + readonly type?: string; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface TagUpdate { + tags?: { + [propertyName: string]: string; + }; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/graphservices/arm-graphservices/rollup.config.js b/sdk/graphservices/arm-graphservices/rollup.config.js new file mode 100644 index 000000000000..3f89d7309da5 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/rollup.config.js @@ -0,0 +1,122 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import nodeResolve from "@rollup/plugin-node-resolve"; +import cjs from "@rollup/plugin-commonjs"; +import sourcemaps from "rollup-plugin-sourcemaps"; +import multiEntry from "@rollup/plugin-multi-entry"; +import json from "@rollup/plugin-json"; + +import nodeBuiltins from "builtin-modules"; + +// #region Warning Handler + +/** + * A function that can determine whether a rollup warning should be ignored. If + * the function returns `true`, then the warning will not be displayed. + */ + +function ignoreNiseSinonEval(warning) { + return ( + warning.code === "EVAL" && + warning.id && + (warning.id.includes("node_modules/nise") || + warning.id.includes("node_modules/sinon")) === true + ); +} + +function ignoreChaiCircularDependency(warning) { + return ( + warning.code === "CIRCULAR_DEPENDENCY" && + warning.importer && warning.importer.includes("node_modules/chai") === true + ); +} + +const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval]; + +/** + * Construct a warning handler for the shared rollup configuration + * that ignores certain warnings that are not relevant to testing. + */ +function makeOnWarnForTesting() { + return (warning, warn) => { + // If every inhibitor returns false (i.e. no inhibitors), then show the warning + if (warningInhibitors.every((inhib) => !inhib(warning))) { + warn(warning); + } + }; +} + +// #endregion + +function makeBrowserTestConfig() { + const config = { + input: { + include: ["dist-esm/test/**/*.spec.js"], + exclude: ["dist-esm/test/**/node/**"] + }, + output: { + file: `dist-test/index.browser.js`, + format: "umd", + sourcemap: true + }, + preserveSymlinks: false, + plugins: [ + multiEntry({ exports: false }), + nodeResolve({ + mainFields: ["module", "browser"] + }), + cjs(), + json(), + sourcemaps() + //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) + ], + onwarn: makeOnWarnForTesting(), + // Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, + // rollup started respecting the "sideEffects" field in package.json. Since + // our package.json sets "sideEffects=false", this also applies to test + // code, which causes all tests to be removed by tree-shaking. + treeshake: false + }; + + return config; +} + +const defaultConfigurationOptions = { + disableBrowserBundle: false +}; + +export function makeConfig(pkg, options) { + options = { + ...defaultConfigurationOptions, + ...(options || {}) + }; + + const baseConfig = { + // Use the package's module field if it has one + input: pkg["module"] || "dist-esm/src/index.js", + external: [ + ...nodeBuiltins, + ...Object.keys(pkg.dependencies), + ...Object.keys(pkg.devDependencies) + ], + output: { file: "dist/index.js", format: "cjs", sourcemap: true }, + preserveSymlinks: false, + plugins: [sourcemaps(), nodeResolve()] + }; + + const config = [baseConfig]; + + if (!options.disableBrowserBundle) { + config.push(makeBrowserTestConfig()); + } + + return config; +} + +export default makeConfig(require("./package.json")); diff --git a/sdk/graphservices/arm-graphservices/sample.env b/sdk/graphservices/arm-graphservices/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/graphservices/arm-graphservices/src/graphServices.ts b/sdk/graphservices/arm-graphservices/src/graphServices.ts new file mode 100644 index 000000000000..1de88b93d883 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/graphServices.ts @@ -0,0 +1,148 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +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 { + AccountsImpl, + AccountImpl, + OperationOperationsImpl +} from "./operations"; +import { Accounts, Account, OperationOperations } from "./operationsInterfaces"; +import { GraphServicesOptionalParams } from "./models"; + +export class GraphServices extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + subscriptionId: string; + + /** + * Initializes a new instance of the GraphServices class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param subscriptionId The ID of the target subscription. + * @param options The parameter options + */ + constructor( + credentials: coreAuth.TokenCredential, + subscriptionId: string, + options?: GraphServicesOptionalParams + ) { + 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: GraphServicesOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; + + const packageDetails = `azsdk-js-arm-graphservices/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 || "2022-09-22-preview"; + this.accounts = new AccountsImpl(this); + this.account = new AccountImpl(this); + this.operationOperations = new OperationOperationsImpl(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 { + 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); + } + + accounts: Accounts; + account: Account; + operationOperations: OperationOperations; +} diff --git a/sdk/graphservices/arm-graphservices/src/index.ts b/sdk/graphservices/arm-graphservices/src/index.ts new file mode 100644 index 000000000000..32d7aa474b87 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +/// +export { getContinuationToken } from "./pagingHelper"; +export * from "./models"; +export { GraphServices } from "./graphServices"; +export * from "./operationsInterfaces"; diff --git a/sdk/graphservices/arm-graphservices/src/lroImpl.ts b/sdk/graphservices/arm-graphservices/src/lroImpl.ts new file mode 100644 index 000000000000..dd803cd5e28c --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/lroImpl.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// 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(inputs: { + sendOperationFn: (args: any, spec: any) => Promise>; + args: Record; + spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record; +}): LongRunningOperation { + 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 + }); + } + }; +} diff --git a/sdk/graphservices/arm-graphservices/src/models/index.ts b/sdk/graphservices/arm-graphservices/src/models/index.ts new file mode 100644 index 000000000000..bf50e6ae3181 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/models/index.ts @@ -0,0 +1,368 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; + +/** The list of accounts. */ +export interface AccountResourceList { + /** The link to the next page of items */ + nextLink?: string; + /** The list of recommendations. */ + value?: AccountResource[]; +} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + +/** Property bag from billing account */ +export interface AccountResourceProperties { + /** + * Provisioning state. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: ProvisioningState; + /** Customer owned application ID */ + applicationId: string; + /** + * Billing plan Id + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly billingPlanId?: string; +} + +/** An Azure resource. */ +export interface Resource { + /** + * Azure resource ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * Azure resource name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Azure resource type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** Location of the resource. */ + location?: string; + /** resource tags. */ + tags?: { [propertyName: string]: string }; +} + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +/** The error detail. */ +export interface ErrorDetail { + /** + * The error code. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly code?: string; + /** + * The error message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** + * The error target. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly target?: string; + /** + * The error details. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly details?: ErrorDetail[]; + /** + * The error additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** + * The additional info type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly info?: Record; +} + +/** Request payload used to update an existing resource's tags. */ +export interface TagUpdate { + /** List of key value pairs that describe the resource. This will overwrite the existing tags. */ + tags?: { [propertyName: string]: string }; +} + +/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ +export interface OperationListResult { + /** + * List of operations supported by the resource provider + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: Operation[]; + /** + * URL to get the next set of operation list results (if there are any). + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; +} + +/** Details of a REST API operation, returned from the Resource Provider Operations API */ +export interface Operation { + /** + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly isDataAction?: boolean; + /** Localized display information for this particular operation. */ + display?: OperationDisplay; + /** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly origin?: Origin; + /** + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly actionType?: ActionType; +} + +/** Localized display information for this particular operation. */ +export interface OperationDisplay { + /** + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provider?: string; + /** + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly resource?: string; + /** + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly operation?: string; + /** + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly description?: string; +} + +/** Account details */ +export interface AccountResource extends Resource { + /** + * Metadata pertaining to creation and last modification of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: SystemData; + /** Property bag from billing account */ + properties: AccountResourceProperties; +} + +/** Account patch properties */ +export interface AccountPatchResource extends TagUpdate {} + +/** Known values of {@link CreatedByType} that the service accepts. */ +export enum KnownCreatedByType { + /** User */ + User = "User", + /** Application */ + Application = "Application", + /** ManagedIdentity */ + ManagedIdentity = "ManagedIdentity", + /** Key */ + Key = "Key" +} + +/** + * Defines values for CreatedByType. \ + * {@link KnownCreatedByType} can be used interchangeably with CreatedByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User** \ + * **Application** \ + * **ManagedIdentity** \ + * **Key** + */ +export type CreatedByType = string; + +/** Known values of {@link ProvisioningState} that the service accepts. */ +export enum KnownProvisioningState { + /** Succeeded */ + Succeeded = "Succeeded", + /** Failed */ + Failed = "Failed", + /** Canceled */ + Canceled = "Canceled" +} + +/** + * Defines values for ProvisioningState. \ + * {@link KnownProvisioningState} can be used interchangeably with ProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded** \ + * **Failed** \ + * **Canceled** + */ +export type ProvisioningState = string; + +/** Known values of {@link Origin} that the service accepts. */ +export enum KnownOrigin { + /** User */ + User = "user", + /** System */ + System = "system", + /** UserSystem */ + UserSystem = "user,system" +} + +/** + * Defines values for Origin. \ + * {@link KnownOrigin} can be used interchangeably with Origin, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **user** \ + * **system** \ + * **user,system** + */ +export type Origin = string; + +/** Known values of {@link ActionType} that the service accepts. */ +export enum KnownActionType { + /** Internal */ + Internal = "Internal" +} + +/** + * Defines values for ActionType. \ + * {@link KnownActionType} can be used interchangeably with ActionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Internal** + */ +export type ActionType = string; + +/** Optional parameters. */ +export interface AccountsListByResourceGroupOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceGroup operation. */ +export type AccountsListByResourceGroupResponse = AccountResourceList; + +/** Optional parameters. */ +export interface AccountsListBySubscriptionOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listBySubscription operation. */ +export type AccountsListBySubscriptionResponse = AccountResourceList; + +/** Optional parameters. */ +export interface AccountsListByResourceGroupNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceGroupNext operation. */ +export type AccountsListByResourceGroupNextResponse = AccountResourceList; + +/** Optional parameters. */ +export interface AccountsListBySubscriptionNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listBySubscriptionNext operation. */ +export type AccountsListBySubscriptionNextResponse = AccountResourceList; + +/** Optional parameters. */ +export interface AccountGetOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type AccountGetResponse = AccountResource; + +/** Optional parameters. */ +export interface AccountCreateAndUpdateOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the createAndUpdate operation. */ +export type AccountCreateAndUpdateResponse = AccountResource; + +/** Optional parameters. */ +export interface AccountUpdateOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the update operation. */ +export type AccountUpdateResponse = AccountResource; + +/** Optional parameters. */ +export interface AccountDeleteOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface OperationListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type OperationListResponse = OperationListResult; + +/** Optional parameters. */ +export interface OperationListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type OperationListNextResponse = OperationListResult; + +/** Optional parameters. */ +export interface GraphServicesOptionalParams + extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/graphservices/arm-graphservices/src/models/mappers.ts b/sdk/graphservices/arm-graphservices/src/models/mappers.ts new file mode 100644 index 000000000000..87e7bc3866dd --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/models/mappers.ts @@ -0,0 +1,420 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; + +export const AccountResourceList: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AccountResourceList", + modelProperties: { + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + }, + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "AccountResource" + } + } + } + } + } + } +}; + +export const SystemData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SystemData", + modelProperties: { + createdBy: { + serializedName: "createdBy", + type: { + name: "String" + } + }, + createdByType: { + serializedName: "createdByType", + type: { + name: "String" + } + }, + createdAt: { + serializedName: "createdAt", + type: { + name: "DateTime" + } + }, + lastModifiedBy: { + serializedName: "lastModifiedBy", + type: { + name: "String" + } + }, + lastModifiedByType: { + serializedName: "lastModifiedByType", + type: { + name: "String" + } + }, + lastModifiedAt: { + serializedName: "lastModifiedAt", + type: { + name: "DateTime" + } + } + } + } +}; + +export const AccountResourceProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AccountResourceProperties", + modelProperties: { + provisioningState: { + serializedName: "provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + applicationId: { + constraints: { + Pattern: new RegExp( + "(^[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}?)$" + ) + }, + serializedName: "applicationId", + required: true, + type: { + name: "String" + } + }, + billingPlanId: { + constraints: { + Pattern: new RegExp( + "(^[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}?)$" + ) + }, + serializedName: "billingPlanId", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const Resource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Resource", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + location: { + serializedName: "location", + type: { + name: "String" + } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const ErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorDetail" + } + } + } + } +}; + +export const ErrorDetail: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorDetail", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + target: { + serializedName: "target", + readOnly: true, + type: { + name: "String" + } + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorDetail" + } + } + } + }, + additionalInfo: { + serializedName: "additionalInfo", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorAdditionalInfo" + } + } + } + } + } + } +}; + +export const ErrorAdditionalInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + modelProperties: { + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + info: { + serializedName: "info", + readOnly: true, + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const TagUpdate: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TagUpdate", + modelProperties: { + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const OperationListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationListResult", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const Operation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + isDataAction: { + serializedName: "isDataAction", + readOnly: true, + type: { + name: "Boolean" + } + }, + display: { + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplay" + } + }, + origin: { + serializedName: "origin", + readOnly: true, + type: { + name: "String" + } + }, + actionType: { + serializedName: "actionType", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const OperationDisplay: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationDisplay", + modelProperties: { + provider: { + serializedName: "provider", + readOnly: true, + type: { + name: "String" + } + }, + resource: { + serializedName: "resource", + readOnly: true, + type: { + name: "String" + } + }, + operation: { + serializedName: "operation", + readOnly: true, + type: { + name: "String" + } + }, + description: { + serializedName: "description", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const AccountResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AccountResource", + modelProperties: { + ...Resource.type.modelProperties, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "AccountResourceProperties" + } + } + } + } +}; + +export const AccountPatchResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AccountPatchResource", + modelProperties: { + ...TagUpdate.type.modelProperties + } + } +}; diff --git a/sdk/graphservices/arm-graphservices/src/models/parameters.ts b/sdk/graphservices/arm-graphservices/src/models/parameters.ts new file mode 100644 index 000000000000..1f58ec857eed --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/models/parameters.ts @@ -0,0 +1,127 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-client"; +import { + AccountResource as AccountResourceMapper, + AccountPatchResource as AccountPatchResourceMapper +} from "../models/mappers"; + +export const accept: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String" + } + } +}; + +export const $host: OperationURLParameter = { + parameterPath: "$host", + mapper: { + serializedName: "$host", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2022-09-22-preview", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const subscriptionId: OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + constraints: { + MinLength: 1 + }, + serializedName: "subscriptionId", + required: true, + type: { + name: "String" + } + } +}; + +export const resourceGroupName: OperationURLParameter = { + parameterPath: "resourceGroupName", + mapper: { + constraints: { + MaxLength: 90, + MinLength: 1 + }, + serializedName: "resourceGroupName", + required: true, + type: { + name: "String" + } + } +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const resourceName: OperationURLParameter = { + parameterPath: "resourceName", + mapper: { + serializedName: "resourceName", + required: true, + type: { + name: "String" + } + } +}; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const accountResource: OperationParameter = { + parameterPath: "accountResource", + mapper: AccountResourceMapper +}; + +export const accountResource1: OperationParameter = { + parameterPath: "accountResource", + mapper: AccountPatchResourceMapper +}; diff --git a/sdk/graphservices/arm-graphservices/src/operations/account.ts b/sdk/graphservices/arm-graphservices/src/operations/account.ts new file mode 100644 index 000000000000..1f5ef2c5bb6f --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/operations/account.ts @@ -0,0 +1,295 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { Account } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { GraphServices } from "../graphServices"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; +import { + AccountGetOptionalParams, + AccountGetResponse, + AccountResource, + AccountCreateAndUpdateOptionalParams, + AccountCreateAndUpdateResponse, + AccountPatchResource, + AccountUpdateOptionalParams, + AccountUpdateResponse, + AccountDeleteOptionalParams +} from "../models"; + +/** Class containing Account operations. */ +export class AccountImpl implements Account { + private readonly client: GraphServices; + + /** + * Initialize a new instance of the class Account class. + * @param client Reference to the service client + */ + constructor(client: GraphServices) { + this.client = client; + } + + /** + * Returns account resource for a given name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + resourceName: string, + options?: AccountGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, resourceName, options }, + getOperationSpec + ); + } + + /** + * Create or update account resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @param options The options parameters. + */ + async beginCreateAndUpdate( + resourceGroupName: string, + resourceName: string, + accountResource: AccountResource, + options?: AccountCreateAndUpdateOptionalParams + ): Promise< + SimplePollerLike< + OperationState, + AccountCreateAndUpdateResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperationFn = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ) => { + let currentRawResponse: + | coreClient.FullOperationResponse + | undefined = undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback + } + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON() + } + }; + }; + + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, resourceName, accountResource, options }, + spec: createAndUpdateOperationSpec + }); + const poller = await createHttpPoller< + AccountCreateAndUpdateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: "azure-async-operation" + }); + await poller.poll(); + return poller; + } + + /** + * Create or update account resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @param options The options parameters. + */ + async beginCreateAndUpdateAndWait( + resourceGroupName: string, + resourceName: string, + accountResource: AccountResource, + options?: AccountCreateAndUpdateOptionalParams + ): Promise { + const poller = await this.beginCreateAndUpdate( + resourceGroupName, + resourceName, + accountResource, + options + ); + return poller.pollUntilDone(); + } + + /** + * Update account details. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @param options The options parameters. + */ + update( + resourceGroupName: string, + resourceName: string, + accountResource: AccountPatchResource, + options?: AccountUpdateOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, resourceName, accountResource, options }, + updateOperationSpec + ); + } + + /** + * Deletes a account resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param options The options parameters. + */ + delete( + resourceGroupName: string, + resourceName: string, + options?: AccountDeleteOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, resourceName, options }, + deleteOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const getOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AccountResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName + ], + headerParameters: [Parameters.accept], + serializer +}; +const createAndUpdateOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.AccountResource + }, + 201: { + bodyMapper: Mappers.AccountResource + }, + 202: { + bodyMapper: Mappers.AccountResource + }, + 204: { + bodyMapper: Mappers.AccountResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.accountResource, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const updateOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.AccountResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.accountResource1, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const deleteOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", + httpMethod: "DELETE", + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/graphservices/arm-graphservices/src/operations/accounts.ts b/sdk/graphservices/arm-graphservices/src/operations/accounts.ts new file mode 100644 index 000000000000..ceff731a8c6d --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/operations/accounts.ts @@ -0,0 +1,303 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { Accounts } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { GraphServices } from "../graphServices"; +import { + AccountResource, + AccountsListByResourceGroupNextOptionalParams, + AccountsListByResourceGroupOptionalParams, + AccountsListByResourceGroupResponse, + AccountsListBySubscriptionNextOptionalParams, + AccountsListBySubscriptionOptionalParams, + AccountsListBySubscriptionResponse, + AccountsListByResourceGroupNextResponse, + AccountsListBySubscriptionNextResponse +} from "../models"; + +/// +/** Class containing Accounts operations. */ +export class AccountsImpl implements Accounts { + private readonly client: GraphServices; + + /** + * Initialize a new instance of the class Accounts class. + * @param client Reference to the service client + */ + constructor(client: GraphServices) { + this.client = client; + } + + /** + * Returns list of accounts apps. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + public listByResourceGroup( + resourceGroupName: string, + options?: AccountsListByResourceGroupOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listByResourceGroupPagingAll(resourceGroupName, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); + } + }; + } + + private async *listByResourceGroupPagingPage( + resourceGroupName: string, + options?: AccountsListByResourceGroupOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: AccountsListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listByResourceGroupNext( + resourceGroupName, + continuationToken, + options + ); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listByResourceGroupPagingAll( + resourceGroupName: string, + options?: AccountsListByResourceGroupOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listByResourceGroupPagingPage( + resourceGroupName, + options + )) { + yield* page; + } + } + + /** + * Returns list of accounts belonging to a subscription. + * @param options The options parameters. + */ + public listBySubscription( + options?: AccountsListBySubscriptionOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listBySubscriptionPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listBySubscriptionPagingPage(options, settings); + } + }; + } + + private async *listBySubscriptionPagingPage( + options?: AccountsListBySubscriptionOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: AccountsListBySubscriptionResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBySubscription(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listBySubscriptionNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listBySubscriptionPagingAll( + options?: AccountsListBySubscriptionOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listBySubscriptionPagingPage(options)) { + yield* page; + } + } + + /** + * Returns list of accounts apps. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + private _listByResourceGroup( + resourceGroupName: string, + options?: AccountsListByResourceGroupOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, options }, + listByResourceGroupOperationSpec + ); + } + + /** + * Returns list of accounts belonging to a subscription. + * @param options The options parameters. + */ + private _listBySubscription( + options?: AccountsListBySubscriptionOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { options }, + listBySubscriptionOperationSpec + ); + } + + /** + * ListByResourceGroupNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. + * @param options The options parameters. + */ + private _listByResourceGroupNext( + resourceGroupName: string, + nextLink: string, + options?: AccountsListByResourceGroupNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, nextLink, options }, + listByResourceGroupNextOperationSpec + ); + } + + /** + * ListBySubscriptionNext + * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. + * @param options The options parameters. + */ + private _listBySubscriptionNext( + nextLink: string, + options?: AccountsListBySubscriptionNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listBySubscriptionNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listByResourceGroupOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AccountResourceList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName + ], + headerParameters: [Parameters.accept], + serializer +}; +const listBySubscriptionOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.GraphServices/accounts", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AccountResourceList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; +const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AccountResourceList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.nextLink + ], + headerParameters: [Parameters.accept], + serializer +}; +const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AccountResourceList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.nextLink + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/graphservices/arm-graphservices/src/operations/index.ts b/sdk/graphservices/arm-graphservices/src/operations/index.ts new file mode 100644 index 000000000000..db63b2eb9c1e --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/operations/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./accounts"; +export * from "./account"; +export * from "./operationOperations"; diff --git a/sdk/graphservices/arm-graphservices/src/operations/operationOperations.ts b/sdk/graphservices/arm-graphservices/src/operations/operationOperations.ts new file mode 100644 index 000000000000..a8a84b3ca4ef --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/operations/operationOperations.ts @@ -0,0 +1,149 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { OperationOperations } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { GraphServices } from "../graphServices"; +import { + Operation, + OperationListNextOptionalParams, + OperationListOptionalParams, + OperationListResponse, + OperationListNextResponse +} from "../models"; + +/// +/** Class containing OperationOperations operations. */ +export class OperationOperationsImpl implements OperationOperations { + private readonly client: GraphServices; + + /** + * Initialize a new instance of the class OperationOperations class. + * @param client Reference to the service client + */ + constructor(client: GraphServices) { + this.client = client; + } + + /** + * Returns list of operations. + * @param options The options parameters. + */ + public list( + options?: OperationListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); + } + }; + } + + private async *listPagingPage( + options?: OperationListOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: OperationListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listPagingAll( + options?: OperationListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * Returns list of operations. + * @param options The options parameters. + */ + private _list( + options?: OperationListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: OperationListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.GraphServices/operations", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/graphservices/arm-graphservices/src/operationsInterfaces/account.ts b/sdk/graphservices/arm-graphservices/src/operationsInterfaces/account.ts new file mode 100644 index 000000000000..7f7720a6e4ea --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/operationsInterfaces/account.ts @@ -0,0 +1,90 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { SimplePollerLike, OperationState } from "@azure/core-lro"; +import { + AccountGetOptionalParams, + AccountGetResponse, + AccountResource, + AccountCreateAndUpdateOptionalParams, + AccountCreateAndUpdateResponse, + AccountPatchResource, + AccountUpdateOptionalParams, + AccountUpdateResponse, + AccountDeleteOptionalParams +} from "../models"; + +/** Interface representing a Account. */ +export interface Account { + /** + * Returns account resource for a given name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + resourceName: string, + options?: AccountGetOptionalParams + ): Promise; + /** + * Create or update account resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @param options The options parameters. + */ + beginCreateAndUpdate( + resourceGroupName: string, + resourceName: string, + accountResource: AccountResource, + options?: AccountCreateAndUpdateOptionalParams + ): Promise< + SimplePollerLike< + OperationState, + AccountCreateAndUpdateResponse + > + >; + /** + * Create or update account resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account details. + * @param options The options parameters. + */ + beginCreateAndUpdateAndWait( + resourceGroupName: string, + resourceName: string, + accountResource: AccountResource, + options?: AccountCreateAndUpdateOptionalParams + ): Promise; + /** + * Update account details. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param accountResource Account patch details. + * @param options The options parameters. + */ + update( + resourceGroupName: string, + resourceName: string, + accountResource: AccountPatchResource, + options?: AccountUpdateOptionalParams + ): Promise; + /** + * Deletes a account resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName The name of the resource. + * @param options The options parameters. + */ + delete( + resourceGroupName: string, + resourceName: string, + options?: AccountDeleteOptionalParams + ): Promise; +} diff --git a/sdk/graphservices/arm-graphservices/src/operationsInterfaces/accounts.ts b/sdk/graphservices/arm-graphservices/src/operationsInterfaces/accounts.ts new file mode 100644 index 000000000000..839f356dc462 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/operationsInterfaces/accounts.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + AccountResource, + AccountsListByResourceGroupOptionalParams, + AccountsListBySubscriptionOptionalParams +} from "../models"; + +/// +/** Interface representing a Accounts. */ +export interface Accounts { + /** + * Returns list of accounts apps. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + listByResourceGroup( + resourceGroupName: string, + options?: AccountsListByResourceGroupOptionalParams + ): PagedAsyncIterableIterator; + /** + * Returns list of accounts belonging to a subscription. + * @param options The options parameters. + */ + listBySubscription( + options?: AccountsListBySubscriptionOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/graphservices/arm-graphservices/src/operationsInterfaces/index.ts b/sdk/graphservices/arm-graphservices/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..db63b2eb9c1e --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/operationsInterfaces/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./accounts"; +export * from "./account"; +export * from "./operationOperations"; diff --git a/sdk/graphservices/arm-graphservices/src/operationsInterfaces/operationOperations.ts b/sdk/graphservices/arm-graphservices/src/operationsInterfaces/operationOperations.ts new file mode 100644 index 000000000000..4512d71bd7de --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/operationsInterfaces/operationOperations.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Operation, OperationListOptionalParams } from "../models"; + +/// +/** Interface representing a OperationOperations. */ +export interface OperationOperations { + /** + * Returns list of operations. + * @param options The options parameters. + */ + list( + options?: OperationListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/graphservices/arm-graphservices/src/pagingHelper.ts b/sdk/graphservices/arm-graphservices/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/graphservices/arm-graphservices/test/sampleTest.ts b/sdk/graphservices/arm-graphservices/test/sampleTest.ts new file mode 100644 index 000000000000..25aeb3ebcc36 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/test/sampleTest.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + Recorder, + RecorderStartOptions, + env +} from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { Context } from "mocha"; + +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/graphservices/arm-graphservices/tsconfig.json b/sdk/graphservices/arm-graphservices/tsconfig.json new file mode 100644 index 000000000000..3e6ae96443f3 --- /dev/null +++ b/sdk/graphservices/arm-graphservices/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es6", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": [ + "es6", + "dom" + ], + "declaration": true, + "outDir": "./dist-esm", + "importHelpers": true + }, + "include": [ + "./src/**/*.ts", + "./test/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/graphservices/ci.mgmt.yml b/sdk/graphservices/ci.mgmt.yml new file mode 100644 index 000000000000..ffb6943dfa83 --- /dev/null +++ b/sdk/graphservices/ci.mgmt.yml @@ -0,0 +1,38 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/graphservices/arm-graphservices + - sdk/graphservices/ci.mgmt.yml + +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/graphservices/arm-graphservices + - sdk/graphservices/ci.mgmt.yml + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: graphservices + Artifacts: + - name: azure-arm-graphservices + safeName: azurearmgraphservices + \ No newline at end of file