diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index d37dbec8470c..461649f9a616 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -10060,28 +10060,27 @@ packages: dev: false file:projects/arm-consumption.tgz: - resolution: {integrity: sha512-NQFxrW/D3odjtPrxLs6gwb+AyosrVpjGVmISx1HvJpfEs12cYKRWGNNYGnKdiv4vjyKW8RWrBEg4SP8duHVDGQ==, tarball: file:projects/arm-consumption.tgz} + resolution: {integrity: sha512-tdApnqzpk08PxZN4N99ntXSkGs1acCC4Rm5wnONfrpDsm00Df5Wh40TjYsOOHajivuzWMkq8S6rks0hjC+idBQ==, tarball: file:projects/arm-consumption.tgz} name: '@rush-temp/arm-consumption' version: 0.0.0 dependencies: '@azure-tools/test-recorder': 1.0.2 '@azure/identity': 2.0.4 - '@microsoft/api-extractor': 7.18.11 - '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 - '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 - '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 + '@microsoft/api-extractor': 7.22.1 + '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 + '@rollup/plugin-json': 4.1.0_rollup@1.32.1 + '@rollup/plugin-multi-entry': 3.0.1_rollup@1.32.1 + '@rollup/plugin-node-resolve': 8.4.0_rollup@1.32.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 - rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 + rollup: 1.32.1 + rollup-plugin-sourcemaps: 0.4.2_rollup@1.32.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: - - '@types/node' - debug - encoding - supports-color @@ -15021,7 +15020,7 @@ packages: dev: false file:projects/dtdl-parser.tgz: - resolution: {integrity: sha512-/Dpf2haY7btQZGQuvHBOvp+FV73jJdRtvEb9Iq2FlChhxnlxi3rnU+c5d3RiTER/V7CN2eTqZTmGqU81I5hofA==, tarball: file:projects/dtdl-parser.tgz} + resolution: {integrity: sha512-4fU57xg4ogr10JRjNfFZSQHD/efBKZZGYEsX6yLNQLr7d+v8DeUkBR6wL01Eu2X4BVVSWkhB+Hg+cgnbhlxQfg==, tarball: file:projects/dtdl-parser.tgz} name: '@rush-temp/dtdl-parser' version: 0.0.0 dependencies: @@ -15468,7 +15467,7 @@ packages: dev: false file:projects/iot-device-update.tgz: - resolution: {integrity: sha512-eYZc1OhjpW+iMs7ckvpoPSXLSq0Z4otKFuEFl8wcsvlTyeqq/bjRElOHVmNwl4dtRw1fNy4DGQUdoH5aXsT17w==, tarball: file:projects/iot-device-update.tgz} + resolution: {integrity: sha512-qEzFrCUOGxmgQ19d6cFJDtwdEhlb6Dn9yYLO5yrMg8KYyH6hLQa5JaxVbgvfK6ZFneTaYVaLnEMiZzmzXMgZVg==, tarball: file:projects/iot-device-update.tgz} name: '@rush-temp/iot-device-update' version: 0.0.0 dependencies: @@ -15989,7 +15988,7 @@ packages: dev: false file:projects/opentelemetry-instrumentation-azure-sdk.tgz: - resolution: {integrity: sha512-Fe2F+/VXo+2tFHmXPDJLFMmhQOYnX5wSqu+TG6Msek9ViI1x/cL8DhW3LcMwUvw5ohysFX8QsTfd9OPKO1msaQ==, tarball: file:projects/opentelemetry-instrumentation-azure-sdk.tgz} + resolution: {integrity: sha512-rWiPsZxSnuYGdFux77mxyZBjJ1I9LgMWvb+x04sDyizzAp4495+V81pN9O+9btqu1hr72zKv/hNseMEpUEf31A==, tarball: file:projects/opentelemetry-instrumentation-azure-sdk.tgz} name: '@rush-temp/opentelemetry-instrumentation-azure-sdk' version: 0.0.0 dependencies: diff --git a/sdk/consumption/arm-consumption/CHANGELOG.md b/sdk/consumption/arm-consumption/CHANGELOG.md index 523754a9f6d8..6ceb0e5ba558 100644 --- a/sdk/consumption/arm-consumption/CHANGELOG.md +++ b/sdk/consumption/arm-consumption/CHANGELOG.md @@ -1,15 +1,21 @@ # Release History - -## 9.0.2 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 10.0.0 (2022-04-25) + +**Features** + + - Added operation LotsOperations.listByCustomer + - Added Interface LotsListByCustomerNextOptionalParams + - Added Interface LotsListByCustomerOptionalParams + - Added Type Alias LotsListByCustomerNextResponse + - Added Type Alias LotsListByCustomerResponse + - Type Alias LegacyUsageDetail has a new parameter benefitId + - Type Alias LegacyUsageDetail has a new parameter benefitName + +**Breaking Changes** + + - Interface BudgetFilter no longer has parameter not + ## 9.0.1 (2022-04-11) **features** diff --git a/sdk/consumption/arm-consumption/README.md b/sdk/consumption/arm-consumption/README.md index e4f6818d0901..0deee092228b 100644 --- a/sdk/consumption/arm-consumption/README.md +++ b/sdk/consumption/arm-consumption/README.md @@ -16,8 +16,6 @@ Consumption management client provides access to consumption resources for Azure - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -51,17 +49,8 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { ConsumptionManagementClient } = require("@azure/arm-consumption"); 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 ConsumptionManagementClient(new DefaultAzureCredential(), subscriptionId); - -// For client-side applications running in the browser, use this code instead: -// const credential = new InteractiveBrowserCredential({ -// tenantId: "", -// clientId: "" -// }); -// const client = new ConsumptionManagementClient(credential, subscriptionId); ``` diff --git a/sdk/consumption/arm-consumption/_meta.json b/sdk/consumption/arm-consumption/_meta.json index 422d27075fcf..c4902a3b8892 100644 --- a/sdk/consumption/arm-consumption/_meta.json +++ b/sdk/consumption/arm-consumption/_meta.json @@ -1,8 +1,8 @@ { - "commit": "82fdf284eea880a8e027c354911a814999a77178", - "readme": "specification\\consumption\\resource-manager\\readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\containerservice\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.18.20220329.1 --generate-sample=true", + "commit": "3f9dbfe11cd5d35b1a98815d20b340e636df0601", + "readme": "specification/consumption/resource-manager/readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --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/consumption/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20220105.1", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.2.1", - "use": "@autorest/typescript@6.0.0-alpha.18.20220329.1" -} + "release_tool": "@azure-tools/js-sdk-release-tools@2.3.0", + "use": "@autorest/typescript@6.0.0-alpha.16.20220105.1" +} \ No newline at end of file diff --git a/sdk/consumption/arm-consumption/package.json b/sdk/consumption/arm-consumption/package.json index aacd14c97e81..c1c409064ac6 100644 --- a/sdk/consumption/arm-consumption/package.json +++ b/sdk/consumption/arm-consumption/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for ConsumptionManagementClient.", - "version": "9.0.2", + "version": "10.0.0", "engines": { "node": ">=12.0.0" }, @@ -26,14 +26,14 @@ "module": "./dist-esm/src/index.js", "types": "./types/arm-consumption.d.ts", "devDependencies": { - "@microsoft/api-extractor": "7.18.11", - "@rollup/plugin-commonjs": "^21.0.1", - "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-multi-entry": "^4.1.0", - "@rollup/plugin-node-resolve": "^13.1.3", + "@microsoft/api-extractor": "^7.18.11", + "@rollup/plugin-commonjs": "11.0.2", + "@rollup/plugin-json": "^4.0.0", + "@rollup/plugin-multi-entry": "^3.0.0", + "@rollup/plugin-node-resolve": "^8.0.0", "mkdirp": "^1.0.4", - "rollup": "^2.66.1", - "rollup-plugin-sourcemaps": "^0.6.3", + "rollup": "^1.16.3", + "rollup-plugin-sourcemaps": "^0.4.2", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -96,21 +96,5 @@ "docs": "echo skipped" }, "sideEffects": false, - "//metadata": { - "constantPaths": [ - { - "path": "src/consumptionManagementClient.ts", - "prefix": "packageDetails" - } - ] - }, - "autoPublish": true, - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-consumption?view=azure-node-preview" - } -} + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/consumption/arm-consumption/review/arm-consumption.api.md b/sdk/consumption/arm-consumption/review/arm-consumption.api.md index ff700c3e0aac..d1ab26dba7b7 100644 --- a/sdk/consumption/arm-consumption/review/arm-consumption.api.md +++ b/sdk/consumption/arm-consumption/review/arm-consumption.api.md @@ -120,7 +120,6 @@ export interface BudgetComparisonExpression { export interface BudgetFilter { and?: BudgetFilterProperties[]; dimensions?: BudgetComparisonExpression; - not?: BudgetFilterProperties; tags?: BudgetComparisonExpression; } @@ -746,6 +745,8 @@ export type LegacyUsageDetail = UsageDetail & { readonly chargeType?: string; readonly frequency?: string; readonly payGPrice?: number; + readonly benefitId?: string; + readonly benefitName?: string; readonly pricingModel?: PricingModelType; }; @@ -788,10 +789,27 @@ export interface LotsListByBillingProfileOptionalParams extends coreClient.Opera // @public export type LotsListByBillingProfileResponse = Lots; +// @public +export interface LotsListByCustomerNextOptionalParams extends coreClient.OperationOptions { + filter?: string; +} + +// @public +export type LotsListByCustomerNextResponse = Lots; + +// @public +export interface LotsListByCustomerOptionalParams extends coreClient.OperationOptions { + filter?: string; +} + +// @public +export type LotsListByCustomerResponse = Lots; + // @public export interface LotsOperations { listByBillingAccount(billingAccountId: string, options?: LotsListByBillingAccountOptionalParams): PagedAsyncIterableIterator; listByBillingProfile(billingAccountId: string, billingProfileId: string, options?: LotsListByBillingProfileOptionalParams): PagedAsyncIterableIterator; + listByCustomer(billingAccountId: string, customerId: string, options?: LotsListByCustomerOptionalParams): PagedAsyncIterableIterator; } // @public diff --git a/sdk/consumption/arm-consumption/rollup.config.js b/sdk/consumption/arm-consumption/rollup.config.js index 3f89d7309da5..9be1955eb7f1 100644 --- a/sdk/consumption/arm-consumption/rollup.config.js +++ b/sdk/consumption/arm-consumption/rollup.config.js @@ -14,14 +14,62 @@ import json from "@rollup/plugin-json"; import nodeBuiltins from "builtin-modules"; +/** + * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api. + * + * NOTE: this manual configuration is only needed because OpenTelemetry uses an + * __exportStar downleveled helper function to declare its exports which confuses + * rollup's automatic discovery mechanism. + * + * @returns an object reference that can be `...`'d into your cjs() configuration. + */ +export function openTelemetryCommonJs() { + const namedExports = {}; + + for (const key of [ + "@opentelemetry/api", + "@azure/core-tracing/node_modules/@opentelemetry/api" + ]) { + namedExports[key] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "SpanStatusCode", + "getSpanContext", + "setSpanContext" + ]; + } + + const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"]; + + for (const version of releasedOpenTelemetryVersions) { + namedExports[ + // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path. + `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js` + ] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "StatusCode", + "CanonicalCode", + "getSpanContext", + "setSpanContext" + ]; + } + + return namedExports; +} + // #region Warning Handler /** - * A function that can determine whether a rollup warning should be ignored. If + * A function that can determine whether a rollupwarning should be ignored. If * the function returns `true`, then the warning will not be displayed. */ -function ignoreNiseSinonEval(warning) { +function ignoreNiseSinonEvalWarnings(warning) { return ( warning.code === "EVAL" && warning.id && @@ -30,14 +78,17 @@ function ignoreNiseSinonEval(warning) { ); } -function ignoreChaiCircularDependency(warning) { +function ignoreChaiCircularDependencyWarnings(warning) { return ( warning.code === "CIRCULAR_DEPENDENCY" && warning.importer && warning.importer.includes("node_modules/chai") === true ); } -const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval]; +const warningInhibitors = [ + ignoreChaiCircularDependencyWarnings, + ignoreNiseSinonEvalWarnings +]; /** * Construct a warning handler for the shared rollup configuration @@ -71,7 +122,22 @@ function makeBrowserTestConfig() { nodeResolve({ mainFields: ["module", "browser"] }), - cjs(), + cjs({ + namedExports: { + // Chai's strange internal architecture makes it impossible to statically + // analyze its exports. + chai: [ + "version", + "use", + "util", + "config", + "expect", + "should", + "assert" + ], + ...openTelemetryCommonJs() + } + }), json(), sourcemaps() //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) @@ -107,7 +173,7 @@ export function makeConfig(pkg, options) { ], output: { file: "dist/index.js", format: "cjs", sourcemap: true }, preserveSymlinks: false, - plugins: [sourcemaps(), nodeResolve()] + plugins: [sourcemaps(), nodeResolve(), cjs()] }; const config = [baseConfig]; diff --git a/sdk/consumption/arm-consumption/src/consumptionManagementClient.ts b/sdk/consumption/arm-consumption/src/consumptionManagementClient.ts index eb3037e9597e..7b16f0d9b493 100644 --- a/sdk/consumption/arm-consumption/src/consumptionManagementClient.ts +++ b/sdk/consumption/arm-consumption/src/consumptionManagementClient.ts @@ -80,7 +80,7 @@ export class ConsumptionManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-consumption/9.0.2`; + const packageDetails = `azsdk-js-arm-consumption/10.0.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -95,8 +95,7 @@ export class ConsumptionManagementClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: - options.endpoint ?? options.baseUri ?? "https://management.azure.com" + baseUri: options.endpoint || "https://management.azure.com" }; super(optionsWithDefaults); // Parameter assignments diff --git a/sdk/consumption/arm-consumption/src/models/index.ts b/sdk/consumption/arm-consumption/src/models/index.ts index c37726a97d85..ce764396111e 100644 --- a/sdk/consumption/arm-consumption/src/models/index.ts +++ b/sdk/consumption/arm-consumption/src/models/index.ts @@ -136,8 +136,6 @@ export interface BudgetTimePeriod { export interface BudgetFilter { /** The logical "AND" expression. Must have at least 2 items. */ and?: BudgetFilterProperties[]; - /** The logical "NOT" expression. */ - not?: BudgetFilterProperties; /** Has comparison expression for a dimension */ dimensions?: BudgetComparisonExpression; /** Has comparison expression for a tag */ @@ -2121,6 +2119,16 @@ export type LegacyUsageDetail = UsageDetail & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly payGPrice?: number; + /** + * Unique identifier for the applicable benefit. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly benefitId?: string; + /** + * Name of the applicable benefit. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly benefitName?: string; /** * Identifier that indicates how the meter is priced. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -3586,6 +3594,16 @@ export interface LotsListByBillingAccountOptionalParams /** Contains response data for the listByBillingAccount operation. */ export type LotsListByBillingAccountResponse = Lots; +/** Optional parameters. */ +export interface LotsListByCustomerOptionalParams + extends coreClient.OperationOptions { + /** May be used to filter the lots by Status, Source etc. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. Tag filter is a key value pair string where key and value is separated by a colon (:). */ + filter?: string; +} + +/** Contains response data for the listByCustomer operation. */ +export type LotsListByCustomerResponse = Lots; + /** Optional parameters. */ export interface LotsListByBillingProfileNextOptionalParams extends coreClient.OperationOptions {} @@ -3603,6 +3621,16 @@ export interface LotsListByBillingAccountNextOptionalParams /** Contains response data for the listByBillingAccountNext operation. */ export type LotsListByBillingAccountNextResponse = Lots; +/** Optional parameters. */ +export interface LotsListByCustomerNextOptionalParams + extends coreClient.OperationOptions { + /** May be used to filter the lots by Status, Source etc. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. Tag filter is a key value pair string where key and value is separated by a colon (:). */ + filter?: string; +} + +/** Contains response data for the listByCustomerNext operation. */ +export type LotsListByCustomerNextResponse = Lots; + /** Optional parameters. */ export interface CreditsGetOptionalParams extends coreClient.OperationOptions {} diff --git a/sdk/consumption/arm-consumption/src/models/mappers.ts b/sdk/consumption/arm-consumption/src/models/mappers.ts index 2433e367e222..b6c08c54b470 100644 --- a/sdk/consumption/arm-consumption/src/models/mappers.ts +++ b/sdk/consumption/arm-consumption/src/models/mappers.ts @@ -218,13 +218,6 @@ export const BudgetFilter: coreClient.CompositeMapper = { } } }, - not: { - serializedName: "not", - type: { - name: "Composite", - className: "BudgetFilterProperties" - } - }, dimensions: { serializedName: "dimensions", type: { @@ -3023,7 +3016,6 @@ export const ReservationTransaction: coreClient.CompositeMapper = { }; export const ModernReservationTransaction: coreClient.CompositeMapper = { - serializedName: "Modern", type: { name: "Composite", className: "ModernReservationTransaction", @@ -3542,6 +3534,20 @@ export const LegacyUsageDetail: coreClient.CompositeMapper = { name: "Number" } }, + benefitId: { + serializedName: "properties.benefitId", + readOnly: true, + type: { + name: "String" + } + }, + benefitName: { + serializedName: "properties.benefitName", + readOnly: true, + type: { + name: "String" + } + }, pricingModel: { serializedName: "properties.pricingModel", readOnly: true, diff --git a/sdk/consumption/arm-consumption/src/models/parameters.ts b/sdk/consumption/arm-consumption/src/models/parameters.ts index d3cccb1067c2..b21b5789e64e 100644 --- a/sdk/consumption/arm-consumption/src/models/parameters.ts +++ b/sdk/consumption/arm-consumption/src/models/parameters.ts @@ -369,3 +369,14 @@ export const endDate1: OperationQueryParameter = { } } }; + +export const customerId: OperationURLParameter = { + parameterPath: "customerId", + mapper: { + serializedName: "customerId", + required: true, + type: { + name: "String" + } + } +}; diff --git a/sdk/consumption/arm-consumption/src/operations/lotsOperations.ts b/sdk/consumption/arm-consumption/src/operations/lotsOperations.ts index cedd214243ff..1da8f7c3ddd6 100644 --- a/sdk/consumption/arm-consumption/src/operations/lotsOperations.ts +++ b/sdk/consumption/arm-consumption/src/operations/lotsOperations.ts @@ -18,10 +18,14 @@ import { LotsListByBillingProfileOptionalParams, LotsListByBillingAccountNextOptionalParams, LotsListByBillingAccountOptionalParams, + LotsListByCustomerNextOptionalParams, + LotsListByCustomerOptionalParams, LotsListByBillingProfileResponse, LotsListByBillingAccountResponse, + LotsListByCustomerResponse, LotsListByBillingProfileNextResponse, - LotsListByBillingAccountNextResponse + LotsListByBillingAccountNextResponse, + LotsListByCustomerNextResponse } from "../models"; /// @@ -38,9 +42,8 @@ export class LotsOperationsImpl implements LotsOperations { } /** - * Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - * billing profile. Microsoft Azure consumption commitments are only supported for the billing account - * scope. + * Lists all Azure credits for a billing account or a billing profile. The API is only supported for + * Microsoft Customer Agreements (MCA) billing accounts. * @param billingAccountId BillingAccount ID * @param billingProfileId Azure Billing Profile ID. * @param options The options parameters. @@ -111,9 +114,8 @@ export class LotsOperationsImpl implements LotsOperations { } /** - * Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - * billing profile. Microsoft Azure consumption commitments are only supported for the billing account - * scope. + * Lists all Microsoft Azure consumption commitments for a billing account. The API is only supported + * for Microsoft Customer Agreements (MCA) and Direct Enterprise Agreement (EA) billing accounts. * @param billingAccountId BillingAccount ID * @param options The options parameters. */ @@ -166,9 +168,80 @@ export class LotsOperationsImpl implements LotsOperations { } /** - * Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - * billing profile. Microsoft Azure consumption commitments are only supported for the billing account - * scope. + * Lists all Azure credits for a customer. The API is only supported for Microsoft Partner Agreements + * (MPA) billing accounts. + * @param billingAccountId BillingAccount ID + * @param customerId Customer ID + * @param options The options parameters. + */ + public listByCustomer( + billingAccountId: string, + customerId: string, + options?: LotsListByCustomerOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listByCustomerPagingAll( + billingAccountId, + customerId, + options + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listByCustomerPagingPage( + billingAccountId, + customerId, + options + ); + } + }; + } + + private async *listByCustomerPagingPage( + billingAccountId: string, + customerId: string, + options?: LotsListByCustomerOptionalParams + ): AsyncIterableIterator { + let result = await this._listByCustomer( + billingAccountId, + customerId, + options + ); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listByCustomerNext( + billingAccountId, + customerId, + continuationToken, + options + ); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listByCustomerPagingAll( + billingAccountId: string, + customerId: string, + options?: LotsListByCustomerOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listByCustomerPagingPage( + billingAccountId, + customerId, + options + )) { + yield* page; + } + } + + /** + * Lists all Azure credits for a billing account or a billing profile. The API is only supported for + * Microsoft Customer Agreements (MCA) billing accounts. * @param billingAccountId BillingAccount ID * @param billingProfileId Azure Billing Profile ID. * @param options The options parameters. @@ -185,9 +258,8 @@ export class LotsOperationsImpl implements LotsOperations { } /** - * Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - * billing profile. Microsoft Azure consumption commitments are only supported for the billing account - * scope. + * Lists all Microsoft Azure consumption commitments for a billing account. The API is only supported + * for Microsoft Customer Agreements (MCA) and Direct Enterprise Agreement (EA) billing accounts. * @param billingAccountId BillingAccount ID * @param options The options parameters. */ @@ -201,6 +273,24 @@ export class LotsOperationsImpl implements LotsOperations { ); } + /** + * Lists all Azure credits for a customer. The API is only supported for Microsoft Partner Agreements + * (MPA) billing accounts. + * @param billingAccountId BillingAccount ID + * @param customerId Customer ID + * @param options The options parameters. + */ + private _listByCustomer( + billingAccountId: string, + customerId: string, + options?: LotsListByCustomerOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { billingAccountId, customerId, options }, + listByCustomerOperationSpec + ); + } + /** * ListByBillingProfileNext * @param billingAccountId BillingAccount ID @@ -236,6 +326,25 @@ export class LotsOperationsImpl implements LotsOperations { listByBillingAccountNextOperationSpec ); } + + /** + * ListByCustomerNext + * @param billingAccountId BillingAccount ID + * @param customerId Customer ID + * @param nextLink The nextLink from the previous successful call to the ListByCustomer method. + * @param options The options parameters. + */ + private _listByCustomerNext( + billingAccountId: string, + customerId: string, + nextLink: string, + options?: LotsListByCustomerNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { billingAccountId, customerId, nextLink, options }, + listByCustomerNextOperationSpec + ); + } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); @@ -278,6 +387,27 @@ const listByBillingAccountOperationSpec: coreClient.OperationSpec = { headerParameters: [Parameters.accept], serializer }; +const listByCustomerOperationSpec: coreClient.OperationSpec = { + path: + "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.Lots + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.filter, Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.billingAccountId, + Parameters.customerId + ], + headerParameters: [Parameters.accept], + serializer +}; const listByBillingProfileNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", @@ -319,3 +449,24 @@ const listByBillingAccountNextOperationSpec: coreClient.OperationSpec = { headerParameters: [Parameters.accept], serializer }; +const listByCustomerNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.Lots + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.filter, Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.billingAccountId, + Parameters.customerId + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/consumption/arm-consumption/src/operations/usageDetails.ts b/sdk/consumption/arm-consumption/src/operations/usageDetails.ts index dcde2c7c829d..2836e80fc7a3 100644 --- a/sdk/consumption/arm-consumption/src/operations/usageDetails.ts +++ b/sdk/consumption/arm-consumption/src/operations/usageDetails.ts @@ -177,6 +177,7 @@ const listOperationSpec: coreClient.OperationSpec = { 200: { bodyMapper: Mappers.UsageDetailsListResult }, + 204: {}, default: { bodyMapper: Mappers.ErrorResponse } @@ -200,6 +201,7 @@ const listNextOperationSpec: coreClient.OperationSpec = { 200: { bodyMapper: Mappers.UsageDetailsListResult }, + 204: {}, default: { bodyMapper: Mappers.ErrorResponse } diff --git a/sdk/consumption/arm-consumption/src/operationsInterfaces/lotsOperations.ts b/sdk/consumption/arm-consumption/src/operationsInterfaces/lotsOperations.ts index cee7524cb172..3be08764527e 100644 --- a/sdk/consumption/arm-consumption/src/operationsInterfaces/lotsOperations.ts +++ b/sdk/consumption/arm-consumption/src/operationsInterfaces/lotsOperations.ts @@ -10,16 +10,16 @@ import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { LotSummary, LotsListByBillingProfileOptionalParams, - LotsListByBillingAccountOptionalParams + LotsListByBillingAccountOptionalParams, + LotsListByCustomerOptionalParams } from "../models"; /// /** Interface representing a LotsOperations. */ export interface LotsOperations { /** - * Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - * billing profile. Microsoft Azure consumption commitments are only supported for the billing account - * scope. + * Lists all Azure credits for a billing account or a billing profile. The API is only supported for + * Microsoft Customer Agreements (MCA) billing accounts. * @param billingAccountId BillingAccount ID * @param billingProfileId Azure Billing Profile ID. * @param options The options parameters. @@ -30,9 +30,8 @@ export interface LotsOperations { options?: LotsListByBillingProfileOptionalParams ): PagedAsyncIterableIterator; /** - * Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - * billing profile. Microsoft Azure consumption commitments are only supported for the billing account - * scope. + * Lists all Microsoft Azure consumption commitments for a billing account. The API is only supported + * for Microsoft Customer Agreements (MCA) and Direct Enterprise Agreement (EA) billing accounts. * @param billingAccountId BillingAccount ID * @param options The options parameters. */ @@ -40,4 +39,16 @@ export interface LotsOperations { billingAccountId: string, options?: LotsListByBillingAccountOptionalParams ): PagedAsyncIterableIterator; + /** + * Lists all Azure credits for a customer. The API is only supported for Microsoft Partner Agreements + * (MPA) billing accounts. + * @param billingAccountId BillingAccount ID + * @param customerId Customer ID + * @param options The options parameters. + */ + listByCustomer( + billingAccountId: string, + customerId: string, + options?: LotsListByCustomerOptionalParams + ): PagedAsyncIterableIterator; } diff --git a/sdk/consumption/arm-consumption/test/sampleTest.ts b/sdk/consumption/arm-consumption/test/sampleTest.ts new file mode 100644 index 000000000000..7ed89b043e1b --- /dev/null +++ b/sdk/consumption/arm-consumption/test/sampleTest.ts @@ -0,0 +1,48 @@ +/* + * 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 { + env, + record, + RecorderEnvironmentSetup, + Recorder +} from "@azure-tools/test-recorder"; +import * as assert from "assert"; + +const recorderEnvSetup: RecorderEnvironmentSetup = { + replaceableVariables: { + 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" + }, + customizationsOnRecordings: [ + (recording: any): any => + recording.replace( + /"access_token":"[^"]*"/g, + `"access_token":"access_token"` + ) + ], + queryParametersToSkip: [] +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function() { + recorder = record(this, recorderEnvSetup); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/consumption/arm-consumption/tsconfig.json b/sdk/consumption/arm-consumption/tsconfig.json index 6e8ad365181f..3e6ae96443f3 100644 --- a/sdk/consumption/arm-consumption/tsconfig.json +++ b/sdk/consumption/arm-consumption/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-consumption": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"