@azure-rest/purview-scanning 1.0.0-alpha.20210901.2 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Release History
2
2
 
3
- ## 1.0.0-beta.2 (Unreleased)
3
+ ## 1.0.0-beta.2 (2021-09-30)
4
4
 
5
+ - refresh package with latest swagger and code generator.
6
+ - add paging helper support.
5
7
 
6
8
  ## 1.0.0-beta.1 (2021-05-11)
7
9
 
package/README.md CHANGED
@@ -79,7 +79,8 @@ The following section shows you how to initialize and authenticate your client,
79
79
  ### List All Data Sources
80
80
 
81
81
  ```typescript
82
- import PurviewScanning from "@azure-rest/purview-scanning";
82
+ import PurviewScanning, { paginate, DataSource } from "@azure-rest/purview-scanning";
83
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
83
84
  import { DefaultAzureCredential } from "@azure/identity";
84
85
 
85
86
  async function main() {
@@ -90,12 +91,18 @@ async function main() {
90
91
  );
91
92
 
92
93
  const dataSources = await client.path("/datasources").get();
93
-
94
94
  if (dataSources.status !== "200") {
95
95
  throw dataSources.body.error;
96
96
  }
97
+ const iter = paginate(client, dataSources)
98
+
99
+ const items: DataSource[] = [];
100
+
101
+ for await (const item of <PagedAsyncIterableIterator<DataSource, (DataSource)[], PageSettings>>iter) {
102
+ items.push(item);
103
+ }
97
104
 
98
- console.log(dataSources.body.value?.map((ds) => ds.name).join("\n"));
105
+ console.log(items?.map((ds) => ds.name).join("\n"));
99
106
  }
100
107
 
101
108
  main().catch(console.error);
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var coreClient = require('@azure-rest/core-client');
6
+ var corePaging = require('@azure/core-paging');
4
7
 
5
8
  // Copyright (c) Microsoft Corporation.
6
9
  function PurviewScanning(Endpoint, credentials, options = {}) {
@@ -13,7 +16,75 @@ function PurviewScanning(Endpoint, credentials, options = {}) {
13
16
  return coreClient.getClient(baseUrl, credentials, options);
14
17
  }
15
18
 
19
+ // Copyright (c) Microsoft Corporation.
20
+ /**
21
+ * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
22
+ * @param client - Client to use for sending the next page requests
23
+ * @param initialResponse - Initial response containing the nextLink and current page of elements
24
+ * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
25
+ * @returns - PagedAsyncIterableIterator to iterate the elements
26
+ */
27
+ function paginate(client, initialResponse, options = {}) {
28
+ let firstRun = true;
29
+ const itemName = "value";
30
+ const nextLinkName = "nextLink";
31
+ const { customGetPage } = options;
32
+ const pagedResult = {
33
+ firstPageLink: "",
34
+ getPage: typeof customGetPage === "function"
35
+ ? customGetPage
36
+ : async (pageLink) => {
37
+ const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
38
+ firstRun = false;
39
+ checkPagingRequest(result);
40
+ const nextLink = getNextLink(result.body, nextLinkName);
41
+ const values = getElements(result.body, itemName);
42
+ return {
43
+ page: values,
44
+ nextPageLink: nextLink,
45
+ };
46
+ },
47
+ };
48
+ return corePaging.getPagedAsyncIterator(pagedResult);
49
+ }
50
+ /**
51
+ * Gets for the value of nextLink in the body
52
+ */
53
+ function getNextLink(body, nextLinkName) {
54
+ if (!nextLinkName) {
55
+ return undefined;
56
+ }
57
+ const nextLink = body[nextLinkName];
58
+ if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
59
+ throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
60
+ }
61
+ return nextLink;
62
+ }
63
+ /**
64
+ * Gets the elements of the current request in the body.
65
+ */
66
+ function getElements(body, itemName) {
67
+ const value = body[itemName];
68
+ // value has to be an array according to the x-ms-pageable extension.
69
+ // The fact that this must be an array is used above to calculate the
70
+ // type of elements in the page in PaginateReturn
71
+ if (!Array.isArray(value)) {
72
+ throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
73
+ }
74
+ return value !== null && value !== void 0 ? value : [];
75
+ }
76
+ /**
77
+ * Checks if a request failed
78
+ */
79
+ function checkPagingRequest(response) {
80
+ const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
81
+ if (!Http2xxStatusCodes.includes(response.status)) {
82
+ throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
83
+ }
84
+ }
85
+
16
86
  // Copyright (c) Microsoft Corporation.
17
87
 
18
- module.exports = PurviewScanning;
88
+ exports.default = PurviewScanning;
89
+ exports.paginate = paginate;
19
90
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/purviewScanning.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n KeyVaultConnectionsGetParameters,\n KeyVaultConnectionsCreateParameters,\n KeyVaultConnectionsDeleteParameters,\n KeyVaultConnectionsListAllParameters,\n ClassificationRulesGetParameters,\n ClassificationRulesCreateOrUpdateParameters,\n ClassificationRulesDeleteParameters,\n ClassificationRulesListAllParameters,\n ClassificationRulesListVersionsByClassificationRuleNameParameters,\n ClassificationRulesTagClassificationVersionParameters,\n DataSourcesCreateOrUpdateParameters,\n DataSourcesGetParameters,\n DataSourcesDeleteParameters,\n DataSourcesListAllParameters,\n FiltersGetParameters,\n FiltersCreateOrUpdateParameters,\n ScansCreateOrUpdateParameters,\n ScansGetParameters,\n ScansDeleteParameters,\n ScansListByDataSourceParameters,\n ScanResultRunScanParameters,\n ScanResultCancelScanParameters,\n ScanResultListScanHistoryParameters,\n ScanRulesetsGetParameters,\n ScanRulesetsCreateOrUpdateParameters,\n ScanRulesetsDeleteParameters,\n ScanRulesetsListAllParameters,\n SystemScanRulesetsListAllParameters,\n SystemScanRulesetsGetParameters,\n SystemScanRulesetsGetByVersionParameters,\n SystemScanRulesetsGetLatestParameters,\n SystemScanRulesetsListVersionsByDataSourceParameters,\n TriggersGetTriggerParameters,\n TriggersCreateTriggerParameters,\n TriggersDeleteTriggerParameters,\n} from \"./parameters\";\nimport {\n KeyVaultConnectionsGet200Response,\n KeyVaultConnectionsGetdefaultResponse,\n KeyVaultConnectionsCreate200Response,\n KeyVaultConnectionsCreatedefaultResponse,\n KeyVaultConnectionsDelete200Response,\n KeyVaultConnectionsDelete204Response,\n KeyVaultConnectionsDeletedefaultResponse,\n KeyVaultConnectionsListAll200Response,\n KeyVaultConnectionsListAlldefaultResponse,\n ClassificationRulesGet200Response,\n ClassificationRulesGetdefaultResponse,\n ClassificationRulesCreateOrUpdate200Response,\n ClassificationRulesCreateOrUpdate201Response,\n ClassificationRulesCreateOrUpdatedefaultResponse,\n ClassificationRulesDelete200Response,\n ClassificationRulesDelete204Response,\n ClassificationRulesDeletedefaultResponse,\n ClassificationRulesListAll200Response,\n ClassificationRulesListAlldefaultResponse,\n ClassificationRulesListVersionsByClassificationRuleName200Response,\n ClassificationRulesListVersionsByClassificationRuleNamedefaultResponse,\n ClassificationRulesTagClassificationVersion202Response,\n ClassificationRulesTagClassificationVersiondefaultResponse,\n DataSourcesCreateOrUpdate200Response,\n DataSourcesCreateOrUpdate201Response,\n DataSourcesCreateOrUpdatedefaultResponse,\n DataSourcesGet200Response,\n DataSourcesGetdefaultResponse,\n DataSourcesDelete200Response,\n DataSourcesDelete204Response,\n DataSourcesDeletedefaultResponse,\n DataSourcesListAll200Response,\n DataSourcesListAlldefaultResponse,\n FiltersGet200Response,\n FiltersGetdefaultResponse,\n FiltersCreateOrUpdate200Response,\n FiltersCreateOrUpdate201Response,\n FiltersCreateOrUpdatedefaultResponse,\n ScansCreateOrUpdate200Response,\n ScansCreateOrUpdate201Response,\n ScansCreateOrUpdatedefaultResponse,\n ScansGet200Response,\n ScansGetdefaultResponse,\n ScansDelete200Response,\n ScansDelete204Response,\n ScansDeletedefaultResponse,\n ScansListByDataSource200Response,\n ScansListByDataSourcedefaultResponse,\n ScanResultRunScan202Response,\n ScanResultRunScandefaultResponse,\n ScanResultCancelScan202Response,\n ScanResultCancelScandefaultResponse,\n ScanResultListScanHistory200Response,\n ScanResultListScanHistorydefaultResponse,\n ScanRulesetsGet200Response,\n ScanRulesetsGetdefaultResponse,\n ScanRulesetsCreateOrUpdate200Response,\n ScanRulesetsCreateOrUpdate201Response,\n ScanRulesetsCreateOrUpdatedefaultResponse,\n ScanRulesetsDelete200Response,\n ScanRulesetsDelete204Response,\n ScanRulesetsDeletedefaultResponse,\n ScanRulesetsListAll200Response,\n ScanRulesetsListAlldefaultResponse,\n SystemScanRulesetsListAll200Response,\n SystemScanRulesetsListAlldefaultResponse,\n SystemScanRulesetsGet200Response,\n SystemScanRulesetsGetdefaultResponse,\n SystemScanRulesetsGetByVersion200Response,\n SystemScanRulesetsGetByVersiondefaultResponse,\n SystemScanRulesetsGetLatest200Response,\n SystemScanRulesetsGetLatestdefaultResponse,\n SystemScanRulesetsListVersionsByDataSource200Response,\n SystemScanRulesetsListVersionsByDataSourcedefaultResponse,\n TriggersGetTrigger200Response,\n TriggersGetTriggerdefaultResponse,\n TriggersCreateTrigger200Response,\n TriggersCreateTrigger201Response,\n TriggersCreateTriggerdefaultResponse,\n TriggersDeleteTrigger200Response,\n TriggersDeleteTrigger204Response,\n TriggersDeleteTriggerdefaultResponse,\n} from \"./responses\";\nimport { getClient, ClientOptions, Client } from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\n\nexport interface KeyVaultConnectionsDelete {\n /** Gets key vault information */\n get(\n options?: KeyVaultConnectionsGetParameters\n ): Promise<KeyVaultConnectionsGet200Response | KeyVaultConnectionsGetdefaultResponse>;\n /** Creates an instance of a key vault connection */\n put(\n options: KeyVaultConnectionsCreateParameters\n ): Promise<KeyVaultConnectionsCreate200Response | KeyVaultConnectionsCreatedefaultResponse>;\n /** Deletes the key vault connection associated with the account */\n delete(\n options?: KeyVaultConnectionsDeleteParameters\n ): Promise<\n | KeyVaultConnectionsDelete200Response\n | KeyVaultConnectionsDelete204Response\n | KeyVaultConnectionsDeletedefaultResponse\n >;\n}\n\nexport interface KeyVaultConnectionsListAll {\n /** List key vault connections in account */\n get(\n options?: KeyVaultConnectionsListAllParameters\n ): Promise<KeyVaultConnectionsListAll200Response | KeyVaultConnectionsListAlldefaultResponse>;\n}\n\nexport interface ClassificationRulesDelete {\n /** Get a classification rule */\n get(\n options?: ClassificationRulesGetParameters\n ): Promise<ClassificationRulesGet200Response | ClassificationRulesGetdefaultResponse>;\n /** Creates or Updates a classification rule */\n put(\n options?: ClassificationRulesCreateOrUpdateParameters\n ): Promise<\n | ClassificationRulesCreateOrUpdate200Response\n | ClassificationRulesCreateOrUpdate201Response\n | ClassificationRulesCreateOrUpdatedefaultResponse\n >;\n /** Deletes a classification rule */\n delete(\n options?: ClassificationRulesDeleteParameters\n ): Promise<\n | ClassificationRulesDelete200Response\n | ClassificationRulesDelete204Response\n | ClassificationRulesDeletedefaultResponse\n >;\n}\n\nexport interface ClassificationRulesListAll {\n /** List classification rules in Account */\n get(\n options?: ClassificationRulesListAllParameters\n ): Promise<ClassificationRulesListAll200Response | ClassificationRulesListAlldefaultResponse>;\n}\n\nexport interface ClassificationRulesListVersionsByClassificationRuleName {\n /** Lists the rule versions of a classification rule */\n get(\n options?: ClassificationRulesListVersionsByClassificationRuleNameParameters\n ): Promise<\n | ClassificationRulesListVersionsByClassificationRuleName200Response\n | ClassificationRulesListVersionsByClassificationRuleNamedefaultResponse\n >;\n}\n\nexport interface ClassificationRulesTagClassificationVersion {\n /** Sets Classification Action on a specific classification rule version. */\n post(\n options?: ClassificationRulesTagClassificationVersionParameters\n ): Promise<\n | ClassificationRulesTagClassificationVersion202Response\n | ClassificationRulesTagClassificationVersiondefaultResponse\n >;\n}\n\nexport interface DataSourcesDelete {\n /** Creates or Updates a data source */\n put(\n options?: DataSourcesCreateOrUpdateParameters\n ): Promise<\n | DataSourcesCreateOrUpdate200Response\n | DataSourcesCreateOrUpdate201Response\n | DataSourcesCreateOrUpdatedefaultResponse\n >;\n /** Get a data source */\n get(\n options?: DataSourcesGetParameters\n ): Promise<DataSourcesGet200Response | DataSourcesGetdefaultResponse>;\n /** Deletes a data source */\n delete(\n options?: DataSourcesDeleteParameters\n ): Promise<\n DataSourcesDelete200Response | DataSourcesDelete204Response | DataSourcesDeletedefaultResponse\n >;\n}\n\nexport interface DataSourcesListAll {\n /** List data sources in Data catalog */\n get(\n options?: DataSourcesListAllParameters\n ): Promise<DataSourcesListAll200Response | DataSourcesListAlldefaultResponse>;\n}\n\nexport interface FiltersCreateOrUpdate {\n /** Get a filter */\n get(options?: FiltersGetParameters): Promise<FiltersGet200Response | FiltersGetdefaultResponse>;\n /** Creates or updates a filter */\n put(\n options?: FiltersCreateOrUpdateParameters\n ): Promise<\n | FiltersCreateOrUpdate200Response\n | FiltersCreateOrUpdate201Response\n | FiltersCreateOrUpdatedefaultResponse\n >;\n}\n\nexport interface ScansDelete {\n /** Creates an instance of a scan */\n put(\n options: ScansCreateOrUpdateParameters\n ): Promise<\n | ScansCreateOrUpdate200Response\n | ScansCreateOrUpdate201Response\n | ScansCreateOrUpdatedefaultResponse\n >;\n /** Gets a scan information */\n get(options?: ScansGetParameters): Promise<ScansGet200Response | ScansGetdefaultResponse>;\n /** Deletes the scan associated with the data source */\n delete(\n options?: ScansDeleteParameters\n ): Promise<ScansDelete200Response | ScansDelete204Response | ScansDeletedefaultResponse>;\n}\n\nexport interface ScansListByDataSource {\n /** List scans in data source */\n get(\n options?: ScansListByDataSourceParameters\n ): Promise<ScansListByDataSource200Response | ScansListByDataSourcedefaultResponse>;\n}\n\nexport interface ScanResultRunScan {\n /** Runs the scan */\n put(\n options?: ScanResultRunScanParameters\n ): Promise<ScanResultRunScan202Response | ScanResultRunScandefaultResponse>;\n}\n\nexport interface ScanResultCancelScan {\n /** Cancels a scan */\n post(\n options?: ScanResultCancelScanParameters\n ): Promise<ScanResultCancelScan202Response | ScanResultCancelScandefaultResponse>;\n}\n\nexport interface ScanResultListScanHistory {\n /** Lists the scan history of a scan */\n get(\n options?: ScanResultListScanHistoryParameters\n ): Promise<ScanResultListScanHistory200Response | ScanResultListScanHistorydefaultResponse>;\n}\n\nexport interface ScanRulesetsDelete {\n /** Get a scan ruleset */\n get(\n options?: ScanRulesetsGetParameters\n ): Promise<ScanRulesetsGet200Response | ScanRulesetsGetdefaultResponse>;\n /** Creates or Updates a scan ruleset */\n put(\n options?: ScanRulesetsCreateOrUpdateParameters\n ): Promise<\n | ScanRulesetsCreateOrUpdate200Response\n | ScanRulesetsCreateOrUpdate201Response\n | ScanRulesetsCreateOrUpdatedefaultResponse\n >;\n /** Deletes a scan ruleset */\n delete(\n options?: ScanRulesetsDeleteParameters\n ): Promise<\n | ScanRulesetsDelete200Response\n | ScanRulesetsDelete204Response\n | ScanRulesetsDeletedefaultResponse\n >;\n}\n\nexport interface ScanRulesetsListAll {\n /** List scan rulesets in Data catalog */\n get(\n options?: ScanRulesetsListAllParameters\n ): Promise<ScanRulesetsListAll200Response | ScanRulesetsListAlldefaultResponse>;\n}\n\nexport interface SystemScanRulesetsListAll {\n /** List all system scan rulesets for an account */\n get(\n options?: SystemScanRulesetsListAllParameters\n ): Promise<SystemScanRulesetsListAll200Response | SystemScanRulesetsListAlldefaultResponse>;\n}\n\nexport interface SystemScanRulesetsGet {\n /** Get a system scan ruleset for a data source */\n get(\n options?: SystemScanRulesetsGetParameters\n ): Promise<SystemScanRulesetsGet200Response | SystemScanRulesetsGetdefaultResponse>;\n}\n\nexport interface SystemScanRulesetsGetByVersion {\n /** Get a scan ruleset by version */\n get(\n options?: SystemScanRulesetsGetByVersionParameters\n ): Promise<\n SystemScanRulesetsGetByVersion200Response | SystemScanRulesetsGetByVersiondefaultResponse\n >;\n}\n\nexport interface SystemScanRulesetsGetLatest {\n /** Get the latest version of a system scan ruleset */\n get(\n options?: SystemScanRulesetsGetLatestParameters\n ): Promise<SystemScanRulesetsGetLatest200Response | SystemScanRulesetsGetLatestdefaultResponse>;\n}\n\nexport interface SystemScanRulesetsListVersionsByDataSource {\n /** List system scan ruleset versions in Data catalog */\n get(\n options?: SystemScanRulesetsListVersionsByDataSourceParameters\n ): Promise<\n | SystemScanRulesetsListVersionsByDataSource200Response\n | SystemScanRulesetsListVersionsByDataSourcedefaultResponse\n >;\n}\n\nexport interface TriggersDeleteTrigger {\n /** Gets trigger information */\n get(\n options?: TriggersGetTriggerParameters\n ): Promise<TriggersGetTrigger200Response | TriggersGetTriggerdefaultResponse>;\n /** Creates an instance of a trigger */\n put(\n options: TriggersCreateTriggerParameters\n ): Promise<\n | TriggersCreateTrigger200Response\n | TriggersCreateTrigger201Response\n | TriggersCreateTriggerdefaultResponse\n >;\n /** Deletes the trigger associated with the scan */\n delete(\n options?: TriggersDeleteTriggerParameters\n ): Promise<\n | TriggersDeleteTrigger200Response\n | TriggersDeleteTrigger204Response\n | TriggersDeleteTriggerdefaultResponse\n >;\n}\n\nexport interface Routes {\n /** Resource for '/azureKeyVaults/\\{keyVaultName\\}' has methods for the following verbs: get, put, delete */\n (path: \"/azureKeyVaults/{keyVaultName}\", keyVaultName: string): KeyVaultConnectionsDelete;\n /** Resource for '/azureKeyVaults' has methods for the following verbs: get */\n (path: \"/azureKeyVaults\"): KeyVaultConnectionsListAll;\n /** Resource for '/classificationrules/\\{classificationRuleName\\}' has methods for the following verbs: get, put, delete */\n (\n path: \"/classificationrules/{classificationRuleName}\",\n classificationRuleName: string\n ): ClassificationRulesDelete;\n /** Resource for '/classificationrules' has methods for the following verbs: get */\n (path: \"/classificationrules\"): ClassificationRulesListAll;\n /** Resource for '/classificationrules/\\{classificationRuleName\\}/versions' has methods for the following verbs: get */\n (\n path: \"/classificationrules/{classificationRuleName}/versions\",\n classificationRuleName: string\n ): ClassificationRulesListVersionsByClassificationRuleName;\n /** Resource for '/classificationrules/\\{classificationRuleName\\}/versions/\\{classificationRuleVersion\\}/:tag' has methods for the following verbs: post */\n (\n path: \"/classificationrules/{classificationRuleName}/versions/{classificationRuleVersion}/:tag\",\n classificationRuleName: string,\n classificationRuleVersion: string\n ): ClassificationRulesTagClassificationVersion;\n /** Resource for '/datasources/\\{dataSourceName\\}' has methods for the following verbs: put, get, delete */\n (path: \"/datasources/{dataSourceName}\", dataSourceName: string): DataSourcesDelete;\n /** Resource for '/datasources' has methods for the following verbs: get */\n (path: \"/datasources\"): DataSourcesListAll;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/filters/custom' has methods for the following verbs: get, put */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/filters/custom\",\n dataSourceName: string,\n scanName: string\n ): FiltersCreateOrUpdate;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}' has methods for the following verbs: put, get, delete */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}\",\n dataSourceName: string,\n scanName: string\n ): ScansDelete;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans' has methods for the following verbs: get */\n (path: \"/datasources/{dataSourceName}/scans\", dataSourceName: string): ScansListByDataSource;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/runs/\\{runId\\}' has methods for the following verbs: put */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}\",\n dataSourceName: string,\n scanName: string,\n runId: string\n ): ScanResultRunScan;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/runs/\\{runId\\}/:cancel' has methods for the following verbs: post */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}/:cancel\",\n dataSourceName: string,\n scanName: string,\n runId: string\n ): ScanResultCancelScan;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/runs' has methods for the following verbs: get */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/runs\",\n dataSourceName: string,\n scanName: string\n ): ScanResultListScanHistory;\n /** Resource for '/scanrulesets/\\{scanRulesetName\\}' has methods for the following verbs: get, put, delete */\n (path: \"/scanrulesets/{scanRulesetName}\", scanRulesetName: string): ScanRulesetsDelete;\n /** Resource for '/scanrulesets' has methods for the following verbs: get */\n (path: \"/scanrulesets\"): ScanRulesetsListAll;\n /** Resource for '/systemScanRulesets' has methods for the following verbs: get */\n (path: \"/systemScanRulesets\"): SystemScanRulesetsListAll;\n /** Resource for '/systemScanRulesets/datasources/\\{dataSourceType\\}' has methods for the following verbs: get */\n (\n path: \"/systemScanRulesets/datasources/{dataSourceType}\",\n dataSourceType: string\n ): SystemScanRulesetsGet;\n /** Resource for '/systemScanRulesets/versions/\\{version\\}' has methods for the following verbs: get */\n (path: \"/systemScanRulesets/versions/{version}\", version: string): SystemScanRulesetsGetByVersion;\n /** Resource for '/systemScanRulesets/versions/latest' has methods for the following verbs: get */\n (path: \"/systemScanRulesets/versions/latest\"): SystemScanRulesetsGetLatest;\n /** Resource for '/systemScanRulesets/versions' has methods for the following verbs: get */\n (path: \"/systemScanRulesets/versions\"): SystemScanRulesetsListVersionsByDataSource;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/triggers/default' has methods for the following verbs: get, put, delete */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/triggers/default\",\n dataSourceName: string,\n scanName: string\n ): TriggersDeleteTrigger;\n}\n\nexport type PurviewScanningRestClient = Client & {\n path: Routes;\n};\n\nexport default function PurviewScanning(\n Endpoint: string,\n credentials: TokenCredential,\n options: ClientOptions = {}\n): PurviewScanningRestClient {\n const baseUrl = options.baseUrl ?? `${Endpoint}`;\n options.apiVersion = options.apiVersion ?? \"2018-12-01-preview\";\n options = {\n ...options,\n credentials: {\n scopes: [\"https://purview.azure.net/.default\"],\n },\n };\n\n return getClient(baseUrl, credentials, options) as PurviewScanningRestClient;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport PurviewScanning from \"./purviewScanning\";\n\nexport * from \"./purviewScanning\";\nexport * from \"./models\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\n\nexport default PurviewScanning;\n"],"names":["getClient"],"mappings":";;;;AAAA;SAwdwB,eAAe,CACrC,QAAgB,EAChB,WAA4B,EAC5B,UAAyB,EAAE;;IAE3B,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,GAAG,QAAQ,EAAE,CAAC;IACjD,OAAO,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,oBAAoB,CAAC;IAChE,OAAO,mCACF,OAAO,KACV,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,oCAAoC,CAAC;SAC/C,GACF,CAAC;IAEF,OAAOA,oBAAS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAA8B,CAAC;AAC/E;;ACveA,uCAAuC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/purviewScanning.ts","../src/paginateHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n KeyVaultConnectionsGetParameters,\n KeyVaultConnectionsCreateParameters,\n KeyVaultConnectionsDeleteParameters,\n KeyVaultConnectionsListAllParameters,\n ClassificationRulesGetParameters,\n ClassificationRulesCreateOrUpdateParameters,\n ClassificationRulesDeleteParameters,\n ClassificationRulesListAllParameters,\n ClassificationRulesListVersionsByClassificationRuleNameParameters,\n ClassificationRulesTagClassificationVersionParameters,\n DataSourcesCreateOrUpdateParameters,\n DataSourcesGetParameters,\n DataSourcesDeleteParameters,\n DataSourcesListAllParameters,\n FiltersGetParameters,\n FiltersCreateOrUpdateParameters,\n ScansCreateOrUpdateParameters,\n ScansGetParameters,\n ScansDeleteParameters,\n ScansListByDataSourceParameters,\n ScanResultRunScanParameters,\n ScanResultCancelScanParameters,\n ScanResultListScanHistoryParameters,\n ScanRulesetsGetParameters,\n ScanRulesetsCreateOrUpdateParameters,\n ScanRulesetsDeleteParameters,\n ScanRulesetsListAllParameters,\n SystemScanRulesetsListAllParameters,\n SystemScanRulesetsGetParameters,\n SystemScanRulesetsGetByVersionParameters,\n SystemScanRulesetsGetLatestParameters,\n SystemScanRulesetsListVersionsByDataSourceParameters,\n TriggersGetTriggerParameters,\n TriggersCreateTriggerParameters,\n TriggersDeleteTriggerParameters,\n} from \"./parameters\";\nimport {\n KeyVaultConnectionsGet200Response,\n KeyVaultConnectionsGetdefaultResponse,\n KeyVaultConnectionsCreate200Response,\n KeyVaultConnectionsCreatedefaultResponse,\n KeyVaultConnectionsDelete200Response,\n KeyVaultConnectionsDelete204Response,\n KeyVaultConnectionsDeletedefaultResponse,\n KeyVaultConnectionsListAll200Response,\n KeyVaultConnectionsListAlldefaultResponse,\n ClassificationRulesGet200Response,\n ClassificationRulesGetdefaultResponse,\n ClassificationRulesCreateOrUpdate200Response,\n ClassificationRulesCreateOrUpdate201Response,\n ClassificationRulesCreateOrUpdatedefaultResponse,\n ClassificationRulesDelete200Response,\n ClassificationRulesDelete204Response,\n ClassificationRulesDeletedefaultResponse,\n ClassificationRulesListAll200Response,\n ClassificationRulesListAlldefaultResponse,\n ClassificationRulesListVersionsByClassificationRuleName200Response,\n ClassificationRulesListVersionsByClassificationRuleNamedefaultResponse,\n ClassificationRulesTagClassificationVersion202Response,\n ClassificationRulesTagClassificationVersiondefaultResponse,\n DataSourcesCreateOrUpdate200Response,\n DataSourcesCreateOrUpdate201Response,\n DataSourcesCreateOrUpdatedefaultResponse,\n DataSourcesGet200Response,\n DataSourcesGetdefaultResponse,\n DataSourcesDelete200Response,\n DataSourcesDelete204Response,\n DataSourcesDeletedefaultResponse,\n DataSourcesListAll200Response,\n DataSourcesListAlldefaultResponse,\n FiltersGet200Response,\n FiltersGetdefaultResponse,\n FiltersCreateOrUpdate200Response,\n FiltersCreateOrUpdate201Response,\n FiltersCreateOrUpdatedefaultResponse,\n ScansCreateOrUpdate200Response,\n ScansCreateOrUpdate201Response,\n ScansCreateOrUpdatedefaultResponse,\n ScansGet200Response,\n ScansGetdefaultResponse,\n ScansDelete200Response,\n ScansDelete204Response,\n ScansDeletedefaultResponse,\n ScansListByDataSource200Response,\n ScansListByDataSourcedefaultResponse,\n ScanResultRunScan202Response,\n ScanResultRunScandefaultResponse,\n ScanResultCancelScan202Response,\n ScanResultCancelScandefaultResponse,\n ScanResultListScanHistory200Response,\n ScanResultListScanHistorydefaultResponse,\n ScanRulesetsGet200Response,\n ScanRulesetsGetdefaultResponse,\n ScanRulesetsCreateOrUpdate200Response,\n ScanRulesetsCreateOrUpdate201Response,\n ScanRulesetsCreateOrUpdatedefaultResponse,\n ScanRulesetsDelete200Response,\n ScanRulesetsDelete204Response,\n ScanRulesetsDeletedefaultResponse,\n ScanRulesetsListAll200Response,\n ScanRulesetsListAlldefaultResponse,\n SystemScanRulesetsListAll200Response,\n SystemScanRulesetsListAlldefaultResponse,\n SystemScanRulesetsGet200Response,\n SystemScanRulesetsGetdefaultResponse,\n SystemScanRulesetsGetByVersion200Response,\n SystemScanRulesetsGetByVersiondefaultResponse,\n SystemScanRulesetsGetLatest200Response,\n SystemScanRulesetsGetLatestdefaultResponse,\n SystemScanRulesetsListVersionsByDataSource200Response,\n SystemScanRulesetsListVersionsByDataSourcedefaultResponse,\n TriggersGetTrigger200Response,\n TriggersGetTriggerdefaultResponse,\n TriggersCreateTrigger200Response,\n TriggersCreateTrigger201Response,\n TriggersCreateTriggerdefaultResponse,\n TriggersDeleteTrigger200Response,\n TriggersDeleteTrigger204Response,\n TriggersDeleteTriggerdefaultResponse,\n} from \"./responses\";\nimport { getClient, ClientOptions, Client } from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\n\nexport interface KeyVaultConnectionsGet {\n /** Gets key vault information */\n get(\n options?: KeyVaultConnectionsGetParameters\n ): Promise<KeyVaultConnectionsGet200Response | KeyVaultConnectionsGetdefaultResponse>;\n /** Creates an instance of a key vault connection */\n put(\n options: KeyVaultConnectionsCreateParameters\n ): Promise<KeyVaultConnectionsCreate200Response | KeyVaultConnectionsCreatedefaultResponse>;\n /** Deletes the key vault connection associated with the account */\n delete(\n options?: KeyVaultConnectionsDeleteParameters\n ): Promise<\n | KeyVaultConnectionsDelete200Response\n | KeyVaultConnectionsDelete204Response\n | KeyVaultConnectionsDeletedefaultResponse\n >;\n}\n\nexport interface KeyVaultConnectionsListAll {\n /** List key vault connections in account */\n get(\n options?: KeyVaultConnectionsListAllParameters\n ): Promise<KeyVaultConnectionsListAll200Response | KeyVaultConnectionsListAlldefaultResponse>;\n}\n\nexport interface ClassificationRulesGet {\n /** Get a classification rule */\n get(\n options?: ClassificationRulesGetParameters\n ): Promise<ClassificationRulesGet200Response | ClassificationRulesGetdefaultResponse>;\n /** Creates or Updates a classification rule */\n put(\n options?: ClassificationRulesCreateOrUpdateParameters\n ): Promise<\n | ClassificationRulesCreateOrUpdate200Response\n | ClassificationRulesCreateOrUpdate201Response\n | ClassificationRulesCreateOrUpdatedefaultResponse\n >;\n /** Deletes a classification rule */\n delete(\n options?: ClassificationRulesDeleteParameters\n ): Promise<\n | ClassificationRulesDelete200Response\n | ClassificationRulesDelete204Response\n | ClassificationRulesDeletedefaultResponse\n >;\n}\n\nexport interface ClassificationRulesListAll {\n /** List classification rules in Account */\n get(\n options?: ClassificationRulesListAllParameters\n ): Promise<ClassificationRulesListAll200Response | ClassificationRulesListAlldefaultResponse>;\n}\n\nexport interface ClassificationRulesListVersionsByClassificationRuleName {\n /** Lists the rule versions of a classification rule */\n get(\n options?: ClassificationRulesListVersionsByClassificationRuleNameParameters\n ): Promise<\n | ClassificationRulesListVersionsByClassificationRuleName200Response\n | ClassificationRulesListVersionsByClassificationRuleNamedefaultResponse\n >;\n}\n\nexport interface ClassificationRulesTagClassificationVersion {\n /** Sets Classification Action on a specific classification rule version. */\n post(\n options: ClassificationRulesTagClassificationVersionParameters\n ): Promise<\n | ClassificationRulesTagClassificationVersion202Response\n | ClassificationRulesTagClassificationVersiondefaultResponse\n >;\n}\n\nexport interface DataSourcesCreateOrUpdate {\n /** Creates or Updates a data source */\n put(\n options?: DataSourcesCreateOrUpdateParameters\n ): Promise<\n | DataSourcesCreateOrUpdate200Response\n | DataSourcesCreateOrUpdate201Response\n | DataSourcesCreateOrUpdatedefaultResponse\n >;\n /** Get a data source */\n get(\n options?: DataSourcesGetParameters\n ): Promise<DataSourcesGet200Response | DataSourcesGetdefaultResponse>;\n /** Deletes a data source */\n delete(\n options?: DataSourcesDeleteParameters\n ): Promise<\n DataSourcesDelete200Response | DataSourcesDelete204Response | DataSourcesDeletedefaultResponse\n >;\n}\n\nexport interface DataSourcesListAll {\n /** List data sources in Data catalog */\n get(\n options?: DataSourcesListAllParameters\n ): Promise<DataSourcesListAll200Response | DataSourcesListAlldefaultResponse>;\n}\n\nexport interface FiltersGet {\n /** Get a filter */\n get(options?: FiltersGetParameters): Promise<FiltersGet200Response | FiltersGetdefaultResponse>;\n /** Creates or updates a filter */\n put(\n options?: FiltersCreateOrUpdateParameters\n ): Promise<\n | FiltersCreateOrUpdate200Response\n | FiltersCreateOrUpdate201Response\n | FiltersCreateOrUpdatedefaultResponse\n >;\n}\n\nexport interface ScansCreateOrUpdate {\n /** Creates an instance of a scan */\n put(\n options: ScansCreateOrUpdateParameters\n ): Promise<\n | ScansCreateOrUpdate200Response\n | ScansCreateOrUpdate201Response\n | ScansCreateOrUpdatedefaultResponse\n >;\n /** Gets a scan information */\n get(options?: ScansGetParameters): Promise<ScansGet200Response | ScansGetdefaultResponse>;\n /** Deletes the scan associated with the data source */\n delete(\n options?: ScansDeleteParameters\n ): Promise<ScansDelete200Response | ScansDelete204Response | ScansDeletedefaultResponse>;\n}\n\nexport interface ScansListByDataSource {\n /** List scans in data source */\n get(\n options?: ScansListByDataSourceParameters\n ): Promise<ScansListByDataSource200Response | ScansListByDataSourcedefaultResponse>;\n}\n\nexport interface ScanResultRunScan {\n /** Runs the scan */\n put(\n options?: ScanResultRunScanParameters\n ): Promise<ScanResultRunScan202Response | ScanResultRunScandefaultResponse>;\n}\n\nexport interface ScanResultCancelScan {\n /** Cancels a scan */\n post(\n options?: ScanResultCancelScanParameters\n ): Promise<ScanResultCancelScan202Response | ScanResultCancelScandefaultResponse>;\n}\n\nexport interface ScanResultListScanHistory {\n /** Lists the scan history of a scan */\n get(\n options?: ScanResultListScanHistoryParameters\n ): Promise<ScanResultListScanHistory200Response | ScanResultListScanHistorydefaultResponse>;\n}\n\nexport interface ScanRulesetsGet {\n /** Get a scan ruleset */\n get(\n options?: ScanRulesetsGetParameters\n ): Promise<ScanRulesetsGet200Response | ScanRulesetsGetdefaultResponse>;\n /** Creates or Updates a scan ruleset */\n put(\n options?: ScanRulesetsCreateOrUpdateParameters\n ): Promise<\n | ScanRulesetsCreateOrUpdate200Response\n | ScanRulesetsCreateOrUpdate201Response\n | ScanRulesetsCreateOrUpdatedefaultResponse\n >;\n /** Deletes a scan ruleset */\n delete(\n options?: ScanRulesetsDeleteParameters\n ): Promise<\n | ScanRulesetsDelete200Response\n | ScanRulesetsDelete204Response\n | ScanRulesetsDeletedefaultResponse\n >;\n}\n\nexport interface ScanRulesetsListAll {\n /** List scan rulesets in Data catalog */\n get(\n options?: ScanRulesetsListAllParameters\n ): Promise<ScanRulesetsListAll200Response | ScanRulesetsListAlldefaultResponse>;\n}\n\nexport interface SystemScanRulesetsListAll {\n /** List all system scan rulesets for an account */\n get(\n options?: SystemScanRulesetsListAllParameters\n ): Promise<SystemScanRulesetsListAll200Response | SystemScanRulesetsListAlldefaultResponse>;\n}\n\nexport interface SystemScanRulesetsGet {\n /** Get a system scan ruleset for a data source */\n get(\n options?: SystemScanRulesetsGetParameters\n ): Promise<SystemScanRulesetsGet200Response | SystemScanRulesetsGetdefaultResponse>;\n}\n\nexport interface SystemScanRulesetsGetByVersion {\n /** Get a scan ruleset by version */\n get(\n options?: SystemScanRulesetsGetByVersionParameters\n ): Promise<\n SystemScanRulesetsGetByVersion200Response | SystemScanRulesetsGetByVersiondefaultResponse\n >;\n}\n\nexport interface SystemScanRulesetsGetLatest {\n /** Get the latest version of a system scan ruleset */\n get(\n options?: SystemScanRulesetsGetLatestParameters\n ): Promise<SystemScanRulesetsGetLatest200Response | SystemScanRulesetsGetLatestdefaultResponse>;\n}\n\nexport interface SystemScanRulesetsListVersionsByDataSource {\n /** List system scan ruleset versions in Data catalog */\n get(\n options?: SystemScanRulesetsListVersionsByDataSourceParameters\n ): Promise<\n | SystemScanRulesetsListVersionsByDataSource200Response\n | SystemScanRulesetsListVersionsByDataSourcedefaultResponse\n >;\n}\n\nexport interface TriggersGetTrigger {\n /** Gets trigger information */\n get(\n options?: TriggersGetTriggerParameters\n ): Promise<TriggersGetTrigger200Response | TriggersGetTriggerdefaultResponse>;\n /** Creates an instance of a trigger */\n put(\n options: TriggersCreateTriggerParameters\n ): Promise<\n | TriggersCreateTrigger200Response\n | TriggersCreateTrigger201Response\n | TriggersCreateTriggerdefaultResponse\n >;\n /** Deletes the trigger associated with the scan */\n delete(\n options?: TriggersDeleteTriggerParameters\n ): Promise<\n | TriggersDeleteTrigger200Response\n | TriggersDeleteTrigger204Response\n | TriggersDeleteTriggerdefaultResponse\n >;\n}\n\nexport interface Routes {\n /** Resource for '/azureKeyVaults/\\{keyVaultName\\}' has methods for the following verbs: get, put, delete */\n (path: \"/azureKeyVaults/{keyVaultName}\", keyVaultName: string): KeyVaultConnectionsGet;\n /** Resource for '/azureKeyVaults' has methods for the following verbs: get */\n (path: \"/azureKeyVaults\"): KeyVaultConnectionsListAll;\n /** Resource for '/classificationrules/\\{classificationRuleName\\}' has methods for the following verbs: get, put, delete */\n (\n path: \"/classificationrules/{classificationRuleName}\",\n classificationRuleName: string\n ): ClassificationRulesGet;\n /** Resource for '/classificationrules' has methods for the following verbs: get */\n (path: \"/classificationrules\"): ClassificationRulesListAll;\n /** Resource for '/classificationrules/\\{classificationRuleName\\}/versions' has methods for the following verbs: get */\n (\n path: \"/classificationrules/{classificationRuleName}/versions\",\n classificationRuleName: string\n ): ClassificationRulesListVersionsByClassificationRuleName;\n /** Resource for '/classificationrules/\\{classificationRuleName\\}/versions/\\{classificationRuleVersion\\}/:tag' has methods for the following verbs: post */\n (\n path: \"/classificationrules/{classificationRuleName}/versions/{classificationRuleVersion}/:tag\",\n classificationRuleName: string,\n classificationRuleVersion: string\n ): ClassificationRulesTagClassificationVersion;\n /** Resource for '/datasources/\\{dataSourceName\\}' has methods for the following verbs: put, get, delete */\n (path: \"/datasources/{dataSourceName}\", dataSourceName: string): DataSourcesCreateOrUpdate;\n /** Resource for '/datasources' has methods for the following verbs: get */\n (path: \"/datasources\"): DataSourcesListAll;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/filters/custom' has methods for the following verbs: get, put */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/filters/custom\",\n dataSourceName: string,\n scanName: string\n ): FiltersGet;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}' has methods for the following verbs: put, get, delete */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}\",\n dataSourceName: string,\n scanName: string\n ): ScansCreateOrUpdate;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans' has methods for the following verbs: get */\n (path: \"/datasources/{dataSourceName}/scans\", dataSourceName: string): ScansListByDataSource;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/runs/\\{runId\\}' has methods for the following verbs: put */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}\",\n dataSourceName: string,\n scanName: string,\n runId: string\n ): ScanResultRunScan;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/runs/\\{runId\\}/:cancel' has methods for the following verbs: post */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}/:cancel\",\n dataSourceName: string,\n scanName: string,\n runId: string\n ): ScanResultCancelScan;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/runs' has methods for the following verbs: get */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/runs\",\n dataSourceName: string,\n scanName: string\n ): ScanResultListScanHistory;\n /** Resource for '/scanrulesets/\\{scanRulesetName\\}' has methods for the following verbs: get, put, delete */\n (path: \"/scanrulesets/{scanRulesetName}\", scanRulesetName: string): ScanRulesetsGet;\n /** Resource for '/scanrulesets' has methods for the following verbs: get */\n (path: \"/scanrulesets\"): ScanRulesetsListAll;\n /** Resource for '/systemScanRulesets' has methods for the following verbs: get */\n (path: \"/systemScanRulesets\"): SystemScanRulesetsListAll;\n /** Resource for '/systemScanRulesets/datasources/\\{dataSourceType\\}' has methods for the following verbs: get */\n (\n path: \"/systemScanRulesets/datasources/{dataSourceType}\",\n dataSourceType: string\n ): SystemScanRulesetsGet;\n /** Resource for '/systemScanRulesets/versions/\\{version\\}' has methods for the following verbs: get */\n (path: \"/systemScanRulesets/versions/{version}\", version: string): SystemScanRulesetsGetByVersion;\n /** Resource for '/systemScanRulesets/versions/latest' has methods for the following verbs: get */\n (path: \"/systemScanRulesets/versions/latest\"): SystemScanRulesetsGetLatest;\n /** Resource for '/systemScanRulesets/versions' has methods for the following verbs: get */\n (path: \"/systemScanRulesets/versions\"): SystemScanRulesetsListVersionsByDataSource;\n /** Resource for '/datasources/\\{dataSourceName\\}/scans/\\{scanName\\}/triggers/default' has methods for the following verbs: get, put, delete */\n (\n path: \"/datasources/{dataSourceName}/scans/{scanName}/triggers/default\",\n dataSourceName: string,\n scanName: string\n ): TriggersGetTrigger;\n}\n\nexport type PurviewScanningRestClient = Client & {\n path: Routes;\n};\n\nexport default function PurviewScanning(\n Endpoint: string,\n credentials: TokenCredential,\n options: ClientOptions = {}\n): PurviewScanningRestClient {\n const baseUrl = options.baseUrl ?? `${Endpoint}`;\n options.apiVersion = options.apiVersion ?? \"2018-12-01-preview\";\n options = {\n ...options,\n credentials: {\n scopes: [\"https://purview.azure.net/.default\"],\n },\n };\n\n return getClient(baseUrl, credentials, options) as PurviewScanningRestClient;\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 PurviewScanning from \"./purviewScanning\";\n\nexport * from \"./purviewScanning\";\nexport * from \"./models\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./paginateHelper\";\n\nexport default PurviewScanning;\n"],"names":["getClient","getPagedAsyncIterator","createRestError"],"mappings":";;;;;;;AAAA;SAwdwB,eAAe,CACrC,QAAgB,EAChB,WAA4B,EAC5B,UAAyB,EAAE;;IAE3B,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,GAAG,QAAQ,EAAE,CAAC;IACjD,OAAO,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,oBAAoB,CAAC;IAChE,OAAO,mCACF,OAAO,KACV,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,oCAAoC,CAAC;SAC/C,GACF,CAAC;IAEF,OAAOA,oBAAS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAA8B,CAAC;AAC/E;;ACveA;AACA,AA4CA;;;;;;;AAOA,SAAgB,QAAQ,CACtB,MAAc,EACd,eAA0B,EAC1B,UAAoC,EAAE;IAItC,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,MAAM,QAAQ,GAAG,OAAO,CAAC;IACzB,MAAM,YAAY,GAAG,UAAU,CAAC;IAChC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,WAAW,GAA4B;QAC3C,aAAa,EAAE,EAAE;QACjB,OAAO,EACL,OAAO,aAAa,KAAK,UAAU;cAC/B,aAAa;cACb,OAAO,QAAgB;gBACrB,MAAM,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;gBACvF,QAAQ,GAAG,KAAK,CAAC;gBACjB,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAC3B,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;gBACxD,MAAM,MAAM,GAAG,WAAW,CAAW,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAC5D,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,YAAY,EAAE,QAAQ;iBACvB,CAAC;aACH;KACR,CAAC;IAEF,OAAOC,gCAAqB,CAAC,WAAW,CAAC,CAAC;AAC5C,CAAC;AAED;;;AAGA,SAAS,WAAW,CAAC,IAAa,EAAE,YAAqB;IACvD,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,QAAQ,GAAI,IAAgC,CAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QACnE,MAAM,IAAI,KAAK,CAAC,iBAAiB,YAAY,kCAAkC,CAAC,CAAC;KAClF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;AAGA,SAAS,WAAW,CAAc,IAAa,EAAE,QAAgB;IAC/D,MAAM,KAAK,GAAI,IAAgC,CAAC,QAAQ,CAAQ,CAAC;;;;IAKjE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,MAAM,IAAI,KAAK,CACb,kFAAkF,QAAQ,EAAE,CAC7F,CAAC;KACH;IAED,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;AACrB,CAAC;AAED;;;AAGA,SAAS,kBAAkB,CAAC,QAA+B;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,gDAAgD,QAAQ,CAAC,MAAM,EAAE,EACjE,QAAQ,CACT,CAAC;KACH;AACH,CAAC;;AClID,uCAAuC;;;;;"}
@@ -5,5 +5,6 @@ export * from "./purviewScanning";
5
5
  export * from "./models";
6
6
  export * from "./parameters";
7
7
  export * from "./responses";
8
+ export * from "./paginateHelper";
8
9
  export default PurviewScanning;
9
10
  //# 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,eAAe,MAAM,mBAAmB,CAAC;AAEhD,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,eAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport PurviewScanning from \"./purviewScanning\";\n\nexport * from \"./purviewScanning\";\nexport * from \"./models\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\n\nexport default PurviewScanning;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AAEjC,eAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport PurviewScanning from \"./purviewScanning\";\n\nexport * from \"./purviewScanning\";\nexport * from \"./models\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./paginateHelper\";\n\nexport default PurviewScanning;\n"]}