@azure/arm-commerce 4.0.0-beta.1 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +12 -1
- package/dist/index.js +132 -19
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist-esm/samples-dev/rateCardGetSample.d.ts +2 -0
- package/dist-esm/samples-dev/rateCardGetSample.d.ts.map +1 -0
- package/dist-esm/samples-dev/rateCardGetSample.js +30 -0
- package/dist-esm/samples-dev/rateCardGetSample.js.map +1 -0
- package/dist-esm/src/index.d.ts +1 -0
- package/dist-esm/src/index.d.ts.map +1 -1
- package/dist-esm/src/index.js +1 -0
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/models/index.d.ts +6 -6
- package/dist-esm/src/models/index.d.ts.map +1 -1
- package/dist-esm/src/operations/usageAggregates.d.ts.map +1 -1
- package/dist-esm/src/operations/usageAggregates.js +19 -7
- package/dist-esm/src/operations/usageAggregates.js.map +1 -1
- package/dist-esm/src/pagingHelper.d.ts +13 -0
- package/dist-esm/src/pagingHelper.d.ts.map +1 -0
- package/dist-esm/src/pagingHelper.js +32 -0
- package/dist-esm/src/pagingHelper.js.map +1 -0
- package/dist-esm/src/usageManagementClient.d.ts +2 -0
- package/dist-esm/src/usageManagementClient.d.ts.map +1 -1
- package/dist-esm/src/usageManagementClient.js +54 -5
- package/dist-esm/src/usageManagementClient.js.map +1 -1
- package/dist-esm/test/commerce_examples.d.ts.map +1 -1
- package/dist-esm/test/commerce_examples.js +16 -18
- package/dist-esm/test/commerce_examples.js.map +1 -1
- package/package.json +41 -22
- package/review/arm-commerce.api.md +11 -8
- package/rollup.config.js +6 -72
- package/src/index.ts +1 -0
- package/src/models/index.ts +7 -6
- package/src/operations/usageAggregates.ts +26 -8
- package/src/pagingHelper.ts +39 -0
- package/src/usageManagementClient.ts +70 -5
- package/tsconfig.json +18 -5
- package/types/arm-commerce.d.ts +17 -6
- package/types/tsdoc-metadata.json +1 -1
- package/LICENSE.txt +0 -21
package/package.json
CHANGED
|
@@ -3,43 +3,58 @@
|
|
|
3
3
|
"sdk-type": "mgmt",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "A generated SDK for UsageManagementClient.",
|
|
6
|
-
"version": "4.0.0-beta.
|
|
7
|
-
"engines": {
|
|
6
|
+
"version": "4.0.0-beta.3",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=14.0.0"
|
|
9
|
+
},
|
|
8
10
|
"dependencies": {
|
|
9
11
|
"@azure/core-paging": "^1.2.0",
|
|
10
|
-
"@azure/core-client": "^1.
|
|
12
|
+
"@azure/core-client": "^1.6.1",
|
|
11
13
|
"@azure/core-auth": "^1.3.0",
|
|
12
|
-
"@azure/core-rest-pipeline": "^1.
|
|
14
|
+
"@azure/core-rest-pipeline": "^1.8.0",
|
|
13
15
|
"tslib": "^2.2.0"
|
|
14
16
|
},
|
|
15
|
-
"keywords": [
|
|
17
|
+
"keywords": [
|
|
18
|
+
"node",
|
|
19
|
+
"azure",
|
|
20
|
+
"typescript",
|
|
21
|
+
"browser",
|
|
22
|
+
"isomorphic"
|
|
23
|
+
],
|
|
16
24
|
"license": "MIT",
|
|
17
25
|
"main": "./dist/index.js",
|
|
18
26
|
"module": "./dist-esm/src/index.js",
|
|
19
27
|
"types": "./types/arm-commerce.d.ts",
|
|
20
28
|
"devDependencies": {
|
|
21
|
-
"@microsoft/api-extractor": "^7.
|
|
22
|
-
"@rollup/plugin-commonjs": "
|
|
23
|
-
"@rollup/plugin-json": "^4.
|
|
24
|
-
"@rollup/plugin-multi-entry": "^
|
|
25
|
-
"@rollup/plugin-node-resolve": "^
|
|
29
|
+
"@microsoft/api-extractor": "^7.31.1",
|
|
30
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
31
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
32
|
+
"@rollup/plugin-multi-entry": "^4.1.0",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
26
34
|
"mkdirp": "^1.0.4",
|
|
27
|
-
"rollup": "^
|
|
28
|
-
"rollup-plugin-sourcemaps": "^0.
|
|
29
|
-
"typescript": "~4.
|
|
35
|
+
"rollup": "^2.66.1",
|
|
36
|
+
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
37
|
+
"typescript": "~4.8.0",
|
|
30
38
|
"uglify-js": "^3.4.9",
|
|
31
39
|
"rimraf": "^3.0.0",
|
|
32
40
|
"@azure/identity": "^2.0.1",
|
|
33
|
-
"@azure-tools/test-recorder": "^
|
|
41
|
+
"@azure-tools/test-recorder": "^2.0.0",
|
|
42
|
+
"@azure-tools/test-credential": "^1.0.0",
|
|
34
43
|
"mocha": "^7.1.1",
|
|
35
|
-
"
|
|
44
|
+
"@types/chai": "^4.2.8",
|
|
45
|
+
"chai": "^4.2.0",
|
|
46
|
+
"cross-env": "^7.0.2",
|
|
47
|
+
"@types/node": "^14.0.0",
|
|
48
|
+
"@azure/dev-tool": "^1.0.0"
|
|
36
49
|
},
|
|
37
50
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/commerce/arm-commerce",
|
|
38
51
|
"repository": {
|
|
39
52
|
"type": "git",
|
|
40
53
|
"url": "https://github.com/Azure/azure-sdk-for-js.git"
|
|
41
54
|
},
|
|
42
|
-
"bugs": {
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
|
57
|
+
},
|
|
43
58
|
"files": [
|
|
44
59
|
"dist/**/*.js",
|
|
45
60
|
"dist/**/*.js.map",
|
|
@@ -81,21 +96,25 @@
|
|
|
81
96
|
"unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node",
|
|
82
97
|
"unit-test:browser": "echo skipped",
|
|
83
98
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
84
|
-
"integration-test:node": "
|
|
85
|
-
"integration-test:browser": "echo skipped"
|
|
86
|
-
"docs": "echo skipped"
|
|
99
|
+
"integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'",
|
|
100
|
+
"integration-test:browser": "echo skipped"
|
|
87
101
|
},
|
|
88
102
|
"sideEffects": false,
|
|
89
103
|
"//metadata": {
|
|
90
104
|
"constantPaths": [
|
|
91
|
-
{
|
|
105
|
+
{
|
|
106
|
+
"path": "src/usageManagementClient.ts",
|
|
107
|
+
"prefix": "packageDetails"
|
|
108
|
+
}
|
|
92
109
|
]
|
|
93
110
|
},
|
|
94
111
|
"autoPublish": true,
|
|
95
112
|
"//sampleConfiguration": {
|
|
96
113
|
"productName": "",
|
|
97
|
-
"productSlugs": [
|
|
114
|
+
"productSlugs": [
|
|
115
|
+
"azure"
|
|
116
|
+
],
|
|
98
117
|
"disableDocsMs": true,
|
|
99
118
|
"apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-commerce?view=azure-node-preview"
|
|
100
119
|
}
|
|
101
|
-
}
|
|
120
|
+
}
|
|
@@ -17,6 +17,9 @@ export interface ErrorResponse {
|
|
|
17
17
|
message?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// @public
|
|
21
|
+
export function getContinuationToken(page: unknown): string | undefined;
|
|
22
|
+
|
|
20
23
|
// @public
|
|
21
24
|
export interface InfoField {
|
|
22
25
|
project?: string;
|
|
@@ -39,20 +42,20 @@ export interface MeterInfo {
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
// @public
|
|
42
|
-
export
|
|
45
|
+
export interface MonetaryCommitment extends OfferTermInfoAutoGenerated {
|
|
46
|
+
excludedMeterIds?: string[];
|
|
43
47
|
name: "Monetary Commitment";
|
|
44
48
|
tieredDiscount?: {
|
|
45
49
|
[propertyName: string]: number;
|
|
46
50
|
};
|
|
47
|
-
|
|
48
|
-
};
|
|
51
|
+
}
|
|
49
52
|
|
|
50
53
|
// @public
|
|
51
|
-
export
|
|
52
|
-
name: "Monetary Credit";
|
|
54
|
+
export interface MonetaryCredit extends OfferTermInfoAutoGenerated {
|
|
53
55
|
credit?: number;
|
|
54
56
|
excludedMeterIds?: string[];
|
|
55
|
-
|
|
57
|
+
name: "Monetary Credit";
|
|
58
|
+
}
|
|
56
59
|
|
|
57
60
|
// @public
|
|
58
61
|
export type OfferTermInfo = "Recurring Charge" | "Monetary Commitment" | "Monetary Credit";
|
|
@@ -87,10 +90,10 @@ export interface RateCardQueryParameters {
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
// @public
|
|
90
|
-
export
|
|
93
|
+
export interface RecurringCharge extends OfferTermInfoAutoGenerated {
|
|
91
94
|
name: "Recurring Charge";
|
|
92
95
|
recurringCharge?: number;
|
|
93
|
-
}
|
|
96
|
+
}
|
|
94
97
|
|
|
95
98
|
// @public
|
|
96
99
|
export interface ResourceRateCardInfo {
|
package/rollup.config.js
CHANGED
|
@@ -14,62 +14,14 @@ import json from "@rollup/plugin-json";
|
|
|
14
14
|
|
|
15
15
|
import nodeBuiltins from "builtin-modules";
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api.
|
|
19
|
-
*
|
|
20
|
-
* NOTE: this manual configuration is only needed because OpenTelemetry uses an
|
|
21
|
-
* __exportStar downleveled helper function to declare its exports which confuses
|
|
22
|
-
* rollup's automatic discovery mechanism.
|
|
23
|
-
*
|
|
24
|
-
* @returns an object reference that can be `...`'d into your cjs() configuration.
|
|
25
|
-
*/
|
|
26
|
-
export function openTelemetryCommonJs() {
|
|
27
|
-
const namedExports = {};
|
|
28
|
-
|
|
29
|
-
for (const key of [
|
|
30
|
-
"@opentelemetry/api",
|
|
31
|
-
"@azure/core-tracing/node_modules/@opentelemetry/api"
|
|
32
|
-
]) {
|
|
33
|
-
namedExports[key] = [
|
|
34
|
-
"SpanKind",
|
|
35
|
-
"TraceFlags",
|
|
36
|
-
"getSpan",
|
|
37
|
-
"setSpan",
|
|
38
|
-
"SpanStatusCode",
|
|
39
|
-
"getSpanContext",
|
|
40
|
-
"setSpanContext"
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"];
|
|
45
|
-
|
|
46
|
-
for (const version of releasedOpenTelemetryVersions) {
|
|
47
|
-
namedExports[
|
|
48
|
-
// 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.
|
|
49
|
-
`../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js`
|
|
50
|
-
] = [
|
|
51
|
-
"SpanKind",
|
|
52
|
-
"TraceFlags",
|
|
53
|
-
"getSpan",
|
|
54
|
-
"setSpan",
|
|
55
|
-
"StatusCode",
|
|
56
|
-
"CanonicalCode",
|
|
57
|
-
"getSpanContext",
|
|
58
|
-
"setSpanContext"
|
|
59
|
-
];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return namedExports;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
17
|
// #region Warning Handler
|
|
66
18
|
|
|
67
19
|
/**
|
|
68
|
-
* A function that can determine whether a
|
|
20
|
+
* A function that can determine whether a rollup warning should be ignored. If
|
|
69
21
|
* the function returns `true`, then the warning will not be displayed.
|
|
70
22
|
*/
|
|
71
23
|
|
|
72
|
-
function
|
|
24
|
+
function ignoreNiseSinonEval(warning) {
|
|
73
25
|
return (
|
|
74
26
|
warning.code === "EVAL" &&
|
|
75
27
|
warning.id &&
|
|
@@ -78,17 +30,14 @@ function ignoreNiseSinonEvalWarnings(warning) {
|
|
|
78
30
|
);
|
|
79
31
|
}
|
|
80
32
|
|
|
81
|
-
function
|
|
33
|
+
function ignoreChaiCircularDependency(warning) {
|
|
82
34
|
return (
|
|
83
35
|
warning.code === "CIRCULAR_DEPENDENCY" &&
|
|
84
36
|
warning.importer && warning.importer.includes("node_modules/chai") === true
|
|
85
37
|
);
|
|
86
38
|
}
|
|
87
39
|
|
|
88
|
-
const warningInhibitors = [
|
|
89
|
-
ignoreChaiCircularDependencyWarnings,
|
|
90
|
-
ignoreNiseSinonEvalWarnings
|
|
91
|
-
];
|
|
40
|
+
const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval];
|
|
92
41
|
|
|
93
42
|
/**
|
|
94
43
|
* Construct a warning handler for the shared rollup configuration
|
|
@@ -122,22 +71,7 @@ function makeBrowserTestConfig() {
|
|
|
122
71
|
nodeResolve({
|
|
123
72
|
mainFields: ["module", "browser"]
|
|
124
73
|
}),
|
|
125
|
-
cjs(
|
|
126
|
-
namedExports: {
|
|
127
|
-
// Chai's strange internal architecture makes it impossible to statically
|
|
128
|
-
// analyze its exports.
|
|
129
|
-
chai: [
|
|
130
|
-
"version",
|
|
131
|
-
"use",
|
|
132
|
-
"util",
|
|
133
|
-
"config",
|
|
134
|
-
"expect",
|
|
135
|
-
"should",
|
|
136
|
-
"assert"
|
|
137
|
-
],
|
|
138
|
-
...openTelemetryCommonJs()
|
|
139
|
-
}
|
|
140
|
-
}),
|
|
74
|
+
cjs(),
|
|
141
75
|
json(),
|
|
142
76
|
sourcemaps()
|
|
143
77
|
//viz({ filename: "dist-test/browser-stats.html", sourcemap: true })
|
|
@@ -173,7 +107,7 @@ export function makeConfig(pkg, options) {
|
|
|
173
107
|
],
|
|
174
108
|
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
|
|
175
109
|
preserveSymlinks: false,
|
|
176
|
-
plugins: [sourcemaps(), nodeResolve()
|
|
110
|
+
plugins: [sourcemaps(), nodeResolve()]
|
|
177
111
|
};
|
|
178
112
|
|
|
179
113
|
const config = [baseConfig];
|
package/src/index.ts
CHANGED
package/src/models/index.ts
CHANGED
|
@@ -129,32 +129,33 @@ export interface RateCardQueryParameters {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/** Indicates that this is a monetary credit offer. */
|
|
132
|
-
export
|
|
132
|
+
export interface MonetaryCredit extends OfferTermInfoAutoGenerated {
|
|
133
133
|
/** Polymorphic discriminator, which specifies the different types this object can be */
|
|
134
134
|
name: "Monetary Credit";
|
|
135
135
|
/** The amount of credit provided under the terms of the given offer level. */
|
|
136
136
|
credit?: number;
|
|
137
137
|
/** An array of meter ids that are excluded from the given offer terms. */
|
|
138
138
|
excludedMeterIds?: string[];
|
|
139
|
-
}
|
|
139
|
+
}
|
|
140
140
|
|
|
141
141
|
/** Indicates that a monetary commitment is required for this offer */
|
|
142
|
-
export
|
|
142
|
+
export interface MonetaryCommitment extends OfferTermInfoAutoGenerated {
|
|
143
143
|
/** Polymorphic discriminator, which specifies the different types this object can be */
|
|
144
144
|
name: "Monetary Commitment";
|
|
145
145
|
/** The list of key/value pairs for the tiered meter rates, in the format 'key':'value' where key = price, and value = the corresponding discount percentage. This field is used only by offer terms of type 'Monetary Commitment'. */
|
|
146
146
|
tieredDiscount?: { [propertyName: string]: number };
|
|
147
147
|
/** An array of meter ids that are excluded from the given offer terms. */
|
|
148
148
|
excludedMeterIds?: string[];
|
|
149
|
-
}
|
|
149
|
+
}
|
|
150
150
|
|
|
151
151
|
/** Indicates a recurring charge is present for this offer. */
|
|
152
|
-
export
|
|
152
|
+
export interface RecurringCharge extends OfferTermInfoAutoGenerated {
|
|
153
153
|
/** Polymorphic discriminator, which specifies the different types this object can be */
|
|
154
154
|
name: "Recurring Charge";
|
|
155
155
|
/** The amount of recurring charge as per the offer term. */
|
|
156
156
|
recurringCharge?: number;
|
|
157
|
-
}
|
|
157
|
+
}
|
|
158
|
+
|
|
158
159
|
/** Defines values for AggregationGranularity. */
|
|
159
160
|
export type AggregationGranularity = "Daily" | "Hourly";
|
|
160
161
|
/** Defines values for OfferTermInfo. */
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { PagedAsyncIterableIterator } from "@azure/core-paging";
|
|
9
|
+
import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
|
|
10
|
+
import { setContinuationToken } from "../pagingHelper";
|
|
10
11
|
import { UsageAggregates } from "../operationsInterfaces";
|
|
11
12
|
import * as coreClient from "@azure/core-client";
|
|
12
13
|
import * as Mappers from "../models/mappers";
|
|
@@ -56,8 +57,16 @@ export class UsageAggregatesImpl implements UsageAggregates {
|
|
|
56
57
|
[Symbol.asyncIterator]() {
|
|
57
58
|
return this;
|
|
58
59
|
},
|
|
59
|
-
byPage: () => {
|
|
60
|
-
|
|
60
|
+
byPage: (settings?: PageSettings) => {
|
|
61
|
+
if (settings?.maxPageSize) {
|
|
62
|
+
throw new Error("maxPageSize is not supported by this operation.");
|
|
63
|
+
}
|
|
64
|
+
return this.listPagingPage(
|
|
65
|
+
reportedStartTime,
|
|
66
|
+
reportedEndTime,
|
|
67
|
+
options,
|
|
68
|
+
settings
|
|
69
|
+
);
|
|
61
70
|
}
|
|
62
71
|
};
|
|
63
72
|
}
|
|
@@ -65,11 +74,18 @@ export class UsageAggregatesImpl implements UsageAggregates {
|
|
|
65
74
|
private async *listPagingPage(
|
|
66
75
|
reportedStartTime: Date,
|
|
67
76
|
reportedEndTime: Date,
|
|
68
|
-
options?: UsageAggregatesListOptionalParams
|
|
77
|
+
options?: UsageAggregatesListOptionalParams,
|
|
78
|
+
settings?: PageSettings
|
|
69
79
|
): AsyncIterableIterator<UsageAggregation[]> {
|
|
70
|
-
let result
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
let result: UsageAggregatesListResponse;
|
|
81
|
+
let continuationToken = settings?.continuationToken;
|
|
82
|
+
if (!continuationToken) {
|
|
83
|
+
result = await this._list(reportedStartTime, reportedEndTime, options);
|
|
84
|
+
let page = result.value || [];
|
|
85
|
+
continuationToken = result.nextLink;
|
|
86
|
+
setContinuationToken(page, continuationToken);
|
|
87
|
+
yield page;
|
|
88
|
+
}
|
|
73
89
|
while (continuationToken) {
|
|
74
90
|
result = await this._listNext(
|
|
75
91
|
reportedStartTime,
|
|
@@ -78,7 +94,9 @@ export class UsageAggregatesImpl implements UsageAggregates {
|
|
|
78
94
|
options
|
|
79
95
|
);
|
|
80
96
|
continuationToken = result.nextLink;
|
|
81
|
-
|
|
97
|
+
let page = result.value || [];
|
|
98
|
+
setContinuationToken(page, continuationToken);
|
|
99
|
+
yield page;
|
|
82
100
|
}
|
|
83
101
|
}
|
|
84
102
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
|
6
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface PageInfo {
|
|
10
|
+
continuationToken?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const pageMap = new WeakMap<object, PageInfo>();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Given a result page from a pageable operation, returns a
|
|
17
|
+
* continuation token that can be used to begin paging from
|
|
18
|
+
* that point later.
|
|
19
|
+
* @param page A result object from calling .byPage() on a paged operation.
|
|
20
|
+
* @returns The continuation token that can be passed into byPage().
|
|
21
|
+
*/
|
|
22
|
+
export function getContinuationToken(page: unknown): string | undefined {
|
|
23
|
+
if (typeof page !== "object" || page === null) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return pageMap.get(page)?.continuationToken;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function setContinuationToken(
|
|
30
|
+
page: unknown,
|
|
31
|
+
continuationToken: string | undefined
|
|
32
|
+
): void {
|
|
33
|
+
if (typeof page !== "object" || page === null || !continuationToken) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const pageInfo = pageMap.get(page) ?? {};
|
|
37
|
+
pageInfo.continuationToken = continuationToken;
|
|
38
|
+
pageMap.set(page, pageInfo);
|
|
39
|
+
}
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as coreClient from "@azure/core-client";
|
|
10
|
+
import * as coreRestPipeline from "@azure/core-rest-pipeline";
|
|
11
|
+
import {
|
|
12
|
+
PipelineRequest,
|
|
13
|
+
PipelineResponse,
|
|
14
|
+
SendRequest
|
|
15
|
+
} from "@azure/core-rest-pipeline";
|
|
10
16
|
import * as coreAuth from "@azure/core-auth";
|
|
11
17
|
import { UsageAggregatesImpl, RateCardImpl } from "./operations";
|
|
12
18
|
import { UsageAggregates, RateCard } from "./operationsInterfaces";
|
|
@@ -45,24 +51,54 @@ export class UsageManagementClient extends coreClient.ServiceClient {
|
|
|
45
51
|
credential: credentials
|
|
46
52
|
};
|
|
47
53
|
|
|
48
|
-
const packageDetails = `azsdk-js-arm-commerce/4.0.0-beta.
|
|
54
|
+
const packageDetails = `azsdk-js-arm-commerce/4.0.0-beta.3`;
|
|
49
55
|
const userAgentPrefix =
|
|
50
56
|
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
51
57
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
52
58
|
: `${packageDetails}`;
|
|
53
59
|
|
|
54
|
-
if (!options.credentialScopes) {
|
|
55
|
-
options.credentialScopes = ["https://management.azure.com/.default"];
|
|
56
|
-
}
|
|
57
60
|
const optionsWithDefaults = {
|
|
58
61
|
...defaults,
|
|
59
62
|
...options,
|
|
60
63
|
userAgentOptions: {
|
|
61
64
|
userAgentPrefix
|
|
62
65
|
},
|
|
63
|
-
|
|
66
|
+
endpoint:
|
|
67
|
+
options.endpoint ?? options.baseUri ?? "https://management.azure.com"
|
|
64
68
|
};
|
|
65
69
|
super(optionsWithDefaults);
|
|
70
|
+
|
|
71
|
+
let bearerTokenAuthenticationPolicyFound: boolean = false;
|
|
72
|
+
if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) {
|
|
73
|
+
const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies();
|
|
74
|
+
bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
|
|
75
|
+
(pipelinePolicy) =>
|
|
76
|
+
pipelinePolicy.name ===
|
|
77
|
+
coreRestPipeline.bearerTokenAuthenticationPolicyName
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
!options ||
|
|
82
|
+
!options.pipeline ||
|
|
83
|
+
options.pipeline.getOrderedPolicies().length == 0 ||
|
|
84
|
+
!bearerTokenAuthenticationPolicyFound
|
|
85
|
+
) {
|
|
86
|
+
this.pipeline.removePolicy({
|
|
87
|
+
name: coreRestPipeline.bearerTokenAuthenticationPolicyName
|
|
88
|
+
});
|
|
89
|
+
this.pipeline.addPolicy(
|
|
90
|
+
coreRestPipeline.bearerTokenAuthenticationPolicy({
|
|
91
|
+
credential: credentials,
|
|
92
|
+
scopes:
|
|
93
|
+
optionsWithDefaults.credentialScopes ??
|
|
94
|
+
`${optionsWithDefaults.endpoint}/.default`,
|
|
95
|
+
challengeCallbacks: {
|
|
96
|
+
authorizeRequestOnChallenge:
|
|
97
|
+
coreClient.authorizeRequestOnClaimChallenge
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
}
|
|
66
102
|
// Parameter assignments
|
|
67
103
|
this.subscriptionId = subscriptionId;
|
|
68
104
|
|
|
@@ -71,6 +107,35 @@ export class UsageManagementClient extends coreClient.ServiceClient {
|
|
|
71
107
|
this.apiVersion = options.apiVersion || "2015-06-01-preview";
|
|
72
108
|
this.usageAggregates = new UsageAggregatesImpl(this);
|
|
73
109
|
this.rateCard = new RateCardImpl(this);
|
|
110
|
+
this.addCustomApiVersionPolicy(options.apiVersion);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
|
|
114
|
+
private addCustomApiVersionPolicy(apiVersion?: string) {
|
|
115
|
+
if (!apiVersion) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const apiVersionPolicy = {
|
|
119
|
+
name: "CustomApiVersionPolicy",
|
|
120
|
+
async sendRequest(
|
|
121
|
+
request: PipelineRequest,
|
|
122
|
+
next: SendRequest
|
|
123
|
+
): Promise<PipelineResponse> {
|
|
124
|
+
const param = request.url.split("?");
|
|
125
|
+
if (param.length > 1) {
|
|
126
|
+
const newParams = param[1].split("&").map((item) => {
|
|
127
|
+
if (item.indexOf("api-version") > -1) {
|
|
128
|
+
return "api-version=" + apiVersion;
|
|
129
|
+
} else {
|
|
130
|
+
return item;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
request.url = param[0] + "?" + newParams.join("&");
|
|
134
|
+
}
|
|
135
|
+
return next(request);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
this.pipeline.addPolicy(apiVersionPolicy);
|
|
74
139
|
}
|
|
75
140
|
|
|
76
141
|
usageAggregates: UsageAggregates;
|
package/tsconfig.json
CHANGED
|
@@ -9,12 +9,25 @@
|
|
|
9
9
|
"esModuleInterop": true,
|
|
10
10
|
"allowSyntheticDefaultImports": true,
|
|
11
11
|
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"lib": [
|
|
12
|
+
"lib": [
|
|
13
|
+
"es6",
|
|
14
|
+
"dom"
|
|
15
|
+
],
|
|
13
16
|
"declaration": true,
|
|
14
17
|
"outDir": "./dist-esm",
|
|
15
18
|
"importHelpers": true,
|
|
16
|
-
"paths": {
|
|
19
|
+
"paths": {
|
|
20
|
+
"@azure/arm-commerce": [
|
|
21
|
+
"./src/index"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
17
24
|
},
|
|
18
|
-
"include": [
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
"include": [
|
|
26
|
+
"./src/**/*.ts",
|
|
27
|
+
"./test/**/*.ts",
|
|
28
|
+
"samples-dev/**/*.ts"
|
|
29
|
+
],
|
|
30
|
+
"exclude": [
|
|
31
|
+
"node_modules"
|
|
32
|
+
]
|
|
33
|
+
}
|
package/types/arm-commerce.d.ts
CHANGED
|
@@ -13,6 +13,15 @@ export declare interface ErrorResponse {
|
|
|
13
13
|
message?: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Given a result page from a pageable operation, returns a
|
|
18
|
+
* continuation token that can be used to begin paging from
|
|
19
|
+
* that point later.
|
|
20
|
+
* @param page A result object from calling .byPage() on a paged operation.
|
|
21
|
+
* @returns The continuation token that can be passed into byPage().
|
|
22
|
+
*/
|
|
23
|
+
export declare function getContinuationToken(page: unknown): string | undefined;
|
|
24
|
+
|
|
16
25
|
/** Key-value pairs of instance details in the legacy format. */
|
|
17
26
|
export declare interface InfoField {
|
|
18
27
|
/** Identifies the name of the instance provisioned by the user. */
|
|
@@ -46,7 +55,7 @@ export declare interface MeterInfo {
|
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
/** Indicates that a monetary commitment is required for this offer */
|
|
49
|
-
export declare
|
|
58
|
+
export declare interface MonetaryCommitment extends OfferTermInfoAutoGenerated {
|
|
50
59
|
/** Polymorphic discriminator, which specifies the different types this object can be */
|
|
51
60
|
name: "Monetary Commitment";
|
|
52
61
|
/** The list of key/value pairs for the tiered meter rates, in the format 'key':'value' where key = price, and value = the corresponding discount percentage. This field is used only by offer terms of type 'Monetary Commitment'. */
|
|
@@ -55,17 +64,17 @@ export declare type MonetaryCommitment = OfferTermInfoAutoGenerated & {
|
|
|
55
64
|
};
|
|
56
65
|
/** An array of meter ids that are excluded from the given offer terms. */
|
|
57
66
|
excludedMeterIds?: string[];
|
|
58
|
-
}
|
|
67
|
+
}
|
|
59
68
|
|
|
60
69
|
/** Indicates that this is a monetary credit offer. */
|
|
61
|
-
export declare
|
|
70
|
+
export declare interface MonetaryCredit extends OfferTermInfoAutoGenerated {
|
|
62
71
|
/** Polymorphic discriminator, which specifies the different types this object can be */
|
|
63
72
|
name: "Monetary Credit";
|
|
64
73
|
/** The amount of credit provided under the terms of the given offer level. */
|
|
65
74
|
credit?: number;
|
|
66
75
|
/** An array of meter ids that are excluded from the given offer terms. */
|
|
67
76
|
excludedMeterIds?: string[];
|
|
68
|
-
}
|
|
77
|
+
}
|
|
69
78
|
|
|
70
79
|
/** Defines values for OfferTermInfo. */
|
|
71
80
|
export declare type OfferTermInfo = "Recurring Charge" | "Monetary Commitment" | "Monetary Credit";
|
|
@@ -118,12 +127,12 @@ export declare interface RateCardQueryParameters {
|
|
|
118
127
|
}
|
|
119
128
|
|
|
120
129
|
/** Indicates a recurring charge is present for this offer. */
|
|
121
|
-
export declare
|
|
130
|
+
export declare interface RecurringCharge extends OfferTermInfoAutoGenerated {
|
|
122
131
|
/** Polymorphic discriminator, which specifies the different types this object can be */
|
|
123
132
|
name: "Recurring Charge";
|
|
124
133
|
/** The amount of recurring charge as per the offer term. */
|
|
125
134
|
recurringCharge?: number;
|
|
126
|
-
}
|
|
135
|
+
}
|
|
127
136
|
|
|
128
137
|
/** Price and Metadata information for resources */
|
|
129
138
|
export declare interface ResourceRateCardInfo {
|
|
@@ -230,6 +239,8 @@ export declare class UsageManagementClient extends coreClient.ServiceClient {
|
|
|
230
239
|
* @param options The parameter options
|
|
231
240
|
*/
|
|
232
241
|
constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: UsageManagementClientOptionalParams);
|
|
242
|
+
/** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
|
|
243
|
+
private addCustomApiVersionPolicy;
|
|
233
244
|
usageAggregates: UsageAggregates;
|
|
234
245
|
rateCard: RateCard;
|
|
235
246
|
}
|
package/LICENSE.txt
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Microsoft
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|