@azure-rest/load-testing 1.0.0-beta.1 → 1.0.0

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.
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getFileValidationPoller = void 0;
6
+ const tslib_1 = require("tslib");
7
+ const abort_controller_1 = require("@azure/abort-controller");
8
+ const isUnexpected_1 = require("./isUnexpected");
9
+ const LROUtil_1 = require("./util/LROUtil");
10
+ /**
11
+ * Uploads a file and creates a poller to poll for validation.
12
+ * @param client - The Load Testing client.
13
+ * @param options - The operation options.
14
+ * @returns A poller which can be called to poll until completion of the job.
15
+ */
16
+ function getFileValidationPoller(client, fileUploadResult, polledOperationOptions = {}) {
17
+ var _a;
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ // get filename and testid from initial response
20
+ const fileName = fileUploadResult.body.fileName;
21
+ const requestUrl = fileUploadResult.request.url;
22
+ const testId = requestUrl.substring(requestUrl.indexOf("tests/") + 6, requestUrl.lastIndexOf("/files"));
23
+ const state = {
24
+ status: "notStarted",
25
+ };
26
+ const progressCallbacks = new Map();
27
+ const processProgressCallbacks = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return progressCallbacks.forEach((h) => h(state)); });
28
+ let resultPromise;
29
+ let cancelJob;
30
+ const abortController = new abort_controller_1.AbortController();
31
+ const currentPollIntervalInMs = (_a = polledOperationOptions.updateIntervalInMs) !== null && _a !== void 0 ? _a : 2000;
32
+ const poller = {
33
+ poll(options) {
34
+ var _a;
35
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
+ if ((_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
37
+ throw new abort_controller_1.AbortError("The polling was aborted.");
38
+ }
39
+ if (fileName) {
40
+ const fileValidationResponse = yield client
41
+ .path("/tests/{testId}/files/{fileName}", testId, fileName)
42
+ .get();
43
+ if ((0, isUnexpected_1.isUnexpected)(fileValidationResponse)) {
44
+ state.status = "failed";
45
+ state.error = new Error(fileValidationResponse.body.error.message);
46
+ return;
47
+ }
48
+ switch (fileValidationResponse.body.validationStatus) {
49
+ case "NOT_VALIDATED": {
50
+ if (fileValidationResponse.body.fileType === "JMX_FILE") {
51
+ state.status = "running";
52
+ }
53
+ else {
54
+ state.status = "succeeded";
55
+ }
56
+ break;
57
+ }
58
+ case "VALIDATION_INITIATED": {
59
+ state.status = "running";
60
+ break;
61
+ }
62
+ case "VALIDATION_SUCCESS":
63
+ case "VALIDATION_NOT_REQUIRED": {
64
+ state.status = "succeeded";
65
+ break;
66
+ }
67
+ case "VALIDATION_FAILURE": {
68
+ state.status = "failed";
69
+ state.error = new Error(fileValidationResponse.body.validationFailureDetails);
70
+ break;
71
+ }
72
+ }
73
+ state.result = fileValidationResponse;
74
+ yield processProgressCallbacks();
75
+ }
76
+ });
77
+ },
78
+ pollUntilDone(pollOptions) {
79
+ return (resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (() => tslib_1.__awaiter(this, void 0, void 0, function* () {
80
+ const { abortSignal: inputAbortSignal } = pollOptions || {};
81
+ const { signal: abortSignal } = inputAbortSignal
82
+ ? new abort_controller_1.AbortController([inputAbortSignal, abortController.signal])
83
+ : abortController;
84
+ if (!poller.isDone()) {
85
+ yield poller.poll({ abortSignal });
86
+ while (!poller.isDone()) {
87
+ const delay = (0, LROUtil_1.sleep)(currentPollIntervalInMs, abortSignal);
88
+ cancelJob = () => abortController.abort();
89
+ yield delay;
90
+ yield poller.poll({ abortSignal });
91
+ }
92
+ }
93
+ switch (state.status) {
94
+ case "succeeded":
95
+ case "failed":
96
+ case "canceled": {
97
+ return poller.getResult();
98
+ }
99
+ case "notStarted":
100
+ case "running": {
101
+ // Unreachable
102
+ throw new Error(`polling completed without succeeding or failing`);
103
+ }
104
+ }
105
+ }))().finally(() => {
106
+ resultPromise = undefined;
107
+ })));
108
+ },
109
+ onProgress(callback) {
110
+ const s = Symbol();
111
+ progressCallbacks.set(s, callback);
112
+ return () => progressCallbacks.delete(s);
113
+ },
114
+ isDone() {
115
+ return ["succeeded", "failed", "canceled"].includes(state.status);
116
+ },
117
+ stopPolling() {
118
+ abortController.abort();
119
+ cancelJob === null || cancelJob === void 0 ? void 0 : cancelJob();
120
+ },
121
+ isStopped() {
122
+ return resultPromise === undefined;
123
+ },
124
+ getOperationState() {
125
+ return state;
126
+ },
127
+ getResult() {
128
+ return state.result;
129
+ },
130
+ toString() {
131
+ return JSON.stringify({ state });
132
+ },
133
+ };
134
+ return poller;
135
+ });
136
+ }
137
+ exports.getFileValidationPoller = getFileValidationPoller;
138
+ //# sourceMappingURL=getFileValidationPoller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFileValidationPoller.js","sourceRoot":"","sources":["../../src/getFileValidationPoller.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,8DAAuF;AAKvF,iDAA8C;AAC9C,4CAAuC;AAEvC;;;;;GAKG;AACH,SAAsB,uBAAuB,CAC3C,MAA8B,EAC9B,gBAA2C,EAC3C,yBAAiD,EAAE;;;QAEnD,gDAAgD;QAChD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;QAChD,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC;QAChD,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CACjC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAChC,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CACjC,CAAC;QAGF,MAAM,KAAK,GAA2C;YACpD,MAAM,EAAE,YAAY;SACrB,CAAC;QAEF,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAmB,CAAC;QACrD,MAAM,wBAAwB,GAAG,GAAwB,EAAE,wDACzD,O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ortController, AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport { CancelOnProgress, OperationState, SimplePollerLike } from \"@azure/core-lro\";\nimport { FileUploadAndValidatePoller, PolledOperationOptions } from \"./models\";\nimport { AzureLoadTestingClient } from \"./clientDefinitions\";\nimport { TestGetFile200Response, TestUploadFile201Response } from \"./responses\";\nimport { isUnexpected } from \"./isUnexpected\";\nimport { sleep } from \"./util/LROUtil\";\n\n/**\n * Uploads a file and creates a poller to poll for validation.\n * @param client - The Load Testing client.\n * @param options - The operation options.\n * @returns A poller which can be called to poll until completion of the job.\n */\nexport async function getFileValidationPoller(\n client: AzureLoadTestingClient,\n fileUploadResult: TestUploadFile201Response,\n polledOperationOptions: PolledOperationOptions = {}\n): Promise<FileUploadAndValidatePoller> {\n // get filename and testid from initial response\n const fileName = fileUploadResult.body.fileName;\n const requestUrl = fileUploadResult.request.url;\n const testId = requestUrl.substring(\n requestUrl.indexOf(\"tests/\") + 6,\n requestUrl.lastIndexOf(\"/files\")\n );\n type Handler = (state: OperationState<TestGetFile200Response>) => void;\n\n const state: OperationState<TestGetFile200Response> = {\n status: \"notStarted\",\n };\n\n const progressCallbacks = new Map<symbol, Handler>();\n const processProgressCallbacks = async (): Promise<void> =>\n progressCallbacks.forEach((h) => h(state));\n let resultPromise: Promise<TestGetFile200Response> | undefined;\n let cancelJob: (() => void) | undefined;\n const abortController = new AbortController();\n const currentPollIntervalInMs = polledOperationOptions.updateIntervalInMs ?? 2000;\n\n const poller: SimplePollerLike<OperationState<TestGetFile200Response>, TestGetFile200Response> = {\n async poll(options?: { abortSignal?: AbortSignalLike }): Promise<void> {\n if (options?.abortSignal?.aborted) {\n throw new AbortError(\"The polling was aborted.\");\n }\n\n if (fileName) {\n const fileValidationResponse = await client\n .path(\"/tests/{testId}/files/{fileName}\", testId, fileName)\n .get();\n if (isUnexpected(fileValidationResponse)) {\n state.status = \"failed\";\n state.error = new Error(fileValidationResponse.body.error.message);\n return;\n }\n\n switch (fileValidationResponse.body.validationStatus) {\n case \"NOT_VALIDATED\": {\n if (fileValidationResponse.body.fileType === \"JMX_FILE\") {\n state.status = \"running\";\n } else {\n state.status = \"succeeded\";\n }\n break;\n }\n case \"VALIDATION_INITIATED\": {\n state.status = \"running\";\n break;\n }\n case \"VALIDATION_SUCCESS\":\n case \"VALIDATION_NOT_REQUIRED\": {\n state.status = \"succeeded\";\n break;\n }\n case \"VALIDATION_FAILURE\": {\n state.status = \"failed\";\n state.error = new Error(fileValidationResponse.body.validationFailureDetails);\n break;\n }\n }\n state.result = fileValidationResponse;\n\n await processProgressCallbacks();\n }\n },\n\n pollUntilDone(pollOptions?: {\n abortSignal?: AbortSignalLike;\n }): Promise<TestGetFile200Response> {\n return (resultPromise ??= (async () => {\n const { abortSignal: inputAbortSignal } = pollOptions || {};\n const { signal: abortSignal } = inputAbortSignal\n ? new AbortController([inputAbortSignal, abortController.signal])\n : abortController;\n if (!poller.isDone()) {\n await poller.poll({ abortSignal });\n while (!poller.isDone()) {\n const delay = sleep(currentPollIntervalInMs, abortSignal);\n cancelJob = () => abortController.abort();\n await delay;\n await poller.poll({ abortSignal });\n }\n }\n switch (state.status) {\n case \"succeeded\":\n case \"failed\":\n case \"canceled\": {\n return poller.getResult() as TestGetFile200Response;\n }\n case \"notStarted\":\n case \"running\": {\n // Unreachable\n throw new Error(`polling completed without succeeding or failing`);\n }\n }\n })().finally(() => {\n resultPromise = undefined;\n }));\n },\n\n onProgress(\n callback: (state: OperationState<TestGetFile200Response>) => void\n ): CancelOnProgress {\n const s = Symbol();\n progressCallbacks.set(s, callback);\n\n return () => progressCallbacks.delete(s);\n },\n\n isDone(): boolean {\n return [\"succeeded\", \"failed\", \"canceled\"].includes(state.status);\n },\n\n stopPolling(): void {\n abortController.abort();\n cancelJob?.();\n },\n\n isStopped(): boolean {\n return resultPromise === undefined;\n },\n\n getOperationState(): OperationState<TestGetFile200Response> {\n return state;\n },\n\n getResult(): TestGetFile200Response | undefined {\n return state.result;\n },\n\n toString() {\n return JSON.stringify({ state });\n },\n };\n\n return poller;\n}\n"]}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getTestRunCompletionPoller = void 0;
6
+ const tslib_1 = require("tslib");
7
+ const abort_controller_1 = require("@azure/abort-controller");
8
+ const isUnexpected_1 = require("./isUnexpected");
9
+ const LROUtil_1 = require("./util/LROUtil");
10
+ /**
11
+ * Creates a poller to poll for test run status.
12
+ * @param client - The Load Testing client.
13
+ * @param options - The operation options.
14
+ * @returns A poller which can be called to poll until completion of the job.
15
+ */
16
+ function getTestRunCompletionPoller(client, createTestRunResponse, polledOperationOptions = {}) {
17
+ var _a;
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ const state = {
20
+ status: "notStarted",
21
+ };
22
+ const progressCallbacks = new Map();
23
+ const processProgressCallbacks = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return progressCallbacks.forEach((h) => h(state)); });
24
+ let resultPromise;
25
+ let cancelJob;
26
+ const abortController = new abort_controller_1.AbortController();
27
+ const currentPollIntervalInMs = (_a = polledOperationOptions.updateIntervalInMs) !== null && _a !== void 0 ? _a : 2000;
28
+ const testRunId = createTestRunResponse.body.testRunId;
29
+ const poller = {
30
+ poll(options) {
31
+ var _a;
32
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
33
+ if ((_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
34
+ throw new abort_controller_1.AbortError("The polling was aborted.");
35
+ }
36
+ if (testRunId) {
37
+ const getTestRunResult = yield client.path("/test-runs/{testRunId}", testRunId).get();
38
+ if ((0, isUnexpected_1.isUnexpected)(getTestRunResult)) {
39
+ state.status = "failed";
40
+ state.error = new Error(getTestRunResult.body.error.message);
41
+ return;
42
+ }
43
+ if (getTestRunResult.body.status === "FAILED") {
44
+ state.status = "failed";
45
+ state.error = new Error(getTestRunResult.body.status);
46
+ }
47
+ if (getTestRunResult.body.status === "CANCELLED") {
48
+ state.status = "canceled";
49
+ }
50
+ if (getTestRunResult.body.status === "DONE") {
51
+ state.status = "succeeded";
52
+ }
53
+ if ((0, LROUtil_1.isTestRunInProgress)(getTestRunResult.body)) {
54
+ state.status = "running";
55
+ }
56
+ state.result = getTestRunResult;
57
+ yield processProgressCallbacks();
58
+ }
59
+ });
60
+ },
61
+ pollUntilDone(pollOptions) {
62
+ return (resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (() => tslib_1.__awaiter(this, void 0, void 0, function* () {
63
+ const { abortSignal: inputAbortSignal } = pollOptions || {};
64
+ const { signal: abortSignal } = inputAbortSignal
65
+ ? new abort_controller_1.AbortController([inputAbortSignal, abortController.signal])
66
+ : abortController;
67
+ if (!poller.isDone()) {
68
+ yield poller.poll({ abortSignal });
69
+ while (!poller.isDone()) {
70
+ const delay = (0, LROUtil_1.sleep)(currentPollIntervalInMs, abortSignal);
71
+ cancelJob = () => abortController.abort();
72
+ yield delay;
73
+ yield poller.poll({ abortSignal });
74
+ }
75
+ }
76
+ switch (state.status) {
77
+ case "succeeded":
78
+ case "failed":
79
+ case "canceled": {
80
+ return poller.getResult();
81
+ }
82
+ case "notStarted":
83
+ case "running": {
84
+ // Unreachable
85
+ throw new Error(`polling completed without succeeding or failing`);
86
+ }
87
+ }
88
+ }))().finally(() => {
89
+ resultPromise = undefined;
90
+ })));
91
+ },
92
+ onProgress(callback) {
93
+ const s = Symbol();
94
+ progressCallbacks.set(s, callback);
95
+ return () => progressCallbacks.delete(s);
96
+ },
97
+ isDone() {
98
+ return ["succeeded", "failed", "canceled"].includes(state.status);
99
+ },
100
+ stopPolling() {
101
+ abortController.abort();
102
+ cancelJob === null || cancelJob === void 0 ? void 0 : cancelJob();
103
+ },
104
+ isStopped() {
105
+ return resultPromise === undefined;
106
+ },
107
+ getOperationState() {
108
+ return state;
109
+ },
110
+ getResult() {
111
+ return state.result;
112
+ },
113
+ toString() {
114
+ return JSON.stringify({ state });
115
+ },
116
+ };
117
+ return poller;
118
+ });
119
+ }
120
+ exports.getTestRunCompletionPoller = getTestRunCompletionPoller;
121
+ //# sourceMappingURL=getTestRunCompletionPoller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTestRunCompletionPoller.js","sourceRoot":"","sources":["../../src/getTestRunCompletionPoller.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,8DAAuF;AASvF,iDAA8C;AAC9C,4CAA4D;AAE5D;;;;;GAKG;AACH,SAAsB,0BAA0B,CAC9C,MAA8B,EAC9B,qBAA0F,EAC1F,yBAAiD,EAAE;;;QAInD,MAAM,KAAK,GAA0C;YACnD,MAAM,EAAE,YAAY;SACrB,CAAC;QAEF,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAmB,CAAC;QACrD,MAAM,wBAAwB,GAAG,GAAwB,EAAE,wDACzD,OAAA,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA,GAAA,CAAC;QAC7C,IAAI,aAAyD,CAAC;QAC9D,IAAI,SAAmC,CAAC;QACxC,MAAM,eAAe,GAAG,IAAI,kCAAe,EAAE,CAAC;QAC9C,MAAM,uBAAuB,GAAG,MAAA,sBAAsB,CAAC,kBAAkB,mCAAI,IAAI,CAAC;QAClF,MAAM,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC;QAEvD,MAAM,MAAM,GAAmF;YACvF,IAAI,CAAC,OAA2C;;;oBACpD,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,0CAAE,OAAO,EAAE;wBACjC,MAAM,IAAI,6BAAU,CAAC,0BAA0B,CAAC,CAAC;qBAClD;oBAED,IAAI,SAAS,EAAE;wBACb,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,wBAAwB,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AAC,CAAC;YACpE,CAAC;YAED,WAAW;gBACT,eAAe,CAAC,KAAK,EAAE,CAAC;gBACxB,SAAS,aAAT,SAAS,uBAAT,SAAS,EAAI,CAAC;YAChB,CAAC;YAED,SAAS;gBACP,OAAO,aAAa,KAAK,SAAS,CAAC;YACrC,CAAC;YAED,iBAAiB;gBACf,OAAO,KAAK,CAAC;YACf,CAAC;YAED,SAAS;gBACP,OAAO,KAAK,CAAC,MAAM,CAAC;YACtB,CAAC;YAED,QAAQ;gBACN,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;YACnC,CAAC;SACF,CAAC;QAEF,OAAO,MAAM,CAAC;;CACf;AAzHD,gEAyHC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortController, AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport { CancelOnProgress, OperationState, SimplePollerLike } from \"@azure/core-lro\";\nimport { TestRunCompletionPoller, PolledOperationOptions } from \"./models\";\nimport { AzureLoadTestingClient } from \"./clientDefinitions\";\nimport {\n TestRunCreateOrUpdate200Response,\n TestRunCreateOrUpdate201Response,\n TestRunGet200Response,\n} from \"./responses\";\nimport { isUnexpected } from \"./isUnexpected\";\nimport { sleep, isTestRunInProgress } from \"./util/LROUtil\";\n\n/**\n * Creates a poller to poll for test run status.\n * @param client - The Load Testing client.\n * @param options - The operation options.\n * @returns A poller which can be called to poll until completion of the job.\n */\nexport async function getTestRunCompletionPoller(\n client: AzureLoadTestingClient,\n createTestRunResponse: TestRunCreateOrUpdate200Response | TestRunCreateOrUpdate201Response,\n polledOperationOptions: PolledOperationOptions = {}\n): Promise<TestRunCompletionPoller> {\n type Handler = (state: OperationState<TestRunGet200Response>) => void;\n\n const state: OperationState<TestRunGet200Response> = {\n status: \"notStarted\",\n };\n\n const progressCallbacks = new Map<symbol, Handler>();\n const processProgressCallbacks = async (): Promise<void> =>\n progressCallbacks.forEach((h) => h(state));\n let resultPromise: Promise<TestRunGet200Response> | undefined;\n let cancelJob: (() => void) | undefined;\n const abortController = new AbortController();\n const currentPollIntervalInMs = polledOperationOptions.updateIntervalInMs ?? 2000;\n const testRunId = createTestRunResponse.body.testRunId;\n\n const poller: SimplePollerLike<OperationState<TestRunGet200Response>, TestRunGet200Response> = {\n async poll(options?: { abortSignal?: AbortSignalLike }): Promise<void> {\n if (options?.abortSignal?.aborted) {\n throw new AbortError(\"The polling was aborted.\");\n }\n\n if (testRunId) {\n const getTestRunResult = await client.path(\"/test-runs/{testRunId}\", testRunId).get();\n if (isUnexpected(getTestRunResult)) {\n state.status = \"failed\";\n state.error = new Error(getTestRunResult.body.error.message);\n return;\n }\n\n if (getTestRunResult.body.status === \"FAILED\") {\n state.status = \"failed\";\n state.error = new Error(getTestRunResult.body.status);\n }\n\n if (getTestRunResult.body.status === \"CANCELLED\") {\n state.status = \"canceled\";\n }\n\n if (getTestRunResult.body.status === \"DONE\") {\n state.status = \"succeeded\";\n }\n\n if (isTestRunInProgress(getTestRunResult.body)) {\n state.status = \"running\";\n }\n state.result = getTestRunResult;\n await processProgressCallbacks();\n }\n },\n\n pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<TestRunGet200Response> {\n return (resultPromise ??= (async () => {\n const { abortSignal: inputAbortSignal } = pollOptions || {};\n const { signal: abortSignal } = inputAbortSignal\n ? new AbortController([inputAbortSignal, abortController.signal])\n : abortController;\n if (!poller.isDone()) {\n await poller.poll({ abortSignal });\n while (!poller.isDone()) {\n const delay = sleep(currentPollIntervalInMs, abortSignal);\n cancelJob = () => abortController.abort();\n await delay;\n await poller.poll({ abortSignal });\n }\n }\n switch (state.status) {\n case \"succeeded\":\n case \"failed\":\n case \"canceled\": {\n return poller.getResult() as TestRunGet200Response;\n }\n case \"notStarted\":\n case \"running\": {\n // Unreachable\n throw new Error(`polling completed without succeeding or failing`);\n }\n }\n })().finally(() => {\n resultPromise = undefined;\n }));\n },\n\n onProgress(callback: (state: OperationState<TestRunGet200Response>) => void): CancelOnProgress {\n const s = Symbol();\n progressCallbacks.set(s, callback);\n\n return () => progressCallbacks.delete(s);\n },\n\n isDone(): boolean {\n return [\"succeeded\", \"failed\", \"canceled\"].includes(state.status);\n },\n\n stopPolling(): void {\n abortController.abort();\n cancelJob?.();\n },\n\n isStopped(): boolean {\n return resultPromise === undefined;\n },\n\n getOperationState(): OperationState<TestRunGet200Response> {\n return state;\n },\n\n getResult(): TestRunGet200Response | undefined {\n return state.result;\n },\n\n toString() {\n return JSON.stringify({ state });\n },\n };\n\n return poller;\n}\n"]}
@@ -1,13 +1,19 @@
1
+ "use strict";
1
2
  // Copyright (c) Microsoft Corporation.
2
3
  // Licensed under the MIT license.
3
- import AzureLoadTesting from "./azureLoadTesting";
4
- export * from "./azureLoadTesting";
5
- export * from "./parameters";
6
- export * from "./responses";
7
- export * from "./clientDefinitions";
8
- export * from "./isUnexpected";
9
- export * from "./models";
10
- export * from "./outputModels";
11
- export * from "./paginateHelper";
12
- export default AzureLoadTesting;
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getLongRunningPoller = void 0;
6
+ const tslib_1 = require("tslib");
7
+ const azureLoadTesting_1 = tslib_1.__importDefault(require("./azureLoadTesting"));
8
+ tslib_1.__exportStar(require("./azureLoadTesting"), exports);
9
+ tslib_1.__exportStar(require("./parameters"), exports);
10
+ tslib_1.__exportStar(require("./responses"), exports);
11
+ tslib_1.__exportStar(require("./clientDefinitions"), exports);
12
+ tslib_1.__exportStar(require("./isUnexpected"), exports);
13
+ tslib_1.__exportStar(require("./models"), exports);
14
+ tslib_1.__exportStar(require("./outputModels"), exports);
15
+ tslib_1.__exportStar(require("./paginateHelper"), exports);
16
+ var pollingHelper_1 = require("./pollingHelper");
17
+ Object.defineProperty(exports, "getLongRunningPoller", { enumerable: true, get: function () { return pollingHelper_1.getLongRunningPoller; } });
18
+ exports.default = azureLoadTesting_1.default;
13
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AAEjC,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport AzureLoadTesting from \"./azureLoadTesting\";\n\nexport * from \"./azureLoadTesting\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\n\nexport default AzureLoadTesting;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,kFAAkD;AAElD,6DAAmC;AACnC,uDAA6B;AAC7B,sDAA4B;AAC5B,8DAAoC;AACpC,yDAA+B;AAC/B,mDAAyB;AACzB,yDAA+B;AAC/B,2DAAiC;AACjC,iDAAuD;AAA9C,qHAAA,oBAAoB,OAAA;AAC7B,kBAAe,0BAAgB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport AzureLoadTesting from \"./azureLoadTesting\";\n\nexport * from \"./azureLoadTesting\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport { getLongRunningPoller } from \"./pollingHelper\";\nexport default AzureLoadTesting;\n"]}
@@ -1,49 +1,57 @@
1
+ "use strict";
1
2
  // Copyright (c) Microsoft Corporation.
2
3
  // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.isUnexpected = void 0;
3
6
  const responseMap = {
4
- "PATCH /appcomponents/{name}": ["200", "201"],
5
- "DELETE /appcomponents/{name}": ["204"],
6
- "GET /appcomponents/{name}": ["200"],
7
- "GET /appcomponents": ["200"],
8
- "PATCH /serverMetricsConfig/{name}": ["200", "201"],
9
- "GET /serverMetricsConfig/{name}": ["200"],
10
- "DELETE /serverMetricsConfig/{name}": ["204"],
11
- "GET /serverMetricsConfig": ["200"],
12
- "GET /serverMetricsConfig/default": ["200"],
13
- "GET /serverMetricsConfig/supportedResourceTypes": ["200"],
14
- "PATCH /loadtests/{testId}": ["200", "201"],
15
- "DELETE /loadtests/{testId}": ["204"],
16
- "GET /loadtests/{testId}": ["200"],
17
- "GET /loadtests/sortAndFilter": ["200"],
18
- "PUT /loadtests/{testId}/files/{fileId}": ["201"],
19
- "GET /loadtests/{testId}/files/{fileId}": ["200"],
20
- "DELETE /loadtests/{testId}/files/{fileId}": ["204"],
21
- "GET /loadtests/{testId}/files": ["200"],
22
- "DELETE /testruns/{testRunId}": ["204"],
23
- "PATCH /testruns/{testRunId}": ["200"],
24
- "GET /testruns/{testRunId}": ["200"],
25
- "GET /testruns/{testRunId}/files/{fileId}": ["200"],
26
- "GET /testruns/sortAndFilter": ["200"],
27
- "POST /testruns/{testRunId}:stop": ["200"],
28
- "POST /testruns/{testRunId}/clientMetrics": ["200"],
29
- "GET /testruns/{testRunId}/clientMetricsFilters": ["200"],
7
+ "PATCH /tests/{testId}": ["200", "201"],
8
+ "DELETE /tests/{testId}": ["204"],
9
+ "GET /tests/{testId}": ["200"],
10
+ "GET /tests": ["200"],
11
+ "PUT /tests/{testId}/files/{fileName}": ["201"],
12
+ "GET /tests/{testId}/files/{fileName}": ["200"],
13
+ "DELETE /tests/{testId}/files/{fileName}": ["204"],
14
+ "GET /tests/{testId}/files": ["200"],
15
+ "PATCH /tests/{testId}/app-components": ["200", "201"],
16
+ "GET /tests/{testId}/app-components": ["200"],
17
+ "PATCH /tests/{testId}/server-metrics-config": ["200", "201"],
18
+ "GET /tests/{testId}/server-metrics-config": ["200"],
19
+ "DELETE /test-runs/{testRunId}": ["204"],
20
+ "PATCH /test-runs/{testRunId}": ["200", "201"],
21
+ "GET /test-runs/{testRunId}": ["200"],
22
+ "GET /test-runs/{testRunId}/files/{fileName}": ["200"],
23
+ "GET /test-runs": ["200"],
24
+ "POST /test-runs/{testRunId}:stop": ["200"],
25
+ "GET /test-runs/{testRunId}/metric-namespaces": ["200"],
26
+ "GET /test-runs/{testRunId}/metric-definitions": ["200"],
27
+ "POST /test-runs/{testRunId}/metrics": ["200"],
28
+ "GET /test-runs/{testRunId}/metric-dimensions/{name}/values": ["200"],
29
+ "PATCH /test-runs/{testRunId}/app-components": ["200", "201"],
30
+ "GET /test-runs/{testRunId}/app-components": ["200"],
31
+ "PATCH /test-runs/{testRunId}/server-metrics-config": ["200", "201"],
32
+ "GET /test-runs/{testRunId}/server-metrics-config": ["200"],
30
33
  };
31
- export function isUnexpected(response) {
34
+ function isUnexpected(response) {
32
35
  const lroOriginal = response.headers["x-ms-original-url"];
33
36
  const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
34
37
  const method = response.request.method;
35
38
  let pathDetails = responseMap[`${method} ${url.pathname}`];
36
39
  if (!pathDetails) {
37
- pathDetails = geParametrizedPathSuccess(url.pathname);
40
+ pathDetails = geParametrizedPathSuccess(method, url.pathname);
38
41
  }
39
42
  return !pathDetails.includes(response.status);
40
43
  }
41
- function geParametrizedPathSuccess(path) {
44
+ exports.isUnexpected = isUnexpected;
45
+ function geParametrizedPathSuccess(method, path) {
46
+ var _a, _b;
42
47
  const pathParts = path.split("/");
43
48
  // Iterate the responseMap to find a match
44
49
  for (const [key, value] of Object.entries(responseMap)) {
45
50
  // Extracting the path from the map key which is in format
46
51
  // GET /path/foo
52
+ if (!key.startsWith(method)) {
53
+ continue;
54
+ }
47
55
  const candidatePath = getPathFromMapKey(key);
48
56
  // Get each part of the url path
49
57
  const candidateParts = candidatePath.split("/");
@@ -53,7 +61,7 @@ function geParametrizedPathSuccess(path) {
53
61
  // track if we have found a match to return the values found.
54
62
  let found = true;
55
63
  for (let i = 0; i < candidateParts.length; i++) {
56
- if (candidateParts[i].startsWith("{") && candidateParts[i].endsWith("}")) {
64
+ if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.endsWith("}"))) {
57
65
  // If the current part of the candidate is a "template" part
58
66
  // it is a match with the actual path part on hand
59
67
  // skip as the parameterized part can match anything
@@ -1 +1 @@
1
- {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA4DlC,MAAM,WAAW,GAA6B;IAC5C,6BAA6B,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC7C,8BAA8B,EAAE,CAAC,KAAK,CAAC;IACvC,2BAA2B,EAAE,CAAC,KAAK,CAAC;IACpC,oBAAoB,EAAE,CAAC,KAAK,CAAC;IAC7B,mCAAmC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IACnD,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,0BAA0B,EAAE,CAAC,KAAK,CAAC;IACnC,kCAAkC,EAAE,CAAC,KAAK,CAAC;IAC3C,iDAAiD,EAAE,CAAC,KAAK,CAAC;IAC1D,2BAA2B,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC3C,4BAA4B,EAAE,CAAC,KAAK,CAAC;IACrC,yBAAyB,EAAE,CAAC,KAAK,CAAC;IAClC,8BAA8B,EAAE,CAAC,KAAK,CAAC;IACvC,wCAAwC,EAAE,CAAC,KAA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CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AppComponentCreateOrUpdateAppComponents200Response,\n AppComponentCreateOrUpdateAppComponents201Response,\n AppComponentCreateOrUpdateAppComponentsdefaultResponse,\n AppComponentDeleteAppComponents204Response,\n AppComponentDeleteAppComponentsdefaultResponse,\n AppComponentGetAppComponentByName200Response,\n AppComponentGetAppComponentByNamedefaultResponse,\n AppComponentGetAppComponent200Response,\n AppComponentGetAppComponentdefaultResponse,\n ServerMetricsCreateOrUpdateServerMetricsConfig200Response,\n ServerMetricsCreateOrUpdateServerMetricsConfig201Response,\n ServerMetricsCreateOrUpdateServerMetricsConfigdefaultResponse,\n ServerMetricsGetServerMetricsConfigByName200Response,\n ServerMetricsGetServerMetricsConfigByNamedefaultResponse,\n ServerMetricsDeleteServerMetricsConfig204Response,\n ServerMetricsDeleteServerMetricsConfigdefaultResponse,\n ServerMetricsGetServerMetricsConfig200Response,\n ServerMetricsGetServerMetricsConfigdefaultResponse,\n ServerMetricsGetServerDefaultMetricsConfig200Response,\n ServerMetricsGetServerDefaultMetricsConfigdefaultResponse,\n ServerMetricsListSupportedResourceTypes200Response,\n ServerMetricsListSupportedResourceTypesdefaultResponse,\n TestCreateOrUpdateTest200Response,\n TestCreateOrUpdateTest201Response,\n TestCreateOrUpdateTestdefaultResponse,\n TestDeleteLoadTest204Response,\n TestDeleteLoadTestdefaultResponse,\n TestGetLoadTest200Response,\n TestGetLoadTestdefaultResponse,\n TestListLoadTestSearch200Response,\n TestListLoadTestSearchdefaultResponse,\n TestUploadTestFile201Response,\n TestUploadTestFiledefaultResponse,\n TestGetTestFile200Response,\n TestGetTestFiledefaultResponse,\n TestDeleteTestFile204Response,\n TestDeleteTestFiledefaultResponse,\n TestListTestFiles200Response,\n TestListTestFilesdefaultResponse,\n TestRunDeleteTestRun204Response,\n TestRunDeleteTestRundefaultResponse,\n TestRunCreateOrUpdateTestRun200Response,\n TestRunCreateOrUpdateTestRundefaultResponse,\n TestRunGetTestRun200Response,\n TestRunGetTestRundefaultResponse,\n TestRunGetTestRunFile200Response,\n TestRunGetTestRunFiledefaultResponse,\n TestRunListTestRuns200Response,\n TestRunListTestRunsdefaultResponse,\n TestRunStopTestRun200Response,\n TestRunStopTestRundefaultResponse,\n TestRunGetTestRunClientMetrics200Response,\n TestRunGetTestRunClientMetricsdefaultResponse,\n TestRunGetTestRunClientMetricsFilters200Response,\n TestRunGetTestRunClientMetricsFiltersdefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"PATCH /appcomponents/{name}\": [\"200\", \"201\"],\n \"DELETE /appcomponents/{name}\": [\"204\"],\n \"GET /appcomponents/{name}\": [\"200\"],\n \"GET /appcomponents\": [\"200\"],\n \"PATCH /serverMetricsConfig/{name}\": [\"200\", \"201\"],\n \"GET /serverMetricsConfig/{name}\": [\"200\"],\n \"DELETE /serverMetricsConfig/{name}\": [\"204\"],\n \"GET /serverMetricsConfig\": [\"200\"],\n \"GET /serverMetricsConfig/default\": [\"200\"],\n \"GET /serverMetricsConfig/supportedResourceTypes\": [\"200\"],\n \"PATCH /loadtests/{testId}\": [\"200\", \"201\"],\n \"DELETE /loadtests/{testId}\": [\"204\"],\n \"GET /loadtests/{testId}\": [\"200\"],\n \"GET /loadtests/sortAndFilter\": [\"200\"],\n \"PUT /loadtests/{testId}/files/{fileId}\": [\"201\"],\n \"GET /loadtests/{testId}/files/{fileId}\": [\"200\"],\n \"DELETE /loadtests/{testId}/files/{fileId}\": [\"204\"],\n \"GET /loadtests/{testId}/files\": [\"200\"],\n \"DELETE /testruns/{testRunId}\": [\"204\"],\n \"PATCH /testruns/{testRunId}\": [\"200\"],\n \"GET /testruns/{testRunId}\": [\"200\"],\n \"GET /testruns/{testRunId}/files/{fileId}\": [\"200\"],\n \"GET /testruns/sortAndFilter\": [\"200\"],\n \"POST /testruns/{testRunId}:stop\": [\"200\"],\n \"POST /testruns/{testRunId}/clientMetrics\": [\"200\"],\n \"GET /testruns/{testRunId}/clientMetricsFilters\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | AppComponentCreateOrUpdateAppComponents200Response\n | AppComponentCreateOrUpdateAppComponents201Response\n | AppComponentCreateOrUpdateAppComponentsdefaultResponse\n): response is AppComponentCreateOrUpdateAppComponentsdefaultResponse;\nexport function isUnexpected(\n response:\n | AppComponentDeleteAppComponents204Response\n | AppComponentDeleteAppComponentsdefaultResponse\n): response is AppComponentDeleteAppComponentsdefaultResponse;\nexport function isUnexpected(\n response:\n | AppComponentGetAppComponentByName200Response\n | AppComponentGetAppComponentByNamedefaultResponse\n): response is AppComponentGetAppComponentByNamedefaultResponse;\nexport function isUnexpected(\n response: AppComponentGetAppComponent200Response | AppComponentGetAppComponentdefaultResponse\n): response is AppComponentGetAppComponentdefaultResponse;\nexport function isUnexpected(\n response:\n | ServerMetricsCreateOrUpdateServerMetricsConfig200Response\n | ServerMetricsCreateOrUpdateServerMetricsConfig201Response\n | ServerMetricsCreateOrUpdateServerMetricsConfigdefaultResponse\n): response is ServerMetricsCreateOrUpdateServerMetricsConfigdefaultResponse;\nexport function isUnexpected(\n response:\n | ServerMetricsGetServerMetricsConfigByName200Response\n | ServerMetricsGetServerMetricsConfigByNamedefaultResponse\n): response is ServerMetricsGetServerMetricsConfigByNamedefaultResponse;\nexport function isUnexpected(\n response:\n | ServerMetricsDeleteServerMetricsConfig204Response\n | ServerMetricsDeleteServerMetricsConfigdefaultResponse\n): response is ServerMetricsDeleteServerMetricsConfigdefaultResponse;\nexport function isUnexpected(\n response:\n | ServerMetricsGetServerMetricsConfig200Response\n | ServerMetricsGetServerMetricsConfigdefaultResponse\n): response is ServerMetricsGetServerMetricsConfigdefaultResponse;\nexport function isUnexpected(\n response:\n | ServerMetricsGetServerDefaultMetricsConfig200Response\n | ServerMetricsGetServerDefaultMetricsConfigdefaultResponse\n): response is ServerMetricsGetServerDefaultMetricsConfigdefaultResponse;\nexport function isUnexpected(\n response:\n | ServerMetricsListSupportedResourceTypes200Response\n | ServerMetricsListSupportedResourceTypesdefaultResponse\n): response is ServerMetricsListSupportedResourceTypesdefaultResponse;\nexport function isUnexpected(\n response:\n | TestCreateOrUpdateTest200Response\n | TestCreateOrUpdateTest201Response\n | TestCreateOrUpdateTestdefaultResponse\n): response is TestCreateOrUpdateTestdefaultResponse;\nexport function isUnexpected(\n response: TestDeleteLoadTest204Response | TestDeleteLoadTestdefaultResponse\n): response is TestDeleteLoadTestdefaultResponse;\nexport function isUnexpected(\n response: TestGetLoadTest200Response | TestGetLoadTestdefaultResponse\n): response is TestGetLoadTestdefaultResponse;\nexport function isUnexpected(\n response: TestListLoadTestSearch200Response | TestListLoadTestSearchdefaultResponse\n): response is TestListLoadTestSearchdefaultResponse;\nexport function isUnexpected(\n response: TestUploadTestFile201Response | TestUploadTestFiledefaultResponse\n): response is TestUploadTestFiledefaultResponse;\nexport function isUnexpected(\n response: TestGetTestFile200Response | TestGetTestFiledefaultResponse\n): response is TestGetTestFiledefaultResponse;\nexport function isUnexpected(\n response: TestDeleteTestFile204Response | TestDeleteTestFiledefaultResponse\n): response is TestDeleteTestFiledefaultResponse;\nexport function isUnexpected(\n response: TestListTestFiles200Response | TestListTestFilesdefaultResponse\n): response is TestListTestFilesdefaultResponse;\nexport function isUnexpected(\n response: TestRunDeleteTestRun204Response | TestRunDeleteTestRundefaultResponse\n): response is TestRunDeleteTestRundefaultResponse;\nexport function isUnexpected(\n response: TestRunCreateOrUpdateTestRun200Response | TestRunCreateOrUpdateTestRundefaultResponse\n): response is TestRunCreateOrUpdateTestRundefaultResponse;\nexport function isUnexpected(\n response: TestRunGetTestRun200Response | TestRunGetTestRundefaultResponse\n): response is TestRunGetTestRundefaultResponse;\nexport function isUnexpected(\n response: TestRunGetTestRunFile200Response | TestRunGetTestRunFiledefaultResponse\n): response is TestRunGetTestRunFiledefaultResponse;\nexport function isUnexpected(\n response: TestRunListTestRuns200Response | TestRunListTestRunsdefaultResponse\n): response is TestRunListTestRunsdefaultResponse;\nexport function isUnexpected(\n response: TestRunStopTestRun200Response | TestRunStopTestRundefaultResponse\n): response is TestRunStopTestRundefaultResponse;\nexport function isUnexpected(\n response:\n | TestRunGetTestRunClientMetrics200Response\n | TestRunGetTestRunClientMetricsdefaultResponse\n): response is TestRunGetTestRunClientMetricsdefaultResponse;\nexport function isUnexpected(\n response:\n | TestRunGetTestRunClientMetricsFilters200Response\n | TestRunGetTestRunClientMetricsFiltersdefaultResponse\n): response is TestRunGetTestRunClientMetricsFiltersdefaultResponse;\nexport function isUnexpected(\n response:\n | AppComponentCreateOrUpdateAppComponents200Response\n | AppComponentCreateOrUpdateAppComponents201Response\n | AppComponentCreateOrUpdateAppComponentsdefaultResponse\n | AppComponentDeleteAppComponents204Response\n | AppComponentDeleteAppComponentsdefaultResponse\n | AppComponentGetAppComponentByName200Response\n | AppComponentGetAppComponentByNamedefaultResponse\n | AppComponentGetAppComponent200Response\n | AppComponentGetAppComponentdefaultResponse\n | ServerMetricsCreateOrUpdateServerMetricsConfig200Response\n | ServerMetricsCreateOrUpdateServerMetricsConfig201Response\n | ServerMetricsCreateOrUpdateServerMetricsConfigdefaultResponse\n | ServerMetricsGetServerMetricsConfigByName200Response\n | ServerMetricsGetServerMetricsConfigByNamedefaultResponse\n | ServerMetricsDeleteServerMetricsConfig204Response\n | ServerMetricsDeleteServerMetricsConfigdefaultResponse\n | ServerMetricsGetServerMetricsConfig200Response\n | ServerMetricsGetServerMetricsConfigdefaultResponse\n | ServerMetricsGetServerDefaultMetricsConfig200Response\n | ServerMetricsGetServerDefaultMetricsConfigdefaultResponse\n | ServerMetricsListSupportedResourceTypes200Response\n | ServerMetricsListSupportedResourceTypesdefaultResponse\n | TestCreateOrUpdateTest200Response\n | TestCreateOrUpdateTest201Response\n | TestCreateOrUpdateTestdefaultResponse\n | TestDeleteLoadTest204Response\n | TestDeleteLoadTestdefaultResponse\n | TestGetLoadTest200Response\n | TestGetLoadTestdefaultResponse\n | TestListLoadTestSearch200Response\n | TestListLoadTestSearchdefaultResponse\n | TestUploadTestFile201Response\n | TestUploadTestFiledefaultResponse\n | TestGetTestFile200Response\n | TestGetTestFiledefaultResponse\n | TestDeleteTestFile204Response\n | TestDeleteTestFiledefaultResponse\n | TestListTestFiles200Response\n | TestListTestFilesdefaultResponse\n | TestRunDeleteTestRun204Response\n | TestRunDeleteTestRundefaultResponse\n | TestRunCreateOrUpdateTestRun200Response\n | TestRunCreateOrUpdateTestRundefaultResponse\n | TestRunGetTestRun200Response\n | TestRunGetTestRundefaultResponse\n | TestRunGetTestRunFile200Response\n | TestRunGetTestRunFiledefaultResponse\n | TestRunListTestRuns200Response\n | TestRunListTestRunsdefaultResponse\n | TestRunStopTestRun200Response\n | TestRunStopTestRundefaultResponse\n | TestRunGetTestRunClientMetrics200Response\n | TestRunGetTestRunClientMetricsdefaultResponse\n | TestRunGetTestRunClientMetricsFilters200Response\n | TestRunGetTestRunClientMetricsFiltersdefaultResponse\n): response is\n | AppComponentCreateOrUpdateAppComponentsdefaultResponse\n | AppComponentDeleteAppComponentsdefaultResponse\n | AppComponentGetAppComponentByNamedefaultResponse\n | AppComponentGetAppComponentdefaultResponse\n | ServerMetricsCreateOrUpdateServerMetricsConfigdefaultResponse\n | ServerMetricsGetServerMetricsConfigByNamedefaultResponse\n | ServerMetricsDeleteServerMetricsConfigdefaultResponse\n | ServerMetricsGetServerMetricsConfigdefaultResponse\n | ServerMetricsGetServerDefaultMetricsConfigdefaultResponse\n | ServerMetricsListSupportedResourceTypesdefaultResponse\n | TestCreateOrUpdateTestdefaultResponse\n | TestDeleteLoadTestdefaultResponse\n | TestGetLoadTestdefaultResponse\n | TestListLoadTestSearchdefaultResponse\n | TestUploadTestFiledefaultResponse\n | TestGetTestFiledefaultResponse\n | TestDeleteTestFiledefaultResponse\n | TestListTestFilesdefaultResponse\n | TestRunDeleteTestRundefaultResponse\n | TestRunCreateOrUpdateTestRundefaultResponse\n | TestRunGetTestRundefaultResponse\n | TestRunGetTestRunFiledefaultResponse\n | TestRunListTestRunsdefaultResponse\n | TestRunStopTestRundefaultResponse\n | TestRunGetTestRunClientMetricsdefaultResponse\n | TestRunGetTestRunClientMetricsFiltersdefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = geParametrizedPathSuccess(url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (candidateParts.length === pathParts.length && hasParametrizedPath(key)) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (candidateParts[i].startsWith(\"{\") && candidateParts[i].endsWith(\"}\")) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
1
+ {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA+DlC,MAAM,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CAAA,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,UAAU,CAAC,GAAG,CAAC,MAAI,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,QAAQ,CAAC,GAAG,CAAC,CAAA,EAAE;oBAC1E,4DAA4D;oBAC5D,kDAAkD;oBAClD,oDAAoD;oBACpD,SAAS;iBACV;gBAED,8CAA8C;gBAC9C,wDAAwD;gBACxD,2CAA2C;gBAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;oBACtC,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;iBACP;aACF;YAED,qDAAqD;YACrD,yDAAyD;YACzD,oBAAoB;YACpB,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;KACF;IAED,6CAA6C;IAC7C,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n TestCreateOrUpdate200Response,\n TestCreateOrUpdate201Response,\n TestCreateOrUpdateDefaultResponse,\n TestDelete204Response,\n TestDeleteDefaultResponse,\n TestGet200Response,\n TestGetDefaultResponse,\n TestList200Response,\n TestListDefaultResponse,\n TestUploadFile201Response,\n TestUploadFileDefaultResponse,\n TestGetFile200Response,\n TestGetFileDefaultResponse,\n TestDeleteFile204Response,\n TestDeleteFileDefaultResponse,\n TestListFiles200Response,\n TestListFilesDefaultResponse,\n TestCreateOrUpdateAppComponents200Response,\n TestCreateOrUpdateAppComponents201Response,\n TestCreateOrUpdateAppComponentsDefaultResponse,\n TestListAppComponents200Response,\n TestListAppComponentsDefaultResponse,\n TestCreateOrUpdateServerMetricsConfig200Response,\n TestCreateOrUpdateServerMetricsConfig201Response,\n TestCreateOrUpdateServerMetricsConfigDefaultResponse,\n TestListServerMetricsConfig200Response,\n TestListServerMetricsConfigDefaultResponse,\n TestRunDelete204Response,\n TestRunDeleteDefaultResponse,\n TestRunCreateOrUpdate200Response,\n TestRunCreateOrUpdate201Response,\n TestRunCreateOrUpdateDefaultResponse,\n TestRunGet200Response,\n TestRunGetDefaultResponse,\n TestRunGetFile200Response,\n TestRunGetFileDefaultResponse,\n TestRunList200Response,\n TestRunListDefaultResponse,\n TestRunStop200Response,\n TestRunStopDefaultResponse,\n TestRunListMetricNamespaces200Response,\n TestRunListMetricNamespacesDefaultResponse,\n TestRunListMetricDefinitions200Response,\n TestRunListMetricDefinitionsDefaultResponse,\n TestRunListMetrics200Response,\n TestRunListMetricsDefaultResponse,\n TestRunListMetricDimensionValues200Response,\n TestRunListMetricDimensionValuesDefaultResponse,\n TestRunCreateOrUpdateAppComponents200Response,\n TestRunCreateOrUpdateAppComponents201Response,\n TestRunCreateOrUpdateAppComponentsDefaultResponse,\n TestRunListAppComponents200Response,\n TestRunListAppComponentsDefaultResponse,\n TestRunCreateOrUpdateServerMetricsConfig200Response,\n TestRunCreateOrUpdateServerMetricsConfig201Response,\n TestRunCreateOrUpdateServerMetricsConfigDefaultResponse,\n TestRunListServerMetricsConfig200Response,\n TestRunListServerMetricsConfigDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"PATCH /tests/{testId}\": [\"200\", \"201\"],\n \"DELETE /tests/{testId}\": [\"204\"],\n \"GET /tests/{testId}\": [\"200\"],\n \"GET /tests\": [\"200\"],\n \"PUT /tests/{testId}/files/{fileName}\": [\"201\"],\n \"GET /tests/{testId}/files/{fileName}\": [\"200\"],\n \"DELETE /tests/{testId}/files/{fileName}\": [\"204\"],\n \"GET /tests/{testId}/files\": [\"200\"],\n \"PATCH /tests/{testId}/app-components\": [\"200\", \"201\"],\n \"GET /tests/{testId}/app-components\": [\"200\"],\n \"PATCH /tests/{testId}/server-metrics-config\": [\"200\", \"201\"],\n \"GET /tests/{testId}/server-metrics-config\": [\"200\"],\n \"DELETE /test-runs/{testRunId}\": [\"204\"],\n \"PATCH /test-runs/{testRunId}\": [\"200\", \"201\"],\n \"GET /test-runs/{testRunId}\": [\"200\"],\n \"GET /test-runs/{testRunId}/files/{fileName}\": [\"200\"],\n \"GET /test-runs\": [\"200\"],\n \"POST /test-runs/{testRunId}:stop\": [\"200\"],\n \"GET /test-runs/{testRunId}/metric-namespaces\": [\"200\"],\n \"GET /test-runs/{testRunId}/metric-definitions\": [\"200\"],\n \"POST /test-runs/{testRunId}/metrics\": [\"200\"],\n \"GET /test-runs/{testRunId}/metric-dimensions/{name}/values\": [\"200\"],\n \"PATCH /test-runs/{testRunId}/app-components\": [\"200\", \"201\"],\n \"GET /test-runs/{testRunId}/app-components\": [\"200\"],\n \"PATCH /test-runs/{testRunId}/server-metrics-config\": [\"200\", \"201\"],\n \"GET /test-runs/{testRunId}/server-metrics-config\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | TestCreateOrUpdate200Response\n | TestCreateOrUpdate201Response\n | TestCreateOrUpdateDefaultResponse\n): response is TestCreateOrUpdateDefaultResponse;\nexport function isUnexpected(\n response: TestDelete204Response | TestDeleteDefaultResponse\n): response is TestDeleteDefaultResponse;\nexport function isUnexpected(\n response: TestGet200Response | TestGetDefaultResponse\n): response is TestGetDefaultResponse;\nexport function isUnexpected(\n response: TestList200Response | TestListDefaultResponse\n): response is TestListDefaultResponse;\nexport function isUnexpected(\n response: TestUploadFile201Response | TestUploadFileDefaultResponse\n): response is TestUploadFileDefaultResponse;\nexport function isUnexpected(\n response: TestGetFile200Response | TestGetFileDefaultResponse\n): response is TestGetFileDefaultResponse;\nexport function isUnexpected(\n response: TestDeleteFile204Response | TestDeleteFileDefaultResponse\n): response is TestDeleteFileDefaultResponse;\nexport function isUnexpected(\n response: TestListFiles200Response | TestListFilesDefaultResponse\n): response is TestListFilesDefaultResponse;\nexport function isUnexpected(\n response:\n | TestCreateOrUpdateAppComponents200Response\n | TestCreateOrUpdateAppComponents201Response\n | TestCreateOrUpdateAppComponentsDefaultResponse\n): response is TestCreateOrUpdateAppComponentsDefaultResponse;\nexport function isUnexpected(\n response: TestListAppComponents200Response | TestListAppComponentsDefaultResponse\n): response is TestListAppComponentsDefaultResponse;\nexport function isUnexpected(\n response:\n | TestCreateOrUpdateServerMetricsConfig200Response\n | TestCreateOrUpdateServerMetricsConfig201Response\n | TestCreateOrUpdateServerMetricsConfigDefaultResponse\n): response is TestCreateOrUpdateServerMetricsConfigDefaultResponse;\nexport function isUnexpected(\n response: TestListServerMetricsConfig200Response | TestListServerMetricsConfigDefaultResponse\n): response is TestListServerMetricsConfigDefaultResponse;\nexport function isUnexpected(\n response: TestRunDelete204Response | TestRunDeleteDefaultResponse\n): response is TestRunDeleteDefaultResponse;\nexport function isUnexpected(\n response:\n | TestRunCreateOrUpdate200Response\n | TestRunCreateOrUpdate201Response\n | TestRunCreateOrUpdateDefaultResponse\n): response is TestRunCreateOrUpdateDefaultResponse;\nexport function isUnexpected(\n response: TestRunGet200Response | TestRunGetDefaultResponse\n): response is TestRunGetDefaultResponse;\nexport function isUnexpected(\n response: TestRunGetFile200Response | TestRunGetFileDefaultResponse\n): response is TestRunGetFileDefaultResponse;\nexport function isUnexpected(\n response: TestRunList200Response | TestRunListDefaultResponse\n): response is TestRunListDefaultResponse;\nexport function isUnexpected(\n response: TestRunStop200Response | TestRunStopDefaultResponse\n): response is TestRunStopDefaultResponse;\nexport function isUnexpected(\n response: TestRunListMetricNamespaces200Response | TestRunListMetricNamespacesDefaultResponse\n): response is TestRunListMetricNamespacesDefaultResponse;\nexport function isUnexpected(\n response: TestRunListMetricDefinitions200Response | TestRunListMetricDefinitionsDefaultResponse\n): response is TestRunListMetricDefinitionsDefaultResponse;\nexport function isUnexpected(\n response: TestRunListMetrics200Response | TestRunListMetricsDefaultResponse\n): response is TestRunListMetricsDefaultResponse;\nexport function isUnexpected(\n response:\n | TestRunListMetricDimensionValues200Response\n | TestRunListMetricDimensionValuesDefaultResponse\n): response is TestRunListMetricDimensionValuesDefaultResponse;\nexport function isUnexpected(\n response:\n | TestRunCreateOrUpdateAppComponents200Response\n | TestRunCreateOrUpdateAppComponents201Response\n | TestRunCreateOrUpdateAppComponentsDefaultResponse\n): response is TestRunCreateOrUpdateAppComponentsDefaultResponse;\nexport function isUnexpected(\n response: TestRunListAppComponents200Response | TestRunListAppComponentsDefaultResponse\n): response is TestRunListAppComponentsDefaultResponse;\nexport function isUnexpected(\n response:\n | TestRunCreateOrUpdateServerMetricsConfig200Response\n | TestRunCreateOrUpdateServerMetricsConfig201Response\n | TestRunCreateOrUpdateServerMetricsConfigDefaultResponse\n): response is TestRunCreateOrUpdateServerMetricsConfigDefaultResponse;\nexport function isUnexpected(\n response:\n | TestRunListServerMetricsConfig200Response\n | TestRunListServerMetricsConfigDefaultResponse\n): response is TestRunListServerMetricsConfigDefaultResponse;\nexport function isUnexpected(\n response:\n | TestCreateOrUpdate200Response\n | TestCreateOrUpdate201Response\n | TestCreateOrUpdateDefaultResponse\n | TestDelete204Response\n | TestDeleteDefaultResponse\n | TestGet200Response\n | TestGetDefaultResponse\n | TestList200Response\n | TestListDefaultResponse\n | TestUploadFile201Response\n | TestUploadFileDefaultResponse\n | TestGetFile200Response\n | TestGetFileDefaultResponse\n | TestDeleteFile204Response\n | TestDeleteFileDefaultResponse\n | TestListFiles200Response\n | TestListFilesDefaultResponse\n | TestCreateOrUpdateAppComponents200Response\n | TestCreateOrUpdateAppComponents201Response\n | TestCreateOrUpdateAppComponentsDefaultResponse\n | TestListAppComponents200Response\n | TestListAppComponentsDefaultResponse\n | TestCreateOrUpdateServerMetricsConfig200Response\n | TestCreateOrUpdateServerMetricsConfig201Response\n | TestCreateOrUpdateServerMetricsConfigDefaultResponse\n | TestListServerMetricsConfig200Response\n | TestListServerMetricsConfigDefaultResponse\n | TestRunDelete204Response\n | TestRunDeleteDefaultResponse\n | TestRunCreateOrUpdate200Response\n | TestRunCreateOrUpdate201Response\n | TestRunCreateOrUpdateDefaultResponse\n | TestRunGet200Response\n | TestRunGetDefaultResponse\n | TestRunGetFile200Response\n | TestRunGetFileDefaultResponse\n | TestRunList200Response\n | TestRunListDefaultResponse\n | TestRunStop200Response\n | TestRunStopDefaultResponse\n | TestRunListMetricNamespaces200Response\n | TestRunListMetricNamespacesDefaultResponse\n | TestRunListMetricDefinitions200Response\n | TestRunListMetricDefinitionsDefaultResponse\n | TestRunListMetrics200Response\n | TestRunListMetricsDefaultResponse\n | TestRunListMetricDimensionValues200Response\n | TestRunListMetricDimensionValuesDefaultResponse\n | TestRunCreateOrUpdateAppComponents200Response\n | TestRunCreateOrUpdateAppComponents201Response\n | TestRunCreateOrUpdateAppComponentsDefaultResponse\n | TestRunListAppComponents200Response\n | TestRunListAppComponentsDefaultResponse\n | TestRunCreateOrUpdateServerMetricsConfig200Response\n | TestRunCreateOrUpdateServerMetricsConfig201Response\n | TestRunCreateOrUpdateServerMetricsConfigDefaultResponse\n | TestRunListServerMetricsConfig200Response\n | TestRunListServerMetricsConfigDefaultResponse\n): response is\n | TestCreateOrUpdateDefaultResponse\n | TestDeleteDefaultResponse\n | TestGetDefaultResponse\n | TestListDefaultResponse\n | TestUploadFileDefaultResponse\n | TestGetFileDefaultResponse\n | TestDeleteFileDefaultResponse\n | TestListFilesDefaultResponse\n | TestCreateOrUpdateAppComponentsDefaultResponse\n | TestListAppComponentsDefaultResponse\n | TestCreateOrUpdateServerMetricsConfigDefaultResponse\n | TestListServerMetricsConfigDefaultResponse\n | TestRunDeleteDefaultResponse\n | TestRunCreateOrUpdateDefaultResponse\n | TestRunGetDefaultResponse\n | TestRunGetFileDefaultResponse\n | TestRunListDefaultResponse\n | TestRunStopDefaultResponse\n | TestRunListMetricNamespacesDefaultResponse\n | TestRunListMetricDefinitionsDefaultResponse\n | TestRunListMetricsDefaultResponse\n | TestRunListMetricDimensionValuesDefaultResponse\n | TestRunCreateOrUpdateAppComponentsDefaultResponse\n | TestRunListAppComponentsDefaultResponse\n | TestRunCreateOrUpdateServerMetricsConfigDefaultResponse\n | TestRunListServerMetricsConfigDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = geParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (candidateParts.length === pathParts.length && hasParametrizedPath(key)) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.endsWith(\"}\")) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
@@ -1,4 +1,5 @@
1
+ "use strict";
1
2
  // Copyright (c) Microsoft Corporation.
2
3
  // Licensed under the MIT license.
3
- export {};
4
+ Object.defineProperty(exports, "__esModule", { value: true });
4
5
  //# sourceMappingURL=models.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport interface AppComponentsMap {\n /** Azure Load Testing resource Id */\n resourceId?: string;\n /** [Required, if testRunId is not given] Load test unique identifier */\n testId?: string;\n /** [Required if testId is not given] Load test run unique identifier */\n testRunId?: string;\n /** AppComponent name */\n name?: string;\n /** AppComponents Map { resource id (Fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } */\n value: Record<string, AppComponent>;\n}\n\nexport interface AppComponent {\n /** Fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName} */\n resourceId: string;\n /** Azure resource name */\n resourceName: string;\n /** Azure resource type */\n resourceType: string;\n /** Azure resource display name */\n displayName?: string;\n /** Resource group name of the Azure resource */\n resourceGroup?: string;\n /** Subscription Id of the Azure resource */\n subscriptionId?: string;\n /** Kind of Azure resource type */\n kind?: string;\n}\n\nexport interface ServerMetricsModel {\n /** Server metrics config name. */\n name?: string;\n /** [Required, if testRunId is not given] Load test unique identifier */\n testId?: string;\n /** [Required, if testId is not given] Load test run unique identifier */\n testRunId?: string;\n /** Metrics map {metric id : metrics object} (Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition for metric id). */\n metrics?: Record<string, ResourceMetricModel>;\n}\n\nexport interface ResourceMetricModel {\n /** Unique identifier for metric. */\n id?: string;\n /** Azure resource Id. */\n resourceId: string;\n /** Metric name space. */\n metricnamespace: string;\n /** Metric description. */\n displayDescription?: string;\n /** Metric name object. */\n name: ServerMetricName;\n /** Metric aggregation. */\n aggregation: string;\n /** Metric unit. */\n unit?: string;\n /** Azure resource type. */\n resourceType: string;\n}\n\nexport interface ServerMetricName {\n /** Metric name value. */\n value: string;\n /** Metric localized name. */\n localizedValue: string;\n}\n\nexport interface TestModel {\n /** Unique test name as identifier. */\n testId?: string;\n /** The test description. */\n description?: string;\n /** Display name of a test. */\n displayName?: string;\n /** Fully qualified resource Id e.g /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. */\n resourceId?: string;\n /** The load test configuration. */\n loadTestConfig?: LoadTestConfig;\n /** Pass fail criteria for a test. */\n passFailCriteria?: PassFailCriteria;\n /** The created DateTime(ISO 8601 literal format) of the test model. */\n createdDateTime?: Date | string;\n /** The user that created the test model. */\n createdBy?: string;\n /** The last Modified DateTime(ISO 8601 literal format) of the test model. */\n lastModifiedDateTime?: Date | string;\n /** The user that last modified the test model. */\n lastModifiedBy?: string;\n /** The input artifacts for the test. */\n inputArtifacts?: InputTestArtifacts;\n /** Secrets can be stored in an Azure Key Vault or any other secret store. If the secret is stored in an Azure Key Vault, the value should be the secret identifier and the type should be AKV_SECRET_URI. If the secret is stored elsewhere, the secret value should be provided directly and the type should be SECRET_VALUE. */\n secrets?: Record<string, SecretMetadata>;\n /** Environment variables which are defined as a set of <name,value> pairs. */\n environmentVariables?: Record<string, string>;\n /** Subnet ID on which the load test instances should run. */\n subnetId?: string;\n /** Type of the managed identity referencing the Key vault. */\n keyvaultReferenceIdentityType?: string;\n /** Resource Id of the managed identity referencing the Key vault. */\n keyvaultReferenceIdentityId?: string;\n}\n\nexport interface LoadTestConfig {\n /** The number of engine instances to execute load test. Supported values are in range of 1-45. Required for creating a new test. */\n engineInstances?: number;\n /** Whether all the input CSV files should be split evenly across all engines. */\n splitAllCSVs?: boolean;\n}\n\nexport interface PassFailCriteria {\n /** Map of id and pass fail metrics { id : pass fail metrics }. */\n passFailMetrics?: Record<string, PassFailMetric>;\n}\n\nexport interface PassFailMetric {\n /** The client metric on which the criteria should be applied. Allowed values - ‘response_time_ms’ , ‘latency’, ‘error’, ‘requests’, ‘requests_per_sec’. */\n clientmetric?: string;\n /** The aggregation function to be applied on the client metric. Allowed functions - ‘percentage’ - for error metric ,‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, ‘count’ - for requests. */\n aggregate?: string;\n /** The comparison operator. Supported types ‘>’ */\n condition?: string;\n /** Request name for which the Pass fail criteria has to be applied. */\n requestName?: string;\n /** The value to compare with the client metric. Allowed values - ‘error : [0.0 , 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. */\n value?: number;\n /** Either ‘stop’ or ‘continue’ after the threshold is met. Default is ‘continue’. */\n action?: string;\n /** The actual value of the client metric for the test run. */\n actualValue?: number;\n /** Outcome of the test run. possible outcome - ‘passed’ , ‘failed’ , ‘undetermined’. */\n result?: string;\n}\n\nexport interface InputTestArtifacts {\n /** FileUrl Model. */\n configUrl?: FileUrl;\n /** FileUrl Model. */\n testScriptUrl?: FileUrl;\n /** FileUrl Model. */\n userPropUrl?: FileUrl;\n /** FileUrl Model. */\n inputArtifactsZipFileurl?: FileUrl;\n /** The input artifacts file { name : url } map for the test run. */\n additionalUrls?: Array<FileUrl>;\n}\n\nexport interface FileUrl {\n /** File URL. */\n url?: string;\n /** File unique identifier. */\n fileId?: string;\n /** Name of the file. */\n filename?: string;\n /** Integer representation of the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS) */\n fileType?: \"0\" | \"1\" | \"2\";\n /** Expiry time of the file */\n expireTime?: Date | string;\n /** Validation status of the file */\n validationStatus?: string;\n}\n\nexport interface SecretMetadata {\n /** The value of the secret, of type AKV_SECRET_URI or SECRET_VALUE */\n value?: string;\n /** Type of secret. eg. AKV_SECRET_URI/SECRET_VALUE */\n type?: string;\n}\n\nexport interface TestRunModel {\n /** Unique test run name as identifier. */\n testRunId?: string;\n /** Display name of a test run. */\n displayName?: string;\n /** Associated test Id. */\n testId?: string;\n /** Load test resource Id. */\n resourceId?: string;\n /** The test run description. */\n description?: string;\n /** The test run status. */\n status?: string;\n /** The test run start DateTime(ISO 8601 literal format). */\n startDateTime?: Date | string;\n /** The test run end DateTime(ISO 8601 literal format). */\n endDateTime?: Date | string;\n /** The load test configuration. */\n loadTestConfig?: LoadTestConfig;\n /** Test result for pass/Fail criteria used during the test run. possible outcome - ‘Passed’ , ‘Failed’ , ‘Not Applicable’. */\n testResult?: string;\n /** Pass fail criteria for a test. */\n passFailCriteria?: PassFailCriteria;\n testArtifacts?: TestArtifacts;\n /** Test run initiated time */\n executedDateTime?: Date | string;\n /** Number of virtual users, for which test has been run. */\n vusers?: number;\n /** Test run statistics */\n testRunStatistics?: Record<string, TestRunStatisticsModel>;\n /** The created DateTime(ISO 8601 literal format) of the test run. */\n createdDateTime?: Date | string;\n /** The user that created the test run. */\n createdBy?: string;\n /** The last updated DateTime(ISO 8601 literal format) of the test run. */\n lastModifiedDateTime?: Date | string;\n /** The user that updated the test run. */\n lastModifiedBy?: string;\n /** Portal url. */\n portalUrl?: string;\n /** Secrets can be stored in an Azure Key Vault or any other secret store. If the secret is stored in an Azure Key Vault, the value should be the secret identifier and the type should be AKV_SECRET_URI. If the secret is stored elsewhere, the secret value should be provided directly and the type should be SECRET_VALUE. */\n secrets?: Record<string, SecretMetadata>;\n /** Environment variables which are defined as a set of <name,value> pairs. */\n environmentVariables?: Record<string, string>;\n /** Test run duration in milliseconds. */\n duration?: number;\n /** Subnet ID on which the load test instances should run. */\n subnetId?: string;\n}\n\nexport interface TestArtifacts {\n /** The input artifacts for the test. */\n inputArtifacts: InputTestArtifacts;\n /** The output artifacts for the test run. */\n outputArtifacts?: OutputTestArtifacts;\n}\n\nexport interface OutputTestArtifacts {\n /** FileUrl Model. */\n resultUrl?: FileUrl;\n /** FileUrl Model. */\n logsUrl?: FileUrl;\n}\n\nexport interface TestRunStatisticsModel {\n /** Transaction name. */\n transaction?: string;\n /** Sampler count. */\n sampleCount?: number;\n /** Error count. */\n errorCount?: number;\n /** Error percentage. */\n errorPct?: number;\n /** Mean response time. */\n meanResTime?: number;\n /** Median response time. */\n medianResTime?: number;\n /** Max response time. */\n maxResTime?: number;\n /** Minimum response time. */\n minResTime?: number;\n /** 90 percentile response time. */\n pct1ResTime?: number;\n /** 95 percentile response time. */\n pct2ResTime?: number;\n /** 99 percentile response time. */\n pct3ResTime?: number;\n /** Throughput. */\n throughput?: number;\n /** Received network bytes. */\n receivedKBytesPerSec?: number;\n /** Sent network bytes. */\n sentKBytesPerSec?: number;\n}\n\nexport interface ClientMetricsRequestModel {\n /** List of request samplers, maximum supported samplers for queries are 20. In case of empty, it will return metrics for maximum 20 samplers */\n requestSamplers?: Array<string>;\n /** List of errors, maximum supported errors for queries are 20. In case of empty, by default will return metrics for maximum 20 errors */\n errors?: Array<string>;\n /** List of percentiles values for response time, supported values 50,90,99,95. Default value is 50th percentile. */\n percentiles?: Array<string>;\n /** For test duration less than 10 minutes group by time interval can be any one of 5s,10s,1m,5m.\\n\\nFor test duration greater than 10 minutes, group by time interval can be any one of 1m,5m,1h. Default value is 1m. */\n groupByInterval?: string;\n /** Start time */\n startTime: Date | string;\n /** End time */\n endTime: Date | string;\n}\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationState, SimplePollerLike } from \"@azure/core-lro\";\nimport {\n TestGetFile200Response,\n TestRunCreateOrUpdate200Response,\n TestRunCreateOrUpdate201Response,\n TestRunGet200Response,\n TestUploadFile201Response,\n} from \"./responses\";\n\n/** Load test model */\nexport interface Test {\n /** Pass fail criteria for a test. */\n passFailCriteria?: PassFailCriteria;\n /** Secrets can be stored in an Azure Key Vault or any other secret store. If the secret is stored in an Azure Key Vault, the value should be the secret identifier and the type should be AKV_SECRET_URI. If the secret is stored elsewhere, the secret value should be provided directly and the type should be SECRET_VALUE. */\n secrets?: Record<string, Secret>;\n /** Certificates metadata */\n certificate?: CertificateMetadata;\n /** Environment variables which are defined as a set of <name,value> pairs. */\n environmentVariables?: Record<string, string>;\n /** The load test configuration. */\n loadTestConfiguration?: LoadTestConfiguration;\n /** The input artifacts for the test. */\n inputArtifacts?: TestInputArtifacts;\n /** Unique test name as identifier. */\n testId?: string;\n /** The test description. */\n description?: string;\n /** Display name of a test. */\n displayName?: string;\n /** Subnet ID on which the load test instances should run. */\n subnetId?: string;\n /** Type of the managed identity referencing the Key vault. */\n keyvaultReferenceIdentityType?: string;\n /** Resource Id of the managed identity referencing the Key vault. */\n keyvaultReferenceIdentityId?: string;\n /** The creation datetime(ISO 8601 literal format). */\n createdDateTime?: Date | string;\n /** The user that created. */\n createdBy?: string;\n /** The last Modified datetime(ISO 8601 literal format). */\n lastModifiedDateTime?: Date | string;\n /** The user that last modified. */\n lastModifiedBy?: string;\n}\n\n/** Pass fail criteria for a test. */\nexport interface PassFailCriteria {\n /** Map of id and pass fail metrics { id : pass fail metrics }. */\n passFailMetrics?: Record<string, PassFailMetric>;\n}\n\n/** Pass fail metric */\nexport interface PassFailMetric {\n /** The client metric on which the criteria should be applied. */\n clientMetric?: \"response_time_ms\" | \"latency\" | \"error\" | \"requests\" | \"requests_per_sec\";\n /** The aggregation function to be applied on the client metric. Allowed functions - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, ‘count’ - for requests */\n aggregate?: \"count\" | \"percentage\" | \"avg\" | \"p50\" | \"p90\" | \"p95\" | \"p99\" | \"min\" | \"max\";\n /** The comparison operator. Supported types ‘>’, ‘<’ */\n condition?: string;\n /** Request name for which the Pass fail criteria has to be applied */\n requestName?: string;\n /** The value to compare with the client metric. Allowed values - ‘error : [0.0 , 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. */\n value?: number;\n /** Action taken after the threshold is met. Default is ‘continue’. */\n action?: \"stop\" | \"continue\";\n /** The actual value of the client metric for the test run. */\n actualValue?: number;\n /** Outcome of the test run. */\n result?: \"passed\" | \"undetermined\" | \"failed\";\n}\n\n/** Secret */\nexport interface Secret {\n /** The value of the secret for the respective type */\n value?: string;\n /** Type of secret */\n type?: \"AKV_SECRET_URI\" | \"SECRET_VALUE\";\n}\n\n/** Certificates metadata */\nexport interface CertificateMetadata {\n /** The value of the certificate for respective type */\n value?: string;\n /** Type of certificate */\n type?: \"AKV_CERT_URI\";\n /** Name of the certificate. */\n name?: string;\n}\n\n/** The load test configuration. */\nexport interface LoadTestConfiguration {\n /** The number of engine instances to execute load test. Supported values are in range of 1-45. Required for creating a new test. */\n engineInstances?: number;\n /** If false, Azure Load Testing copies and processes your input files unmodified across all test engine instances. If true, Azure Load Testing splits the CSV input data evenly across all engine instances. If you provide multiple CSV files, each file will be split evenly. */\n splitAllCSVs?: boolean;\n /** If true, optionalLoadTestConfig is required and JMX script for the load test is not required to upload. */\n quickStartTest?: boolean;\n /** Optional load test config */\n optionalLoadTestConfig?: OptionalLoadTestConfig;\n}\n\n/** Optional load test config */\nexport interface OptionalLoadTestConfig {\n /** Test URL. Provide the complete HTTP URL. For example, http://contoso-app.azurewebsites.net/login */\n endpointUrl?: string;\n /** No of concurrent virtual users */\n virtualUsers?: number;\n /** Ramp up time */\n rampUpTime?: number;\n /** Test run duration */\n duration?: number;\n}\n\n/** The input artifacts for the test. */\nexport interface TestInputArtifacts {\n /** File info */\n configFileInfo?: FileInfo;\n /** File info */\n testScriptFileInfo?: FileInfo;\n /** File info */\n userPropFileInfo?: FileInfo;\n /** File info */\n inputArtifactsZipFileInfo?: FileInfo;\n /** Additional supported files for the test run */\n additionalFileInfo?: Array<FileInfo>;\n}\n\n/** File info */\nexport interface FileInfo {\n /** File URL. */\n url?: string;\n /** Name of the file. */\n fileName?: string;\n /** File type */\n fileType?: \"JMX_FILE\" | \"USER_PROPERTIES\" | \"ADDITIONAL_ARTIFACTS\";\n /** Expiry time of the file (ISO 8601 literal format) */\n expireDateTime?: Date | string;\n /** Validation status of the file */\n validationStatus?:\n | \"NOT_VALIDATED\"\n | \"VALIDATION_SUCCESS\"\n | \"VALIDATION_FAILURE\"\n | \"VALIDATION_INITIATED\"\n | \"VALIDATION_NOT_REQUIRED\";\n /** Validation failure error details */\n validationFailureDetails?: string;\n}\n\n/** Test app component */\nexport interface TestAppComponents {\n /** Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } */\n components: Record<string, AppComponent>;\n /** Test identifier */\n testId?: string;\n /** The creation datetime(ISO 8601 literal format). */\n createdDateTime?: Date | string;\n /** The user that created. */\n createdBy?: string;\n /** The last Modified datetime(ISO 8601 literal format). */\n lastModifiedDateTime?: Date | string;\n /** The user that last modified. */\n lastModifiedBy?: string;\n}\n\n/** An Azure resource object (Refer azure generic resource model : https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource) */\nexport interface AppComponent {\n /** fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName} */\n resourceId?: string;\n /** Azure resource name, required while creating the app component. */\n resourceName?: string;\n /** Azure resource type, required while creating the app component. */\n resourceType?: string;\n /** Azure resource display name */\n displayName?: string;\n /** Resource group name of the Azure resource */\n resourceGroup?: string;\n /** Subscription Id of the Azure resource */\n subscriptionId?: string;\n /** Kind of Azure resource type */\n kind?: string;\n}\n\n/** Test server metrics configuration */\nexport interface TestServerMetricConfig {\n /** Test identifier */\n testId?: string;\n /** Azure resource metrics collection {metric id : metrics object} (Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition for metric id). */\n metrics?: Record<string, ResourceMetric>;\n /** The creation datetime(ISO 8601 literal format). */\n createdDateTime?: Date | string;\n /** The user that created. */\n createdBy?: string;\n /** The last Modified datetime(ISO 8601 literal format). */\n lastModifiedDateTime?: Date | string;\n /** The user that last modified. */\n lastModifiedBy?: string;\n}\n\n/** Associated metric definition for particular metrics of the azure resource ( Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). */\nexport interface ResourceMetric {\n /** Unique name for metric. */\n id?: string;\n /** Azure resource id. */\n resourceId: string;\n /** Metric name space. */\n metricNamespace: string;\n /** Metric description. */\n displayDescription?: string;\n /** The invariant value of metric name */\n name: string;\n /** Metric aggregation. */\n aggregation: string;\n /** Metric unit. */\n unit?: string;\n /** Azure resource type. */\n resourceType: string;\n}\n\n/** Load test run model */\nexport interface TestRun {\n /** Pass fail criteria for a test. */\n passFailCriteria?: PassFailCriteria;\n /** Secrets can be stored in an Azure Key Vault or any other secret store. If the secret is stored in an Azure Key Vault, the value should be the secret identifier and the type should be AKV_SECRET_URI. If the secret is stored elsewhere, the secret value should be provided directly and the type should be SECRET_VALUE. */\n secrets?: Record<string, Secret>;\n /** Certificates metadata */\n certificate?: CertificateMetadata;\n /** Environment variables which are defined as a set of <name,value> pairs. */\n environmentVariables?: Record<string, string>;\n /** Error details if there is any failure in load test run */\n errorDetails?: Array<ErrorDetails>;\n /** Test run statistics. */\n testRunStatistics?: Record<string, TestRunStatistics>;\n /** The load test configuration. */\n loadTestConfiguration?: LoadTestConfiguration;\n /** Collection of test run artifacts */\n testArtifacts?: TestRunArtifacts;\n /** Test result for pass/Fail criteria used during the test run. */\n testResult?: \"PASSED\" | \"NOT_APPLICABLE\" | \"FAILED\";\n /** Number of virtual users, for which test has been run. */\n virtualUsers?: number;\n /** Unique test run name as identifier */\n testRunId?: string;\n /** Display name of a testRun. */\n displayName?: string;\n /** Associated test Id. */\n testId?: string;\n /** The test run description. */\n description?: string;\n /** The test run status. */\n status?:\n | \"ACCEPTED\"\n | \"NOTSTARTED\"\n | \"PROVISIONING\"\n | \"PROVISIONED\"\n | \"CONFIGURING\"\n | \"CONFIGURED\"\n | \"EXECUTING\"\n | \"EXECUTED\"\n | \"DEPROVISIONING\"\n | \"DEPROVISIONED\"\n | \"DONE\"\n | \"CANCELLING\"\n | \"CANCELLED\"\n | \"FAILED\"\n | \"VALIDATION_SUCCESS\"\n | \"VALIDATION_FAILURE\";\n /** The test run start DateTime(ISO 8601 literal format). */\n startDateTime?: Date | string;\n /** The test run end DateTime(ISO 8601 literal format). */\n endDateTime?: Date | string;\n /** Test run initiated time. */\n executedDateTime?: Date | string;\n /** Portal url. */\n portalUrl?: string;\n /** Test run duration in milliseconds. */\n duration?: number;\n /** Subnet ID on which the load test instances should run. */\n subnetId?: string;\n /** The creation datetime(ISO 8601 literal format). */\n createdDateTime?: Date | string;\n /** The user that created. */\n createdBy?: string;\n /** The last Modified datetime(ISO 8601 literal format). */\n lastModifiedDateTime?: Date | string;\n /** The user that last modified. */\n lastModifiedBy?: string;\n}\n\n/** Error details if there is any failure in load test run */\nexport interface ErrorDetails {\n /** Error details in case test run was not successfully run. */\n message?: string;\n}\n\n/** Test run statistics. */\nexport interface TestRunStatistics {\n /** Transaction name. */\n transaction?: string;\n /** Sampler count. */\n sampleCount?: number;\n /** Error count. */\n errorCount?: number;\n /** Error percentage. */\n errorPct?: number;\n /** Mean response time. */\n meanResTime?: number;\n /** Median response time. */\n medianResTime?: number;\n /** Max response time. */\n maxResTime?: number;\n /** Minimum response time. */\n minResTime?: number;\n /** 90 percentile response time. */\n pct1ResTime?: number;\n /** 95 percentile response time. */\n pct2ResTime?: number;\n /** 99 percentile response time. */\n pct3ResTime?: number;\n /** Throughput. */\n throughput?: number;\n /** Received network bytes. */\n receivedKBytesPerSec?: number;\n /** Send network bytes. */\n sentKBytesPerSec?: number;\n}\n\n/** Collection of test run artifacts */\nexport interface TestRunArtifacts {\n /** The input artifacts for the test run. */\n inputArtifacts?: TestRunInputArtifacts;\n /** The output artifacts for the test run. */\n outputArtifacts?: TestRunOutputArtifacts;\n}\n\n/** The input artifacts for the test run. */\nexport interface TestRunInputArtifacts {\n /** File info */\n configFileInfo?: FileInfo;\n /** File info */\n testScriptFileInfo?: FileInfo;\n /** File info */\n userPropFileInfo?: FileInfo;\n /** File info */\n inputArtifactsZipFileInfo?: FileInfo;\n /** Additional supported files for the test run */\n additionalFileInfo?: Array<FileInfo>;\n}\n\n/** The output artifacts for the test run. */\nexport interface TestRunOutputArtifacts {\n /** File info */\n resultFileInfo?: FileInfo;\n /** File info */\n logsFileInfo?: FileInfo;\n}\n\n/** Filters to fetch the set of metric */\nexport interface MetricRequestPayload {\n /** Get metrics for specific dimension values. Example: Metric contains dimension like SamplerName, Error. To retrieve all the time series data where SamplerName is equals to HTTPRequest1 or HTTPRequest2, the DimensionFilter value will be {\"SamplerName\", [\"HTTPRequest1\", \"HTTPRequest2\"} */\n filters?: Array<DimensionFilter>;\n}\n\n/** Dimension name and values to filter */\nexport interface DimensionFilter {\n /** The dimension name */\n name?: string;\n /** The dimension values. Maximum values can be 20. */\n values?: Array<string>;\n}\n\n/** Test run app component */\nexport interface TestRunAppComponents {\n /** Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } */\n components: Record<string, AppComponent>;\n /** Test run identifier */\n testRunId?: string;\n /** The creation datetime(ISO 8601 literal format). */\n createdDateTime?: Date | string;\n /** The user that created. */\n createdBy?: string;\n /** The last Modified datetime(ISO 8601 literal format). */\n lastModifiedDateTime?: Date | string;\n /** The user that last modified. */\n lastModifiedBy?: string;\n}\n\n/** Test run server metrics configuration */\nexport interface TestRunServerMetricConfig {\n /** Test run identifier */\n testRunId?: string;\n /** Azure resource metrics collection {metric id : metrics object} (Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition for metric id). */\n metrics?: Record<string, ResourceMetric>;\n /** The creation datetime(ISO 8601 literal format). */\n createdDateTime?: Date | string;\n /** The user that created. */\n createdBy?: string;\n /** The last Modified datetime(ISO 8601 literal format). */\n lastModifiedDateTime?: Date | string;\n /** The user that last modified. */\n lastModifiedBy?: string;\n}\n\n/**\n * Describes a poller for NotificationHubJob types.\n */\nexport type FileUploadAndValidatePoller = SimplePollerLike<\n OperationState<TestGetFile200Response>,\n TestGetFile200Response\n>;\n\nexport type TestRunCompletionPoller = SimplePollerLike<\n OperationState<TestRunGet200Response>,\n TestRunGet200Response\n>;\n\nexport type TestRunCreateOrUpdateSuccessResponse =\n | TestRunCreateOrUpdate200Response\n | TestRunCreateOrUpdate201Response;\n\nexport type TestUploadFileSuccessResponse = TestUploadFile201Response;\n\nexport interface PolledOperationOptions {\n /**\n * Time delay between poll requests, in milliseconds.\n */\n updateIntervalInMs?: number;\n}\n"]}