@azure-rest/defender-easm 1.0.0-alpha.20231031.1

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/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Azure DefenderEasm REST client library for JavaScript
2
+
3
+ Defender EASM discovers and maps your digital attack surface to provide an "outside-in" perspective using probes to discover assets. The assets are provided with detailed metadata associated, including vulnerabilities, configurations and web components, allowing customers to view and prioritize external risk. The EASM REST API enables you to develop clients that integrate with your application.
4
+
5
+ **Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
6
+
7
+ Key links:
8
+
9
+ - [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/easm/defender-easm-rest)
10
+ - [Package (NPM)](https://www.npmjs.com/package/@azure-rest/defender-easm)
11
+ - [API reference documentation](https://azure.github.io/azure-sdk-for-js)
12
+ - [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/easm/defender-easm-rest/samples/v1-beta)
13
+
14
+ ## Getting started
15
+
16
+ ### Currently supported environments
17
+
18
+ - LTS versions of Node.js
19
+
20
+ ### Prerequisites
21
+
22
+ - You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package.
23
+
24
+ ### Install the `@azure-rest/defender-easm` package
25
+
26
+ Install the Azure DefenderEasm REST client REST client library for JavaScript with `npm`:
27
+
28
+ ```bash
29
+ npm install @azure-rest/defender-easm
30
+ ```
31
+
32
+ ### Create and authenticate a `EasmClient`
33
+
34
+ To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
35
+ provide an instance of the desired credential type obtained from the
36
+ [@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
37
+
38
+ To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
39
+
40
+ After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use.
41
+ As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
42
+ can be used to authenticate the client.
43
+
44
+ Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
45
+ AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
46
+
47
+ ## Troubleshooting
48
+
49
+ ### Logging
50
+
51
+ Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
52
+
53
+ ```javascript
54
+ const { setLogLevel } = require("@azure/logger");
55
+
56
+ setLogLevel("info");
57
+ ```
58
+
59
+ For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
package/dist/index.js ADDED
@@ -0,0 +1,213 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var coreClient = require('@azure-rest/core-client');
6
+ var logger$1 = require('@azure/logger');
7
+ var corePaging = require('@azure/core-paging');
8
+
9
+ // Copyright (c) Microsoft Corporation.
10
+ // Licensed under the MIT license.
11
+ const logger = logger$1.createClientLogger("defender-easm");
12
+
13
+ // Copyright (c) Microsoft Corporation.
14
+ // Licensed under the MIT license.
15
+ /**
16
+ * Initialize a new instance of `EasmClient`
17
+ * @param endpoint - The endpoint hosting the requested resource. For example, https://{region}.easm.defender.microsoft.com
18
+ * @param subscriptionId - The ID of the target subscription.
19
+ * @param resourceGroupName - The name of the Resource Group.
20
+ * @param workspaceName - The name of the Workspace.
21
+ * @param credentials - uniquely identify client credential
22
+ * @param options - the parameter for all optional parameters
23
+ */
24
+ function createClient(endpoint, subscriptionId, resourceGroupName, workspaceName, credentials, options = {}) {
25
+ var _a, _b, _c, _d, _e, _f;
26
+ const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/workspaces/${workspaceName}`;
27
+ options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2023-03-01-preview";
28
+ options = Object.assign(Object.assign({}, options), { credentials: {
29
+ scopes: (_d = (_c = options.credentials) === null || _c === void 0 ? void 0 : _c.scopes) !== null && _d !== void 0 ? _d : ["https://easm.defender.microsoft.com/.default"],
30
+ } });
31
+ const userAgentInfo = `azsdk-js-defender-easm-rest/1.0.0-beta.1`;
32
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
33
+ ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
34
+ : `${userAgentInfo}`;
35
+ options = Object.assign(Object.assign({}, options), { userAgentOptions: {
36
+ userAgentPrefix,
37
+ }, loggingOptions: {
38
+ logger: (_f = (_e = options.loggingOptions) === null || _e === void 0 ? void 0 : _e.logger) !== null && _f !== void 0 ? _f : logger.info,
39
+ } });
40
+ const client = coreClient.getClient(baseUrl, credentials, options);
41
+ return client;
42
+ }
43
+
44
+ // Copyright (c) Microsoft Corporation.
45
+ // Licensed under the MIT license.
46
+ const responseMap = {
47
+ "GET /assets": ["200"],
48
+ "POST /assets": ["200"],
49
+ "GET /assets/{assetId}": ["200"],
50
+ "GET /dataConnections": ["200"],
51
+ "POST /dataConnections:validate": ["200"],
52
+ "GET /dataConnections/{dataConnectionName}": ["200"],
53
+ "PUT /dataConnections/{dataConnectionName}": ["200"],
54
+ "DELETE /dataConnections/{dataConnectionName}": ["204"],
55
+ "GET /discoGroups": ["200"],
56
+ "POST /discoGroups:validate": ["200"],
57
+ "GET /discoGroups/{groupName}": ["200"],
58
+ "PUT /discoGroups/{groupName}": ["200"],
59
+ "POST /discoGroups/{groupName}:run": ["204"],
60
+ "GET /discoGroups/{groupName}/runs": ["200"],
61
+ "GET /discoTemplates": ["200"],
62
+ "GET /discoTemplates/{templateId}": ["200"],
63
+ "POST /reports/assets:getBillable": ["200"],
64
+ "POST /reports/assets:getSnapshot": ["200"],
65
+ "POST /reports/assets:getSummary": ["200"],
66
+ "GET /savedFilters": ["200"],
67
+ "GET /savedFilters/{filterName}": ["200"],
68
+ "PUT /savedFilters/{filterName}": ["200"],
69
+ "DELETE /savedFilters/{filterName}": ["204"],
70
+ "GET /tasks": ["200"],
71
+ "GET /tasks/{taskId}": ["200"],
72
+ "POST /tasks/{taskId}:cancel": ["200"],
73
+ };
74
+ function isUnexpected(response) {
75
+ const lroOriginal = response.headers["x-ms-original-url"];
76
+ const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
77
+ const method = response.request.method;
78
+ let pathDetails = responseMap[`${method} ${url.pathname}`];
79
+ if (!pathDetails) {
80
+ pathDetails = getParametrizedPathSuccess(method, url.pathname);
81
+ }
82
+ return !pathDetails.includes(response.status);
83
+ }
84
+ function getParametrizedPathSuccess(method, path) {
85
+ var _a, _b, _c, _d;
86
+ const pathParts = path.split("/");
87
+ // Traverse list to match the longest candidate
88
+ // matchedLen: the length of candidate path
89
+ // matchedValue: the matched status code array
90
+ let matchedLen = -1, matchedValue = [];
91
+ // Iterate the responseMap to find a match
92
+ for (const [key, value] of Object.entries(responseMap)) {
93
+ // Extracting the path from the map key which is in format
94
+ // GET /path/foo
95
+ if (!key.startsWith(method)) {
96
+ continue;
97
+ }
98
+ const candidatePath = getPathFromMapKey(key);
99
+ // Get each part of the url path
100
+ const candidateParts = candidatePath.split("/");
101
+ // track if we have found a match to return the values found.
102
+ let found = true;
103
+ for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
104
+ if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
105
+ const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
106
+ // If the current part of the candidate is a "template" part
107
+ // Try to use the suffix of pattern to match the path
108
+ // {guid} ==> $
109
+ // {guid}:export ==> :export$
110
+ const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
111
+ if (!isMatched) {
112
+ found = false;
113
+ break;
114
+ }
115
+ continue;
116
+ }
117
+ // If the candidate part is not a template and
118
+ // the parts don't match mark the candidate as not found
119
+ // to move on with the next candidate path.
120
+ if (candidateParts[i] !== pathParts[j]) {
121
+ found = false;
122
+ break;
123
+ }
124
+ }
125
+ // We finished evaluating the current candidate parts
126
+ // Update the matched value if and only if we found the longer pattern
127
+ if (found && candidatePath.length > matchedLen) {
128
+ matchedLen = candidatePath.length;
129
+ matchedValue = value;
130
+ }
131
+ }
132
+ return matchedValue;
133
+ }
134
+ function getPathFromMapKey(mapKey) {
135
+ const pathStart = mapKey.indexOf("/");
136
+ return mapKey.slice(pathStart);
137
+ }
138
+
139
+ // Copyright (c) Microsoft Corporation.
140
+ // Licensed under the MIT license.
141
+ /**
142
+ * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
143
+ * @param client - Client to use for sending the next page requests
144
+ * @param initialResponse - Initial response containing the nextLink and current page of elements
145
+ * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
146
+ * @returns - PagedAsyncIterableIterator to iterate the elements
147
+ */
148
+ function paginate(client, initialResponse, options = {}) {
149
+ let firstRun = true;
150
+ const itemName = "value";
151
+ const nextLinkName = "nextLink";
152
+ const { customGetPage } = options;
153
+ const pagedResult = {
154
+ firstPageLink: "",
155
+ getPage: typeof customGetPage === "function"
156
+ ? customGetPage
157
+ : async (pageLink) => {
158
+ const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
159
+ firstRun = false;
160
+ checkPagingRequest(result);
161
+ const nextLink = getNextLink(result.body, nextLinkName);
162
+ const values = getElements(result.body, itemName);
163
+ return {
164
+ page: values,
165
+ nextPageLink: nextLink,
166
+ };
167
+ },
168
+ };
169
+ return corePaging.getPagedAsyncIterator(pagedResult);
170
+ }
171
+ /**
172
+ * Gets for the value of nextLink in the body
173
+ */
174
+ function getNextLink(body, nextLinkName) {
175
+ if (!nextLinkName) {
176
+ return undefined;
177
+ }
178
+ const nextLink = body[nextLinkName];
179
+ if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
180
+ throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
181
+ }
182
+ return nextLink;
183
+ }
184
+ /**
185
+ * Gets the elements of the current request in the body.
186
+ */
187
+ function getElements(body, itemName) {
188
+ const value = body[itemName];
189
+ // value has to be an array according to the x-ms-pageable extension.
190
+ // The fact that this must be an array is used above to calculate the
191
+ // type of elements in the page in PaginateReturn
192
+ if (!Array.isArray(value)) {
193
+ throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
194
+ }
195
+ return value !== null && value !== void 0 ? value : [];
196
+ }
197
+ /**
198
+ * Checks if a request failed
199
+ */
200
+ function checkPagingRequest(response) {
201
+ const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
202
+ if (!Http2xxStatusCodes.includes(response.status)) {
203
+ throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
204
+ }
205
+ }
206
+
207
+ // Copyright (c) Microsoft Corporation.
208
+ // Licensed under the MIT license.
209
+
210
+ exports.default = createClient;
211
+ exports.isUnexpected = isUnexpected;
212
+ exports.paginate = paginate;
213
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/logger.ts","../src/easm.ts","../src/isUnexpected.ts","../src/paginateHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"defender-easm\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { EasmClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `EasmClient`\n * @param endpoint - The endpoint hosting the requested resource. For example, https://{region}.easm.defender.microsoft.com\n * @param subscriptionId - The ID of the target subscription.\n * @param resourceGroupName - The name of the Resource Group.\n * @param workspaceName - The name of the Workspace.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n subscriptionId: string,\n resourceGroupName: string,\n workspaceName: string,\n credentials: TokenCredential,\n options: ClientOptions = {}\n): EasmClient {\n const baseUrl =\n options.baseUrl ??\n `${endpoint}/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/workspaces/${workspaceName}`;\n options.apiVersion = options.apiVersion ?? \"2023-03-01-preview\";\n options = {\n ...options,\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://easm.defender.microsoft.com/.default\"],\n },\n };\n\n const userAgentInfo = `azsdk-js-defender-easm-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n };\n\n const client = getClient(baseUrl, credentials, options) as EasmClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ListAssetResource200Response,\n ListAssetResourceDefaultResponse,\n UpdateAssets200Response,\n UpdateAssetsDefaultResponse,\n GetAssetResource200Response,\n GetAssetResourceDefaultResponse,\n ListDataConnection200Response,\n ListDataConnectionDefaultResponse,\n ValidateDataConnection200Response,\n ValidateDataConnectionDefaultResponse,\n GetDataConnection200Response,\n GetDataConnectionDefaultResponse,\n CreateOrReplaceDataConnection200Response,\n CreateOrReplaceDataConnectionDefaultResponse,\n DeleteDataConnection204Response,\n DeleteDataConnectionDefaultResponse,\n ListDiscoGroup200Response,\n ListDiscoGroupDefaultResponse,\n ValidateDiscoGroup200Response,\n ValidateDiscoGroupDefaultResponse,\n GetDiscoGroup200Response,\n GetDiscoGroupDefaultResponse,\n CreateOrReplaceDiscoGroup200Response,\n CreateOrReplaceDiscoGroupDefaultResponse,\n RunDiscoGroup204Response,\n RunDiscoGroupDefaultResponse,\n ListRuns200Response,\n ListRunsDefaultResponse,\n ListDiscoTemplate200Response,\n ListDiscoTemplateDefaultResponse,\n GetDiscoTemplate200Response,\n GetDiscoTemplateDefaultResponse,\n GetBillable200Response,\n GetBillableDefaultResponse,\n GetSnapshot200Response,\n GetSnapshotDefaultResponse,\n GetSummary200Response,\n GetSummaryDefaultResponse,\n ListSavedFilter200Response,\n ListSavedFilterDefaultResponse,\n GetSavedFilter200Response,\n GetSavedFilterDefaultResponse,\n CreateOrReplaceSavedFilter200Response,\n CreateOrReplaceSavedFilterDefaultResponse,\n DeleteSavedFilter204Response,\n DeleteSavedFilterDefaultResponse,\n ListTask200Response,\n ListTaskDefaultResponse,\n GetTask200Response,\n GetTaskDefaultResponse,\n CancelTask200Response,\n CancelTaskDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /assets\": [\"200\"],\n \"POST /assets\": [\"200\"],\n \"GET /assets/{assetId}\": [\"200\"],\n \"GET /dataConnections\": [\"200\"],\n \"POST /dataConnections:validate\": [\"200\"],\n \"GET /dataConnections/{dataConnectionName}\": [\"200\"],\n \"PUT /dataConnections/{dataConnectionName}\": [\"200\"],\n \"DELETE /dataConnections/{dataConnectionName}\": [\"204\"],\n \"GET /discoGroups\": [\"200\"],\n \"POST /discoGroups:validate\": [\"200\"],\n \"GET /discoGroups/{groupName}\": [\"200\"],\n \"PUT /discoGroups/{groupName}\": [\"200\"],\n \"POST /discoGroups/{groupName}:run\": [\"204\"],\n \"GET /discoGroups/{groupName}/runs\": [\"200\"],\n \"GET /discoTemplates\": [\"200\"],\n \"GET /discoTemplates/{templateId}\": [\"200\"],\n \"POST /reports/assets:getBillable\": [\"200\"],\n \"POST /reports/assets:getSnapshot\": [\"200\"],\n \"POST /reports/assets:getSummary\": [\"200\"],\n \"GET /savedFilters\": [\"200\"],\n \"GET /savedFilters/{filterName}\": [\"200\"],\n \"PUT /savedFilters/{filterName}\": [\"200\"],\n \"DELETE /savedFilters/{filterName}\": [\"204\"],\n \"GET /tasks\": [\"200\"],\n \"GET /tasks/{taskId}\": [\"200\"],\n \"POST /tasks/{taskId}:cancel\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: ListAssetResource200Response | ListAssetResourceDefaultResponse\n): response is ListAssetResourceDefaultResponse;\nexport function isUnexpected(\n response: UpdateAssets200Response | UpdateAssetsDefaultResponse\n): response is UpdateAssetsDefaultResponse;\nexport function isUnexpected(\n response: GetAssetResource200Response | GetAssetResourceDefaultResponse\n): response is GetAssetResourceDefaultResponse;\nexport function isUnexpected(\n response: ListDataConnection200Response | ListDataConnectionDefaultResponse\n): response is ListDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: ValidateDataConnection200Response | ValidateDataConnectionDefaultResponse\n): response is ValidateDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: GetDataConnection200Response | GetDataConnectionDefaultResponse\n): response is GetDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: CreateOrReplaceDataConnection200Response | CreateOrReplaceDataConnectionDefaultResponse\n): response is CreateOrReplaceDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: DeleteDataConnection204Response | DeleteDataConnectionDefaultResponse\n): response is DeleteDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: ListDiscoGroup200Response | ListDiscoGroupDefaultResponse\n): response is ListDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: ValidateDiscoGroup200Response | ValidateDiscoGroupDefaultResponse\n): response is ValidateDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: GetDiscoGroup200Response | GetDiscoGroupDefaultResponse\n): response is GetDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: CreateOrReplaceDiscoGroup200Response | CreateOrReplaceDiscoGroupDefaultResponse\n): response is CreateOrReplaceDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: RunDiscoGroup204Response | RunDiscoGroupDefaultResponse\n): response is RunDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: ListRuns200Response | ListRunsDefaultResponse\n): response is ListRunsDefaultResponse;\nexport function isUnexpected(\n response: ListDiscoTemplate200Response | ListDiscoTemplateDefaultResponse\n): response is ListDiscoTemplateDefaultResponse;\nexport function isUnexpected(\n response: GetDiscoTemplate200Response | GetDiscoTemplateDefaultResponse\n): response is GetDiscoTemplateDefaultResponse;\nexport function isUnexpected(\n response: GetBillable200Response | GetBillableDefaultResponse\n): response is GetBillableDefaultResponse;\nexport function isUnexpected(\n response: GetSnapshot200Response | GetSnapshotDefaultResponse\n): response is GetSnapshotDefaultResponse;\nexport function isUnexpected(\n response: GetSummary200Response | GetSummaryDefaultResponse\n): response is GetSummaryDefaultResponse;\nexport function isUnexpected(\n response: ListSavedFilter200Response | ListSavedFilterDefaultResponse\n): response is ListSavedFilterDefaultResponse;\nexport function isUnexpected(\n response: GetSavedFilter200Response | GetSavedFilterDefaultResponse\n): response is GetSavedFilterDefaultResponse;\nexport function isUnexpected(\n response: CreateOrReplaceSavedFilter200Response | CreateOrReplaceSavedFilterDefaultResponse\n): response is CreateOrReplaceSavedFilterDefaultResponse;\nexport function isUnexpected(\n response: DeleteSavedFilter204Response | DeleteSavedFilterDefaultResponse\n): response is DeleteSavedFilterDefaultResponse;\nexport function isUnexpected(\n response: ListTask200Response | ListTaskDefaultResponse\n): response is ListTaskDefaultResponse;\nexport function isUnexpected(\n response: GetTask200Response | GetTaskDefaultResponse\n): response is GetTaskDefaultResponse;\nexport function isUnexpected(\n response: CancelTask200Response | CancelTaskDefaultResponse\n): response is CancelTaskDefaultResponse;\nexport function isUnexpected(\n response:\n | ListAssetResource200Response\n | ListAssetResourceDefaultResponse\n | UpdateAssets200Response\n | UpdateAssetsDefaultResponse\n | GetAssetResource200Response\n | GetAssetResourceDefaultResponse\n | ListDataConnection200Response\n | ListDataConnectionDefaultResponse\n | ValidateDataConnection200Response\n | ValidateDataConnectionDefaultResponse\n | GetDataConnection200Response\n | GetDataConnectionDefaultResponse\n | CreateOrReplaceDataConnection200Response\n | CreateOrReplaceDataConnectionDefaultResponse\n | DeleteDataConnection204Response\n | DeleteDataConnectionDefaultResponse\n | ListDiscoGroup200Response\n | ListDiscoGroupDefaultResponse\n | ValidateDiscoGroup200Response\n | ValidateDiscoGroupDefaultResponse\n | GetDiscoGroup200Response\n | GetDiscoGroupDefaultResponse\n | CreateOrReplaceDiscoGroup200Response\n | CreateOrReplaceDiscoGroupDefaultResponse\n | RunDiscoGroup204Response\n | RunDiscoGroupDefaultResponse\n | ListRuns200Response\n | ListRunsDefaultResponse\n | ListDiscoTemplate200Response\n | ListDiscoTemplateDefaultResponse\n | GetDiscoTemplate200Response\n | GetDiscoTemplateDefaultResponse\n | GetBillable200Response\n | GetBillableDefaultResponse\n | GetSnapshot200Response\n | GetSnapshotDefaultResponse\n | GetSummary200Response\n | GetSummaryDefaultResponse\n | ListSavedFilter200Response\n | ListSavedFilterDefaultResponse\n | GetSavedFilter200Response\n | GetSavedFilterDefaultResponse\n | CreateOrReplaceSavedFilter200Response\n | CreateOrReplaceSavedFilterDefaultResponse\n | DeleteSavedFilter204Response\n | DeleteSavedFilterDefaultResponse\n | ListTask200Response\n | ListTaskDefaultResponse\n | GetTask200Response\n | GetTaskDefaultResponse\n | CancelTask200Response\n | CancelTaskDefaultResponse\n): response is\n | ListAssetResourceDefaultResponse\n | UpdateAssetsDefaultResponse\n | GetAssetResourceDefaultResponse\n | ListDataConnectionDefaultResponse\n | ValidateDataConnectionDefaultResponse\n | GetDataConnectionDefaultResponse\n | CreateOrReplaceDataConnectionDefaultResponse\n | DeleteDataConnectionDefaultResponse\n | ListDiscoGroupDefaultResponse\n | ValidateDiscoGroupDefaultResponse\n | GetDiscoGroupDefaultResponse\n | CreateOrReplaceDiscoGroupDefaultResponse\n | RunDiscoGroupDefaultResponse\n | ListRunsDefaultResponse\n | ListDiscoTemplateDefaultResponse\n | GetDiscoTemplateDefaultResponse\n | GetBillableDefaultResponse\n | GetSnapshotDefaultResponse\n | GetSummaryDefaultResponse\n | ListSavedFilterDefaultResponse\n | GetSavedFilterDefaultResponse\n | CreateOrReplaceSavedFilterDefaultResponse\n | DeleteSavedFilterDefaultResponse\n | ListTaskDefaultResponse\n | GetTaskDefaultResponse\n | CancelTaskDefaultResponse {\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 = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\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 // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\"\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\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[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { Client, createRestError, PathUncheckedResponse } from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {}\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport Easm from \"./easm\";\n\nexport * from \"./easm\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\n\nexport default Easm;\n"],"names":["createClientLogger","getClient","getPagedAsyncIterator","createRestError"],"mappings":";;;;;;;;AAAA;AACA;AAGO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,eAAe,CAAC;;ACJzD;AACA;AAOA;;;;;;;;AAQG;AACW,SAAU,YAAY,CAClC,QAAgB,EAChB,cAAsB,EACtB,iBAAyB,EACzB,aAAqB,EACrB,WAA4B,EAC5B,UAAyB,EAAE,EAAA;;AAE3B,IAAA,MAAM,OAAO,GACX,CAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MACf,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAG,QAAQ,CAAA,eAAA,EAAkB,cAAc,CAAmB,gBAAA,EAAA,iBAAiB,CAAe,YAAA,EAAA,aAAa,EAAE,CAAC;IAChH,OAAO,CAAC,UAAU,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,UAAU,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,oBAAoB,CAAC;AAChE,IAAA,OAAO,GACF,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,CACV,EAAA,EAAA,WAAW,EAAE;YACX,MAAM,EAAE,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,WAA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AAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACnE,QAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,YAAY,CAAA,gCAAA,CAAkC,CAAC,CAAC;AAClF,KAAA;AAED,IAAA,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;AAEG;AACH,SAAS,WAAW,CAAc,IAAa,EAAE,QAAgB,EAAA;AAC/D,IAAA,MAAM,KAAK,GAAI,IAAgC,CAAC,QAAQ,CAAQ,CAAC;;;;AAKjE,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACzB,QAAA,MAAM,IAAI,KAAK,CACb,kFAAkF,QAAQ,CAAA,CAAE,CAC7F,CAAC;AACH,KAAA;AAED,IAAA,OAAO,KAAK,KAAL,IAAA,IAAA,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;AACrB,CAAC;AAED;;AAEG;AACH,SAAS,kBAAkB,CAAC,QAA+B,EAAA;IACzD,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAClG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjD,MAAMC,0BAAe,CACnB,CAAA,6CAAA,EAAgD,QAAQ,CAAC,MAAM,CAAE,CAAA,EACjE,QAAQ,CACT,CAAC;AACH,KAAA;AACH;;AClIA;AACA;;;;;;"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=clientDefinitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../src/clientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ListAssetResourceParameters,\n UpdateAssetsParameters,\n GetAssetResourceParameters,\n ListDataConnectionParameters,\n ValidateDataConnectionParameters,\n GetDataConnectionParameters,\n CreateOrReplaceDataConnectionParameters,\n DeleteDataConnectionParameters,\n ListDiscoGroupParameters,\n ValidateDiscoGroupParameters,\n GetDiscoGroupParameters,\n CreateOrReplaceDiscoGroupParameters,\n RunDiscoGroupParameters,\n ListRunsParameters,\n ListDiscoTemplateParameters,\n GetDiscoTemplateParameters,\n GetBillableParameters,\n GetSnapshotParameters,\n GetSummaryParameters,\n ListSavedFilterParameters,\n GetSavedFilterParameters,\n CreateOrReplaceSavedFilterParameters,\n DeleteSavedFilterParameters,\n ListTaskParameters,\n GetTaskParameters,\n CancelTaskParameters,\n} from \"./parameters\";\nimport {\n ListAssetResource200Response,\n ListAssetResourceDefaultResponse,\n UpdateAssets200Response,\n UpdateAssetsDefaultResponse,\n GetAssetResource200Response,\n GetAssetResourceDefaultResponse,\n ListDataConnection200Response,\n ListDataConnectionDefaultResponse,\n ValidateDataConnection200Response,\n ValidateDataConnectionDefaultResponse,\n GetDataConnection200Response,\n GetDataConnectionDefaultResponse,\n CreateOrReplaceDataConnection200Response,\n CreateOrReplaceDataConnectionDefaultResponse,\n DeleteDataConnection204Response,\n DeleteDataConnectionDefaultResponse,\n ListDiscoGroup200Response,\n ListDiscoGroupDefaultResponse,\n ValidateDiscoGroup200Response,\n ValidateDiscoGroupDefaultResponse,\n GetDiscoGroup200Response,\n GetDiscoGroupDefaultResponse,\n CreateOrReplaceDiscoGroup200Response,\n CreateOrReplaceDiscoGroupDefaultResponse,\n RunDiscoGroup204Response,\n RunDiscoGroupDefaultResponse,\n ListRuns200Response,\n ListRunsDefaultResponse,\n ListDiscoTemplate200Response,\n ListDiscoTemplateDefaultResponse,\n GetDiscoTemplate200Response,\n GetDiscoTemplateDefaultResponse,\n GetBillable200Response,\n GetBillableDefaultResponse,\n GetSnapshot200Response,\n GetSnapshotDefaultResponse,\n GetSummary200Response,\n GetSummaryDefaultResponse,\n ListSavedFilter200Response,\n ListSavedFilterDefaultResponse,\n GetSavedFilter200Response,\n GetSavedFilterDefaultResponse,\n CreateOrReplaceSavedFilter200Response,\n CreateOrReplaceSavedFilterDefaultResponse,\n DeleteSavedFilter204Response,\n DeleteSavedFilterDefaultResponse,\n ListTask200Response,\n ListTaskDefaultResponse,\n GetTask200Response,\n GetTaskDefaultResponse,\n CancelTask200Response,\n CancelTaskDefaultResponse,\n} from \"./responses\";\nimport { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface ListAssetResource {\n /** Retrieve a list of assets for the provided search parameters. */\n get(\n options?: ListAssetResourceParameters\n ): StreamableMethod<ListAssetResource200Response | ListAssetResourceDefaultResponse>;\n /** Update labels on assets matching the provided filter. */\n post(\n options: UpdateAssetsParameters\n ): StreamableMethod<UpdateAssets200Response | UpdateAssetsDefaultResponse>;\n}\n\nexport interface GetAssetResource {\n /** Retrieve an asset by assetId. */\n get(\n options?: GetAssetResourceParameters\n ): StreamableMethod<GetAssetResource200Response | GetAssetResourceDefaultResponse>;\n}\n\nexport interface ListDataConnection {\n /** Retrieve a list of data connections. */\n get(\n options?: ListDataConnectionParameters\n ): StreamableMethod<ListDataConnection200Response | ListDataConnectionDefaultResponse>;\n}\n\nexport interface ValidateDataConnection {\n /** Validate a data connection with a given dataConnectionName. */\n post(\n options?: ValidateDataConnectionParameters\n ): StreamableMethod<ValidateDataConnection200Response | ValidateDataConnectionDefaultResponse>;\n}\n\nexport interface GetDataConnection {\n /** Retrieve a data connection with a given dataConnectionName. */\n get(\n options?: GetDataConnectionParameters\n ): StreamableMethod<GetDataConnection200Response | GetDataConnectionDefaultResponse>;\n /** Create or replace a data connection with a given dataConnectionName. */\n put(\n options?: CreateOrReplaceDataConnectionParameters\n ): StreamableMethod<\n CreateOrReplaceDataConnection200Response | CreateOrReplaceDataConnectionDefaultResponse\n >;\n /** Delete a data connection with a given dataConnectionName. */\n delete(\n options?: DeleteDataConnectionParameters\n ): StreamableMethod<DeleteDataConnection204Response | DeleteDataConnectionDefaultResponse>;\n}\n\nexport interface ListDiscoGroup {\n /** Retrieve a list of discovery group for the provided search parameters. */\n get(\n options?: ListDiscoGroupParameters\n ): StreamableMethod<ListDiscoGroup200Response | ListDiscoGroupDefaultResponse>;\n}\n\nexport interface ValidateDiscoGroup {\n /** Validate a discovery group with a given groupName. */\n post(\n options?: ValidateDiscoGroupParameters\n ): StreamableMethod<ValidateDiscoGroup200Response | ValidateDiscoGroupDefaultResponse>;\n}\n\nexport interface GetDiscoGroup {\n /** Retrieve a discovery group with a given groupName. */\n get(\n options?: GetDiscoGroupParameters\n ): StreamableMethod<GetDiscoGroup200Response | GetDiscoGroupDefaultResponse>;\n /** Create a discovery group with a given groupName. */\n put(\n options?: CreateOrReplaceDiscoGroupParameters\n ): StreamableMethod<\n CreateOrReplaceDiscoGroup200Response | CreateOrReplaceDiscoGroupDefaultResponse\n >;\n}\n\nexport interface RunDiscoGroup {\n /** Run a discovery group with a given groupName. */\n post(\n options?: RunDiscoGroupParameters\n ): StreamableMethod<RunDiscoGroup204Response | RunDiscoGroupDefaultResponse>;\n}\n\nexport interface ListRuns {\n /** Retrieve a collection of discovery run results for a discovery group with a given groupName. */\n get(\n options?: ListRunsParameters\n ): StreamableMethod<ListRuns200Response | ListRunsDefaultResponse>;\n}\n\nexport interface ListDiscoTemplate {\n /** Retrieve a list of disco templates for the provided search parameters. */\n get(\n options?: ListDiscoTemplateParameters\n ): StreamableMethod<ListDiscoTemplate200Response | ListDiscoTemplateDefaultResponse>;\n}\n\nexport interface GetDiscoTemplate {\n /** Retrieve a disco template with a given templateId. */\n get(\n options?: GetDiscoTemplateParameters\n ): StreamableMethod<GetDiscoTemplate200Response | GetDiscoTemplateDefaultResponse>;\n}\n\nexport interface GetBillable {\n /** Get billable assets summary for the workspace. */\n post(\n options?: GetBillableParameters\n ): StreamableMethod<GetBillable200Response | GetBillableDefaultResponse>;\n}\n\nexport interface GetSnapshot {\n /** Get the most recent snapshot of asset summary values for the snapshot request. */\n post(\n options?: GetSnapshotParameters\n ): StreamableMethod<GetSnapshot200Response | GetSnapshotDefaultResponse>;\n}\n\nexport interface GetSummary {\n /** Get asset summary details for the summary request. */\n post(\n options?: GetSummaryParameters\n ): StreamableMethod<GetSummary200Response | GetSummaryDefaultResponse>;\n}\n\nexport interface ListSavedFilter {\n /** Retrieve a list of saved filters for the provided search parameters. */\n get(\n options?: ListSavedFilterParameters\n ): StreamableMethod<ListSavedFilter200Response | ListSavedFilterDefaultResponse>;\n}\n\nexport interface GetSavedFilter {\n /** Retrieve a saved filter by filterName. */\n get(\n options?: GetSavedFilterParameters\n ): StreamableMethod<GetSavedFilter200Response | GetSavedFilterDefaultResponse>;\n /** Create or replace a saved filter with a given filterName. */\n put(\n options?: CreateOrReplaceSavedFilterParameters\n ): StreamableMethod<\n CreateOrReplaceSavedFilter200Response | CreateOrReplaceSavedFilterDefaultResponse\n >;\n /** Delete a saved filter with a given filterName. */\n delete(\n options?: DeleteSavedFilterParameters\n ): StreamableMethod<DeleteSavedFilter204Response | DeleteSavedFilterDefaultResponse>;\n}\n\nexport interface ListTask {\n /** Retrieve a list of tasks for the provided search parameters. */\n get(\n options?: ListTaskParameters\n ): StreamableMethod<ListTask200Response | ListTaskDefaultResponse>;\n}\n\nexport interface GetTask {\n /** Retrieve a task by taskId. */\n get(options?: GetTaskParameters): StreamableMethod<GetTask200Response | GetTaskDefaultResponse>;\n}\n\nexport interface CancelTask {\n /** Cancel a task by taskId. */\n post(\n options?: CancelTaskParameters\n ): StreamableMethod<CancelTask200Response | CancelTaskDefaultResponse>;\n}\n\nexport interface Routes {\n /** Resource for '/assets' has methods for the following verbs: get, post */\n (path: \"/assets\"): ListAssetResource;\n /** Resource for '/assets/\\{assetId\\}' has methods for the following verbs: get */\n (path: \"/assets/{assetId}\", assetId: string): GetAssetResource;\n /** Resource for '/dataConnections' has methods for the following verbs: get */\n (path: \"/dataConnections\"): ListDataConnection;\n /** Resource for '/dataConnections:validate' has methods for the following verbs: post */\n (path: \"/dataConnections:validate\"): ValidateDataConnection;\n /** Resource for '/dataConnections/\\{dataConnectionName\\}' has methods for the following verbs: get, put, delete */\n (path: \"/dataConnections/{dataConnectionName}\", dataConnectionName: string): GetDataConnection;\n /** Resource for '/discoGroups' has methods for the following verbs: get */\n (path: \"/discoGroups\"): ListDiscoGroup;\n /** Resource for '/discoGroups:validate' has methods for the following verbs: post */\n (path: \"/discoGroups:validate\"): ValidateDiscoGroup;\n /** Resource for '/discoGroups/\\{groupName\\}' has methods for the following verbs: get, put */\n (path: \"/discoGroups/{groupName}\", groupName: string): GetDiscoGroup;\n /** Resource for '/discoGroups/\\{groupName\\}:run' has methods for the following verbs: post */\n (path: \"/discoGroups/{groupName}:run\", groupName: string): RunDiscoGroup;\n /** Resource for '/discoGroups/\\{groupName\\}/runs' has methods for the following verbs: get */\n (path: \"/discoGroups/{groupName}/runs\", groupName: string): ListRuns;\n /** Resource for '/discoTemplates' has methods for the following verbs: get */\n (path: \"/discoTemplates\"): ListDiscoTemplate;\n /** Resource for '/discoTemplates/\\{templateId\\}' has methods for the following verbs: get */\n (path: \"/discoTemplates/{templateId}\", templateId: string): GetDiscoTemplate;\n /** Resource for '/reports/assets:getBillable' has methods for the following verbs: post */\n (path: \"/reports/assets:getBillable\"): GetBillable;\n /** Resource for '/reports/assets:getSnapshot' has methods for the following verbs: post */\n (path: \"/reports/assets:getSnapshot\"): GetSnapshot;\n /** Resource for '/reports/assets:getSummary' has methods for the following verbs: post */\n (path: \"/reports/assets:getSummary\"): GetSummary;\n /** Resource for '/savedFilters' has methods for the following verbs: get */\n (path: \"/savedFilters\"): ListSavedFilter;\n /** Resource for '/savedFilters/\\{filterName\\}' has methods for the following verbs: get, put, delete */\n (path: \"/savedFilters/{filterName}\", filterName: string): GetSavedFilter;\n /** Resource for '/tasks' has methods for the following verbs: get */\n (path: \"/tasks\"): ListTask;\n /** Resource for '/tasks/\\{taskId\\}' has methods for the following verbs: get */\n (path: \"/tasks/{taskId}\", taskId: string): GetTask;\n /** Resource for '/tasks/\\{taskId\\}:cancel' has methods for the following verbs: post */\n (path: \"/tasks/{taskId}:cancel\", taskId: string): CancelTask;\n}\n\nexport type EasmClient = Client & {\n path: Routes;\n};\n"]}
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { getClient } from "@azure-rest/core-client";
4
+ import { logger } from "./logger";
5
+ /**
6
+ * Initialize a new instance of `EasmClient`
7
+ * @param endpoint - The endpoint hosting the requested resource. For example, https://{region}.easm.defender.microsoft.com
8
+ * @param subscriptionId - The ID of the target subscription.
9
+ * @param resourceGroupName - The name of the Resource Group.
10
+ * @param workspaceName - The name of the Workspace.
11
+ * @param credentials - uniquely identify client credential
12
+ * @param options - the parameter for all optional parameters
13
+ */
14
+ export default function createClient(endpoint, subscriptionId, resourceGroupName, workspaceName, credentials, options = {}) {
15
+ var _a, _b, _c, _d, _e, _f;
16
+ const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/workspaces/${workspaceName}`;
17
+ options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2023-03-01-preview";
18
+ options = Object.assign(Object.assign({}, options), { credentials: {
19
+ scopes: (_d = (_c = options.credentials) === null || _c === void 0 ? void 0 : _c.scopes) !== null && _d !== void 0 ? _d : ["https://easm.defender.microsoft.com/.default"],
20
+ } });
21
+ const userAgentInfo = `azsdk-js-defender-easm-rest/1.0.0-beta.1`;
22
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
23
+ ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
24
+ : `${userAgentInfo}`;
25
+ options = Object.assign(Object.assign({}, options), { userAgentOptions: {
26
+ userAgentPrefix,
27
+ }, loggingOptions: {
28
+ logger: (_f = (_e = options.loggingOptions) === null || _e === void 0 ? void 0 : _e.logger) !== null && _f !== void 0 ? _f : logger.info,
29
+ } });
30
+ const client = getClient(baseUrl, credentials, options);
31
+ return client;
32
+ }
33
+ //# sourceMappingURL=easm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"easm.js","sourceRoot":"","sources":["../../src/easm.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,QAAgB,EAChB,cAAsB,EACtB,iBAAyB,EACzB,aAAqB,EACrB,WAA4B,EAC5B,UAAyB,EAAE;;IAE3B,MAAM,OAAO,GACX,MAAA,OAAO,CAAC,OAAO,mCACf,GAAG,QAAQ,kBAAkB,cAAc,mBAAmB,iBAAiB,eAAe,aAAa,EAAE,CAAC;IAChH,OAAO,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,oBAAoB,CAAC;IAChE,OAAO,mCACF,OAAO,KACV,WAAW,EAAE;YACX,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,MAAM,mCAAI,CAAC,8CAA8C,CAAC;SACxF,GACF,CAAC;IAEF,MAAM,aAAa,GAAG,0CAA0C,CAAC;IACjE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,mCACF,OAAO,KACV,gBAAgB,EAAE;YAChB,eAAe;SAChB,EACD,cAAc,EAAE;YACd,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,cAAc,0CAAE,MAAM,mCAAI,MAAM,CAAC,IAAI;SACtD,GACF,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAe,CAAC;IAEtE,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { EasmClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `EasmClient`\n * @param endpoint - The endpoint hosting the requested resource. For example, https://{region}.easm.defender.microsoft.com\n * @param subscriptionId - The ID of the target subscription.\n * @param resourceGroupName - The name of the Resource Group.\n * @param workspaceName - The name of the Workspace.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n subscriptionId: string,\n resourceGroupName: string,\n workspaceName: string,\n credentials: TokenCredential,\n options: ClientOptions = {}\n): EasmClient {\n const baseUrl =\n options.baseUrl ??\n `${endpoint}/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/workspaces/${workspaceName}`;\n options.apiVersion = options.apiVersion ?? \"2023-03-01-preview\";\n options = {\n ...options,\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://easm.defender.microsoft.com/.default\"],\n },\n };\n\n const userAgentInfo = `azsdk-js-defender-easm-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n };\n\n const client = getClient(baseUrl, credentials, options) as EasmClient;\n\n return client;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import Easm from "./easm";
4
+ export * from "./easm";
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 Easm;
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,cAAc,QAAQ,CAAC;AACvB,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,IAAI,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport Easm from \"./easm\";\n\nexport * from \"./easm\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\n\nexport default Easm;\n"]}
@@ -0,0 +1,95 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ const responseMap = {
4
+ "GET /assets": ["200"],
5
+ "POST /assets": ["200"],
6
+ "GET /assets/{assetId}": ["200"],
7
+ "GET /dataConnections": ["200"],
8
+ "POST /dataConnections:validate": ["200"],
9
+ "GET /dataConnections/{dataConnectionName}": ["200"],
10
+ "PUT /dataConnections/{dataConnectionName}": ["200"],
11
+ "DELETE /dataConnections/{dataConnectionName}": ["204"],
12
+ "GET /discoGroups": ["200"],
13
+ "POST /discoGroups:validate": ["200"],
14
+ "GET /discoGroups/{groupName}": ["200"],
15
+ "PUT /discoGroups/{groupName}": ["200"],
16
+ "POST /discoGroups/{groupName}:run": ["204"],
17
+ "GET /discoGroups/{groupName}/runs": ["200"],
18
+ "GET /discoTemplates": ["200"],
19
+ "GET /discoTemplates/{templateId}": ["200"],
20
+ "POST /reports/assets:getBillable": ["200"],
21
+ "POST /reports/assets:getSnapshot": ["200"],
22
+ "POST /reports/assets:getSummary": ["200"],
23
+ "GET /savedFilters": ["200"],
24
+ "GET /savedFilters/{filterName}": ["200"],
25
+ "PUT /savedFilters/{filterName}": ["200"],
26
+ "DELETE /savedFilters/{filterName}": ["204"],
27
+ "GET /tasks": ["200"],
28
+ "GET /tasks/{taskId}": ["200"],
29
+ "POST /tasks/{taskId}:cancel": ["200"],
30
+ };
31
+ export function isUnexpected(response) {
32
+ const lroOriginal = response.headers["x-ms-original-url"];
33
+ const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
34
+ const method = response.request.method;
35
+ let pathDetails = responseMap[`${method} ${url.pathname}`];
36
+ if (!pathDetails) {
37
+ pathDetails = getParametrizedPathSuccess(method, url.pathname);
38
+ }
39
+ return !pathDetails.includes(response.status);
40
+ }
41
+ function getParametrizedPathSuccess(method, path) {
42
+ var _a, _b, _c, _d;
43
+ const pathParts = path.split("/");
44
+ // Traverse list to match the longest candidate
45
+ // matchedLen: the length of candidate path
46
+ // matchedValue: the matched status code array
47
+ let matchedLen = -1, matchedValue = [];
48
+ // Iterate the responseMap to find a match
49
+ for (const [key, value] of Object.entries(responseMap)) {
50
+ // Extracting the path from the map key which is in format
51
+ // GET /path/foo
52
+ if (!key.startsWith(method)) {
53
+ continue;
54
+ }
55
+ const candidatePath = getPathFromMapKey(key);
56
+ // Get each part of the url path
57
+ const candidateParts = candidatePath.split("/");
58
+ // track if we have found a match to return the values found.
59
+ let found = true;
60
+ for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
61
+ if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
62
+ const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
63
+ // If the current part of the candidate is a "template" part
64
+ // Try to use the suffix of pattern to match the path
65
+ // {guid} ==> $
66
+ // {guid}:export ==> :export$
67
+ const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
68
+ if (!isMatched) {
69
+ found = false;
70
+ break;
71
+ }
72
+ continue;
73
+ }
74
+ // If the candidate part is not a template and
75
+ // the parts don't match mark the candidate as not found
76
+ // to move on with the next candidate path.
77
+ if (candidateParts[i] !== pathParts[j]) {
78
+ found = false;
79
+ break;
80
+ }
81
+ }
82
+ // We finished evaluating the current candidate parts
83
+ // Update the matched value if and only if we found the longer pattern
84
+ if (found && candidatePath.length > matchedLen) {
85
+ matchedLen = candidatePath.length;
86
+ matchedValue = value;
87
+ }
88
+ }
89
+ return matchedValue;
90
+ }
91
+ function getPathFromMapKey(mapKey) {
92
+ const pathStart = mapKey.indexOf("/");
93
+ return mapKey.slice(pathStart);
94
+ }
95
+ //# sourceMappingURL=isUnexpected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAyDlC,MAAM,WAAW,GAA6B;IAC5C,aAAa,EAAE,CAAC,KAAK,CAAC;IACtB,cAAc,EAAE,CAAC,KAAK,CAAC;IACvB,uBAAuB,EAAE,CAAC,KAAK,CAAC;IAChC,sBAAsB,EAAE,CAAC,KAAK,CAAC;IAC/B,gCAAgC,EAAE,CAAC,KAAK,CAAC;IACzC,2CAA2C,EAAE,CAAC,KAAK,CAAC;IACpD,2CAA2C,EAAE,CAAC,KAAK,CAAC;IACpD,8CAA8C,EAAE,CAAC,KAAK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0CAAE,MAAM,CAAC;gBAClC,4DAA4D;gBAC5D,qDAAqD;gBACrD,eAAe;gBACf,6BAA6B;gBAC7B,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,GAAG,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAC1E,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CACnB,CAAC;gBAEF,IAAI,CAAC,SAAS,EAAE;oBACd,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;iBACP;gBACD,SAAS;aACV;YAED,8CAA8C;YAC9C,wDAAwD;YACxD,2CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;gBACtC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;aACP;SACF;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE;YAC9C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;SACtB;KACF;IAED,OAAO,YAAY,CAAC;AACtB,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 ListAssetResource200Response,\n ListAssetResourceDefaultResponse,\n UpdateAssets200Response,\n UpdateAssetsDefaultResponse,\n GetAssetResource200Response,\n GetAssetResourceDefaultResponse,\n ListDataConnection200Response,\n ListDataConnectionDefaultResponse,\n ValidateDataConnection200Response,\n ValidateDataConnectionDefaultResponse,\n GetDataConnection200Response,\n GetDataConnectionDefaultResponse,\n CreateOrReplaceDataConnection200Response,\n CreateOrReplaceDataConnectionDefaultResponse,\n DeleteDataConnection204Response,\n DeleteDataConnectionDefaultResponse,\n ListDiscoGroup200Response,\n ListDiscoGroupDefaultResponse,\n ValidateDiscoGroup200Response,\n ValidateDiscoGroupDefaultResponse,\n GetDiscoGroup200Response,\n GetDiscoGroupDefaultResponse,\n CreateOrReplaceDiscoGroup200Response,\n CreateOrReplaceDiscoGroupDefaultResponse,\n RunDiscoGroup204Response,\n RunDiscoGroupDefaultResponse,\n ListRuns200Response,\n ListRunsDefaultResponse,\n ListDiscoTemplate200Response,\n ListDiscoTemplateDefaultResponse,\n GetDiscoTemplate200Response,\n GetDiscoTemplateDefaultResponse,\n GetBillable200Response,\n GetBillableDefaultResponse,\n GetSnapshot200Response,\n GetSnapshotDefaultResponse,\n GetSummary200Response,\n GetSummaryDefaultResponse,\n ListSavedFilter200Response,\n ListSavedFilterDefaultResponse,\n GetSavedFilter200Response,\n GetSavedFilterDefaultResponse,\n CreateOrReplaceSavedFilter200Response,\n CreateOrReplaceSavedFilterDefaultResponse,\n DeleteSavedFilter204Response,\n DeleteSavedFilterDefaultResponse,\n ListTask200Response,\n ListTaskDefaultResponse,\n GetTask200Response,\n GetTaskDefaultResponse,\n CancelTask200Response,\n CancelTaskDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /assets\": [\"200\"],\n \"POST /assets\": [\"200\"],\n \"GET /assets/{assetId}\": [\"200\"],\n \"GET /dataConnections\": [\"200\"],\n \"POST /dataConnections:validate\": [\"200\"],\n \"GET /dataConnections/{dataConnectionName}\": [\"200\"],\n \"PUT /dataConnections/{dataConnectionName}\": [\"200\"],\n \"DELETE /dataConnections/{dataConnectionName}\": [\"204\"],\n \"GET /discoGroups\": [\"200\"],\n \"POST /discoGroups:validate\": [\"200\"],\n \"GET /discoGroups/{groupName}\": [\"200\"],\n \"PUT /discoGroups/{groupName}\": [\"200\"],\n \"POST /discoGroups/{groupName}:run\": [\"204\"],\n \"GET /discoGroups/{groupName}/runs\": [\"200\"],\n \"GET /discoTemplates\": [\"200\"],\n \"GET /discoTemplates/{templateId}\": [\"200\"],\n \"POST /reports/assets:getBillable\": [\"200\"],\n \"POST /reports/assets:getSnapshot\": [\"200\"],\n \"POST /reports/assets:getSummary\": [\"200\"],\n \"GET /savedFilters\": [\"200\"],\n \"GET /savedFilters/{filterName}\": [\"200\"],\n \"PUT /savedFilters/{filterName}\": [\"200\"],\n \"DELETE /savedFilters/{filterName}\": [\"204\"],\n \"GET /tasks\": [\"200\"],\n \"GET /tasks/{taskId}\": [\"200\"],\n \"POST /tasks/{taskId}:cancel\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: ListAssetResource200Response | ListAssetResourceDefaultResponse\n): response is ListAssetResourceDefaultResponse;\nexport function isUnexpected(\n response: UpdateAssets200Response | UpdateAssetsDefaultResponse\n): response is UpdateAssetsDefaultResponse;\nexport function isUnexpected(\n response: GetAssetResource200Response | GetAssetResourceDefaultResponse\n): response is GetAssetResourceDefaultResponse;\nexport function isUnexpected(\n response: ListDataConnection200Response | ListDataConnectionDefaultResponse\n): response is ListDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: ValidateDataConnection200Response | ValidateDataConnectionDefaultResponse\n): response is ValidateDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: GetDataConnection200Response | GetDataConnectionDefaultResponse\n): response is GetDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: CreateOrReplaceDataConnection200Response | CreateOrReplaceDataConnectionDefaultResponse\n): response is CreateOrReplaceDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: DeleteDataConnection204Response | DeleteDataConnectionDefaultResponse\n): response is DeleteDataConnectionDefaultResponse;\nexport function isUnexpected(\n response: ListDiscoGroup200Response | ListDiscoGroupDefaultResponse\n): response is ListDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: ValidateDiscoGroup200Response | ValidateDiscoGroupDefaultResponse\n): response is ValidateDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: GetDiscoGroup200Response | GetDiscoGroupDefaultResponse\n): response is GetDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: CreateOrReplaceDiscoGroup200Response | CreateOrReplaceDiscoGroupDefaultResponse\n): response is CreateOrReplaceDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: RunDiscoGroup204Response | RunDiscoGroupDefaultResponse\n): response is RunDiscoGroupDefaultResponse;\nexport function isUnexpected(\n response: ListRuns200Response | ListRunsDefaultResponse\n): response is ListRunsDefaultResponse;\nexport function isUnexpected(\n response: ListDiscoTemplate200Response | ListDiscoTemplateDefaultResponse\n): response is ListDiscoTemplateDefaultResponse;\nexport function isUnexpected(\n response: GetDiscoTemplate200Response | GetDiscoTemplateDefaultResponse\n): response is GetDiscoTemplateDefaultResponse;\nexport function isUnexpected(\n response: GetBillable200Response | GetBillableDefaultResponse\n): response is GetBillableDefaultResponse;\nexport function isUnexpected(\n response: GetSnapshot200Response | GetSnapshotDefaultResponse\n): response is GetSnapshotDefaultResponse;\nexport function isUnexpected(\n response: GetSummary200Response | GetSummaryDefaultResponse\n): response is GetSummaryDefaultResponse;\nexport function isUnexpected(\n response: ListSavedFilter200Response | ListSavedFilterDefaultResponse\n): response is ListSavedFilterDefaultResponse;\nexport function isUnexpected(\n response: GetSavedFilter200Response | GetSavedFilterDefaultResponse\n): response is GetSavedFilterDefaultResponse;\nexport function isUnexpected(\n response: CreateOrReplaceSavedFilter200Response | CreateOrReplaceSavedFilterDefaultResponse\n): response is CreateOrReplaceSavedFilterDefaultResponse;\nexport function isUnexpected(\n response: DeleteSavedFilter204Response | DeleteSavedFilterDefaultResponse\n): response is DeleteSavedFilterDefaultResponse;\nexport function isUnexpected(\n response: ListTask200Response | ListTaskDefaultResponse\n): response is ListTaskDefaultResponse;\nexport function isUnexpected(\n response: GetTask200Response | GetTaskDefaultResponse\n): response is GetTaskDefaultResponse;\nexport function isUnexpected(\n response: CancelTask200Response | CancelTaskDefaultResponse\n): response is CancelTaskDefaultResponse;\nexport function isUnexpected(\n response:\n | ListAssetResource200Response\n | ListAssetResourceDefaultResponse\n | UpdateAssets200Response\n | UpdateAssetsDefaultResponse\n | GetAssetResource200Response\n | GetAssetResourceDefaultResponse\n | ListDataConnection200Response\n | ListDataConnectionDefaultResponse\n | ValidateDataConnection200Response\n | ValidateDataConnectionDefaultResponse\n | GetDataConnection200Response\n | GetDataConnectionDefaultResponse\n | CreateOrReplaceDataConnection200Response\n | CreateOrReplaceDataConnectionDefaultResponse\n | DeleteDataConnection204Response\n | DeleteDataConnectionDefaultResponse\n | ListDiscoGroup200Response\n | ListDiscoGroupDefaultResponse\n | ValidateDiscoGroup200Response\n | ValidateDiscoGroupDefaultResponse\n | GetDiscoGroup200Response\n | GetDiscoGroupDefaultResponse\n | CreateOrReplaceDiscoGroup200Response\n | CreateOrReplaceDiscoGroupDefaultResponse\n | RunDiscoGroup204Response\n | RunDiscoGroupDefaultResponse\n | ListRuns200Response\n | ListRunsDefaultResponse\n | ListDiscoTemplate200Response\n | ListDiscoTemplateDefaultResponse\n | GetDiscoTemplate200Response\n | GetDiscoTemplateDefaultResponse\n | GetBillable200Response\n | GetBillableDefaultResponse\n | GetSnapshot200Response\n | GetSnapshotDefaultResponse\n | GetSummary200Response\n | GetSummaryDefaultResponse\n | ListSavedFilter200Response\n | ListSavedFilterDefaultResponse\n | GetSavedFilter200Response\n | GetSavedFilterDefaultResponse\n | CreateOrReplaceSavedFilter200Response\n | CreateOrReplaceSavedFilterDefaultResponse\n | DeleteSavedFilter204Response\n | DeleteSavedFilterDefaultResponse\n | ListTask200Response\n | ListTaskDefaultResponse\n | GetTask200Response\n | GetTaskDefaultResponse\n | CancelTask200Response\n | CancelTaskDefaultResponse\n): response is\n | ListAssetResourceDefaultResponse\n | UpdateAssetsDefaultResponse\n | GetAssetResourceDefaultResponse\n | ListDataConnectionDefaultResponse\n | ValidateDataConnectionDefaultResponse\n | GetDataConnectionDefaultResponse\n | CreateOrReplaceDataConnectionDefaultResponse\n | DeleteDataConnectionDefaultResponse\n | ListDiscoGroupDefaultResponse\n | ValidateDiscoGroupDefaultResponse\n | GetDiscoGroupDefaultResponse\n | CreateOrReplaceDiscoGroupDefaultResponse\n | RunDiscoGroupDefaultResponse\n | ListRunsDefaultResponse\n | ListDiscoTemplateDefaultResponse\n | GetDiscoTemplateDefaultResponse\n | GetBillableDefaultResponse\n | GetSnapshotDefaultResponse\n | GetSummaryDefaultResponse\n | ListSavedFilterDefaultResponse\n | GetSavedFilterDefaultResponse\n | CreateOrReplaceSavedFilterDefaultResponse\n | DeleteSavedFilterDefaultResponse\n | ListTaskDefaultResponse\n | GetTaskDefaultResponse\n | CancelTaskDefaultResponse {\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 = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\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 // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\"\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\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[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
@@ -0,0 +1,5 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { createClientLogger } from "@azure/logger";
4
+ export const logger = createClientLogger("defender-easm");
5
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"defender-easm\");\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=models.js.map
@@ -0,0 +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\n/** A request body used to update an asset. */\nexport interface AssetUpdateData {\n /**\n * The state to update the asset to.\n *\n * Possible values: candidate, confirmed, dismissed, candidateInvestigate, associatedPartner, associatedThirdparty\n */\n state?: string;\n /** A string which can be used to identify the asset in external systems. */\n externalId?: string;\n /** Any Labels to update the asset with. */\n labels?: Record<string, boolean>;\n /**\n * A list of asset types to cascade the updates to.\n *\n * Possible values: as, contact, domain, host, ipAddress, ipBlock, page, sslCert\n */\n transfers?: string;\n}\n\nexport interface DataConnectionDataParent {\n /** The name of data connection */\n name?: string;\n /**\n * The type of data the data connection will transfer.\n *\n * Possible values: assets, attackSurfaceInsights\n */\n content?: string;\n /**\n * The rate at which the data connection will receive updates.\n *\n * Possible values: daily, weekly, monthly\n */\n frequency?: string;\n /** The day to update the data connection on. (1-7 for weekly, 1-31 for monthly) */\n frequencyOffset?: number;\n kind: string;\n}\n\n/** Source entity used to drive discovery. */\nexport interface DiscoSource {\n /**\n * The kind of disco source.\n *\n * Possible values: as, attribute, contact, domain, host, ipBlock\n */\n kind?: string;\n /** The name for the disco source. */\n name?: string;\n}\n\n/** A request body used to create a discovery group. */\nexport interface DiscoGroupData {\n /** The name for a disco group. */\n name?: string;\n /** The description for a disco group. */\n description?: string;\n /** The tier for the disco group which will affect the algorithm used for the disco runs in this group. */\n tier?: string;\n /** The frequency at which the disco group is supposed to be rerun in milliseconds. */\n frequencyMilliseconds?: number;\n /** The list of seeds used for the disco group runs. */\n seeds?: Array<DiscoSource>;\n /** The list of names used for the disco group runs. */\n names?: string[];\n /** The list of excludes used for the disco group runs, aka assets to exclude from the discovery algorithm. */\n excludes?: Array<DiscoSource>;\n /** The unique identifier for the disco template used for the disco group creation. */\n templateId?: string;\n}\n\n/** A request body used to retrieve an asset report snapshot. */\nexport interface ReportAssetSnapshotRequest {\n /** The metric to retrieve a snapshot for. */\n metric?: string;\n /** The name of the label to retrieve a snapshot for. */\n labelName?: string;\n /** The number of assets per page. */\n size?: number;\n /** The page to retrieve. */\n page?: number;\n}\n\n/** A request body used to retrieve summary asset information. One and only one collection of summary identifiers must be provided: filters, metrics, or metricCategories. */\nexport interface ReportAssetSummaryRequest {\n /** Categories to retrieve risk reporting data for. */\n metricCategories?: string[];\n /** Metrics to retrieve risk reporting data for. */\n metrics?: string[];\n /** Query filters to apply to the asset summary. */\n filters?: string[];\n /** A parameter to group the assets by (first level facet field), only used when the chosen summary identifier is filters. */\n groupBy?: string;\n /** A parameter to segment the assets by (second level facet field), only used when the chosen summary identifier is filters. */\n segmentBy?: string;\n /** Currently unused. */\n labelName?: string;\n}\n\n/** A request body used to create a saved filter. */\nexport interface SavedFilterData {\n /** An expression on the resource type that selects the resources to be returned. */\n filter: string;\n /** A human readable description of the saved filter. */\n description: string;\n}\n\nexport type DataConnectionData =\n | LogAnalyticsDataConnectionData\n | AzureDataExplorerDataConnectionData;\n\nexport interface LogAnalyticsDataConnectionData extends DataConnectionDataParent {\n kind: \"logAnalytics\";\n properties: LogAnalyticsDataConnectionProperties;\n}\n\nexport interface AzureDataExplorerDataConnectionData extends DataConnectionDataParent {\n kind: \"azureDataExplorer\";\n properties: AzureDataExplorerDataConnectionProperties;\n}\n\n/** LogAnalyticsDataConnectionProperties */\nexport interface LogAnalyticsDataConnectionProperties extends DataConnectionProperties {\n /** log analytics api key */\n apiKey?: string;\n /** log analytics workspace id */\n workspaceId?: string;\n}\n\n/** DataConnectionProperties */\nexport interface DataConnectionProperties {}\n\n/** AzureDataExplorerDataConnectionProperties */\nexport interface AzureDataExplorerDataConnectionProperties extends DataConnectionProperties {\n /** The azure data explorer cluster name */\n clusterName?: string;\n /** The azure data explorer region */\n region?: string;\n /** The azure data explorer database name */\n databaseName?: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=outputModels.js.map