From 3b3324fa4af887c5d05a13390c89122d018f41c9 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:53:31 +0800 Subject: [PATCH 01/11] refresh purview-administration-rest sdk --- .../review/purview-administration.api.md | 1202 +++++++++++------ .../samples-dev/accountCollections.ts | 6 +- .../samples-dev/metadataPolicies.ts | 13 +- .../src/account/clientDefinitions.ts | 124 +- .../src/account/index.ts | 21 +- .../src/account/isUnexpected.ts | 251 ++++ .../src/account/models.ts | 244 +--- .../src/account/outputModels.ts | 391 ++++++ .../src/account/paginateHelper.ts | 184 ++- .../src/account/parameters.ts | 46 +- .../src/account/purviewAccount.ts | 65 +- .../src/account/responses.ts | 167 ++- .../purview-administration-rest/src/index.ts | 7 +- .../purview-administration-rest/src/logger.ts | 5 + .../src/metadataPolicies/clientDefinitions.ts | 41 +- .../src/metadataPolicies/index.ts | 24 +- .../src/metadataPolicies/isUnexpected.ts | 134 ++ .../src/metadataPolicies/models.ts | 61 +- .../src/metadataPolicies/outputModels.ts | 126 ++ .../src/metadataPolicies/paginateHelper.ts | 192 ++- .../src/metadataPolicies/parameters.ts | 13 +- .../purviewMetadataPolicies.ts | 67 +- .../src/metadataPolicies/responses.ts | 57 +- .../swagger/README.md | 13 +- .../test/public/account.spec.ts | 2 +- .../test/public/collections.spec.ts | 2 +- .../test/public/metadataPolicies.spec.ts | 7 +- .../test/public/utils/recordedClient.ts | 10 +- 28 files changed, 2536 insertions(+), 939 deletions(-) create mode 100644 sdk/purview/purview-administration-rest/src/account/isUnexpected.ts create mode 100644 sdk/purview/purview-administration-rest/src/account/outputModels.ts create mode 100644 sdk/purview/purview-administration-rest/src/logger.ts create mode 100644 sdk/purview/purview-administration-rest/src/metadataPolicies/isUnexpected.ts create mode 100644 sdk/purview/purview-administration-rest/src/metadataPolicies/outputModels.ts diff --git a/sdk/purview/purview-administration-rest/review/purview-administration.api.md b/sdk/purview/purview-administration-rest/review/purview-administration.api.md index 4cc9e2b69cf8..6b1d22b0eff1 100644 --- a/sdk/purview/purview-administration-rest/review/purview-administration.api.md +++ b/sdk/purview/purview-administration-rest/review/purview-administration.api.md @@ -7,85 +7,85 @@ import { Client } from '@azure-rest/core-client'; import { ClientOptions } from '@azure-rest/core-client'; import { HttpResponse } from '@azure-rest/core-client'; -import { PagedAsyncIterableIterator } from '@azure/core-paging'; import { PathUncheckedResponse } from '@azure-rest/core-client'; import { RawHttpHeaders } from '@azure/core-rest-pipeline'; import { RequestParameters } from '@azure-rest/core-client'; +import { StreamableMethod } from '@azure-rest/core-client'; import { TokenCredential } from '@azure/core-auth'; -// @public (undocumented) +// @public interface AccessKeyOptions { keyType?: "PrimaryAtlasKafkaKey" | "SecondaryAtlasKafkaKey"; } -// @public (undocumented) -interface AccessKeys { +// @public +interface AccessKeysOutput { atlasKafkaPrimaryEndpoint?: string; atlasKafkaSecondaryEndpoint?: string; } -// @public (undocumented) -interface Account { - id?: string; - identity?: Identity; - location?: string; - name?: string; - properties?: AccountProperties; - sku?: AccountSku; - systemData?: AccountSystemData; - tags?: Record; - type?: string; +// @public +interface AccountEndpointsOutput { + readonly catalog?: string; + readonly guardian?: string; + readonly scan?: string; } -// @public (undocumented) -interface AccountEndpoints { - catalog?: string; - guardian?: string; - scan?: string; +// @public +interface AccountOutput { + readonly id?: string; + identity?: IdentityOutput; + location?: string; + readonly name?: string; + properties?: AccountPropertiesOutput; + sku?: AccountSkuOutput; + readonly systemData?: AccountSystemDataOutput; + tags?: Record; + readonly type?: string; } -// @public (undocumented) -interface AccountProperties { - cloudConnectors?: CloudConnectors; - createdAt?: Date; - createdBy?: string; - createdByObjectId?: string; - endpoints?: AccountPropertiesEndpoints; - friendlyName?: string; - managedResourceGroupName?: string; - managedResources?: AccountPropertiesManagedResources; - privateEndpointConnections?: Array; - provisioningState?: "Unknown" | "Creating" | "Moving" | "Deleting" | "SoftDeleting" | "SoftDeleted" | "Failed" | "Succeeded" | "Canceled"; - publicNetworkAccess?: "NotSpecified" | "Enabled" | "Disabled"; +// @public +interface AccountPropertiesEndpointsOutput extends AccountEndpointsOutput { } -// @public (undocumented) -interface AccountPropertiesEndpoints extends AccountEndpoints { +// @public +interface AccountPropertiesManagedResourcesOutput extends ManagedResourcesOutput { } -// @public (undocumented) -interface AccountPropertiesManagedResources extends ManagedResources { +// @public +interface AccountPropertiesOutput { + cloudConnectors?: CloudConnectorsOutput; + readonly createdAt?: string; + readonly createdBy?: string; + readonly createdByObjectId?: string; + readonly endpoints?: AccountPropertiesEndpointsOutput; + readonly friendlyName?: string; + managedResourceGroupName?: string; + readonly managedResources?: AccountPropertiesManagedResourcesOutput; + readonly privateEndpointConnections?: Array; + readonly provisioningState?: "Unknown" | "Creating" | "Moving" | "Deleting" | "SoftDeleting" | "SoftDeleted" | "Failed" | "Succeeded" | "Canceled"; + publicNetworkAccess?: "NotSpecified" | "Enabled" | "Disabled"; } // @public (undocumented) interface AccountsGetAccessKeys { - post(options?: AccountsGetAccessKeysParameters): Promise; + post(options?: AccountsGetAccessKeysParameters): StreamableMethod; } // @public interface AccountsGetAccessKeys200Response extends HttpResponse { // (undocumented) - body: AccessKeys; + body: AccessKeysOutput; // (undocumented) status: "200"; } // @public -interface AccountsGetAccessKeysdefaultResponse extends HttpResponse { +interface AccountsGetAccessKeysDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -93,44 +93,44 @@ type AccountsGetAccessKeysParameters = RequestParameters; // @public (undocumented) interface AccountsGetAccountProperties { - get(options?: AccountsGetAccountPropertiesParameters): Promise; - patch(options: AccountsUpdateAccountPropertiesParameters): Promise; + get(options?: AccountsGetAccountPropertiesParameters): StreamableMethod; + patch(options: AccountsUpdateAccountPropertiesParameters): StreamableMethod; } // @public interface AccountsGetAccountProperties200Response extends HttpResponse { // (undocumented) - body: Account; + body: AccountOutput; // (undocumented) status: "200"; } // @public -interface AccountsGetAccountPropertiesdefaultResponse extends HttpResponse { +interface AccountsGetAccountPropertiesDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) type AccountsGetAccountPropertiesParameters = RequestParameters; -// @public (undocumented) -interface AccountSku { +// @public +interface AccountSkuOutput { capacity?: number; name?: "Standard"; } // @public (undocumented) interface AccountsRegenerateAccessKey { - post(options: AccountsRegenerateAccessKeyParameters): Promise; + post(options: AccountsRegenerateAccessKeyParameters): StreamableMethod; } // @public interface AccountsRegenerateAccessKey200Response extends HttpResponse { // (undocumented) - body: AccessKeys; + body: AccessKeysOutput; // (undocumented) status: "200"; } @@ -142,20 +142,25 @@ interface AccountsRegenerateAccessKeyBodyParam { } // @public -interface AccountsRegenerateAccessKeydefaultResponse extends HttpResponse { +interface AccountsRegenerateAccessKeyDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; +} + +// @public (undocumented) +interface AccountsRegenerateAccessKeyMediaTypesParam { + contentType?: "application/json"; } // @public (undocumented) -type AccountsRegenerateAccessKeyParameters = AccountsRegenerateAccessKeyBodyParam & RequestParameters; +type AccountsRegenerateAccessKeyParameters = AccountsRegenerateAccessKeyMediaTypesParam & AccountsRegenerateAccessKeyBodyParam & RequestParameters; // @public interface AccountsUpdateAccountProperties200Response extends HttpResponse { // (undocumented) - body: Account; + body: AccountOutput; // (undocumented) status: "200"; } @@ -167,27 +172,42 @@ interface AccountsUpdateAccountPropertiesBodyParam { } // @public -interface AccountsUpdateAccountPropertiesdefaultResponse extends HttpResponse { +interface AccountsUpdateAccountPropertiesDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) -type AccountsUpdateAccountPropertiesParameters = AccountsUpdateAccountPropertiesBodyParam & RequestParameters; +interface AccountsUpdateAccountPropertiesMediaTypesParam { + contentType?: "application/json"; +} // @public (undocumented) +type AccountsUpdateAccountPropertiesParameters = AccountsUpdateAccountPropertiesMediaTypesParam & AccountsUpdateAccountPropertiesBodyParam & RequestParameters; + +// @public interface AccountSystemData extends SystemData { } -// @public (undocumented) +// @public +interface AccountSystemDataOutput extends SystemDataOutput { +} + +// @public interface AdvancedResourceSet { - modifiedAt?: Date; + modifiedAt?: Date | string; resourceSetProcessing?: "Default" | "Advanced"; } -// @public (undocumented) +// @public +interface AdvancedResourceSetOutput { + modifiedAt?: string; + resourceSetProcessing?: "Default" | "Advanced"; +} + +// @public interface AttributeMatcher { attributeName?: string; attributeValueExcludedIn?: Array; @@ -196,15 +216,41 @@ interface AttributeMatcher { attributeValueIncludes?: string; } -// @public (undocumented) +// @public +interface AttributeMatcherOutput { + attributeName?: string; + attributeValueExcludedIn?: Array; + attributeValueExcludes?: string; + attributeValueIncludedIn?: Array; + attributeValueIncludes?: string; +} + +// @public interface AttributeRule { dnfCondition?: Array>; id?: string; - kind?: "decisionrule" | "attributerule"; + name?: string; +} + +// @public +interface AttributeRuleOutput { + dnfCondition?: Array>; + id?: string; + readonly kind?: "decisionrule" | "attributerule"; name?: string; } declare namespace Client_2 { + export { + MetadataRolesList, + MetadataPolicyListAll, + MetadataPolicyUpdate, + Routes, + PurviewMetadataPoliciesClient + } +} + +declare namespace Client_3 { export { AccountsGetAccountProperties, AccountsGetAccessKeys, @@ -215,78 +261,87 @@ declare namespace Client_2 { CollectionsGetCollectionPath, ResourceSetRulesGetResourceSetRule, ResourceSetRulesListResourceSetRules, - Routes, - PurviewAccountRestClient - } -} - -declare namespace Client_3 { - export { - MetadataRolesList, - MetadataPolicyListAll, - MetadataPolicyUpdate, Routes_2 as Routes, - PurviewMetadataPoliciesRestClient + PurviewAccountClient } } // @public (undocumented) -interface CloudConnectors { - awsExternalId?: string; +interface CloudConnectorsOutput { + readonly awsExternalId?: string; } -// @public (undocumented) +// @public interface Collection { - collectionProvisioningState?: "Unknown" | "Creating" | "Moving" | "Deleting" | "Failed" | "Succeeded"; description?: string; friendlyName?: string; - name?: string; - parentCollection?: CollectionReference; - systemData?: CollectionSystemData; + parentCollection?: CollectionReference_2; } -// @public (undocumented) -interface CollectionList { +// @public +interface CollectionListOutput { count?: number; nextLink?: string; - value: Array; -} - -// @public (undocumented) -interface CollectionNameResponse { - friendlyName?: string; - name?: string; + value: Array; } -// @public (undocumented) -interface CollectionNameResponseList { +// @public +interface CollectionNameResponseListOutput { count?: number; nextLink?: string; - value: Array; + value: Array; } -// @public (undocumented) -interface CollectionPathResponse { - parentFriendlyNameChain?: Array; - parentNameChain?: Array; +// @public +interface CollectionNameResponseOutput { + readonly friendlyName?: string; + readonly name?: string; } -// @public (undocumented) +// @public +interface CollectionOutput { + readonly collectionProvisioningState?: "Unknown" | "Creating" | "Moving" | "Deleting" | "Failed" | "Succeeded"; + description?: string; + friendlyName?: string; + readonly name?: string; + parentCollection?: CollectionReferenceOutput_2; + readonly systemData?: CollectionSystemDataOutput; +} + +// @public +interface CollectionPathResponseOutput { + readonly parentFriendlyNameChain?: Array; + readonly parentNameChain?: Array; +} + +// @public interface CollectionReference { referenceName?: string; type?: string; } -// @public (undocumented) +// @public interface CollectionReference_2 { referenceName?: string; type?: string; } +// @public +interface CollectionReferenceOutput { + referenceName?: string; + type?: string; +} + +// @public +interface CollectionReferenceOutput_2 { + referenceName?: string; + type?: string; +} + // @public interface CollectionsCreateOrUpdateCollection200Response extends HttpResponse { // (undocumented) - body: Collection; + body: CollectionOutput; // (undocumented) status: "200"; } @@ -298,30 +353,33 @@ interface CollectionsCreateOrUpdateCollectionBodyParam { } // @public -interface CollectionsCreateOrUpdateCollectiondefaultResponse extends HttpResponse { +interface CollectionsCreateOrUpdateCollectionDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; +} + +// @public (undocumented) +interface CollectionsCreateOrUpdateCollectionMediaTypesParam { + contentType?: "application/json"; } // @public (undocumented) -type CollectionsCreateOrUpdateCollectionParameters = CollectionsCreateOrUpdateCollectionBodyParam & RequestParameters; +type CollectionsCreateOrUpdateCollectionParameters = CollectionsCreateOrUpdateCollectionMediaTypesParam & CollectionsCreateOrUpdateCollectionBodyParam & RequestParameters; // @public interface CollectionsDeleteCollection204Response extends HttpResponse { - // (undocumented) - body: Record; // (undocumented) status: "204"; } // @public -interface CollectionsDeleteCollectiondefaultResponse extends HttpResponse { +interface CollectionsDeleteCollectionDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -329,25 +387,25 @@ type CollectionsDeleteCollectionParameters = RequestParameters; // @public (undocumented) interface CollectionsGetCollection { - delete(options?: CollectionsDeleteCollectionParameters): Promise; - get(options?: CollectionsGetCollectionParameters): Promise; - put(options: CollectionsCreateOrUpdateCollectionParameters): Promise; + delete(options?: CollectionsDeleteCollectionParameters): StreamableMethod; + get(options?: CollectionsGetCollectionParameters): StreamableMethod; + put(options: CollectionsCreateOrUpdateCollectionParameters): StreamableMethod; } // @public interface CollectionsGetCollection200Response extends HttpResponse { // (undocumented) - body: Collection; + body: CollectionOutput; // (undocumented) status: "200"; } // @public -interface CollectionsGetCollectiondefaultResponse extends HttpResponse { +interface CollectionsGetCollectionDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -355,23 +413,23 @@ type CollectionsGetCollectionParameters = RequestParameters; // @public (undocumented) interface CollectionsGetCollectionPath { - get(options?: CollectionsGetCollectionPathParameters): Promise; + get(options?: CollectionsGetCollectionPathParameters): StreamableMethod; } // @public interface CollectionsGetCollectionPath200Response extends HttpResponse { // (undocumented) - body: CollectionPathResponse; + body: CollectionPathResponseOutput; // (undocumented) status: "200"; } // @public -interface CollectionsGetCollectionPathdefaultResponse extends HttpResponse { +interface CollectionsGetCollectionPathDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -379,23 +437,23 @@ type CollectionsGetCollectionPathParameters = RequestParameters; // @public (undocumented) interface CollectionsListChildCollectionNames { - get(options?: CollectionsListChildCollectionNamesParameters): Promise; + get(options?: CollectionsListChildCollectionNamesParameters): StreamableMethod; } // @public interface CollectionsListChildCollectionNames200Response extends HttpResponse { // (undocumented) - body: CollectionNameResponseList; + body: CollectionNameResponseListOutput; // (undocumented) status: "200"; } // @public -interface CollectionsListChildCollectionNamesdefaultResponse extends HttpResponse { +interface CollectionsListChildCollectionNamesDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -415,23 +473,23 @@ interface CollectionsListChildCollectionNamesQueryParamProperties { // @public (undocumented) interface CollectionsListCollections { - get(options?: CollectionsListCollectionsParameters): Promise; + get(options?: CollectionsListCollectionsParameters): StreamableMethod; } // @public interface CollectionsListCollections200Response extends HttpResponse { // (undocumented) - body: CollectionList; + body: CollectionListOutput; // (undocumented) status: "200"; } // @public -interface CollectionsListCollectionsdefaultResponse extends HttpResponse { +interface CollectionsListCollectionsDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -449,10 +507,14 @@ interface CollectionsListCollectionsQueryParamProperties { $skipToken?: string; } -// @public (undocumented) +// @public interface CollectionSystemData extends SystemData { } +// @public +interface CollectionSystemDataOutput extends SystemDataOutput { +} + // @public (undocumented) interface ComplexReplacerConfig { // (undocumented) @@ -474,45 +536,77 @@ interface ComplexReplacerConfig { } // @public (undocumented) +interface ComplexReplacerConfigOutput { + // (undocumented) + createdBy?: string; + // (undocumented) + description?: string; + // (undocumented) + disabled?: boolean; + // (undocumented) + disableRecursiveReplacerApplication?: boolean; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + modifiedBy?: string; + // (undocumented) + name?: string; + // (undocumented) + typeName?: string; +} + +// @public +function createClient(endpoint: string, credentials: TokenCredential, { apiVersion, ...options }?: PurviewMetadataPoliciesClientOptions): PurviewMetadataPoliciesClient; + +// @public +function createClient_2(endpoint: string, credentials: TokenCredential, { apiVersion, ...options }?: PurviewAccountClientOptions): PurviewAccountClient; + +// @public interface DataPlaneAccountUpdateParameters { friendlyName?: string; } -// @public (undocumented) +// @public interface DecisionRule { dnfCondition?: Array>; effect?: "Deny" | "Permit"; - kind?: "decisionrule" | "attributerule"; } -// @public (undocumented) -interface ErrorModel { - code?: string; - details?: Array; - message?: string; - target?: string; +// @public +interface DecisionRuleOutput { + dnfCondition?: Array>; + effect?: "Deny" | "Permit"; + readonly kind?: "decisionrule" | "attributerule"; } -// @public (undocumented) -interface ErrorModel_2 { +// @public +interface ErrorModelOutput { code: string; - details?: Array; + details?: Array; message: string; target?: string; } -// @public (undocumented) -interface ErrorResponseModel { - error?: ErrorResponseModelError; +// @public +interface ErrorModelOutput_2 { + readonly code?: string; + readonly details?: Array; + readonly message?: string; + readonly target?: string; } -// @public (undocumented) -interface ErrorResponseModel_2 { - error: ErrorModel_2; +// @public +interface ErrorResponseModelErrorOutput extends ErrorModelOutput_2 { } -// @public (undocumented) -interface ErrorResponseModelError extends ErrorModel { +// @public +interface ErrorResponseModelOutput { + error: ErrorModelOutput; +} + +// @public +interface ErrorResponseModelOutput_2 { + readonly error?: ErrorResponseModelErrorOutput; } // @public (undocumented) @@ -541,6 +635,32 @@ interface FastRegex { regexStr?: string; } +// @public (undocumented) +interface FastRegexOutput { + // (undocumented) + maxDigits?: number; + // (undocumented) + maxLetters?: number; + // (undocumented) + minDashes?: number; + // (undocumented) + minDigits?: number; + // (undocumented) + minDigitsOrLetters?: number; + // (undocumented) + minDots?: number; + // (undocumented) + minHex?: number; + // (undocumented) + minLetters?: number; + // (undocumented) + minUnderscores?: number; + // (undocumented) + options?: number; + // (undocumented) + regexStr?: string; +} + // @public (undocumented) interface Filter { // (undocumented) @@ -557,6 +677,22 @@ interface Filter { path: string; } +// @public (undocumented) +interface FilterOutput { + // (undocumented) + createdBy?: string; + // (undocumented) + filterType?: "Pattern" | "Regex"; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + modifiedBy?: string; + // (undocumented) + name: string; + // (undocumented) + path: string; +} + // @public type GetArrayType = T extends Array ? TData : never; @@ -564,29 +700,83 @@ type GetArrayType = T extends Array ? TData : never; type GetArrayType_2 = T extends Array ? TData : never; // @public -type GetPage = (pageLink: string, maxPageSize?: number) => Promise<{ +type GetPage = (pageLink: string) => Promise<{ page: TPage; nextPageLink?: string; }>; // @public -type GetPage_2 = (pageLink: string, maxPageSize?: number) => Promise<{ +type GetPage_2 = (pageLink: string) => Promise<{ page: TPage; nextPageLink?: string; }>; -// @public (undocumented) -interface Identity { - principalId?: string; - tenantId?: string; +// @public +interface IdentityOutput { + readonly principalId?: string; + readonly tenantId?: string; type?: "SystemAssigned"; } // @public (undocumented) -interface ManagedResources { - eventHubNamespace?: string; - resourceGroup?: string; - storageAccount?: string; +function isUnexpected(response: MetadataRolesList200Response | MetadataRolesListDefaultResponse): response is MetadataRolesListDefaultResponse; + +// @public (undocumented) +function isUnexpected(response: MetadataPolicyListAll200Response | MetadataPolicyListAllDefaultResponse): response is MetadataPolicyListAllDefaultResponse; + +// @public (undocumented) +function isUnexpected(response: MetadataPolicyUpdate200Response | MetadataPolicyUpdateDefaultResponse): response is MetadataPolicyUpdateDefaultResponse; + +// @public (undocumented) +function isUnexpected(response: MetadataPolicyGet200Response | MetadataPolicyGetDefaultResponse): response is MetadataPolicyGetDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: AccountsGetAccountProperties200Response | AccountsGetAccountPropertiesDefaultResponse): response is AccountsGetAccountPropertiesDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: AccountsUpdateAccountProperties200Response | AccountsUpdateAccountPropertiesDefaultResponse): response is AccountsUpdateAccountPropertiesDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: AccountsGetAccessKeys200Response | AccountsGetAccessKeysDefaultResponse): response is AccountsGetAccessKeysDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: AccountsRegenerateAccessKey200Response | AccountsRegenerateAccessKeyDefaultResponse): response is AccountsRegenerateAccessKeyDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: CollectionsGetCollection200Response | CollectionsGetCollectionDefaultResponse): response is CollectionsGetCollectionDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: CollectionsCreateOrUpdateCollection200Response | CollectionsCreateOrUpdateCollectionDefaultResponse): response is CollectionsCreateOrUpdateCollectionDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: CollectionsDeleteCollection204Response | CollectionsDeleteCollectionDefaultResponse): response is CollectionsDeleteCollectionDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: CollectionsListCollections200Response | CollectionsListCollectionsDefaultResponse): response is CollectionsListCollectionsDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: CollectionsListChildCollectionNames200Response | CollectionsListChildCollectionNamesDefaultResponse): response is CollectionsListChildCollectionNamesDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: CollectionsGetCollectionPath200Response | CollectionsGetCollectionPathDefaultResponse): response is CollectionsGetCollectionPathDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: ResourceSetRulesGetResourceSetRule200Response | ResourceSetRulesGetResourceSetRuleDefaultResponse): response is ResourceSetRulesGetResourceSetRuleDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: ResourceSetRulesCreateOrUpdateResourceSetRule200Response | ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse): response is ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: ResourceSetRulesDeleteResourceSetRule200Response | ResourceSetRulesDeleteResourceSetRule204Response | ResourceSetRulesDeleteResourceSetRuleDefaultResponse): response is ResourceSetRulesDeleteResourceSetRuleDefaultResponse; + +// @public (undocumented) +function isUnexpected_2(response: ResourceSetRulesListResourceSetRules200Response | ResourceSetRulesListResourceSetRulesDefaultResponse): response is ResourceSetRulesListResourceSetRulesDefaultResponse; + +// @public +interface ManagedResourcesOutput { + readonly eventHubNamespace?: string; + readonly resourceGroup?: string; + readonly storageAccount?: string; } // @public (undocumented) @@ -601,63 +791,55 @@ interface MetadataPolicy { // @public interface MetadataPolicyGet200Response extends HttpResponse { // (undocumented) - body: MetadataPolicy; + body: MetadataPolicyOutput; // (undocumented) status: "200"; } // @public (undocumented) -interface MetadataPolicyGetdefaultHeaders { +interface MetadataPolicyGetDefaultHeaders { "x-ms-error-code"?: string; } // @public -interface MetadataPolicyGetdefaultResponse extends HttpResponse { +interface MetadataPolicyGetDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel_2; + body: ErrorResponseModelOutput; // (undocumented) - headers: RawHttpHeaders & MetadataPolicyGetdefaultHeaders; + headers: RawHttpHeaders & MetadataPolicyGetDefaultHeaders; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) type MetadataPolicyGetParameters = RequestParameters; -// @public (undocumented) -interface MetadataPolicyList { - // (undocumented) - nextLink?: string; - // (undocumented) - values: Array; -} - // @public (undocumented) interface MetadataPolicyListAll { - get(options?: MetadataPolicyListAllParameters): Promise; + get(options?: MetadataPolicyListAllParameters): StreamableMethod; } // @public interface MetadataPolicyListAll200Response extends HttpResponse { // (undocumented) - body: MetadataPolicyList; + body: MetadataPolicyListOutput; // (undocumented) status: "200"; } // @public (undocumented) -interface MetadataPolicyListAlldefaultHeaders { +interface MetadataPolicyListAllDefaultHeaders { "x-ms-error-code"?: string; } // @public -interface MetadataPolicyListAlldefaultResponse extends HttpResponse { +interface MetadataPolicyListAllDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel_2; + body: ErrorResponseModelOutput; // (undocumented) - headers: RawHttpHeaders & MetadataPolicyListAlldefaultHeaders; + headers: RawHttpHeaders & MetadataPolicyListAllDefaultHeaders; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -674,25 +856,51 @@ interface MetadataPolicyListAllQueryParamProperties { collectionName?: string; } -// @public (undocumented) -interface MetadataPolicyProperties { - attributeRules?: Array; - collection?: CollectionReference_2; - decisionRules?: Array; - description?: string; +// @public +interface MetadataPolicyListOutput { + // (undocumented) + nextLink?: string; + // (undocumented) + values: Array; +} + +// @public (undocumented) +interface MetadataPolicyOutput { + id?: string; + name?: string; + // (undocumented) + properties?: MetadataPolicyPropertiesOutput; + version?: number; +} + +// @public (undocumented) +interface MetadataPolicyProperties { + attributeRules?: Array; + collection?: CollectionReference; + decisionRules?: Array; + description?: string; + parentCollectionName?: string; +} + +// @public (undocumented) +interface MetadataPolicyPropertiesOutput { + attributeRules?: Array; + collection?: CollectionReferenceOutput; + decisionRules?: Array; + description?: string; parentCollectionName?: string; } // @public (undocumented) interface MetadataPolicyUpdate { - get(options?: MetadataPolicyGetParameters): Promise; - put(options?: MetadataPolicyUpdateParameters): Promise; + get(options?: MetadataPolicyGetParameters): StreamableMethod; + put(options?: MetadataPolicyUpdateParameters): StreamableMethod; } // @public interface MetadataPolicyUpdate200Response extends HttpResponse { // (undocumented) - body: MetadataPolicy; + body: MetadataPolicyOutput; // (undocumented) status: "200"; } @@ -703,45 +911,50 @@ interface MetadataPolicyUpdateBodyParam { } // @public (undocumented) -interface MetadataPolicyUpdatedefaultHeaders { +interface MetadataPolicyUpdateDefaultHeaders { "x-ms-error-code"?: string; } // @public -interface MetadataPolicyUpdatedefaultResponse extends HttpResponse { +interface MetadataPolicyUpdateDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel_2; + body: ErrorResponseModelOutput; // (undocumented) - headers: RawHttpHeaders & MetadataPolicyUpdatedefaultHeaders; + headers: RawHttpHeaders & MetadataPolicyUpdateDefaultHeaders; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) -type MetadataPolicyUpdateParameters = MetadataPolicyUpdateBodyParam & RequestParameters; +interface MetadataPolicyUpdateMediaTypesParam { + contentType?: "application/json"; +} // @public (undocumented) -interface MetadataRole { - id?: string; - name?: string; +type MetadataPolicyUpdateParameters = MetadataPolicyUpdateMediaTypesParam & MetadataPolicyUpdateBodyParam & RequestParameters; + +// @public +interface MetadataRoleListOutput { // (undocumented) - properties?: MetadataRoleProperties; - type?: string; + nextLink?: string; + // (undocumented) + values: Array; } // @public (undocumented) -interface MetadataRoleList { - // (undocumented) - nextLink?: string; +interface MetadataRoleOutput { + id?: string; + name?: string; // (undocumented) - values: Array; + properties?: MetadataRolePropertiesOutput; + type?: string; } // @public (undocumented) -interface MetadataRoleProperties { - cnfCondition?: Array>; +interface MetadataRolePropertiesOutput { + cnfCondition?: Array>; description?: string; - dnfCondition?: Array>; + dnfCondition?: Array>; friendlyName?: string; provisioningState?: string; roleType?: string; @@ -750,30 +963,30 @@ interface MetadataRoleProperties { // @public (undocumented) interface MetadataRolesList { - get(options?: MetadataRolesListParameters): Promise; + get(options?: MetadataRolesListParameters): StreamableMethod; } // @public interface MetadataRolesList200Response extends HttpResponse { // (undocumented) - body: MetadataRoleList; + body: MetadataRoleListOutput; // (undocumented) status: "200"; } // @public (undocumented) -interface MetadataRolesListdefaultHeaders { +interface MetadataRolesListDefaultHeaders { "x-ms-error-code"?: string; } // @public -interface MetadataRolesListdefaultResponse extends HttpResponse { +interface MetadataRolesListDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel_2; + body: ErrorResponseModelOutput; // (undocumented) - headers: RawHttpHeaders & MetadataRolesListdefaultHeaders; + headers: RawHttpHeaders & MetadataRolesListDefaultHeaders; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -781,34 +994,24 @@ type MetadataRolesListParameters = RequestParameters; declare namespace Models { export { - Account, - Identity, - AccountProperties, - CloudConnectors, - AccountEndpoints, - AccountPropertiesEndpoints, - ManagedResources, - AccountPropertiesManagedResources, - PrivateEndpointConnection, - PrivateEndpointConnectionProperties, - PrivateEndpoint, - PrivateLinkServiceConnectionState, - AccountSku, - SystemData, + AttributeMatcher, + MetadataPolicy, + MetadataPolicyProperties, + DecisionRule, + AttributeRule, + CollectionReference + } +} + +declare namespace Models_2 { + export { AccountSystemData, - ErrorResponseModel, - ErrorModel, - ErrorResponseModelError, + SystemData, DataPlaneAccountUpdateParameters, - AccessKeys, AccessKeyOptions, Collection, - CollectionReference, + CollectionReference_2 as CollectionReference, CollectionSystemData, - CollectionList, - CollectionNameResponseList, - CollectionNameResponse, - CollectionPathResponse, ResourceSetRuleConfig, AdvancedResourceSet, PathPatternExtractorConfig, @@ -818,25 +1021,7 @@ declare namespace Models { FastRegex, RegexReplacer, ScopedRule, - Rule, - ResourceSetRuleConfigList - } -} - -declare namespace Models_2 { - export { - MetadataRoleList, - MetadataRole, - MetadataRoleProperties, - AttributeMatcher, - ErrorResponseModel_2 as ErrorResponseModel, - ErrorModel_2 as ErrorModel, - MetadataPolicyList, - MetadataPolicy, - MetadataPolicyProperties, - DecisionRule, - AttributeRule, - CollectionReference_2 as CollectionReference + Rule } } @@ -862,33 +1047,122 @@ interface NormalizationRule { version?: number; } +// @public (undocumented) +interface NormalizationRuleOutput { + // (undocumented) + description?: string; + // (undocumented) + disabled?: boolean; + // (undocumented) + dynamicReplacement?: boolean; + // (undocumented) + entityTypes?: Array; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + name?: string; + // (undocumented) + regex?: FastRegexOutput; + // (undocumented) + replaceWith?: string; + // (undocumented) + version?: number; +} + +declare namespace OutputModels { + export { + MetadataRoleListOutput, + MetadataRoleOutput, + MetadataRolePropertiesOutput, + AttributeMatcherOutput, + ErrorResponseModelOutput, + ErrorModelOutput, + MetadataPolicyListOutput, + MetadataPolicyOutput, + MetadataPolicyPropertiesOutput, + DecisionRuleOutput, + AttributeRuleOutput, + CollectionReferenceOutput + } +} + +declare namespace OutputModels_2 { + export { + AccountOutput, + IdentityOutput, + AccountPropertiesOutput, + CloudConnectorsOutput, + AccountPropertiesEndpointsOutput, + AccountEndpointsOutput, + AccountPropertiesManagedResourcesOutput, + ManagedResourcesOutput, + PrivateEndpointConnectionOutput, + PrivateEndpointConnectionPropertiesOutput, + PrivateEndpointOutput, + PrivateLinkServiceConnectionStateOutput, + AccountSkuOutput, + AccountSystemDataOutput, + SystemDataOutput, + ErrorResponseModelOutput_2 as ErrorResponseModelOutput, + ErrorResponseModelErrorOutput, + ErrorModelOutput_2 as ErrorModelOutput, + AccessKeysOutput, + CollectionOutput, + CollectionReferenceOutput_2 as CollectionReferenceOutput, + CollectionSystemDataOutput, + CollectionListOutput, + CollectionNameResponseListOutput, + CollectionNameResponseOutput, + CollectionPathResponseOutput, + ResourceSetRuleConfigOutput, + AdvancedResourceSetOutput, + PathPatternExtractorConfigOutput, + FilterOutput, + ComplexReplacerConfigOutput, + NormalizationRuleOutput, + FastRegexOutput, + RegexReplacerOutput, + ScopedRuleOutput, + RuleOutput, + ResourceSetRuleConfigListOutput + } +} + // @public -function paginate(client: Client, initialResponse: TResponse, options?: PagingOptions): PagedAsyncIterableIterator>; +interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator; + next(): Promise>; +} // @public -function paginate_2(client: Client, initialResponse: TResponse, options?: PagingOptions_2): PagedAsyncIterableIterator>; +interface PagedAsyncIterableIterator_2 { + [Symbol.asyncIterator](): PagedAsyncIterableIterator_2; + byPage: (settings?: TPageSettings) => AsyncIterableIterator; + next(): Promise>; +} // @public -type PaginateReturn = TResult extends { - body: { - value?: infer TPage; - }; -} ? GetArrayType : Array; +interface PageSettings { + continuationToken?: string; +} // @public -type PaginateReturn_2 = TResult extends { - body: { - value?: infer TPage; - }; -} | { - body: { - values?: infer TPage; - }; -} ? GetArrayType_2 : Array; +interface PageSettings_2 { + continuationToken?: string; +} -declare namespace Pagination { +// @public +function paginate(client: Client, initialResponse: TResponse, options?: PagingOptions): PagedAsyncIterableIterator>; + +// @public +function paginate_2(client: Client, initialResponse: TResponse, options?: PagingOptions_2): PagedAsyncIterableIterator_2>; + +declare namespace PaginateHelper { export { paginate, + PageSettings, + PagedAsyncIterableIterator, GetArrayType, GetPage, PagingOptions, @@ -896,9 +1170,11 @@ declare namespace Pagination { } } -declare namespace Pagination_2 { +declare namespace PaginateHelper_2 { export { paginate_2 as paginate, + PageSettings_2 as PageSettings, + PagedAsyncIterableIterator_2 as PagedAsyncIterableIterator, GetArrayType_2 as GetArrayType, GetPage_2 as GetPage, PagingOptions_2 as PagingOptions, @@ -906,6 +1182,24 @@ declare namespace Pagination_2 { } } +// @public +type PaginateReturn = TResult extends { + body: { + value?: infer TPage; + }; +} | { + body: { + values?: infer TPage; + }; +} ? GetArrayType : Array; + +// @public +type PaginateReturn_2 = TResult extends { + body: { + value?: infer TPage; + }; +} ? GetArrayType_2 : Array; + // @public interface PagingOptions { customGetPage?: GetPage[]>; @@ -917,15 +1211,31 @@ interface PagingOptions_2 { } declare namespace Parameters_2 { + export { + MetadataRolesListParameters, + MetadataPolicyListAllQueryParamProperties, + MetadataPolicyListAllQueryParam, + MetadataPolicyListAllParameters, + MetadataPolicyUpdateBodyParam, + MetadataPolicyUpdateMediaTypesParam, + MetadataPolicyUpdateParameters, + MetadataPolicyGetParameters + } +} + +declare namespace Parameters_3 { export { AccountsGetAccountPropertiesParameters, AccountsUpdateAccountPropertiesBodyParam, + AccountsUpdateAccountPropertiesMediaTypesParam, AccountsUpdateAccountPropertiesParameters, AccountsGetAccessKeysParameters, AccountsRegenerateAccessKeyBodyParam, + AccountsRegenerateAccessKeyMediaTypesParam, AccountsRegenerateAccessKeyParameters, CollectionsGetCollectionParameters, CollectionsCreateOrUpdateCollectionBodyParam, + CollectionsCreateOrUpdateCollectionMediaTypesParam, CollectionsCreateOrUpdateCollectionParameters, CollectionsDeleteCollectionParameters, CollectionsListCollectionsQueryParamProperties, @@ -937,6 +1247,7 @@ declare namespace Parameters_2 { CollectionsGetCollectionPathParameters, ResourceSetRulesGetResourceSetRuleParameters, ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam, + ResourceSetRulesCreateOrUpdateResourceSetRuleMediaTypesParam, ResourceSetRulesCreateOrUpdateResourceSetRuleParameters, ResourceSetRulesDeleteResourceSetRuleParameters, ResourceSetRulesListResourceSetRulesQueryParamProperties, @@ -945,18 +1256,6 @@ declare namespace Parameters_2 { } } -declare namespace Parameters_3 { - export { - MetadataRolesListParameters, - MetadataPolicyListAllQueryParamProperties, - MetadataPolicyListAllQueryParam, - MetadataPolicyListAllParameters, - MetadataPolicyUpdateBodyParam, - MetadataPolicyUpdateParameters, - MetadataPolicyGetParameters - } -} - // @public (undocumented) interface PathPatternExtractorConfig { // (undocumented) @@ -984,27 +1283,53 @@ interface PathPatternExtractorConfig { } // @public (undocumented) -interface PrivateEndpoint { - id?: string; +interface PathPatternExtractorConfigOutput { + // (undocumented) + acceptedPatterns?: Array; + // (undocumented) + complexReplacers?: Array; + // (undocumented) + createdBy: string; + // (undocumented) + enableDefaultPatterns: boolean; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + modifiedBy?: string; + // (undocumented) + normalizationRules?: Array; + // (undocumented) + regexReplacers?: Array; + // (undocumented) + rejectedPatterns?: Array; + // (undocumented) + scopedRules?: Array; + // (undocumented) + version?: number; } -// @public (undocumented) -interface PrivateEndpointConnection { - id?: string; - name?: string; - properties?: PrivateEndpointConnectionProperties; - type?: string; +// @public +interface PrivateEndpointConnectionOutput { + readonly id?: string; + readonly name?: string; + properties?: PrivateEndpointConnectionPropertiesOutput; + readonly type?: string; } -// @public (undocumented) -interface PrivateEndpointConnectionProperties { - privateEndpoint?: PrivateEndpoint; - privateLinkServiceConnectionState?: PrivateLinkServiceConnectionState; - provisioningState?: string; +// @public +interface PrivateEndpointConnectionPropertiesOutput { + privateEndpoint?: PrivateEndpointOutput; + privateLinkServiceConnectionState?: PrivateLinkServiceConnectionStateOutput; + readonly provisioningState?: string; } -// @public (undocumented) -interface PrivateLinkServiceConnectionState { +// @public +interface PrivateEndpointOutput { + id?: string; +} + +// @public +interface PrivateLinkServiceConnectionStateOutput { actionsRequired?: string; description?: string; status?: "Unknown" | "Pending" | "Approved" | "Rejected" | "Disconnected"; @@ -1012,44 +1337,54 @@ interface PrivateLinkServiceConnectionState { declare namespace PurviewAccount { export { - Models, - Pagination, - Parameters_2 as Parameters, - Client_2 as Client, - Responses, - PurviewAccountClient + createClient_2 as createClient, + PurviewAccountClientOptions, + Parameters_3 as Parameters, + Responses_2 as Responses, + Client_3 as Client, + Models_2 as Models, + OutputModels_2 as OutputModels, + PaginateHelper_2 as PaginateHelper, + UnexpectedHelper_2 as UnexpectedHelper } } export { PurviewAccount } // @public (undocumented) -export function PurviewAccountClient(endpoint: string, credentials: TokenCredential, options?: ClientOptions): PurviewAccountRestClient; - -// @public (undocumented) -type PurviewAccountRestClient = Client & { - path: Routes; +type PurviewAccountClient = Client & { + path: Routes_2; }; +// @public +interface PurviewAccountClientOptions extends ClientOptions { + apiVersion?: string; +} + declare namespace PurviewMetadataPolicies { export { - PurviewMetadataPoliciesClient, - Models_2 as Models, - Pagination_2 as Pagination, - Parameters_3 as Parameters, - Client_3 as Client, - Responses_2 as Responses + createClient, + PurviewMetadataPoliciesClientOptions, + Parameters_2 as Parameters, + Responses, + Client_2 as Client, + Models, + OutputModels, + PaginateHelper, + UnexpectedHelper } } export { PurviewMetadataPolicies } // @public (undocumented) -export function PurviewMetadataPoliciesClient(Endpoint: string, credentials: TokenCredential, options?: ClientOptions): PurviewMetadataPoliciesRestClient; - -// @public (undocumented) -type PurviewMetadataPoliciesRestClient = Client & { - path: Routes_2; +type PurviewMetadataPoliciesClient = Client & { + path: Routes; }; +// @public +interface PurviewMetadataPoliciesClientOptions extends ClientOptions { + apiVersion?: string; +} + // @public (undocumented) interface RegexReplacer { // (undocumented) @@ -1077,23 +1412,55 @@ interface RegexReplacer { } // @public (undocumented) +interface RegexReplacerOutput { + // (undocumented) + condition?: string; + // (undocumented) + createdBy?: string; + // (undocumented) + description?: string; + // (undocumented) + disabled: boolean; + // (undocumented) + disableRecursiveReplacerApplication?: boolean; + // (undocumented) + doNotReplaceRegex?: FastRegexOutput; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + modifiedBy?: string; + // (undocumented) + name: string; + // (undocumented) + regex?: FastRegexOutput; + // (undocumented) + replaceWith?: string; +} + +// @public interface ResourceSetRuleConfig { advancedResourceSet?: AdvancedResourceSet; - name?: string; pathPatternConfig?: PathPatternExtractorConfig; } -// @public (undocumented) -interface ResourceSetRuleConfigList { +// @public +interface ResourceSetRuleConfigListOutput { count?: number; nextLink?: string; - value: Array; + value: Array; +} + +// @public +interface ResourceSetRuleConfigOutput { + advancedResourceSet?: AdvancedResourceSetOutput; + readonly name?: string; + pathPatternConfig?: PathPatternExtractorConfigOutput; } // @public interface ResourceSetRulesCreateOrUpdateResourceSetRule200Response extends HttpResponse { // (undocumented) - body: ResourceSetRuleConfig; + body: ResourceSetRuleConfigOutput; // (undocumented) status: "200"; } @@ -1105,38 +1472,39 @@ interface ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam { } // @public -interface ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse extends HttpResponse { +interface ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; +} + +// @public (undocumented) +interface ResourceSetRulesCreateOrUpdateResourceSetRuleMediaTypesParam { + contentType?: "application/json"; } // @public (undocumented) -type ResourceSetRulesCreateOrUpdateResourceSetRuleParameters = ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam & RequestParameters; +type ResourceSetRulesCreateOrUpdateResourceSetRuleParameters = ResourceSetRulesCreateOrUpdateResourceSetRuleMediaTypesParam & ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam & RequestParameters; // @public interface ResourceSetRulesDeleteResourceSetRule200Response extends HttpResponse { - // (undocumented) - body: Record; // (undocumented) status: "200"; } // @public interface ResourceSetRulesDeleteResourceSetRule204Response extends HttpResponse { - // (undocumented) - body: Record; // (undocumented) status: "204"; } // @public -interface ResourceSetRulesDeleteResourceSetRuledefaultResponse extends HttpResponse { +interface ResourceSetRulesDeleteResourceSetRuleDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -1144,25 +1512,25 @@ type ResourceSetRulesDeleteResourceSetRuleParameters = RequestParameters; // @public (undocumented) interface ResourceSetRulesGetResourceSetRule { - delete(options?: ResourceSetRulesDeleteResourceSetRuleParameters): Promise; - get(options?: ResourceSetRulesGetResourceSetRuleParameters): Promise; - put(options: ResourceSetRulesCreateOrUpdateResourceSetRuleParameters): Promise; + delete(options?: ResourceSetRulesDeleteResourceSetRuleParameters): StreamableMethod; + get(options?: ResourceSetRulesGetResourceSetRuleParameters): StreamableMethod; + put(options: ResourceSetRulesCreateOrUpdateResourceSetRuleParameters): StreamableMethod; } // @public interface ResourceSetRulesGetResourceSetRule200Response extends HttpResponse { // (undocumented) - body: ResourceSetRuleConfig; + body: ResourceSetRuleConfigOutput; // (undocumented) status: "200"; } // @public -interface ResourceSetRulesGetResourceSetRuledefaultResponse extends HttpResponse { +interface ResourceSetRulesGetResourceSetRuleDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -1170,23 +1538,23 @@ type ResourceSetRulesGetResourceSetRuleParameters = RequestParameters; // @public (undocumented) interface ResourceSetRulesListResourceSetRules { - get(options?: ResourceSetRulesListResourceSetRulesParameters): Promise; + get(options?: ResourceSetRulesListResourceSetRulesParameters): StreamableMethod; } // @public interface ResourceSetRulesListResourceSetRules200Response extends HttpResponse { // (undocumented) - body: ResourceSetRuleConfigList; + body: ResourceSetRuleConfigListOutput; // (undocumented) status: "200"; } // @public -interface ResourceSetRulesListResourceSetRulesdefaultResponse extends HttpResponse { +interface ResourceSetRulesListResourceSetRulesDefaultResponse extends HttpResponse { // (undocumented) - body: ErrorResponseModel; + body: ErrorResponseModelOutput_2; // (undocumented) - status: "500"; + status: string; } // @public (undocumented) @@ -1205,58 +1573,65 @@ interface ResourceSetRulesListResourceSetRulesQueryParamProperties { } declare namespace Responses { + export { + MetadataRolesList200Response, + MetadataRolesListDefaultHeaders, + MetadataRolesListDefaultResponse, + MetadataPolicyListAll200Response, + MetadataPolicyListAllDefaultHeaders, + MetadataPolicyListAllDefaultResponse, + MetadataPolicyUpdate200Response, + MetadataPolicyUpdateDefaultHeaders, + MetadataPolicyUpdateDefaultResponse, + MetadataPolicyGet200Response, + MetadataPolicyGetDefaultHeaders, + MetadataPolicyGetDefaultResponse + } +} + +declare namespace Responses_2 { export { AccountsGetAccountProperties200Response, - AccountsGetAccountPropertiesdefaultResponse, + AccountsGetAccountPropertiesDefaultResponse, AccountsUpdateAccountProperties200Response, - AccountsUpdateAccountPropertiesdefaultResponse, + AccountsUpdateAccountPropertiesDefaultResponse, AccountsGetAccessKeys200Response, - AccountsGetAccessKeysdefaultResponse, + AccountsGetAccessKeysDefaultResponse, AccountsRegenerateAccessKey200Response, - AccountsRegenerateAccessKeydefaultResponse, + AccountsRegenerateAccessKeyDefaultResponse, CollectionsGetCollection200Response, - CollectionsGetCollectiondefaultResponse, + CollectionsGetCollectionDefaultResponse, CollectionsCreateOrUpdateCollection200Response, - CollectionsCreateOrUpdateCollectiondefaultResponse, + CollectionsCreateOrUpdateCollectionDefaultResponse, CollectionsDeleteCollection204Response, - CollectionsDeleteCollectiondefaultResponse, + CollectionsDeleteCollectionDefaultResponse, CollectionsListCollections200Response, - CollectionsListCollectionsdefaultResponse, + CollectionsListCollectionsDefaultResponse, CollectionsListChildCollectionNames200Response, - CollectionsListChildCollectionNamesdefaultResponse, + CollectionsListChildCollectionNamesDefaultResponse, CollectionsGetCollectionPath200Response, - CollectionsGetCollectionPathdefaultResponse, + CollectionsGetCollectionPathDefaultResponse, ResourceSetRulesGetResourceSetRule200Response, - ResourceSetRulesGetResourceSetRuledefaultResponse, + ResourceSetRulesGetResourceSetRuleDefaultResponse, ResourceSetRulesCreateOrUpdateResourceSetRule200Response, - ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse, + ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse, ResourceSetRulesDeleteResourceSetRule200Response, ResourceSetRulesDeleteResourceSetRule204Response, - ResourceSetRulesDeleteResourceSetRuledefaultResponse, + ResourceSetRulesDeleteResourceSetRuleDefaultResponse, ResourceSetRulesListResourceSetRules200Response, - ResourceSetRulesListResourceSetRulesdefaultResponse + ResourceSetRulesListResourceSetRulesDefaultResponse } } -declare namespace Responses_2 { - export { - MetadataRolesList200Response, - MetadataRolesListdefaultHeaders, - MetadataRolesListdefaultResponse, - MetadataPolicyListAll200Response, - MetadataPolicyListAlldefaultHeaders, - MetadataPolicyListAlldefaultResponse, - MetadataPolicyUpdate200Response, - MetadataPolicyUpdatedefaultHeaders, - MetadataPolicyUpdatedefaultResponse, - MetadataPolicyGet200Response, - MetadataPolicyGetdefaultHeaders, - MetadataPolicyGetdefaultResponse - } +// @public (undocumented) +interface Routes { + (path: "/metadataRoles"): MetadataRolesList; + (path: "/metadataPolicies"): MetadataPolicyListAll; + (path: "/metadataPolicies/{policyId}", policyId: string): MetadataPolicyUpdate; } // @public (undocumented) -interface Routes { +interface Routes_2 { (path: "/"): AccountsGetAccountProperties; (path: "/listkeys"): AccountsGetAccessKeys; (path: "/regeneratekeys"): AccountsRegenerateAccessKey; @@ -1269,14 +1644,21 @@ interface Routes { } // @public (undocumented) -interface Routes_2 { - (path: "/metadataRoles"): MetadataRolesList; - (path: "/metadataPolicies"): MetadataPolicyListAll; - (path: "/metadataPolicies/{policyId}", policyId: string): MetadataPolicyUpdate; +interface Rule { + // (undocumented) + displayName?: string; + // (undocumented) + isResourceSet?: boolean; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + name?: string; + // (undocumented) + qualifiedName: string; } // @public (undocumented) -interface Rule { +interface RuleOutput { // (undocumented) displayName?: string; // (undocumented) @@ -1300,13 +1682,39 @@ interface ScopedRule { } // @public (undocumented) +interface ScopedRuleOutput { + // (undocumented) + bindingUrl: string; + // (undocumented) + rules?: Array; + // (undocumented) + storeType: string; +} + +// @public interface SystemData { - createdAt?: Date; - createdBy?: string; - createdByType?: "User" | "Application" | "ManagedIdentity" | "Key"; - lastModifiedAt?: Date; - lastModifiedBy?: string; - lastModifiedByType?: "User" | "Application" | "ManagedIdentity" | "Key"; +} + +// @public +interface SystemDataOutput { + readonly createdAt?: string; + readonly createdBy?: string; + readonly createdByType?: "User" | "Application" | "ManagedIdentity" | "Key"; + readonly lastModifiedAt?: string; + readonly lastModifiedBy?: string; + readonly lastModifiedByType?: "User" | "Application" | "ManagedIdentity" | "Key"; +} + +declare namespace UnexpectedHelper { + export { + isUnexpected + } +} + +declare namespace UnexpectedHelper_2 { + export { + isUnexpected_2 as isUnexpected + } } // (No @packageDocumentation comment for this package) diff --git a/sdk/purview/purview-administration-rest/samples-dev/accountCollections.ts b/sdk/purview/purview-administration-rest/samples-dev/accountCollections.ts index e72124c09bbd..181f0bbfe56e 100644 --- a/sdk/purview/purview-administration-rest/samples-dev/accountCollections.ts +++ b/sdk/purview/purview-administration-rest/samples-dev/accountCollections.ts @@ -8,7 +8,7 @@ * @azsdk-weight 40 */ -import { PurviewAccount, PurviewAccountClient } from "@azure-rest/purview-administration"; +import { PurviewAccount } from "@azure-rest/purview-administration"; import { DefaultAzureCredential } from "@azure/identity"; import dotenv from "dotenv"; @@ -18,7 +18,7 @@ const endpoint = process.env["ENDPOINT"] || ""; async function main() { console.log("== List collections sample =="); - const client = PurviewAccountClient(endpoint, new DefaultAzureCredential()); + const client = PurviewAccount.createClient(endpoint, new DefaultAzureCredential()); const response = await client.path("/collections").get(); @@ -26,7 +26,7 @@ async function main() { console.log(`GET "/collections" failed with ${response.status}`); } - const dataSources = PurviewAccount.Pagination.paginate(client, response); + const dataSources = PurviewAccount.PaginateHelper.paginate(client, response); for await (const dataSource of dataSources) { console.log(dataSource); diff --git a/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts b/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts index a1c2f48fb9b2..13bf71f163a9 100644 --- a/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts +++ b/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts @@ -9,8 +9,7 @@ */ import { - PurviewMetadataPolicies, - PurviewMetadataPoliciesClient, + PurviewMetadataPolicies } from "@azure-rest/purview-administration"; import { DefaultAzureCredential } from "@azure/identity"; import dotenv from "dotenv"; @@ -21,7 +20,7 @@ const endpoint = process.env["ENDPOINT"] || ""; async function main() { console.log("== List metadata policies sample =="); - const client = PurviewMetadataPoliciesClient(endpoint, new DefaultAzureCredential()); + const client = PurviewMetadataPolicies.createClient(endpoint, new DefaultAzureCredential()); const response = await client.path("/metadataPolicies").get(); @@ -31,10 +30,14 @@ async function main() { throw new Error(error); } - const policies = PurviewMetadataPolicies.Pagination.paginate(client, response); + const policies = PurviewMetadataPolicies.PaginateHelper.paginate(client, response); for await (const policy of policies) { - console.log(policy.name); + if (Array.isArray(policy)) { + console.error('Unexpected array:', policy); + } else { + console.log(policy.name); + } } } diff --git a/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts b/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts index eacbced12f7e..f4b586742a66 100644 --- a/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts +++ b/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts @@ -1,65 +1,69 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Client } from "@azure-rest/core-client"; import { - AccountsGetAccessKeysParameters, AccountsGetAccountPropertiesParameters, - AccountsRegenerateAccessKeyParameters, AccountsUpdateAccountPropertiesParameters, + AccountsGetAccessKeysParameters, + AccountsRegenerateAccessKeyParameters, + CollectionsGetCollectionParameters, CollectionsCreateOrUpdateCollectionParameters, CollectionsDeleteCollectionParameters, - CollectionsGetCollectionParameters, - CollectionsGetCollectionPathParameters, - CollectionsListChildCollectionNamesParameters, CollectionsListCollectionsParameters, + CollectionsListChildCollectionNamesParameters, + CollectionsGetCollectionPathParameters, + ResourceSetRulesGetResourceSetRuleParameters, ResourceSetRulesCreateOrUpdateResourceSetRuleParameters, ResourceSetRulesDeleteResourceSetRuleParameters, - ResourceSetRulesGetResourceSetRuleParameters, ResourceSetRulesListResourceSetRulesParameters, } from "./parameters"; import { - AccountsGetAccessKeys200Response, - AccountsGetAccessKeysdefaultResponse, AccountsGetAccountProperties200Response, - AccountsGetAccountPropertiesdefaultResponse, - AccountsRegenerateAccessKey200Response, - AccountsRegenerateAccessKeydefaultResponse, + AccountsGetAccountPropertiesDefaultResponse, AccountsUpdateAccountProperties200Response, - AccountsUpdateAccountPropertiesdefaultResponse, + AccountsUpdateAccountPropertiesDefaultResponse, + AccountsGetAccessKeys200Response, + AccountsGetAccessKeysDefaultResponse, + AccountsRegenerateAccessKey200Response, + AccountsRegenerateAccessKeyDefaultResponse, + CollectionsGetCollection200Response, + CollectionsGetCollectionDefaultResponse, CollectionsCreateOrUpdateCollection200Response, - CollectionsCreateOrUpdateCollectiondefaultResponse, + CollectionsCreateOrUpdateCollectionDefaultResponse, CollectionsDeleteCollection204Response, - CollectionsDeleteCollectiondefaultResponse, - CollectionsGetCollection200Response, - CollectionsGetCollectiondefaultResponse, - CollectionsGetCollectionPath200Response, - CollectionsGetCollectionPathdefaultResponse, - CollectionsListChildCollectionNames200Response, - CollectionsListChildCollectionNamesdefaultResponse, + CollectionsDeleteCollectionDefaultResponse, CollectionsListCollections200Response, - CollectionsListCollectionsdefaultResponse, + CollectionsListCollectionsDefaultResponse, + CollectionsListChildCollectionNames200Response, + CollectionsListChildCollectionNamesDefaultResponse, + CollectionsGetCollectionPath200Response, + CollectionsGetCollectionPathDefaultResponse, + ResourceSetRulesGetResourceSetRule200Response, + ResourceSetRulesGetResourceSetRuleDefaultResponse, ResourceSetRulesCreateOrUpdateResourceSetRule200Response, - ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse, + ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse, ResourceSetRulesDeleteResourceSetRule200Response, ResourceSetRulesDeleteResourceSetRule204Response, - ResourceSetRulesDeleteResourceSetRuledefaultResponse, - ResourceSetRulesGetResourceSetRule200Response, - ResourceSetRulesGetResourceSetRuledefaultResponse, + ResourceSetRulesDeleteResourceSetRuleDefaultResponse, ResourceSetRulesListResourceSetRules200Response, - ResourceSetRulesListResourceSetRulesdefaultResponse, + ResourceSetRulesListResourceSetRulesDefaultResponse, } from "./responses"; +import { Client, StreamableMethod } from "@azure-rest/core-client"; export interface AccountsGetAccountProperties { /** Get an account */ get( options?: AccountsGetAccountPropertiesParameters, - ): Promise; + ): StreamableMethod< + | AccountsGetAccountProperties200Response + | AccountsGetAccountPropertiesDefaultResponse + >; /** Updates an account */ patch( options: AccountsUpdateAccountPropertiesParameters, - ): Promise< - AccountsUpdateAccountProperties200Response | AccountsUpdateAccountPropertiesdefaultResponse + ): StreamableMethod< + | AccountsUpdateAccountProperties200Response + | AccountsUpdateAccountPropertiesDefaultResponse >; } @@ -67,48 +71,62 @@ export interface AccountsGetAccessKeys { /** List the authorization keys associated with this account. */ post( options?: AccountsGetAccessKeysParameters, - ): Promise; + ): StreamableMethod< + AccountsGetAccessKeys200Response | AccountsGetAccessKeysDefaultResponse + >; } export interface AccountsRegenerateAccessKey { /** Regenerate the authorization keys associated with this data catalog. */ post( options: AccountsRegenerateAccessKeyParameters, - ): Promise; + ): StreamableMethod< + | AccountsRegenerateAccessKey200Response + | AccountsRegenerateAccessKeyDefaultResponse + >; } export interface CollectionsGetCollection { /** Get a collection */ get( options?: CollectionsGetCollectionParameters, - ): Promise; + ): StreamableMethod< + | CollectionsGetCollection200Response + | CollectionsGetCollectionDefaultResponse + >; /** Creates or updates a collection entity. */ put( options: CollectionsCreateOrUpdateCollectionParameters, - ): Promise< + ): StreamableMethod< | CollectionsCreateOrUpdateCollection200Response - | CollectionsCreateOrUpdateCollectiondefaultResponse + | CollectionsCreateOrUpdateCollectionDefaultResponse >; /** Deletes a Collection entity. */ delete( options?: CollectionsDeleteCollectionParameters, - ): Promise; + ): StreamableMethod< + | CollectionsDeleteCollection204Response + | CollectionsDeleteCollectionDefaultResponse + >; } export interface CollectionsListCollections { /** List the collections in the account. */ get( options?: CollectionsListCollectionsParameters, - ): Promise; + ): StreamableMethod< + | CollectionsListCollections200Response + | CollectionsListCollectionsDefaultResponse + >; } export interface CollectionsListChildCollectionNames { /** Lists the child collections names in the collection. */ get( options?: CollectionsListChildCollectionNamesParameters, - ): Promise< + ): StreamableMethod< | CollectionsListChildCollectionNames200Response - | CollectionsListChildCollectionNamesdefaultResponse + | CollectionsListChildCollectionNamesDefaultResponse >; } @@ -116,31 +134,34 @@ export interface CollectionsGetCollectionPath { /** Gets the parent name and parent friendly name chains that represent the collection path. */ get( options?: CollectionsGetCollectionPathParameters, - ): Promise; + ): StreamableMethod< + | CollectionsGetCollectionPath200Response + | CollectionsGetCollectionPathDefaultResponse + >; } export interface ResourceSetRulesGetResourceSetRule { /** Get a resource set config service model. */ get( options?: ResourceSetRulesGetResourceSetRuleParameters, - ): Promise< + ): StreamableMethod< | ResourceSetRulesGetResourceSetRule200Response - | ResourceSetRulesGetResourceSetRuledefaultResponse + | ResourceSetRulesGetResourceSetRuleDefaultResponse >; /** Creates or updates an resource set config. */ put( options: ResourceSetRulesCreateOrUpdateResourceSetRuleParameters, - ): Promise< + ): StreamableMethod< | ResourceSetRulesCreateOrUpdateResourceSetRule200Response - | ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse + | ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse >; /** Deletes a ResourceSetRuleConfig resource. */ delete( options?: ResourceSetRulesDeleteResourceSetRuleParameters, - ): Promise< + ): StreamableMethod< | ResourceSetRulesDeleteResourceSetRule200Response | ResourceSetRulesDeleteResourceSetRule204Response - | ResourceSetRulesDeleteResourceSetRuledefaultResponse + | ResourceSetRulesDeleteResourceSetRuleDefaultResponse >; } @@ -148,9 +169,9 @@ export interface ResourceSetRulesListResourceSetRules { /** Get a resource set config service model. */ get( options?: ResourceSetRulesListResourceSetRulesParameters, - ): Promise< + ): StreamableMethod< | ResourceSetRulesListResourceSetRules200Response - | ResourceSetRulesListResourceSetRulesdefaultResponse + | ResourceSetRulesListResourceSetRulesDefaultResponse >; } @@ -162,7 +183,10 @@ export interface Routes { /** Resource for '/regeneratekeys' has methods for the following verbs: post */ (path: "/regeneratekeys"): AccountsRegenerateAccessKey; /** Resource for '/collections/\{collectionName\}' has methods for the following verbs: get, put, delete */ - (path: "/collections/{collectionName}", collectionName: string): CollectionsGetCollection; + ( + path: "/collections/{collectionName}", + collectionName: string, + ): CollectionsGetCollection; /** Resource for '/collections' has methods for the following verbs: get */ (path: "/collections"): CollectionsListCollections; /** Resource for '/collections/\{collectionName\}/getChildCollectionNames' has methods for the following verbs: get */ @@ -183,6 +207,6 @@ export interface Routes { (path: "/resourceSetRuleConfigs"): ResourceSetRulesListResourceSetRules; } -export type PurviewAccountRestClient = Client & { +export type PurviewAccountClient = Client & { path: Routes; }; diff --git a/sdk/purview/purview-administration-rest/src/account/index.ts b/sdk/purview/purview-administration-rest/src/account/index.ts index 0c293f4263d8..2d57ad2deade 100644 --- a/sdk/purview/purview-administration-rest/src/account/index.ts +++ b/sdk/purview/purview-administration-rest/src/account/index.ts @@ -1,10 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import * as Models from "./models"; -import * as Pagination from "./paginateHelper"; import * as Parameters from "./parameters"; -import * as Client from "./clientDefinitions"; import * as Responses from "./responses"; -export { Models, Pagination, Parameters, Client, Responses }; -export { PurviewAccountClient } from "./purviewAccount"; +import * as Client from "./clientDefinitions"; +import * as Models from "./models"; +import * as OutputModels from "./outputModels"; +import * as PaginateHelper from "./paginateHelper"; +import * as UnexpectedHelper from "./isUnexpected"; + +export { createClient, PurviewAccountClientOptions } from "./purviewAccount"; +export { + Parameters, + Responses, + Client, + Models, + OutputModels, + PaginateHelper, + UnexpectedHelper, +}; diff --git a/sdk/purview/purview-administration-rest/src/account/isUnexpected.ts b/sdk/purview/purview-administration-rest/src/account/isUnexpected.ts new file mode 100644 index 000000000000..086e2d5dcf63 --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/isUnexpected.ts @@ -0,0 +1,251 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + AccountsGetAccountProperties200Response, + AccountsGetAccountPropertiesDefaultResponse, + AccountsUpdateAccountProperties200Response, + AccountsUpdateAccountPropertiesDefaultResponse, + AccountsGetAccessKeys200Response, + AccountsGetAccessKeysDefaultResponse, + AccountsRegenerateAccessKey200Response, + AccountsRegenerateAccessKeyDefaultResponse, + CollectionsGetCollection200Response, + CollectionsGetCollectionDefaultResponse, + CollectionsCreateOrUpdateCollection200Response, + CollectionsCreateOrUpdateCollectionDefaultResponse, + CollectionsDeleteCollection204Response, + CollectionsDeleteCollectionDefaultResponse, + CollectionsListCollections200Response, + CollectionsListCollectionsDefaultResponse, + CollectionsListChildCollectionNames200Response, + CollectionsListChildCollectionNamesDefaultResponse, + CollectionsGetCollectionPath200Response, + CollectionsGetCollectionPathDefaultResponse, + ResourceSetRulesGetResourceSetRule200Response, + ResourceSetRulesGetResourceSetRuleDefaultResponse, + ResourceSetRulesCreateOrUpdateResourceSetRule200Response, + ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse, + ResourceSetRulesDeleteResourceSetRule200Response, + ResourceSetRulesDeleteResourceSetRule204Response, + ResourceSetRulesDeleteResourceSetRuleDefaultResponse, + ResourceSetRulesListResourceSetRules200Response, + ResourceSetRulesListResourceSetRulesDefaultResponse, +} from "./responses"; + +const responseMap: Record = { + "GET /": ["200"], + "PATCH /": ["200"], + "POST /listkeys": ["200"], + "POST /regeneratekeys": ["200"], + "GET /collections/{collectionName}": ["200"], + "PUT /collections/{collectionName}": ["200"], + "DELETE /collections/{collectionName}": ["204"], + "GET /collections": ["200"], + "GET /collections/{collectionName}/getChildCollectionNames": ["200"], + "GET /collections/{collectionName}/getCollectionPath": ["200"], + "GET /resourceSetRuleConfigs/defaultResourceSetRuleConfig": ["200"], + "PUT /resourceSetRuleConfigs/defaultResourceSetRuleConfig": ["200"], + "DELETE /resourceSetRuleConfigs/defaultResourceSetRuleConfig": ["200", "204"], + "GET /resourceSetRuleConfigs": ["200"], +}; + +export function isUnexpected( + response: + | AccountsGetAccountProperties200Response + | AccountsGetAccountPropertiesDefaultResponse, +): response is AccountsGetAccountPropertiesDefaultResponse; +export function isUnexpected( + response: + | AccountsUpdateAccountProperties200Response + | AccountsUpdateAccountPropertiesDefaultResponse, +): response is AccountsUpdateAccountPropertiesDefaultResponse; +export function isUnexpected( + response: + | AccountsGetAccessKeys200Response + | AccountsGetAccessKeysDefaultResponse, +): response is AccountsGetAccessKeysDefaultResponse; +export function isUnexpected( + response: + | AccountsRegenerateAccessKey200Response + | AccountsRegenerateAccessKeyDefaultResponse, +): response is AccountsRegenerateAccessKeyDefaultResponse; +export function isUnexpected( + response: + | CollectionsGetCollection200Response + | CollectionsGetCollectionDefaultResponse, +): response is CollectionsGetCollectionDefaultResponse; +export function isUnexpected( + response: + | CollectionsCreateOrUpdateCollection200Response + | CollectionsCreateOrUpdateCollectionDefaultResponse, +): response is CollectionsCreateOrUpdateCollectionDefaultResponse; +export function isUnexpected( + response: + | CollectionsDeleteCollection204Response + | CollectionsDeleteCollectionDefaultResponse, +): response is CollectionsDeleteCollectionDefaultResponse; +export function isUnexpected( + response: + | CollectionsListCollections200Response + | CollectionsListCollectionsDefaultResponse, +): response is CollectionsListCollectionsDefaultResponse; +export function isUnexpected( + response: + | CollectionsListChildCollectionNames200Response + | CollectionsListChildCollectionNamesDefaultResponse, +): response is CollectionsListChildCollectionNamesDefaultResponse; +export function isUnexpected( + response: + | CollectionsGetCollectionPath200Response + | CollectionsGetCollectionPathDefaultResponse, +): response is CollectionsGetCollectionPathDefaultResponse; +export function isUnexpected( + response: + | ResourceSetRulesGetResourceSetRule200Response + | ResourceSetRulesGetResourceSetRuleDefaultResponse, +): response is ResourceSetRulesGetResourceSetRuleDefaultResponse; +export function isUnexpected( + response: + | ResourceSetRulesCreateOrUpdateResourceSetRule200Response + | ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse, +): response is ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse; +export function isUnexpected( + response: + | ResourceSetRulesDeleteResourceSetRule200Response + | ResourceSetRulesDeleteResourceSetRule204Response + | ResourceSetRulesDeleteResourceSetRuleDefaultResponse, +): response is ResourceSetRulesDeleteResourceSetRuleDefaultResponse; +export function isUnexpected( + response: + | ResourceSetRulesListResourceSetRules200Response + | ResourceSetRulesListResourceSetRulesDefaultResponse, +): response is ResourceSetRulesListResourceSetRulesDefaultResponse; +export function isUnexpected( + response: + | AccountsGetAccountProperties200Response + | AccountsGetAccountPropertiesDefaultResponse + | AccountsUpdateAccountProperties200Response + | AccountsUpdateAccountPropertiesDefaultResponse + | AccountsGetAccessKeys200Response + | AccountsGetAccessKeysDefaultResponse + | AccountsRegenerateAccessKey200Response + | AccountsRegenerateAccessKeyDefaultResponse + | CollectionsGetCollection200Response + | CollectionsGetCollectionDefaultResponse + | CollectionsCreateOrUpdateCollection200Response + | CollectionsCreateOrUpdateCollectionDefaultResponse + | CollectionsDeleteCollection204Response + | CollectionsDeleteCollectionDefaultResponse + | CollectionsListCollections200Response + | CollectionsListCollectionsDefaultResponse + | CollectionsListChildCollectionNames200Response + | CollectionsListChildCollectionNamesDefaultResponse + | CollectionsGetCollectionPath200Response + | CollectionsGetCollectionPathDefaultResponse + | ResourceSetRulesGetResourceSetRule200Response + | ResourceSetRulesGetResourceSetRuleDefaultResponse + | ResourceSetRulesCreateOrUpdateResourceSetRule200Response + | ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse + | ResourceSetRulesDeleteResourceSetRule200Response + | ResourceSetRulesDeleteResourceSetRule204Response + | ResourceSetRulesDeleteResourceSetRuleDefaultResponse + | ResourceSetRulesListResourceSetRules200Response + | ResourceSetRulesListResourceSetRulesDefaultResponse, +): response is + | AccountsGetAccountPropertiesDefaultResponse + | AccountsUpdateAccountPropertiesDefaultResponse + | AccountsGetAccessKeysDefaultResponse + | AccountsRegenerateAccessKeyDefaultResponse + | CollectionsGetCollectionDefaultResponse + | CollectionsCreateOrUpdateCollectionDefaultResponse + | CollectionsDeleteCollectionDefaultResponse + | CollectionsListCollectionsDefaultResponse + | CollectionsListChildCollectionNamesDefaultResponse + | CollectionsGetCollectionPathDefaultResponse + | ResourceSetRulesGetResourceSetRuleDefaultResponse + | ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse + | ResourceSetRulesDeleteResourceSetRuleDefaultResponse + | ResourceSetRulesListResourceSetRulesDefaultResponse { + const lroOriginal = response.headers["x-ms-original-url"]; + const url = new URL(lroOriginal ?? response.request.url); + const method = response.request.method; + let pathDetails = responseMap[`${method} ${url.pathname}`]; + if (!pathDetails) { + pathDetails = getParametrizedPathSuccess(method, url.pathname); + } + return !pathDetails.includes(response.status); +} + +function getParametrizedPathSuccess(method: string, path: string): string[] { + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: string[] = []; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(responseMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}`, + ).test(pathParts[j] || ""); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/purview/purview-administration-rest/src/account/models.ts b/sdk/purview/purview-administration-rest/src/account/models.ts index 0d2d608408ae..224f07079e77 100644 --- a/sdk/purview/purview-administration-rest/src/account/models.ts +++ b/sdk/purview/purview-administration-rest/src/account/models.ts @@ -1,217 +1,35 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export interface Account { - /** Gets or sets the identifier. */ - id?: string; - /** Identity Info on the tracked resource */ - identity?: Identity; - /** Gets or sets the location. */ - location?: string; - /** Gets or sets the name. */ - name?: string; - /** Gets or sets the properties. */ - properties?: AccountProperties; - /** Gets or sets the Sku. */ - sku?: AccountSku; - /** Metadata pertaining to creation and last modification of the resource. */ - systemData?: AccountSystemData; - /** Tags on the azure resource. */ - tags?: Record; - /** Gets or sets the type. */ - type?: string; -} - -export interface Identity { - /** Service principal object Id */ - principalId?: string; - /** Tenant Id */ - tenantId?: string; - /** Identity Type */ - type?: "SystemAssigned"; -} - -export interface AccountProperties { - /** - * Cloud connectors. - * External cloud identifier used as part of scanning configuration. - */ - cloudConnectors?: CloudConnectors; - /** Gets the time at which the entity was created. */ - createdAt?: Date; - /** Gets the creator of the entity. */ - createdBy?: string; - /** Gets the creators of the entity's object id. */ - createdByObjectId?: string; - /** The URIs that are the public endpoints of the account. */ - endpoints?: AccountPropertiesEndpoints; - /** Gets or sets the friendly name. */ - friendlyName?: string; - /** Gets or sets the managed resource group name */ - managedResourceGroupName?: string; - /** Gets the resource identifiers of the managed resources. */ - managedResources?: AccountPropertiesManagedResources; - /** Gets the private endpoint connections information. */ - privateEndpointConnections?: Array; - /** Gets or sets the state of the provisioning. */ - provisioningState?: - | "Unknown" - | "Creating" - | "Moving" - | "Deleting" - | "SoftDeleting" - | "SoftDeleted" - | "Failed" - | "Succeeded" - | "Canceled"; - /** Gets or sets the public network access. */ - publicNetworkAccess?: "NotSpecified" | "Enabled" | "Disabled"; -} - -export interface CloudConnectors { - /** - * AWS external identifier. - * Configured in AWS to allow use of the role arn used for scanning - */ - awsExternalId?: string; -} - -export interface AccountEndpoints { - /** Gets the catalog endpoint. */ - catalog?: string; - /** Gets the guardian endpoint. */ - guardian?: string; - /** Gets the scan endpoint. */ - scan?: string; -} - -export interface AccountPropertiesEndpoints extends AccountEndpoints {} - -export interface ManagedResources { - /** Gets the managed event hub namespace resource identifier. */ - eventHubNamespace?: string; - /** Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. */ - resourceGroup?: string; - /** Gets the managed storage account resource identifier. */ - storageAccount?: string; -} - -export interface AccountPropertiesManagedResources extends ManagedResources {} - -export interface PrivateEndpointConnection { - /** Gets or sets the identifier. */ - id?: string; - /** Gets or sets the name. */ - name?: string; - /** The connection identifier. */ - properties?: PrivateEndpointConnectionProperties; - /** Gets or sets the type. */ - type?: string; -} - -export interface PrivateEndpointConnectionProperties { - /** The private endpoint information. */ - privateEndpoint?: PrivateEndpoint; - /** The private link service connection state. */ - privateLinkServiceConnectionState?: PrivateLinkServiceConnectionState; - /** The provisioning state. */ - provisioningState?: string; -} - -export interface PrivateEndpoint { - /** The private endpoint identifier. */ - id?: string; -} - -export interface PrivateLinkServiceConnectionState { - /** The required actions. */ - actionsRequired?: string; - /** The description. */ - description?: string; - /** The status. */ - status?: "Unknown" | "Pending" | "Approved" | "Rejected" | "Disconnected"; -} - -export interface AccountSku { - /** Gets or sets the sku capacity. Possible values include: 4, 16 */ - capacity?: number; - /** Gets or sets the sku name. */ - name?: "Standard"; -} - -export interface SystemData { - /** The timestamp of resource creation (UTC). */ - createdAt?: Date; - /** The identity that created the resource. */ - createdBy?: string; - /** The type of identity that created the resource. */ - createdByType?: "User" | "Application" | "ManagedIdentity" | "Key"; - /** The timestamp of the last modification the resource (UTC). */ - lastModifiedAt?: Date; - /** The identity that last modified the resource. */ - lastModifiedBy?: string; - /** The type of identity that last modified the resource. */ - lastModifiedByType?: "User" | "Application" | "ManagedIdentity" | "Key"; -} - +/** Metadata pertaining to creation and last modification of the resource. */ export interface AccountSystemData extends SystemData {} -export interface ErrorResponseModel { - /** Gets or sets the error. */ - error?: ErrorResponseModelError; -} - -export interface ErrorModel { - /** Gets or sets the code. */ - code?: string; - /** Gets or sets the details. */ - details?: Array; - /** Gets or sets the messages. */ - message?: string; - /** Gets or sets the target. */ - target?: string; -} - -export interface ErrorResponseModelError extends ErrorModel {} +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData {} +/** The account properties that can be updated through data plane. */ export interface DataPlaneAccountUpdateParameters { /** The friendly name for the azure resource. */ friendlyName?: string; } -export interface AccessKeys { - /** Gets or sets the primary connection string. */ - atlasKafkaPrimaryEndpoint?: string; - /** Gets or sets the secondary connection string. */ - atlasKafkaSecondaryEndpoint?: string; -} - +/** A access key options used for regeneration. */ export interface AccessKeyOptions { /** The access key type. */ keyType?: "PrimaryAtlasKafkaKey" | "SecondaryAtlasKafkaKey"; } +/** Collection resource. */ export interface Collection { - /** Gets the state of the provisioning. */ - collectionProvisioningState?: - | "Unknown" - | "Creating" - | "Moving" - | "Deleting" - | "Failed" - | "Succeeded"; /** Gets or sets the description. */ description?: string; /** Gets or sets the friendly name of the collection. */ friendlyName?: string; - /** Gets the name. */ - name?: string; /** Gets or sets the parent collection reference. */ parentCollection?: CollectionReference; - /** Metadata pertaining to creation and last modification of the resource. */ - systemData?: CollectionSystemData; } +/** Reference to a Collection. */ export interface CollectionReference { /** Gets or sets the reference name. */ referenceName?: string; @@ -219,52 +37,21 @@ export interface CollectionReference { type?: string; } +/** Metadata pertaining to creation and last modification of the resource. */ export interface CollectionSystemData extends SystemData {} -export interface CollectionList { - /** Total item count. */ - count?: number; - /** The Url of next result page. */ - nextLink?: string; - /** Collection of items of type results. */ - value: Array; -} - -export interface CollectionNameResponseList { - /** Total item count. */ - count?: number; - /** The Url of next result page. */ - nextLink?: string; - /** Collection of items of type results. */ - value: Array; -} - -export interface CollectionNameResponse { - /** Gets or sets the friendly name of the collection. */ - friendlyName?: string; - /** Gets the name. */ - name?: string; -} - -export interface CollectionPathResponse { - /** The friendly names of ancestors starting from the default (root) collection and ending with the immediate parent. */ - parentFriendlyNameChain?: Array; - /** The names of ancestors starting from the default (root) collection and ending with the immediate parent. */ - parentNameChain?: Array; -} - +/** ResourceSetRuleConfig implementation class. */ export interface ResourceSetRuleConfig { /** Gets or sets the advanced resource set property of the account. */ advancedResourceSet?: AdvancedResourceSet; - /** The name of the rule */ - name?: string; /** The configuration rules for path pattern extraction. */ pathPatternConfig?: PathPatternExtractorConfig; } +/** The resource set processing property of the account. */ export interface AdvancedResourceSet { /** Date at which ResourceSetProcessing property of the account is updated. */ - modifiedAt?: Date; + modifiedAt?: Date | string; /** The advanced resource property of the account. */ resourceSetProcessing?: "Default" | "Advanced"; } @@ -356,12 +143,3 @@ export interface Rule { name?: string; qualifiedName: string; } - -export interface ResourceSetRuleConfigList { - /** Total item count. */ - count?: number; - /** The Url of next result page. */ - nextLink?: string; - /** Collection of items of type results. */ - value: Array; -} diff --git a/sdk/purview/purview-administration-rest/src/account/outputModels.ts b/sdk/purview/purview-administration-rest/src/account/outputModels.ts new file mode 100644 index 000000000000..4d56902e89ae --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/outputModels.ts @@ -0,0 +1,391 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** Account resource */ +export interface AccountOutput { + /** Gets or sets the identifier. */ + readonly id?: string; + /** Identity Info on the tracked resource */ + identity?: IdentityOutput; + /** Gets or sets the location. */ + location?: string; + /** Gets or sets the name. */ + readonly name?: string; + /** Gets or sets the properties. */ + properties?: AccountPropertiesOutput; + /** Gets or sets the Sku. */ + sku?: AccountSkuOutput; + /** Metadata pertaining to creation and last modification of the resource. */ + readonly systemData?: AccountSystemDataOutput; + /** Tags on the azure resource. */ + tags?: Record; + /** Gets or sets the type. */ + readonly type?: string; +} + +/** The Managed Identity of the resource */ +export interface IdentityOutput { + /** Service principal object Id */ + readonly principalId?: string; + /** Tenant Id */ + readonly tenantId?: string; + /** Identity Type */ + type?: "SystemAssigned"; +} + +/** The account properties */ +export interface AccountPropertiesOutput { + /** + * Cloud connectors. + * External cloud identifier used as part of scanning configuration. + */ + cloudConnectors?: CloudConnectorsOutput; + /** Gets the time at which the entity was created. */ + readonly createdAt?: string; + /** Gets the creator of the entity. */ + readonly createdBy?: string; + /** Gets the creators of the entity's object id. */ + readonly createdByObjectId?: string; + /** The URIs that are the public endpoints of the account. */ + readonly endpoints?: AccountPropertiesEndpointsOutput; + /** Gets or sets the friendly name. */ + readonly friendlyName?: string; + /** Gets or sets the managed resource group name */ + managedResourceGroupName?: string; + /** Gets the resource identifiers of the managed resources. */ + readonly managedResources?: AccountPropertiesManagedResourcesOutput; + /** Gets the private endpoint connections information. */ + readonly privateEndpointConnections?: Array; + /** Gets or sets the state of the provisioning. */ + readonly provisioningState?: + | "Unknown" + | "Creating" + | "Moving" + | "Deleting" + | "SoftDeleting" + | "SoftDeleted" + | "Failed" + | "Succeeded" + | "Canceled"; + /** Gets or sets the public network access. */ + publicNetworkAccess?: "NotSpecified" | "Enabled" | "Disabled"; +} + +export interface CloudConnectorsOutput { + /** + * AWS external identifier. + * Configured in AWS to allow use of the role arn used for scanning + */ + readonly awsExternalId?: string; +} + +/** The URIs that are the public endpoints of the account. */ +export interface AccountPropertiesEndpointsOutput + extends AccountEndpointsOutput {} + +/** The account endpoints */ +export interface AccountEndpointsOutput { + /** Gets the catalog endpoint. */ + readonly catalog?: string; + /** Gets the guardian endpoint. */ + readonly guardian?: string; + /** Gets the scan endpoint. */ + readonly scan?: string; +} + +/** Gets the resource identifiers of the managed resources. */ +export interface AccountPropertiesManagedResourcesOutput + extends ManagedResourcesOutput {} + +/** The managed resources in customer subscription. */ +export interface ManagedResourcesOutput { + /** Gets the managed event hub namespace resource identifier. */ + readonly eventHubNamespace?: string; + /** Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. */ + readonly resourceGroup?: string; + /** Gets the managed storage account resource identifier. */ + readonly storageAccount?: string; +} + +/** A private endpoint connection class. */ +export interface PrivateEndpointConnectionOutput { + /** Gets or sets the identifier. */ + readonly id?: string; + /** Gets or sets the name. */ + readonly name?: string; + /** The connection identifier. */ + properties?: PrivateEndpointConnectionPropertiesOutput; + /** Gets or sets the type. */ + readonly type?: string; +} + +/** A private endpoint connection properties class. */ +export interface PrivateEndpointConnectionPropertiesOutput { + /** The private endpoint information. */ + privateEndpoint?: PrivateEndpointOutput; + /** The private link service connection state. */ + privateLinkServiceConnectionState?: PrivateLinkServiceConnectionStateOutput; + /** The provisioning state. */ + readonly provisioningState?: string; +} + +/** A private endpoint class. */ +export interface PrivateEndpointOutput { + /** The private endpoint identifier. */ + id?: string; +} + +/** The private link service connection state. */ +export interface PrivateLinkServiceConnectionStateOutput { + /** The required actions. */ + actionsRequired?: string; + /** The description. */ + description?: string; + /** The status. */ + status?: "Unknown" | "Pending" | "Approved" | "Rejected" | "Disconnected"; +} + +/** The Sku */ +export interface AccountSkuOutput { + /** Gets or sets the sku capacity. Possible values include: 4, 16 */ + capacity?: number; + /** Gets or sets the sku name. */ + name?: "Standard"; +} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface AccountSystemDataOutput extends SystemDataOutput {} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemDataOutput { + /** The timestamp of resource creation (UTC). */ + readonly createdAt?: string; + /** The identity that created the resource. */ + readonly createdBy?: string; + /** The type of identity that created the resource. */ + readonly createdByType?: "User" | "Application" | "ManagedIdentity" | "Key"; + /** The timestamp of the last modification the resource (UTC). */ + readonly lastModifiedAt?: string; + /** The identity that last modified the resource. */ + readonly lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + readonly lastModifiedByType?: + | "User" + | "Application" + | "ManagedIdentity" + | "Key"; +} + +/** Default error response model */ +export interface ErrorResponseModelOutput { + /** Gets or sets the error. */ + readonly error?: ErrorResponseModelErrorOutput; +} + +/** Gets or sets the error. */ +export interface ErrorResponseModelErrorOutput extends ErrorModelOutput {} + +/** Default error model */ +export interface ErrorModelOutput { + /** Gets or sets the code. */ + readonly code?: string; + /** Gets or sets the details. */ + readonly details?: Array; + /** Gets or sets the messages. */ + readonly message?: string; + /** Gets or sets the target. */ + readonly target?: string; +} + +/** The Account access keys. */ +export interface AccessKeysOutput { + /** Gets or sets the primary connection string. */ + atlasKafkaPrimaryEndpoint?: string; + /** Gets or sets the secondary connection string. */ + atlasKafkaSecondaryEndpoint?: string; +} + +/** Collection resource. */ +export interface CollectionOutput { + /** Gets the state of the provisioning. */ + readonly collectionProvisioningState?: + | "Unknown" + | "Creating" + | "Moving" + | "Deleting" + | "Failed" + | "Succeeded"; + /** Gets or sets the description. */ + description?: string; + /** Gets or sets the friendly name of the collection. */ + friendlyName?: string; + /** Gets the name. */ + readonly name?: string; + /** Gets or sets the parent collection reference. */ + parentCollection?: CollectionReferenceOutput; + /** Metadata pertaining to creation and last modification of the resource. */ + readonly systemData?: CollectionSystemDataOutput; +} + +/** Reference to a Collection. */ +export interface CollectionReferenceOutput { + /** Gets or sets the reference name. */ + referenceName?: string; + /** Gets or sets the reference type property. */ + type?: string; +} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface CollectionSystemDataOutput extends SystemDataOutput {} + +/** Paged list of collections. */ +export interface CollectionListOutput { + /** Total item count. */ + count?: number; + /** The Url of next result page. */ + nextLink?: string; + /** Collection of items of type results. */ + value: Array; +} + +/** Paged list of collections. */ +export interface CollectionNameResponseListOutput { + /** Total item count. */ + count?: number; + /** The Url of next result page. */ + nextLink?: string; + /** Collection of items of type results. */ + value: Array; +} + +/** Collection resource. */ +export interface CollectionNameResponseOutput { + /** Gets or sets the friendly name of the collection. */ + readonly friendlyName?: string; + /** Gets the name. */ + readonly name?: string; +} + +/** Collection resource. */ +export interface CollectionPathResponseOutput { + /** The friendly names of ancestors starting from the default (root) collection and ending with the immediate parent. */ + readonly parentFriendlyNameChain?: Array; + /** The names of ancestors starting from the default (root) collection and ending with the immediate parent. */ + readonly parentNameChain?: Array; +} + +/** ResourceSetRuleConfig implementation class. */ +export interface ResourceSetRuleConfigOutput { + /** Gets or sets the advanced resource set property of the account. */ + advancedResourceSet?: AdvancedResourceSetOutput; + /** The name of the rule */ + readonly name?: string; + /** The configuration rules for path pattern extraction. */ + pathPatternConfig?: PathPatternExtractorConfigOutput; +} + +/** The resource set processing property of the account. */ +export interface AdvancedResourceSetOutput { + /** Date at which ResourceSetProcessing property of the account is updated. */ + modifiedAt?: string; + /** The advanced resource property of the account. */ + resourceSetProcessing?: "Default" | "Advanced"; +} + +export interface PathPatternExtractorConfigOutput { + acceptedPatterns?: Array; + complexReplacers?: Array; + createdBy: string; + enableDefaultPatterns: boolean; + lastUpdatedTimestamp?: number; + modifiedBy?: string; + normalizationRules?: Array; + regexReplacers?: Array; + rejectedPatterns?: Array; + scopedRules?: Array; + version?: number; +} + +export interface FilterOutput { + createdBy?: string; + filterType?: "Pattern" | "Regex"; + lastUpdatedTimestamp?: number; + modifiedBy?: string; + name: string; + path: string; +} + +export interface ComplexReplacerConfigOutput { + createdBy?: string; + description?: string; + disabled?: boolean; + disableRecursiveReplacerApplication?: boolean; + lastUpdatedTimestamp?: number; + modifiedBy?: string; + name?: string; + typeName?: string; +} + +export interface NormalizationRuleOutput { + description?: string; + disabled?: boolean; + dynamicReplacement?: boolean; + entityTypes?: Array; + lastUpdatedTimestamp?: number; + name?: string; + regex?: FastRegexOutput; + replaceWith?: string; + version?: number; +} + +export interface FastRegexOutput { + maxDigits?: number; + maxLetters?: number; + minDashes?: number; + minDigits?: number; + minDigitsOrLetters?: number; + minDots?: number; + minHex?: number; + minLetters?: number; + minUnderscores?: number; + options?: number; + regexStr?: string; +} + +export interface RegexReplacerOutput { + condition?: string; + createdBy?: string; + description?: string; + disabled: boolean; + disableRecursiveReplacerApplication?: boolean; + doNotReplaceRegex?: FastRegexOutput; + lastUpdatedTimestamp?: number; + modifiedBy?: string; + name: string; + regex?: FastRegexOutput; + replaceWith?: string; +} + +export interface ScopedRuleOutput { + bindingUrl: string; + rules?: Array; + storeType: string; +} + +export interface RuleOutput { + displayName?: string; + isResourceSet?: boolean; + lastUpdatedTimestamp?: number; + name?: string; + qualifiedName: string; +} + +/** Paged list of account resources */ +export interface ResourceSetRuleConfigListOutput { + /** Total item count. */ + count?: number; + /** The Url of next result page. */ + nextLink?: string; + /** Collection of items of type results. */ + value: Array; +} diff --git a/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts b/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts index e27846d32a90..5ef95e5ea0a3 100644 --- a/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts +++ b/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts @@ -1,8 +1,162 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; -import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings = PageSettings, + TLink = string, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator( + pagedResult, + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + (((settings?: PageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken as unknown as TLink | undefined, + }); + }) as unknown as ( + settings?: TPageSettings, + ) => AsyncIterableIterator), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + const firstVal = await pages.next(); + // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is + if (!Array.isArray(firstVal.value)) { + // can extract elements from this page + const { toElements } = pagedResult; + if (toElements) { + yield* toElements(firstVal.value) as TElement[]; + for await (const page of pages) { + yield* toElements(page) as TElement[]; + } + } else { + yield firstVal.value; + // `pages` is of type `AsyncIterableIterator` but TPage = TElement in this case + yield* pages as unknown as AsyncIterableIterator; + } + } else { + yield* firstVal.value; + for await (const page of pages) { + // pages is of type `AsyncIterableIterator` so `page` is of type `TPage`. In this branch, + // it must be the case that `TPage = TElement[]` + yield* page as unknown as TElement[]; + } + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: TLink; + } = {}, +): AsyncIterableIterator { + const { pageLink } = options; + let response = await pagedResult.getPage( + pageLink ?? pagedResult.firstPageLink, + ); + if (!response) { + return; + } + yield response.page; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + yield response.page; + } +} + +/** + * An interface that tracks the settings for paged iteration + */ +export interface PageSettings { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +} + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator; +} + +/** + * An interface that describes how to communicate with the service. + */ +interface PagedResult { + /** + * Link to the first page of results. + */ + firstPageLink: TLink; + /** + * A method that returns a page of results. + */ + getPage: ( + pageLink: TLink, + ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => unknown[]; +} /** * Helper type to extract the type of an array @@ -12,10 +166,7 @@ export type GetArrayType = T extends Array ? TData : never; /** * The type of a custom function that defines how to get a page and a link to the next one if any. */ -export type GetPage = ( - pageLink: string, - maxPageSize?: number, -) => Promise<{ +export type GetPage = (pageLink: string) => Promise<{ page: TPage; nextPageLink?: string; }>; @@ -67,7 +218,9 @@ export function paginate( typeof customGetPage === "function" ? customGetPage : async (pageLink: string) => { - const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); + const result = firstRun + ? initialResponse + : await client.pathUnchecked(pageLink).get(); firstRun = false; checkPagingRequest(result); const nextLink = getNextLink(result.body, nextLinkName); @@ -93,7 +246,9 @@ function getNextLink(body: unknown, nextLinkName?: string): string | undefined { const nextLink = (body as Record)[nextLinkName]; if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); + throw new Error( + `Body Property ${nextLinkName} should be a string or undefined`, + ); } return nextLink; @@ -121,7 +276,18 @@ function getElements(body: unknown, itemName: string): T[] { * Checks if a request failed */ function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; + const Http2xxStatusCodes = [ + "200", + "201", + "202", + "203", + "204", + "205", + "206", + "207", + "208", + "226", + ]; if (!Http2xxStatusCodes.includes(response.status)) { throw createRestError( `Pagination failed with unexpected statusCode ${response.status}`, diff --git a/sdk/purview/purview-administration-rest/src/account/parameters.ts b/sdk/purview/purview-administration-rest/src/account/parameters.ts index da5a22e8fcd8..414caa30ba5e 100644 --- a/sdk/purview/purview-administration-rest/src/account/parameters.ts +++ b/sdk/purview/purview-administration-rest/src/account/parameters.ts @@ -3,9 +3,9 @@ import { RequestParameters } from "@azure-rest/core-client"; import { + DataPlaneAccountUpdateParameters, AccessKeyOptions, Collection, - DataPlaneAccountUpdateParameters, ResourceSetRuleConfig, } from "./models"; @@ -15,24 +15,45 @@ export interface AccountsUpdateAccountPropertiesBodyParam { body: DataPlaneAccountUpdateParameters; } -export type AccountsUpdateAccountPropertiesParameters = AccountsUpdateAccountPropertiesBodyParam & - RequestParameters; +export interface AccountsUpdateAccountPropertiesMediaTypesParam { + /** Request content type */ + contentType?: "application/json"; +} + +export type AccountsUpdateAccountPropertiesParameters = + AccountsUpdateAccountPropertiesMediaTypesParam & + AccountsUpdateAccountPropertiesBodyParam & + RequestParameters; export type AccountsGetAccessKeysParameters = RequestParameters; export interface AccountsRegenerateAccessKeyBodyParam { body: AccessKeyOptions; } -export type AccountsRegenerateAccessKeyParameters = AccountsRegenerateAccessKeyBodyParam & - RequestParameters; +export interface AccountsRegenerateAccessKeyMediaTypesParam { + /** Request content type */ + contentType?: "application/json"; +} + +export type AccountsRegenerateAccessKeyParameters = + AccountsRegenerateAccessKeyMediaTypesParam & + AccountsRegenerateAccessKeyBodyParam & + RequestParameters; export type CollectionsGetCollectionParameters = RequestParameters; export interface CollectionsCreateOrUpdateCollectionBodyParam { body: Collection; } +export interface CollectionsCreateOrUpdateCollectionMediaTypesParam { + /** Request content type */ + contentType?: "application/json"; +} + export type CollectionsCreateOrUpdateCollectionParameters = - CollectionsCreateOrUpdateCollectionBodyParam & RequestParameters; + CollectionsCreateOrUpdateCollectionMediaTypesParam & + CollectionsCreateOrUpdateCollectionBodyParam & + RequestParameters; export type CollectionsDeleteCollectionParameters = RequestParameters; export interface CollectionsListCollectionsQueryParamProperties { @@ -43,8 +64,8 @@ export interface CollectionsListCollectionsQueryParam { queryParameters?: CollectionsListCollectionsQueryParamProperties; } -export type CollectionsListCollectionsParameters = CollectionsListCollectionsQueryParam & - RequestParameters; +export type CollectionsListCollectionsParameters = + CollectionsListCollectionsQueryParam & RequestParameters; export interface CollectionsListChildCollectionNamesQueryParamProperties { $skipToken?: string; @@ -63,8 +84,15 @@ export interface ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam { body: ResourceSetRuleConfig; } +export interface ResourceSetRulesCreateOrUpdateResourceSetRuleMediaTypesParam { + /** Request content type */ + contentType?: "application/json"; +} + export type ResourceSetRulesCreateOrUpdateResourceSetRuleParameters = - ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam & RequestParameters; + ResourceSetRulesCreateOrUpdateResourceSetRuleMediaTypesParam & + ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam & + RequestParameters; export type ResourceSetRulesDeleteResourceSetRuleParameters = RequestParameters; export interface ResourceSetRulesListResourceSetRulesQueryParamProperties { diff --git a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts index c8e74d4fabe3..a6582bb71bbc 100644 --- a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts +++ b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts @@ -1,22 +1,71 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. + import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { logger } from "../logger"; import { TokenCredential } from "@azure/core-auth"; -import { PurviewAccountRestClient } from "./clientDefinitions"; +import { PurviewAccountClient } from "./clientDefinitions"; + +/** The optional parameters for the client */ +export interface PurviewAccountClientOptions extends ClientOptions { + /** The api version option of the client */ + apiVersion?: string; +} -export function PurviewAccountClient( +/** + * Initialize a new instance of `PurviewAccountClient` + * @param endpoint - The account endpoint of your Purview account. Example: https://{accountName}.purview.azure.com/account/ + * @param credentials - uniquely identify client credential + * @param options - the parameter for all optional parameters + */ +export function createClient( endpoint: string, credentials: TokenCredential, - options: ClientOptions = {}, -): PurviewAccountRestClient { - const baseUrl = options.baseUrl ?? `${endpoint}`; - options.apiVersion = options.apiVersion ?? "2019-11-01-preview"; + { + apiVersion = "2019-11-01-preview", + ...options + }: PurviewAccountClientOptions = {}, +): PurviewAccountClient { + const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpoint}`; + const userAgentInfo = `azsdk-js-purview-administration-rest/1.0.0-beta.2`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + : `${userAgentInfo}`; options = { ...options, + userAgentOptions: { + userAgentPrefix, + }, + loggingOptions: { + logger: options.loggingOptions?.logger ?? logger.info, + }, credentials: { - scopes: ["https://purview.azure.net/.default"], + scopes: options.credentials?.scopes ?? ["user_impersonation"], }, }; + const client = getClient( + endpointUrl, + credentials, + options, + ) as PurviewAccountClient; + + client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + client.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version") && apiVersion) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); - return getClient(baseUrl, credentials, options) as PurviewAccountRestClient; + return client; } diff --git a/sdk/purview/purview-administration-rest/src/account/responses.ts b/sdk/purview/purview-administration-rest/src/account/responses.ts index 4551a9126416..8da34f68acb5 100644 --- a/sdk/purview/purview-administration-rest/src/account/responses.ts +++ b/sdk/purview/purview-administration-rest/src/account/responses.ts @@ -3,187 +3,204 @@ import { HttpResponse } from "@azure-rest/core-client"; import { - AccessKeys, - Account, - Collection, - CollectionList, - CollectionNameResponseList, - CollectionPathResponse, - ErrorResponseModel, - ResourceSetRuleConfig, - ResourceSetRuleConfigList, -} from "./models"; + AccountOutput, + ErrorResponseModelOutput, + AccessKeysOutput, + CollectionOutput, + CollectionListOutput, + CollectionNameResponseListOutput, + CollectionPathResponseOutput, + ResourceSetRuleConfigOutput, + ResourceSetRuleConfigListOutput, +} from "./outputModels"; /** Get an account */ export interface AccountsGetAccountProperties200Response extends HttpResponse { status: "200"; - body: Account; + body: AccountOutput; } /** Get an account */ -export interface AccountsGetAccountPropertiesdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface AccountsGetAccountPropertiesDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Updates an account */ -export interface AccountsUpdateAccountProperties200Response extends HttpResponse { +export interface AccountsUpdateAccountProperties200Response + extends HttpResponse { status: "200"; - body: Account; + body: AccountOutput; } /** Updates an account */ -export interface AccountsUpdateAccountPropertiesdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface AccountsUpdateAccountPropertiesDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** List the authorization keys associated with this account. */ export interface AccountsGetAccessKeys200Response extends HttpResponse { status: "200"; - body: AccessKeys; + body: AccessKeysOutput; } /** List the authorization keys associated with this account. */ -export interface AccountsGetAccessKeysdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface AccountsGetAccessKeysDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Regenerate the authorization keys associated with this data catalog. */ export interface AccountsRegenerateAccessKey200Response extends HttpResponse { status: "200"; - body: AccessKeys; + body: AccessKeysOutput; } /** Regenerate the authorization keys associated with this data catalog. */ -export interface AccountsRegenerateAccessKeydefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface AccountsRegenerateAccessKeyDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Get a collection */ export interface CollectionsGetCollection200Response extends HttpResponse { status: "200"; - body: Collection; + body: CollectionOutput; } /** Get a collection */ -export interface CollectionsGetCollectiondefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface CollectionsGetCollectionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Creates or updates a collection entity. */ -export interface CollectionsCreateOrUpdateCollection200Response extends HttpResponse { +export interface CollectionsCreateOrUpdateCollection200Response + extends HttpResponse { status: "200"; - body: Collection; + body: CollectionOutput; } /** Creates or updates a collection entity. */ -export interface CollectionsCreateOrUpdateCollectiondefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface CollectionsCreateOrUpdateCollectionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Deletes a Collection entity. */ export interface CollectionsDeleteCollection204Response extends HttpResponse { status: "204"; - body: Record; } /** Deletes a Collection entity. */ -export interface CollectionsDeleteCollectiondefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface CollectionsDeleteCollectionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** List the collections in the account. */ export interface CollectionsListCollections200Response extends HttpResponse { status: "200"; - body: CollectionList; + body: CollectionListOutput; } /** List the collections in the account. */ -export interface CollectionsListCollectionsdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface CollectionsListCollectionsDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Lists the child collections names in the collection. */ -export interface CollectionsListChildCollectionNames200Response extends HttpResponse { +export interface CollectionsListChildCollectionNames200Response + extends HttpResponse { status: "200"; - body: CollectionNameResponseList; + body: CollectionNameResponseListOutput; } /** Lists the child collections names in the collection. */ -export interface CollectionsListChildCollectionNamesdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface CollectionsListChildCollectionNamesDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Gets the parent name and parent friendly name chains that represent the collection path. */ export interface CollectionsGetCollectionPath200Response extends HttpResponse { status: "200"; - body: CollectionPathResponse; + body: CollectionPathResponseOutput; } /** Gets the parent name and parent friendly name chains that represent the collection path. */ -export interface CollectionsGetCollectionPathdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface CollectionsGetCollectionPathDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Get a resource set config service model. */ -export interface ResourceSetRulesGetResourceSetRule200Response extends HttpResponse { +export interface ResourceSetRulesGetResourceSetRule200Response + extends HttpResponse { status: "200"; - body: ResourceSetRuleConfig; + body: ResourceSetRuleConfigOutput; } /** Get a resource set config service model. */ -export interface ResourceSetRulesGetResourceSetRuledefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface ResourceSetRulesGetResourceSetRuleDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Creates or updates an resource set config. */ -export interface ResourceSetRulesCreateOrUpdateResourceSetRule200Response extends HttpResponse { +export interface ResourceSetRulesCreateOrUpdateResourceSetRule200Response + extends HttpResponse { status: "200"; - body: ResourceSetRuleConfig; + body: ResourceSetRuleConfigOutput; } /** Creates or updates an resource set config. */ -export interface ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Deletes a ResourceSetRuleConfig resource. */ -export interface ResourceSetRulesDeleteResourceSetRule200Response extends HttpResponse { +export interface ResourceSetRulesDeleteResourceSetRule200Response + extends HttpResponse { status: "200"; - body: Record; } /** Deletes a ResourceSetRuleConfig resource. */ -export interface ResourceSetRulesDeleteResourceSetRule204Response extends HttpResponse { +export interface ResourceSetRulesDeleteResourceSetRule204Response + extends HttpResponse { status: "204"; - body: Record; } /** Deletes a ResourceSetRuleConfig resource. */ -export interface ResourceSetRulesDeleteResourceSetRuledefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface ResourceSetRulesDeleteResourceSetRuleDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } /** Get a resource set config service model. */ -export interface ResourceSetRulesListResourceSetRules200Response extends HttpResponse { +export interface ResourceSetRulesListResourceSetRules200Response + extends HttpResponse { status: "200"; - body: ResourceSetRuleConfigList; + body: ResourceSetRuleConfigListOutput; } /** Get a resource set config service model. */ -export interface ResourceSetRulesListResourceSetRulesdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; +export interface ResourceSetRulesListResourceSetRulesDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; } diff --git a/sdk/purview/purview-administration-rest/src/index.ts b/sdk/purview/purview-administration-rest/src/index.ts index 8cd0a85051ca..ea3ca2557eaf 100644 --- a/sdk/purview/purview-administration-rest/src/index.ts +++ b/sdk/purview/purview-administration-rest/src/index.ts @@ -1,10 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import * as PurviewAccount from "./account"; import * as PurviewMetadataPolicies from "./metadataPolicies"; +import * as PurviewAccount from "./account"; -export { PurviewAccount }; -export { PurviewMetadataPolicies }; -export { PurviewAccountClient } from "./account/purviewAccount"; -export { PurviewMetadataPoliciesClient } from "./metadataPolicies/purviewMetadataPolicies"; +export { PurviewMetadataPolicies, PurviewAccount }; diff --git a/sdk/purview/purview-administration-rest/src/logger.ts b/sdk/purview/purview-administration-rest/src/logger.ts new file mode 100644 index 000000000000..f5d8affecfff --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("purview-administration"); diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts index d2de6a5d7e6e..ed1f92636474 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts @@ -1,47 +1,55 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Client } from "@azure-rest/core-client"; import { - MetadataPolicyGetParameters, + MetadataRolesListParameters, MetadataPolicyListAllParameters, MetadataPolicyUpdateParameters, - MetadataRolesListParameters, + MetadataPolicyGetParameters, } from "./parameters"; import { - MetadataPolicyGet200Response, - MetadataPolicyGetdefaultResponse, + MetadataRolesList200Response, + MetadataRolesListDefaultResponse, MetadataPolicyListAll200Response, - MetadataPolicyListAlldefaultResponse, + MetadataPolicyListAllDefaultResponse, MetadataPolicyUpdate200Response, - MetadataPolicyUpdatedefaultResponse, - MetadataRolesList200Response, - MetadataRolesListdefaultResponse, + MetadataPolicyUpdateDefaultResponse, + MetadataPolicyGet200Response, + MetadataPolicyGetDefaultResponse, } from "./responses"; +import { Client, StreamableMethod } from "@azure-rest/core-client"; export interface MetadataRolesList { /** Lists roles for Purview Account */ get( options?: MetadataRolesListParameters, - ): Promise; + ): StreamableMethod< + MetadataRolesList200Response | MetadataRolesListDefaultResponse + >; } export interface MetadataPolicyListAll { /** List or Get metadata policies */ get( options?: MetadataPolicyListAllParameters, - ): Promise; + ): StreamableMethod< + MetadataPolicyListAll200Response | MetadataPolicyListAllDefaultResponse + >; } export interface MetadataPolicyUpdate { /** Updates a metadata policy */ put( options?: MetadataPolicyUpdateParameters, - ): Promise; + ): StreamableMethod< + MetadataPolicyUpdate200Response | MetadataPolicyUpdateDefaultResponse + >; /** Gets a metadata policy */ get( options?: MetadataPolicyGetParameters, - ): Promise; + ): StreamableMethod< + MetadataPolicyGet200Response | MetadataPolicyGetDefaultResponse + >; } export interface Routes { @@ -50,9 +58,12 @@ export interface Routes { /** Resource for '/metadataPolicies' has methods for the following verbs: get */ (path: "/metadataPolicies"): MetadataPolicyListAll; /** Resource for '/metadataPolicies/\{policyId\}' has methods for the following verbs: put, get */ - (path: "/metadataPolicies/{policyId}", policyId: string): MetadataPolicyUpdate; + ( + path: "/metadataPolicies/{policyId}", + policyId: string, + ): MetadataPolicyUpdate; } -export type PurviewMetadataPoliciesRestClient = Client & { +export type PurviewMetadataPoliciesClient = Client & { path: Routes; }; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts index 09f132a17354..e331601d86a8 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts @@ -1,10 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import * as Models from "./models"; -import * as Pagination from "./paginateHelper"; import * as Parameters from "./parameters"; -import * as Client from "./clientDefinitions"; import * as Responses from "./responses"; -export { PurviewMetadataPoliciesClient } from "./purviewMetadataPolicies"; -export { Models, Pagination, Parameters, Client, Responses }; +import * as Client from "./clientDefinitions"; +import * as Models from "./models"; +import * as OutputModels from "./outputModels"; +import * as PaginateHelper from "./paginateHelper"; +import * as UnexpectedHelper from "./isUnexpected"; + +export { + createClient, + PurviewMetadataPoliciesClientOptions, +} from "./purviewMetadataPolicies"; +export { + Parameters, + Responses, + Client, + Models, + OutputModels, + PaginateHelper, + UnexpectedHelper, +}; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/isUnexpected.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/isUnexpected.ts new file mode 100644 index 000000000000..918a7a7b376d --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/isUnexpected.ts @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + MetadataRolesList200Response, + MetadataRolesListDefaultResponse, + MetadataPolicyListAll200Response, + MetadataPolicyListAllDefaultResponse, + MetadataPolicyUpdate200Response, + MetadataPolicyUpdateDefaultResponse, + MetadataPolicyGet200Response, + MetadataPolicyGetDefaultResponse, +} from "./responses"; + +const responseMap: Record = { + "GET /metadataRoles": ["200"], + "GET /metadataPolicies": ["200"], + "PUT /metadataPolicies/{policyId}": ["200"], + "GET /metadataPolicies/{policyId}": ["200"], +}; + +export function isUnexpected( + response: MetadataRolesList200Response | MetadataRolesListDefaultResponse, +): response is MetadataRolesListDefaultResponse; +export function isUnexpected( + response: + | MetadataPolicyListAll200Response + | MetadataPolicyListAllDefaultResponse, +): response is MetadataPolicyListAllDefaultResponse; +export function isUnexpected( + response: + | MetadataPolicyUpdate200Response + | MetadataPolicyUpdateDefaultResponse, +): response is MetadataPolicyUpdateDefaultResponse; +export function isUnexpected( + response: MetadataPolicyGet200Response | MetadataPolicyGetDefaultResponse, +): response is MetadataPolicyGetDefaultResponse; +export function isUnexpected( + response: + | MetadataRolesList200Response + | MetadataRolesListDefaultResponse + | MetadataPolicyListAll200Response + | MetadataPolicyListAllDefaultResponse + | MetadataPolicyUpdate200Response + | MetadataPolicyUpdateDefaultResponse + | MetadataPolicyGet200Response + | MetadataPolicyGetDefaultResponse, +): response is + | MetadataRolesListDefaultResponse + | MetadataPolicyListAllDefaultResponse + | MetadataPolicyUpdateDefaultResponse + | MetadataPolicyGetDefaultResponse { + const lroOriginal = response.headers["x-ms-original-url"]; + const url = new URL(lroOriginal ?? response.request.url); + const method = response.request.method; + let pathDetails = responseMap[`${method} ${url.pathname}`]; + if (!pathDetails) { + pathDetails = getParametrizedPathSuccess(method, url.pathname); + } + return !pathDetails.includes(response.status); +} + +function getParametrizedPathSuccess(method: string, path: string): string[] { + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: string[] = []; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(responseMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}`, + ).test(pathParts[j] || ""); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/models.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/models.ts index b5257759a9f7..c8ee3fb8a3b7 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/models.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/models.ts @@ -1,38 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export interface MetadataRoleList { - values: Array; - nextLink?: string; -} - -export interface MetadataRole { - /** The Id of role */ - id?: string; - /** The name of role */ - name?: string; - /** The type of role */ - type?: string; - properties?: MetadataRoleProperties; -} - -export interface MetadataRoleProperties { - /** The provisioningState of role */ - provisioningState?: string; - /** The type of role */ - roleType?: string; - /** The friendly name of role */ - friendlyName?: string; - /** The description of role */ - description?: string; - /** The cnf Condition for a rule */ - cnfCondition?: Array>; - /** The dnf Condition for a rule */ - dnfCondition?: Array>; - /** The version of role */ - version?: number; -} - +/** Attribute matcher for a rule */ export interface AttributeMatcher { /** AttributeName */ attributeName?: string; @@ -46,27 +15,6 @@ export interface AttributeMatcher { attributeValueExcludedIn?: Array; } -export interface ErrorResponseModel { - /** The error model for metadata policy */ - error: ErrorModel; -} - -export interface ErrorModel { - /** The error code */ - code: string; - /** The error message */ - message: string; - /** The error target */ - target?: string; - /** The error details */ - details?: Array; -} - -export interface MetadataPolicyList { - values: Array; - nextLink?: string; -} - export interface MetadataPolicy { /** The name of policy */ name?: string; @@ -90,18 +38,16 @@ export interface MetadataPolicyProperties { parentCollectionName?: string; } +/** The decision rule for a policy */ export interface DecisionRule { - /** The kind of rule */ - kind?: "decisionrule" | "attributerule"; /** The effect for rule */ effect?: "Deny" | "Permit"; /** The dnf Condition for a rule */ dnfCondition?: Array>; } +/** The attribute rule for a policy */ export interface AttributeRule { - /** The kind of rule */ - kind?: "decisionrule" | "attributerule"; /** The id for rule */ id?: string; /** The name for rule */ @@ -110,6 +56,7 @@ export interface AttributeRule { dnfCondition?: Array>; } +/** The collection reference for a policy */ export interface CollectionReference { /** The type of reference */ type?: string; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/outputModels.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/outputModels.ts new file mode 100644 index 000000000000..90bc7ac21963 --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/outputModels.ts @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** List of Metadata roles */ +export interface MetadataRoleListOutput { + values: Array; + nextLink?: string; +} + +export interface MetadataRoleOutput { + /** The Id of role */ + id?: string; + /** The name of role */ + name?: string; + /** The type of role */ + type?: string; + properties?: MetadataRolePropertiesOutput; +} + +export interface MetadataRolePropertiesOutput { + /** The provisioningState of role */ + provisioningState?: string; + /** The type of role */ + roleType?: string; + /** The friendly name of role */ + friendlyName?: string; + /** The description of role */ + description?: string; + /** The cnf Condition for a rule */ + cnfCondition?: Array>; + /** The dnf Condition for a rule */ + dnfCondition?: Array>; + /** The version of role */ + version?: number; +} + +/** Attribute matcher for a rule */ +export interface AttributeMatcherOutput { + /** AttributeName */ + attributeName?: string; + /** Value for attribute */ + attributeValueIncludes?: string; + /** List of values for attribute */ + attributeValueIncludedIn?: Array; + /** Value excluded for attribute */ + attributeValueExcludes?: string; + /** List of values excluded for attribute */ + attributeValueExcludedIn?: Array; +} + +/** The error response model for metadata policy */ +export interface ErrorResponseModelOutput { + /** The error model for metadata policy */ + error: ErrorModelOutput; +} + +/** The error model for metadata policy */ +export interface ErrorModelOutput { + /** The error code */ + code: string; + /** The error message */ + message: string; + /** The error target */ + target?: string; + /** The error details */ + details?: Array; +} + +/** List of Metadata Policies */ +export interface MetadataPolicyListOutput { + values: Array; + nextLink?: string; +} + +export interface MetadataPolicyOutput { + /** The name of policy */ + name?: string; + /** The id of policy */ + id?: string; + /** The version of policy */ + version?: number; + properties?: MetadataPolicyPropertiesOutput; +} + +export interface MetadataPolicyPropertiesOutput { + /** The description of policy */ + description?: string; + /** The DecisionRules of policy */ + decisionRules?: Array; + /** The AttributeRules of policy */ + attributeRules?: Array; + /** The collection reference for a policy */ + collection?: CollectionReferenceOutput; + /** The parent collection of the policy */ + parentCollectionName?: string; +} + +/** The decision rule for a policy */ +export interface DecisionRuleOutput { + /** The kind of rule */ + readonly kind?: "decisionrule" | "attributerule"; + /** The effect for rule */ + effect?: "Deny" | "Permit"; + /** The dnf Condition for a rule */ + dnfCondition?: Array>; +} + +/** The attribute rule for a policy */ +export interface AttributeRuleOutput { + /** The kind of rule */ + readonly kind?: "decisionrule" | "attributerule"; + /** The id for rule */ + id?: string; + /** The name for rule */ + name?: string; + /** The dnf Condition for a rule */ + dnfCondition?: Array>; +} + +/** The collection reference for a policy */ +export interface CollectionReferenceOutput { + /** The type of reference */ + type?: string; + /** The name of reference */ + referenceName?: string; +} diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts index 0d80bfd1c06e..e06d305e58d0 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts @@ -1,8 +1,162 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; -import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings = PageSettings, + TLink = string, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator( + pagedResult, + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + (((settings?: PageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken as unknown as TLink | undefined, + }); + }) as unknown as ( + settings?: TPageSettings, + ) => AsyncIterableIterator), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + const firstVal = await pages.next(); + // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is + if (!Array.isArray(firstVal.value)) { + // can extract elements from this page + const { toElements } = pagedResult; + if (toElements) { + yield* toElements(firstVal.value) as TElement[]; + for await (const page of pages) { + yield* toElements(page) as TElement[]; + } + } else { + yield firstVal.value; + // `pages` is of type `AsyncIterableIterator` but TPage = TElement in this case + yield* pages as unknown as AsyncIterableIterator; + } + } else { + yield* firstVal.value; + for await (const page of pages) { + // pages is of type `AsyncIterableIterator` so `page` is of type `TPage`. In this branch, + // it must be the case that `TPage = TElement[]` + yield* page as unknown as TElement[]; + } + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: TLink; + } = {}, +): AsyncIterableIterator { + const { pageLink } = options; + let response = await pagedResult.getPage( + pageLink ?? pagedResult.firstPageLink, + ); + if (!response) { + return; + } + yield response.page; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + yield response.page; + } +} + +/** + * An interface that tracks the settings for paged iteration + */ +export interface PageSettings { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +} + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator; +} + +/** + * An interface that describes how to communicate with the service. + */ +interface PagedResult { + /** + * Link to the first page of results. + */ + firstPageLink: TLink; + /** + * A method that returns a page of results. + */ + getPage: ( + pageLink: TLink, + ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => unknown[]; +} /** * Helper type to extract the type of an array @@ -12,10 +166,7 @@ export type GetArrayType = T extends Array ? TData : never; /** * The type of a custom function that defines how to get a page and a link to the next one if any. */ -export type GetPage = ( - pageLink: string, - maxPageSize?: number, -) => Promise<{ +export type GetPage = (pageLink: string) => Promise<{ page: TPage; nextPageLink?: string; }>; @@ -73,7 +224,9 @@ export function paginate( typeof customGetPage === "function" ? customGetPage : async (pageLink: string) => { - const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); + const result = firstRun + ? initialResponse + : await client.pathUnchecked(pageLink).get(); firstRun = false; checkPagingRequest(result); const nextLink = getNextLink(result.body, nextLinkName); @@ -99,7 +252,9 @@ function getNextLink(body: unknown, nextLinkName?: string): string | undefined { const nextLink = (body as Record)[nextLinkName]; if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); + throw new Error( + `Body Property ${nextLinkName} should be a string or undefined`, + ); } return nextLink; @@ -127,7 +282,18 @@ function getElements(body: unknown, itemName: string): T[] { * Checks if a request failed */ function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; + const Http2xxStatusCodes = [ + "200", + "201", + "202", + "203", + "204", + "205", + "206", + "207", + "208", + "226", + ]; if (!Http2xxStatusCodes.includes(response.status)) { throw createRestError( `Pagination failed with unexpected statusCode ${response.status}`, @@ -150,7 +316,9 @@ function getPaginationProperties(initialResponse: PathUncheckedResponse) { let itemName: string | undefined; for (const name of nextLinkNames) { - const nextLink = (initialResponse.body as Record)[name] as string; + const nextLink = (initialResponse.body as Record)[ + name + ] as string; if (nextLink) { nextLinkName = name; break; @@ -158,7 +326,9 @@ function getPaginationProperties(initialResponse: PathUncheckedResponse) { } for (const name of itemNames) { - const item = (initialResponse.body as Record)[name] as string; + const item = (initialResponse.body as Record)[ + name + ] as string; if (item) { itemName = name; break; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts index eaa711e2b885..1b01d456c6c8 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts @@ -15,12 +15,21 @@ export interface MetadataPolicyListAllQueryParam { queryParameters?: MetadataPolicyListAllQueryParamProperties; } -export type MetadataPolicyListAllParameters = MetadataPolicyListAllQueryParam & RequestParameters; +export type MetadataPolicyListAllParameters = MetadataPolicyListAllQueryParam & + RequestParameters; export interface MetadataPolicyUpdateBodyParam { /** Policy to be updated. */ body?: MetadataPolicy; } -export type MetadataPolicyUpdateParameters = MetadataPolicyUpdateBodyParam & RequestParameters; +export interface MetadataPolicyUpdateMediaTypesParam { + /** Request content type */ + contentType?: "application/json"; +} + +export type MetadataPolicyUpdateParameters = + MetadataPolicyUpdateMediaTypesParam & + MetadataPolicyUpdateBodyParam & + RequestParameters; export type MetadataPolicyGetParameters = RequestParameters; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts index 3817cddc1e84..571f4f5cf433 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts @@ -2,22 +2,71 @@ // Licensed under the MIT License. import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { logger } from "../logger"; import { TokenCredential } from "@azure/core-auth"; -import { PurviewMetadataPoliciesRestClient } from "./clientDefinitions"; +import { PurviewMetadataPoliciesClient } from "./clientDefinitions"; -export function PurviewMetadataPoliciesClient( - Endpoint: string, +/** The optional parameters for the client */ +export interface PurviewMetadataPoliciesClientOptions extends ClientOptions { + /** The api version option of the client */ + apiVersion?: string; +} + +/** + * Initialize a new instance of `PurviewMetadataPoliciesClient` + * @param endpoint - The endpoint of your Purview account. Example: https://{accountName}.purview.azure.com. + * @param credentials - uniquely identify client credential + * @param options - the parameter for all optional parameters + */ +export function createClient( + endpoint: string, credentials: TokenCredential, - options: ClientOptions = {}, -): PurviewMetadataPoliciesRestClient { - const baseUrl = options.baseUrl ?? `${Endpoint}/policyStore`; - options.apiVersion = options.apiVersion ?? "2021-07-01-preview"; + { + apiVersion = "2021-07-01-preview", + ...options + }: PurviewMetadataPoliciesClientOptions = {}, +): PurviewMetadataPoliciesClient { + const endpointUrl = + options.endpoint ?? options.baseUrl ?? `${endpoint}/policyStore`; + const userAgentInfo = `azsdk-js-purview-administration-rest/1.0.0-beta.2`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + : `${userAgentInfo}`; options = { ...options, + userAgentOptions: { + userAgentPrefix, + }, + loggingOptions: { + logger: options.loggingOptions?.logger ?? logger.info, + }, credentials: { - scopes: ["https://purview.azure.net/.default"], + scopes: options.credentials?.scopes ?? ["user_impersonation"], }, }; + const client = getClient( + endpointUrl, + credentials, + options, + ) as PurviewMetadataPoliciesClient; + + client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + client.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version") && apiVersion) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); - return getClient(baseUrl, credentials, options) as PurviewMetadataPoliciesRestClient; + return client; } diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/responses.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/responses.ts index 3e0ac5fc685f..d818fe65bd2e 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/responses.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/responses.ts @@ -1,78 +1,83 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { HttpResponse } from "@azure-rest/core-client"; import { RawHttpHeaders } from "@azure/core-rest-pipeline"; -import { ErrorResponseModel, MetadataPolicy, MetadataPolicyList, MetadataRoleList } from "./models"; +import { HttpResponse } from "@azure-rest/core-client"; +import { + MetadataRoleListOutput, + ErrorResponseModelOutput, + MetadataPolicyListOutput, + MetadataPolicyOutput, +} from "./outputModels"; /** Lists roles for Purview Account */ export interface MetadataRolesList200Response extends HttpResponse { status: "200"; - body: MetadataRoleList; + body: MetadataRoleListOutput; } -export interface MetadataRolesListdefaultHeaders { +export interface MetadataRolesListDefaultHeaders { /** The error code */ "x-ms-error-code"?: string; } /** Lists roles for Purview Account */ -export interface MetadataRolesListdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; - headers: RawHttpHeaders & MetadataRolesListdefaultHeaders; +export interface MetadataRolesListDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; + headers: RawHttpHeaders & MetadataRolesListDefaultHeaders; } /** List or Get metadata policies */ export interface MetadataPolicyListAll200Response extends HttpResponse { status: "200"; - body: MetadataPolicyList; + body: MetadataPolicyListOutput; } -export interface MetadataPolicyListAlldefaultHeaders { +export interface MetadataPolicyListAllDefaultHeaders { /** The error code */ "x-ms-error-code"?: string; } /** List or Get metadata policies */ -export interface MetadataPolicyListAlldefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; - headers: RawHttpHeaders & MetadataPolicyListAlldefaultHeaders; +export interface MetadataPolicyListAllDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; + headers: RawHttpHeaders & MetadataPolicyListAllDefaultHeaders; } /** Updates a metadata policy */ export interface MetadataPolicyUpdate200Response extends HttpResponse { status: "200"; - body: MetadataPolicy; + body: MetadataPolicyOutput; } -export interface MetadataPolicyUpdatedefaultHeaders { +export interface MetadataPolicyUpdateDefaultHeaders { /** The error code */ "x-ms-error-code"?: string; } /** Updates a metadata policy */ -export interface MetadataPolicyUpdatedefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; - headers: RawHttpHeaders & MetadataPolicyUpdatedefaultHeaders; +export interface MetadataPolicyUpdateDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; + headers: RawHttpHeaders & MetadataPolicyUpdateDefaultHeaders; } /** Gets a metadata policy */ export interface MetadataPolicyGet200Response extends HttpResponse { status: "200"; - body: MetadataPolicy; + body: MetadataPolicyOutput; } -export interface MetadataPolicyGetdefaultHeaders { +export interface MetadataPolicyGetDefaultHeaders { /** The error code */ "x-ms-error-code"?: string; } /** Gets a metadata policy */ -export interface MetadataPolicyGetdefaultResponse extends HttpResponse { - status: "500"; - body: ErrorResponseModel; - headers: RawHttpHeaders & MetadataPolicyGetdefaultHeaders; +export interface MetadataPolicyGetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseModelOutput; + headers: RawHttpHeaders & MetadataPolicyGetDefaultHeaders; } diff --git a/sdk/purview/purview-administration-rest/swagger/README.md b/sdk/purview/purview-administration-rest/swagger/README.md index 10099375fe9a..3cd368039c63 100644 --- a/sdk/purview/purview-administration-rest/swagger/README.md +++ b/sdk/purview/purview-administration-rest/swagger/README.md @@ -7,21 +7,23 @@ ```yaml $(purview-account) == true title: PurviewAccount description: Purview Account Client -output-folder: ../src/account -source-code-folder-path: ./ +output-folder: ../ +source-code-folder-path: ./src/account input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/purview/data-plane/Azure.Analytics.Purview.Account/preview/2019-11-01-preview/account.json ``` ```yaml $(purview-metadata) == true title: PurviewMetadataPolicies description: Purview Metadata Policies Client -output-folder: ../src/metadataPolicies -source-code-folder-path: ./ +output-folder: ../ +source-code-folder-path: ./src/metadataPolicies input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/purview/data-plane/Azure.Analytics.Purview.MetadataPolicies/preview/2021-07-01-preview/purviewMetadataPolicy.json ``` ```yaml +flavor: azure +openapi-type: data-plane modelerfour.lenient-model-deduplication: true package-name: "@azure-rest/purview-administration" generate-metadata: false @@ -32,4 +34,7 @@ add-credentials: true credential-scopes: "https://purview.azure.net/.default" use-extension: "@autorest/typescript": "latest" +batch: + - purview-metadata: true + - purview-account: true ``` diff --git a/sdk/purview/purview-administration-rest/test/public/account.spec.ts b/sdk/purview/purview-administration-rest/test/public/account.spec.ts index 81a5057ade4a..968b5d4bfde8 100644 --- a/sdk/purview/purview-administration-rest/test/public/account.spec.ts +++ b/sdk/purview/purview-administration-rest/test/public/account.spec.ts @@ -9,7 +9,7 @@ import { Context } from "mocha"; describe("Get account info", () => { let recorder: Recorder; - let client: PurviewAccount.Client.PurviewAccountRestClient; + let client: PurviewAccount.Client.PurviewAccountClient; beforeEach(async function (this: Context) { recorder = new Recorder(this.currentTest); diff --git a/sdk/purview/purview-administration-rest/test/public/collections.spec.ts b/sdk/purview/purview-administration-rest/test/public/collections.spec.ts index 473e78db90f0..030be520882e 100644 --- a/sdk/purview/purview-administration-rest/test/public/collections.spec.ts +++ b/sdk/purview/purview-administration-rest/test/public/collections.spec.ts @@ -9,7 +9,7 @@ import { Context } from "mocha"; describe("List collections", () => { let recorder: Recorder; - let client: PurviewAccount.Client.PurviewAccountRestClient; + let client: PurviewAccount.Client.PurviewAccountClient; beforeEach(async function (this: Context) { recorder = new Recorder(this.currentTest); diff --git a/sdk/purview/purview-administration-rest/test/public/metadataPolicies.spec.ts b/sdk/purview/purview-administration-rest/test/public/metadataPolicies.spec.ts index 13ed79b37a9e..cf0233df1a75 100644 --- a/sdk/purview/purview-administration-rest/test/public/metadataPolicies.spec.ts +++ b/sdk/purview/purview-administration-rest/test/public/metadataPolicies.spec.ts @@ -6,10 +6,11 @@ import { Recorder } from "@azure-tools/test-recorder"; import { assert } from "chai"; import { createMetadataClient } from "./utils/recordedClient"; import { Context } from "mocha"; +import { MetadataPolicyListOutput } from "../../src/metadataPolicies/outputModels"; describe("List Metadata", () => { let recorder: Recorder; - let client: PurviewMetadataPolicies.Client.PurviewMetadataPoliciesRestClient; + let client: PurviewMetadataPolicies.Client.PurviewMetadataPoliciesClient; beforeEach(async function (this: Context) { recorder = new Recorder(this.currentTest); @@ -27,7 +28,7 @@ describe("List Metadata", () => { console.log(result.request.url); assert.fail(`GET "/metadataPolicies" failed with ${result.status}`); } - - assert.isDefined(result.body.values.length); + const metadataPolicyListOutput = result.body as MetadataPolicyListOutput; + assert.isDefined(metadataPolicyListOutput.values.length); }); }); diff --git a/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts b/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts index cfb0b13bcf2e..9421b4625cc0 100644 --- a/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts +++ b/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts @@ -6,9 +6,7 @@ import { env, Recorder, RecorderStartOptions } from "@azure-tools/test-recorder"; import { PurviewAccount, - PurviewAccountClient, PurviewMetadataPolicies, - PurviewMetadataPoliciesClient, } from "../../../src"; import { createTestCredential } from "@azure-tools/test-credential"; @@ -28,11 +26,11 @@ const recorderOptions: RecorderStartOptions = { export async function createAccountClient( recorder: Recorder, options?: ClientOptions, -): Promise { +): Promise { const credential = createTestCredential(); await recorder.start(recorderOptions); - return PurviewAccountClient( + return PurviewAccount.createClient( env.ENDPOINT ?? "", credential, recorder.configureClientOptions({ options }), @@ -42,11 +40,11 @@ export async function createAccountClient( export async function createMetadataClient( recorder: Recorder, options?: ClientOptions, -): Promise { +): Promise { const credential = createTestCredential(); await recorder.start(recorderOptions); - return PurviewMetadataPoliciesClient( + return PurviewMetadataPolicies.createClient( env.ENDPOINT ?? "", credential, recorder.configureClientOptions({ options }), From d7ce91bb037c9528882197c2017c620dd677c303 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:54:55 +0800 Subject: [PATCH 02/11] update --- .../{v1 => v1-beta}/javascript/README.md | 6 +++--- .../javascript/accountCollections.js | 10 ++++------ .../javascript/metadataPolicies.js | 19 +++++++++---------- .../{v1 => v1-beta}/javascript/package.json | 6 +++--- .../{v1 => v1-beta}/javascript/sample.env | 0 .../{v1 => v1-beta}/typescript/README.md | 6 +++--- .../{v1 => v1-beta}/typescript/package.json | 7 ++++--- .../{v1 => v1-beta}/typescript/sample.env | 0 .../typescript/src/accountCollections.ts | 6 +++--- .../typescript/src/metadataPolicies.ts | 13 ++++++++----- .../{v1 => v1-beta}/typescript/tsconfig.json | 2 +- 11 files changed, 38 insertions(+), 37 deletions(-) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/javascript/README.md (92%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/javascript/accountCollections.js (68%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/javascript/metadataPolicies.js (62%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/javascript/package.json (85%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/javascript/sample.env (100%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/typescript/README.md (93%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/typescript/package.json (85%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/typescript/sample.env (100%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/typescript/src/accountCollections.ts (73%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/typescript/src/metadataPolicies.ts (69%) rename sdk/purview/purview-administration-rest/samples/{v1 => v1-beta}/typescript/tsconfig.json (92%) diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/README.md b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/README.md similarity index 92% rename from sdk/purview/purview-administration-rest/samples/v1/javascript/README.md rename to sdk/purview/purview-administration-rest/samples/v1-beta/javascript/README.md index d6df472fdc97..b1a0f87316d4 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/javascript/README.md +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/README.md @@ -1,4 +1,4 @@ -# Azure Purview Administration rest client library samples for JavaScript +# Azure Purview Administration rest client library samples for JavaScript (Beta) These sample programs show how to use the JavaScript client libraries for Azure Purview Administration rest in some common scenarios. @@ -47,8 +47,8 @@ npx cross-env ENDPOINT="" node accountCollections.js Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[accountcollections]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1/javascript/accountCollections.js -[metadatapolicies]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1/javascript/metadataPolicies.js +[accountcollections]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/accountCollections.js +[metadatapolicies]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/metadataPolicies.js [apiref]: https://docs.microsoft.com/rest/api/purview/ [freesub]: https://azure.microsoft.com/free/ [createinstance_azurepurviewinstance]: https://docs.microsoft.com/azure/purview/create-catalog-portal diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/accountCollections.js b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/accountCollections.js similarity index 68% rename from sdk/purview/purview-administration-rest/samples/v1/javascript/accountCollections.js rename to sdk/purview/purview-administration-rest/samples/v1-beta/javascript/accountCollections.js index 07930953a026..9e380226f12b 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/javascript/accountCollections.js +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/accountCollections.js @@ -7,17 +7,15 @@ * @summary gets a list of collections */ -const { PurviewAccount, PurviewAccountClient } = require("@azure-rest/purview-administration"); +const { PurviewAccount } = require("@azure-rest/purview-administration"); const { DefaultAzureCredential } = require("@azure/identity"); -const dotenv = require("dotenv"); - -dotenv.config(); +require("dotenv").config(); const endpoint = process.env["ENDPOINT"] || ""; async function main() { console.log("== List collections sample =="); - const client = PurviewAccountClient(endpoint, new DefaultAzureCredential()); + const client = PurviewAccount.createClient(endpoint, new DefaultAzureCredential()); const response = await client.path("/collections").get(); @@ -25,7 +23,7 @@ async function main() { console.log(`GET "/collections" failed with ${response.status}`); } - const dataSources = PurviewAccount.Pagination.paginate(client, response); + const dataSources = PurviewAccount.PaginateHelper.paginate(client, response); for await (const dataSource of dataSources) { console.log(dataSource); diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/metadataPolicies.js b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/metadataPolicies.js similarity index 62% rename from sdk/purview/purview-administration-rest/samples/v1/javascript/metadataPolicies.js rename to sdk/purview/purview-administration-rest/samples/v1-beta/javascript/metadataPolicies.js index e62269f25754..f49dafdc1a4d 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/javascript/metadataPolicies.js +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/metadataPolicies.js @@ -7,20 +7,15 @@ * @summary gets a list of metadata policies */ -const { - PurviewMetadataPolicies, - PurviewMetadataPoliciesClient -} = require("@azure-rest/purview-administration"); +const { PurviewMetadataPolicies } = require("@azure-rest/purview-administration"); const { DefaultAzureCredential } = require("@azure/identity"); -const dotenv = require("dotenv"); - -dotenv.config(); +require("dotenv").config(); const endpoint = process.env["ENDPOINT"] || ""; async function main() { console.log("== List metadata policies sample =="); - const client = PurviewMetadataPoliciesClient(endpoint, new DefaultAzureCredential()); + const client = PurviewMetadataPolicies.createClient(endpoint, new DefaultAzureCredential()); const response = await client.path("/metadataPolicies").get(); @@ -30,10 +25,14 @@ async function main() { throw new Error(error); } - const policies = PurviewMetadataPolicies.Pagination.paginate(client, response); + const policies = PurviewMetadataPolicies.PaginateHelper.paginate(client, response); for await (const policy of policies) { - console.log(policy.name); + if (Array.isArray(policy)) { + console.error("Unexpected array:", policy); + } else { + console.log(policy.name); + } } } diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/package.json b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/package.json similarity index 85% rename from sdk/purview/purview-administration-rest/samples/v1/javascript/package.json rename to sdk/purview/purview-administration-rest/samples/v1-beta/javascript/package.json index ec791464ef1c..75429082d569 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/javascript/package.json +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/package.json @@ -1,8 +1,8 @@ { - "name": "@azure-samples/purview-administration-js", + "name": "@azure-samples/purview-administration-js-beta", "private": true, "version": "1.0.0", - "description": "Azure Purview Administration rest client library samples for JavaScript", + "description": "Azure Purview Administration rest client library samples for JavaScript (Beta)", "engines": { "node": ">=18.0.0" }, @@ -28,6 +28,6 @@ "dependencies": { "@azure-rest/purview-administration": "next", "dotenv": "latest", - "@azure/identity": "^4.2.1" + "@azure/identity": "^4.0.1" } } diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/sample.env b/sdk/purview/purview-administration-rest/samples/v1-beta/javascript/sample.env similarity index 100% rename from sdk/purview/purview-administration-rest/samples/v1/javascript/sample.env rename to sdk/purview/purview-administration-rest/samples/v1-beta/javascript/sample.env diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/README.md b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/README.md similarity index 93% rename from sdk/purview/purview-administration-rest/samples/v1/typescript/README.md rename to sdk/purview/purview-administration-rest/samples/v1-beta/typescript/README.md index 8ede1018d4f7..483bc0a9f2ab 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/typescript/README.md +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/README.md @@ -1,4 +1,4 @@ -# Azure Purview Administration rest client library samples for TypeScript +# Azure Purview Administration rest client library samples for TypeScript (Beta) These sample programs show how to use the TypeScript client libraries for Azure Purview Administration rest in some common scenarios. @@ -59,8 +59,8 @@ npx cross-env ENDPOINT="" node dist/accountCollections.js Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[accountcollections]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1/typescript/src/accountCollections.ts -[metadatapolicies]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1/typescript/src/metadataPolicies.ts +[accountcollections]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/src/accountCollections.ts +[metadatapolicies]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/src/metadataPolicies.ts [apiref]: https://docs.microsoft.com/rest/api/purview/ [freesub]: https://azure.microsoft.com/free/ [createinstance_azurepurviewinstance]: https://docs.microsoft.com/azure/purview/create-catalog-portal diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/package.json b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/package.json similarity index 85% rename from sdk/purview/purview-administration-rest/samples/v1/typescript/package.json rename to sdk/purview/purview-administration-rest/samples/v1-beta/typescript/package.json index 0ccca24da495..02c318dfc3b9 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/typescript/package.json +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/package.json @@ -1,8 +1,8 @@ { - "name": "@azure-samples/purview-administration-ts", + "name": "@azure-samples/purview-administration-ts-beta", "private": true, "version": "1.0.0", - "description": "Azure Purview Administration rest client library samples for TypeScript", + "description": "Azure Purview Administration rest client library samples for TypeScript (Beta)", "engines": { "node": ">=18.0.0" }, @@ -32,9 +32,10 @@ "dependencies": { "@azure-rest/purview-administration": "next", "dotenv": "latest", - "@azure/identity": "^4.2.1" + "@azure/identity": "^4.0.1" }, "devDependencies": { + "@types/node": "^18.0.0", "typescript": "~5.6.2", "rimraf": "latest" } diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/sample.env b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/sample.env similarity index 100% rename from sdk/purview/purview-administration-rest/samples/v1/typescript/sample.env rename to sdk/purview/purview-administration-rest/samples/v1-beta/typescript/sample.env diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/src/accountCollections.ts b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/src/accountCollections.ts similarity index 73% rename from sdk/purview/purview-administration-rest/samples/v1/typescript/src/accountCollections.ts rename to sdk/purview/purview-administration-rest/samples/v1-beta/typescript/src/accountCollections.ts index 61edc8573d3e..b930aeaed64b 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/typescript/src/accountCollections.ts +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/src/accountCollections.ts @@ -7,7 +7,7 @@ * @summary gets a list of collections */ -import { PurviewAccount, PurviewAccountClient } from "@azure-rest/purview-administration"; +import { PurviewAccount } from "@azure-rest/purview-administration"; import { DefaultAzureCredential } from "@azure/identity"; import dotenv from "dotenv"; @@ -17,7 +17,7 @@ const endpoint = process.env["ENDPOINT"] || ""; async function main() { console.log("== List collections sample =="); - const client = PurviewAccountClient(endpoint, new DefaultAzureCredential()); + const client = PurviewAccount.createClient(endpoint, new DefaultAzureCredential()); const response = await client.path("/collections").get(); @@ -25,7 +25,7 @@ async function main() { console.log(`GET "/collections" failed with ${response.status}`); } - const dataSources = PurviewAccount.Pagination.paginate(client, response); + const dataSources = PurviewAccount.PaginateHelper.paginate(client, response); for await (const dataSource of dataSources) { console.log(dataSource); diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/src/metadataPolicies.ts b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/src/metadataPolicies.ts similarity index 69% rename from sdk/purview/purview-administration-rest/samples/v1/typescript/src/metadataPolicies.ts rename to sdk/purview/purview-administration-rest/samples/v1-beta/typescript/src/metadataPolicies.ts index e5f89d5bad20..7a096641e3b2 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/typescript/src/metadataPolicies.ts +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/src/metadataPolicies.ts @@ -8,8 +8,7 @@ */ import { - PurviewMetadataPolicies, - PurviewMetadataPoliciesClient, + PurviewMetadataPolicies } from "@azure-rest/purview-administration"; import { DefaultAzureCredential } from "@azure/identity"; import dotenv from "dotenv"; @@ -20,7 +19,7 @@ const endpoint = process.env["ENDPOINT"] || ""; async function main() { console.log("== List metadata policies sample =="); - const client = PurviewMetadataPoliciesClient(endpoint, new DefaultAzureCredential()); + const client = PurviewMetadataPolicies.createClient(endpoint, new DefaultAzureCredential()); const response = await client.path("/metadataPolicies").get(); @@ -30,10 +29,14 @@ async function main() { throw new Error(error); } - const policies = PurviewMetadataPolicies.Pagination.paginate(client, response); + const policies = PurviewMetadataPolicies.PaginateHelper.paginate(client, response); for await (const policy of policies) { - console.log(policy.name); + if (Array.isArray(policy)) { + console.error('Unexpected array:', policy); + } else { + console.log(policy.name); + } } } diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/tsconfig.json b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/tsconfig.json similarity index 92% rename from sdk/purview/purview-administration-rest/samples/v1/typescript/tsconfig.json rename to sdk/purview/purview-administration-rest/samples/v1-beta/typescript/tsconfig.json index ad5ff9a19d36..984eed535aa8 100644 --- a/sdk/purview/purview-administration-rest/samples/v1/typescript/tsconfig.json +++ b/sdk/purview/purview-administration-rest/samples/v1-beta/typescript/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2018", + "target": "ES2020", "module": "commonjs", "moduleResolution": "node", "resolveJsonModule": true, From ee54ef3cf2e2a1266b1063b463aa44f6855a67d6 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:55:54 +0800 Subject: [PATCH 03/11] Update CHANGELOG.md --- sdk/purview/purview-administration-rest/CHANGELOG.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sdk/purview/purview-administration-rest/CHANGELOG.md b/sdk/purview/purview-administration-rest/CHANGELOG.md index d3cc776e34b6..e98fd452f7fb 100644 --- a/sdk/purview/purview-administration-rest/CHANGELOG.md +++ b/sdk/purview/purview-administration-rest/CHANGELOG.md @@ -1,12 +1,9 @@ # Release History -## 1.0.0-beta.2 (Unreleased) +## 1.0.0-beta.2 (2024-09-30) ### Features Added - -### Breaking Changes - -### Bugs Fixed +- refresh @azure-rest/purview-administration sdk ### Other Changes From ab36704da4fe44c80a731da6ffb435004c8b606f Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:39:28 +0800 Subject: [PATCH 04/11] lint fix --- .../src/account/purviewAccount.ts | 7 +++---- .../src/metadataPolicies/purviewMetadataPolicies.ts | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts index a6582bb71bbc..99826e62024d 100644 --- a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts +++ b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts @@ -14,7 +14,7 @@ export interface PurviewAccountClientOptions extends ClientOptions { /** * Initialize a new instance of `PurviewAccountClient` - * @param endpoint - The account endpoint of your Purview account. Example: https://{accountName}.purview.azure.com/account/ + * @param endpoint - The account endpoint of your Purview account. Example: https://\{accountName\}.purview.azure.com/account/ * @param credentials - uniquely identify client credential * @param options - the parameter for all optional parameters */ @@ -58,9 +58,8 @@ export function createClient( // Append one if there is no apiVersion and we have one at client options const url = new URL(req.url); if (!url.searchParams.get("api-version") && apiVersion) { - req.url = `${req.url}${ - Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" - }api-version=${apiVersion}`; + req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; } return next(req); diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts index 571f4f5cf433..b9792abf6cee 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts @@ -14,7 +14,7 @@ export interface PurviewMetadataPoliciesClientOptions extends ClientOptions { /** * Initialize a new instance of `PurviewMetadataPoliciesClient` - * @param endpoint - The endpoint of your Purview account. Example: https://{accountName}.purview.azure.com. + * @param endpoint - The endpoint of your Purview account. Example: https://\{accountName\}.purview.azure.com. * @param credentials - uniquely identify client credential * @param options - the parameter for all optional parameters */ @@ -59,9 +59,8 @@ export function createClient( // Append one if there is no apiVersion and we have one at client options const url = new URL(req.url); if (!url.searchParams.get("api-version") && apiVersion) { - req.url = `${req.url}${ - Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" - }api-version=${apiVersion}`; + req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; } return next(req); From d43f12bb26d52c530fa1eaebddf6e4c5bc2ee4a2 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:10:54 +0800 Subject: [PATCH 05/11] format --- .../samples-dev/metadataPolicies.ts | 6 +- .../src/account/clientDefinitions.ts | 30 +++------- .../src/account/index.ts | 10 +--- .../src/account/isUnexpected.ts | 45 ++++---------- .../src/account/outputModels.ts | 12 +--- .../src/account/paginateHelper.ts | 49 +++------------ .../src/account/parameters.ts | 11 ++-- .../src/account/purviewAccount.ts | 16 ++--- .../src/account/responses.ts | 60 +++++++------------ .../src/metadataPolicies/clientDefinitions.ts | 21 ++----- .../src/metadataPolicies/index.ts | 15 +---- .../src/metadataPolicies/isUnexpected.ts | 25 +++----- .../src/metadataPolicies/paginateHelper.ts | 57 ++++-------------- .../src/metadataPolicies/parameters.ts | 10 ++-- .../purviewMetadataPolicies.ts | 19 ++---- .../test/public/utils/recordedClient.ts | 5 +- 16 files changed, 102 insertions(+), 289 deletions(-) diff --git a/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts b/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts index 13bf71f163a9..587797903b87 100644 --- a/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts +++ b/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts @@ -8,9 +8,7 @@ * @azsdk-weight 40 */ -import { - PurviewMetadataPolicies -} from "@azure-rest/purview-administration"; +import { PurviewMetadataPolicies } from "@azure-rest/purview-administration"; import { DefaultAzureCredential } from "@azure/identity"; import dotenv from "dotenv"; @@ -34,7 +32,7 @@ async function main() { for await (const policy of policies) { if (Array.isArray(policy)) { - console.error('Unexpected array:', policy); + console.error("Unexpected array:", policy); } else { console.log(policy.name); } diff --git a/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts b/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts index f4b586742a66..c96ba3447ee0 100644 --- a/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts +++ b/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts @@ -55,15 +55,13 @@ export interface AccountsGetAccountProperties { get( options?: AccountsGetAccountPropertiesParameters, ): StreamableMethod< - | AccountsGetAccountProperties200Response - | AccountsGetAccountPropertiesDefaultResponse + AccountsGetAccountProperties200Response | AccountsGetAccountPropertiesDefaultResponse >; /** Updates an account */ patch( options: AccountsUpdateAccountPropertiesParameters, ): StreamableMethod< - | AccountsUpdateAccountProperties200Response - | AccountsUpdateAccountPropertiesDefaultResponse + AccountsUpdateAccountProperties200Response | AccountsUpdateAccountPropertiesDefaultResponse >; } @@ -71,9 +69,7 @@ export interface AccountsGetAccessKeys { /** List the authorization keys associated with this account. */ post( options?: AccountsGetAccessKeysParameters, - ): StreamableMethod< - AccountsGetAccessKeys200Response | AccountsGetAccessKeysDefaultResponse - >; + ): StreamableMethod; } export interface AccountsRegenerateAccessKey { @@ -81,8 +77,7 @@ export interface AccountsRegenerateAccessKey { post( options: AccountsRegenerateAccessKeyParameters, ): StreamableMethod< - | AccountsRegenerateAccessKey200Response - | AccountsRegenerateAccessKeyDefaultResponse + AccountsRegenerateAccessKey200Response | AccountsRegenerateAccessKeyDefaultResponse >; } @@ -91,8 +86,7 @@ export interface CollectionsGetCollection { get( options?: CollectionsGetCollectionParameters, ): StreamableMethod< - | CollectionsGetCollection200Response - | CollectionsGetCollectionDefaultResponse + CollectionsGetCollection200Response | CollectionsGetCollectionDefaultResponse >; /** Creates or updates a collection entity. */ put( @@ -105,8 +99,7 @@ export interface CollectionsGetCollection { delete( options?: CollectionsDeleteCollectionParameters, ): StreamableMethod< - | CollectionsDeleteCollection204Response - | CollectionsDeleteCollectionDefaultResponse + CollectionsDeleteCollection204Response | CollectionsDeleteCollectionDefaultResponse >; } @@ -115,8 +108,7 @@ export interface CollectionsListCollections { get( options?: CollectionsListCollectionsParameters, ): StreamableMethod< - | CollectionsListCollections200Response - | CollectionsListCollectionsDefaultResponse + CollectionsListCollections200Response | CollectionsListCollectionsDefaultResponse >; } @@ -135,8 +127,7 @@ export interface CollectionsGetCollectionPath { get( options?: CollectionsGetCollectionPathParameters, ): StreamableMethod< - | CollectionsGetCollectionPath200Response - | CollectionsGetCollectionPathDefaultResponse + CollectionsGetCollectionPath200Response | CollectionsGetCollectionPathDefaultResponse >; } @@ -183,10 +174,7 @@ export interface Routes { /** Resource for '/regeneratekeys' has methods for the following verbs: post */ (path: "/regeneratekeys"): AccountsRegenerateAccessKey; /** Resource for '/collections/\{collectionName\}' has methods for the following verbs: get, put, delete */ - ( - path: "/collections/{collectionName}", - collectionName: string, - ): CollectionsGetCollection; + (path: "/collections/{collectionName}", collectionName: string): CollectionsGetCollection; /** Resource for '/collections' has methods for the following verbs: get */ (path: "/collections"): CollectionsListCollections; /** Resource for '/collections/\{collectionName\}/getChildCollectionNames' has methods for the following verbs: get */ diff --git a/sdk/purview/purview-administration-rest/src/account/index.ts b/sdk/purview/purview-administration-rest/src/account/index.ts index 2d57ad2deade..31bfbe82ef65 100644 --- a/sdk/purview/purview-administration-rest/src/account/index.ts +++ b/sdk/purview/purview-administration-rest/src/account/index.ts @@ -10,12 +10,4 @@ import * as PaginateHelper from "./paginateHelper"; import * as UnexpectedHelper from "./isUnexpected"; export { createClient, PurviewAccountClientOptions } from "./purviewAccount"; -export { - Parameters, - Responses, - Client, - Models, - OutputModels, - PaginateHelper, - UnexpectedHelper, -}; +export { Parameters, Responses, Client, Models, OutputModels, PaginateHelper, UnexpectedHelper }; diff --git a/sdk/purview/purview-administration-rest/src/account/isUnexpected.ts b/sdk/purview/purview-administration-rest/src/account/isUnexpected.ts index 086e2d5dcf63..774b2a99649b 100644 --- a/sdk/purview/purview-administration-rest/src/account/isUnexpected.ts +++ b/sdk/purview/purview-administration-rest/src/account/isUnexpected.ts @@ -51,9 +51,7 @@ const responseMap: Record = { }; export function isUnexpected( - response: - | AccountsGetAccountProperties200Response - | AccountsGetAccountPropertiesDefaultResponse, + response: AccountsGetAccountProperties200Response | AccountsGetAccountPropertiesDefaultResponse, ): response is AccountsGetAccountPropertiesDefaultResponse; export function isUnexpected( response: @@ -61,19 +59,13 @@ export function isUnexpected( | AccountsUpdateAccountPropertiesDefaultResponse, ): response is AccountsUpdateAccountPropertiesDefaultResponse; export function isUnexpected( - response: - | AccountsGetAccessKeys200Response - | AccountsGetAccessKeysDefaultResponse, + response: AccountsGetAccessKeys200Response | AccountsGetAccessKeysDefaultResponse, ): response is AccountsGetAccessKeysDefaultResponse; export function isUnexpected( - response: - | AccountsRegenerateAccessKey200Response - | AccountsRegenerateAccessKeyDefaultResponse, + response: AccountsRegenerateAccessKey200Response | AccountsRegenerateAccessKeyDefaultResponse, ): response is AccountsRegenerateAccessKeyDefaultResponse; export function isUnexpected( - response: - | CollectionsGetCollection200Response - | CollectionsGetCollectionDefaultResponse, + response: CollectionsGetCollection200Response | CollectionsGetCollectionDefaultResponse, ): response is CollectionsGetCollectionDefaultResponse; export function isUnexpected( response: @@ -81,14 +73,10 @@ export function isUnexpected( | CollectionsCreateOrUpdateCollectionDefaultResponse, ): response is CollectionsCreateOrUpdateCollectionDefaultResponse; export function isUnexpected( - response: - | CollectionsDeleteCollection204Response - | CollectionsDeleteCollectionDefaultResponse, + response: CollectionsDeleteCollection204Response | CollectionsDeleteCollectionDefaultResponse, ): response is CollectionsDeleteCollectionDefaultResponse; export function isUnexpected( - response: - | CollectionsListCollections200Response - | CollectionsListCollectionsDefaultResponse, + response: CollectionsListCollections200Response | CollectionsListCollectionsDefaultResponse, ): response is CollectionsListCollectionsDefaultResponse; export function isUnexpected( response: @@ -96,9 +84,7 @@ export function isUnexpected( | CollectionsListChildCollectionNamesDefaultResponse, ): response is CollectionsListChildCollectionNamesDefaultResponse; export function isUnexpected( - response: - | CollectionsGetCollectionPath200Response - | CollectionsGetCollectionPathDefaultResponse, + response: CollectionsGetCollectionPath200Response | CollectionsGetCollectionPathDefaultResponse, ): response is CollectionsGetCollectionPathDefaultResponse; export function isUnexpected( response: @@ -199,24 +185,17 @@ function getParametrizedPathSuccess(method: string, path: string): string[] { // track if we have found a match to return the values found. let found = true; - for ( - let i = candidateParts.length - 1, j = pathParts.length - 1; - i >= 1 && j >= 1; - i--, j-- - ) { - if ( - candidateParts[i]?.startsWith("{") && - candidateParts[i]?.indexOf("}") !== -1 - ) { + for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { + if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { const start = candidateParts[i]!.indexOf("}") + 1, end = candidateParts[i]?.length; // If the current part of the candidate is a "template" part // Try to use the suffix of pattern to match the path // {guid} ==> $ // {guid}:export ==> :export$ - const isMatched = new RegExp( - `${candidateParts[i]?.slice(start, end)}`, - ).test(pathParts[j] || ""); + const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test( + pathParts[j] || "", + ); if (!isMatched) { found = false; diff --git a/sdk/purview/purview-administration-rest/src/account/outputModels.ts b/sdk/purview/purview-administration-rest/src/account/outputModels.ts index 4d56902e89ae..7be2b8167214 100644 --- a/sdk/purview/purview-administration-rest/src/account/outputModels.ts +++ b/sdk/purview/purview-administration-rest/src/account/outputModels.ts @@ -80,8 +80,7 @@ export interface CloudConnectorsOutput { } /** The URIs that are the public endpoints of the account. */ -export interface AccountPropertiesEndpointsOutput - extends AccountEndpointsOutput {} +export interface AccountPropertiesEndpointsOutput extends AccountEndpointsOutput {} /** The account endpoints */ export interface AccountEndpointsOutput { @@ -94,8 +93,7 @@ export interface AccountEndpointsOutput { } /** Gets the resource identifiers of the managed resources. */ -export interface AccountPropertiesManagedResourcesOutput - extends ManagedResourcesOutput {} +export interface AccountPropertiesManagedResourcesOutput extends ManagedResourcesOutput {} /** The managed resources in customer subscription. */ export interface ManagedResourcesOutput { @@ -169,11 +167,7 @@ export interface SystemDataOutput { /** The identity that last modified the resource. */ readonly lastModifiedBy?: string; /** The type of identity that last modified the resource. */ - readonly lastModifiedByType?: - | "User" - | "Application" - | "ManagedIdentity" - | "Key"; + readonly lastModifiedByType?: "User" | "Application" | "ManagedIdentity" | "Key"; } /** Default error response model */ diff --git a/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts b/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts index 5ef95e5ea0a3..a5ee77d86caf 100644 --- a/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts +++ b/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts @@ -1,11 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { - Client, - createRestError, - PathUncheckedResponse, -} from "@azure-rest/core-client"; +import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; /** * returns an async iterator that iterates over results. It also has a `byPage` @@ -22,9 +18,7 @@ function getPagedAsyncIterator< >( pagedResult: PagedResult, ): PagedAsyncIterableIterator { - const iter = getItemAsyncIterator( - pagedResult, - ); + const iter = getItemAsyncIterator(pagedResult); return { next() { return iter.next(); @@ -39,9 +33,7 @@ function getPagedAsyncIterator< return getPageAsyncIterator(pagedResult, { pageLink: continuationToken as unknown as TLink | undefined, }); - }) as unknown as ( - settings?: TPageSettings, - ) => AsyncIterableIterator), + }) as unknown as (settings?: TPageSettings) => AsyncIterableIterator), }; } @@ -81,9 +73,7 @@ async function* getPageAsyncIterator( } = {}, ): AsyncIterableIterator { const { pageLink } = options; - let response = await pagedResult.getPage( - pageLink ?? pagedResult.firstPageLink, - ); + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); if (!response) { return; } @@ -122,11 +112,7 @@ export interface PagedAsyncIterableIterator< /** * The connection to the async iterator, part of the iteration protocol */ - [Symbol.asyncIterator](): PagedAsyncIterableIterator< - TElement, - TPage, - TPageSettings - >; + [Symbol.asyncIterator](): PagedAsyncIterableIterator; /** * Return an AsyncIterableIterator that works a page at a time */ @@ -144,9 +130,7 @@ interface PagedResult { /** * A method that returns a page of results. */ - getPage: ( - pageLink: TLink, - ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; + getPage: (pageLink: TLink) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; /** * a function to implement the `byPage` method on the paged async iterator. */ @@ -218,9 +202,7 @@ export function paginate( typeof customGetPage === "function" ? customGetPage : async (pageLink: string) => { - const result = firstRun - ? initialResponse - : await client.pathUnchecked(pageLink).get(); + const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); firstRun = false; checkPagingRequest(result); const nextLink = getNextLink(result.body, nextLinkName); @@ -246,9 +228,7 @@ function getNextLink(body: unknown, nextLinkName?: string): string | undefined { const nextLink = (body as Record)[nextLinkName]; if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error( - `Body Property ${nextLinkName} should be a string or undefined`, - ); + throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); } return nextLink; @@ -276,18 +256,7 @@ function getElements(body: unknown, itemName: string): T[] { * Checks if a request failed */ function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = [ - "200", - "201", - "202", - "203", - "204", - "205", - "206", - "207", - "208", - "226", - ]; + const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; if (!Http2xxStatusCodes.includes(response.status)) { throw createRestError( `Pagination failed with unexpected statusCode ${response.status}`, diff --git a/sdk/purview/purview-administration-rest/src/account/parameters.ts b/sdk/purview/purview-administration-rest/src/account/parameters.ts index 414caa30ba5e..609123872a34 100644 --- a/sdk/purview/purview-administration-rest/src/account/parameters.ts +++ b/sdk/purview/purview-administration-rest/src/account/parameters.ts @@ -35,10 +35,9 @@ export interface AccountsRegenerateAccessKeyMediaTypesParam { contentType?: "application/json"; } -export type AccountsRegenerateAccessKeyParameters = - AccountsRegenerateAccessKeyMediaTypesParam & - AccountsRegenerateAccessKeyBodyParam & - RequestParameters; +export type AccountsRegenerateAccessKeyParameters = AccountsRegenerateAccessKeyMediaTypesParam & + AccountsRegenerateAccessKeyBodyParam & + RequestParameters; export type CollectionsGetCollectionParameters = RequestParameters; export interface CollectionsCreateOrUpdateCollectionBodyParam { @@ -64,8 +63,8 @@ export interface CollectionsListCollectionsQueryParam { queryParameters?: CollectionsListCollectionsQueryParamProperties; } -export type CollectionsListCollectionsParameters = - CollectionsListCollectionsQueryParam & RequestParameters; +export type CollectionsListCollectionsParameters = CollectionsListCollectionsQueryParam & + RequestParameters; export interface CollectionsListChildCollectionNamesQueryParamProperties { $skipToken?: string; diff --git a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts index 99826e62024d..59e758d0c35b 100644 --- a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts +++ b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts @@ -21,10 +21,7 @@ export interface PurviewAccountClientOptions extends ClientOptions { export function createClient( endpoint: string, credentials: TokenCredential, - { - apiVersion = "2019-11-01-preview", - ...options - }: PurviewAccountClientOptions = {}, + { apiVersion = "2019-11-01-preview", ...options }: PurviewAccountClientOptions = {}, ): PurviewAccountClient { const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpoint}`; const userAgentInfo = `azsdk-js-purview-administration-rest/1.0.0-beta.2`; @@ -44,11 +41,7 @@ export function createClient( scopes: options.credentials?.scopes ?? ["user_impersonation"], }, }; - const client = getClient( - endpointUrl, - credentials, - options, - ) as PurviewAccountClient; + const client = getClient(endpointUrl, credentials, options) as PurviewAccountClient; client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); client.pipeline.addPolicy({ @@ -58,8 +51,9 @@ export function createClient( // Append one if there is no apiVersion and we have one at client options const url = new URL(req.url); if (!url.searchParams.get("api-version") && apiVersion) { - req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" - }api-version=${apiVersion}`; + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; } return next(req); diff --git a/sdk/purview/purview-administration-rest/src/account/responses.ts b/sdk/purview/purview-administration-rest/src/account/responses.ts index 8da34f68acb5..c09aa719a8d5 100644 --- a/sdk/purview/purview-administration-rest/src/account/responses.ts +++ b/sdk/purview/purview-administration-rest/src/account/responses.ts @@ -21,22 +21,19 @@ export interface AccountsGetAccountProperties200Response extends HttpResponse { } /** Get an account */ -export interface AccountsGetAccountPropertiesDefaultResponse - extends HttpResponse { +export interface AccountsGetAccountPropertiesDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } /** Updates an account */ -export interface AccountsUpdateAccountProperties200Response - extends HttpResponse { +export interface AccountsUpdateAccountProperties200Response extends HttpResponse { status: "200"; body: AccountOutput; } /** Updates an account */ -export interface AccountsUpdateAccountPropertiesDefaultResponse - extends HttpResponse { +export interface AccountsUpdateAccountPropertiesDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } @@ -60,8 +57,7 @@ export interface AccountsRegenerateAccessKey200Response extends HttpResponse { } /** Regenerate the authorization keys associated with this data catalog. */ -export interface AccountsRegenerateAccessKeyDefaultResponse - extends HttpResponse { +export interface AccountsRegenerateAccessKeyDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } @@ -79,15 +75,13 @@ export interface CollectionsGetCollectionDefaultResponse extends HttpResponse { } /** Creates or updates a collection entity. */ -export interface CollectionsCreateOrUpdateCollection200Response - extends HttpResponse { +export interface CollectionsCreateOrUpdateCollection200Response extends HttpResponse { status: "200"; body: CollectionOutput; } /** Creates or updates a collection entity. */ -export interface CollectionsCreateOrUpdateCollectionDefaultResponse - extends HttpResponse { +export interface CollectionsCreateOrUpdateCollectionDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } @@ -98,8 +92,7 @@ export interface CollectionsDeleteCollection204Response extends HttpResponse { } /** Deletes a Collection entity. */ -export interface CollectionsDeleteCollectionDefaultResponse - extends HttpResponse { +export interface CollectionsDeleteCollectionDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } @@ -111,22 +104,19 @@ export interface CollectionsListCollections200Response extends HttpResponse { } /** List the collections in the account. */ -export interface CollectionsListCollectionsDefaultResponse - extends HttpResponse { +export interface CollectionsListCollectionsDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } /** Lists the child collections names in the collection. */ -export interface CollectionsListChildCollectionNames200Response - extends HttpResponse { +export interface CollectionsListChildCollectionNames200Response extends HttpResponse { status: "200"; body: CollectionNameResponseListOutput; } /** Lists the child collections names in the collection. */ -export interface CollectionsListChildCollectionNamesDefaultResponse - extends HttpResponse { +export interface CollectionsListChildCollectionNamesDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } @@ -138,69 +128,59 @@ export interface CollectionsGetCollectionPath200Response extends HttpResponse { } /** Gets the parent name and parent friendly name chains that represent the collection path. */ -export interface CollectionsGetCollectionPathDefaultResponse - extends HttpResponse { +export interface CollectionsGetCollectionPathDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } /** Get a resource set config service model. */ -export interface ResourceSetRulesGetResourceSetRule200Response - extends HttpResponse { +export interface ResourceSetRulesGetResourceSetRule200Response extends HttpResponse { status: "200"; body: ResourceSetRuleConfigOutput; } /** Get a resource set config service model. */ -export interface ResourceSetRulesGetResourceSetRuleDefaultResponse - extends HttpResponse { +export interface ResourceSetRulesGetResourceSetRuleDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } /** Creates or updates an resource set config. */ -export interface ResourceSetRulesCreateOrUpdateResourceSetRule200Response - extends HttpResponse { +export interface ResourceSetRulesCreateOrUpdateResourceSetRule200Response extends HttpResponse { status: "200"; body: ResourceSetRuleConfigOutput; } /** Creates or updates an resource set config. */ -export interface ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse - extends HttpResponse { +export interface ResourceSetRulesCreateOrUpdateResourceSetRuleDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } /** Deletes a ResourceSetRuleConfig resource. */ -export interface ResourceSetRulesDeleteResourceSetRule200Response - extends HttpResponse { +export interface ResourceSetRulesDeleteResourceSetRule200Response extends HttpResponse { status: "200"; } /** Deletes a ResourceSetRuleConfig resource. */ -export interface ResourceSetRulesDeleteResourceSetRule204Response - extends HttpResponse { +export interface ResourceSetRulesDeleteResourceSetRule204Response extends HttpResponse { status: "204"; } /** Deletes a ResourceSetRuleConfig resource. */ -export interface ResourceSetRulesDeleteResourceSetRuleDefaultResponse - extends HttpResponse { +export interface ResourceSetRulesDeleteResourceSetRuleDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } /** Get a resource set config service model. */ -export interface ResourceSetRulesListResourceSetRules200Response - extends HttpResponse { +export interface ResourceSetRulesListResourceSetRules200Response extends HttpResponse { status: "200"; body: ResourceSetRuleConfigListOutput; } /** Get a resource set config service model. */ -export interface ResourceSetRulesListResourceSetRulesDefaultResponse - extends HttpResponse { +export interface ResourceSetRulesListResourceSetRulesDefaultResponse extends HttpResponse { status: string; body: ErrorResponseModelOutput; } diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts index ed1f92636474..9db75a6a37c7 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts @@ -23,33 +23,25 @@ export interface MetadataRolesList { /** Lists roles for Purview Account */ get( options?: MetadataRolesListParameters, - ): StreamableMethod< - MetadataRolesList200Response | MetadataRolesListDefaultResponse - >; + ): StreamableMethod; } export interface MetadataPolicyListAll { /** List or Get metadata policies */ get( options?: MetadataPolicyListAllParameters, - ): StreamableMethod< - MetadataPolicyListAll200Response | MetadataPolicyListAllDefaultResponse - >; + ): StreamableMethod; } export interface MetadataPolicyUpdate { /** Updates a metadata policy */ put( options?: MetadataPolicyUpdateParameters, - ): StreamableMethod< - MetadataPolicyUpdate200Response | MetadataPolicyUpdateDefaultResponse - >; + ): StreamableMethod; /** Gets a metadata policy */ get( options?: MetadataPolicyGetParameters, - ): StreamableMethod< - MetadataPolicyGet200Response | MetadataPolicyGetDefaultResponse - >; + ): StreamableMethod; } export interface Routes { @@ -58,10 +50,7 @@ export interface Routes { /** Resource for '/metadataPolicies' has methods for the following verbs: get */ (path: "/metadataPolicies"): MetadataPolicyListAll; /** Resource for '/metadataPolicies/\{policyId\}' has methods for the following verbs: put, get */ - ( - path: "/metadataPolicies/{policyId}", - policyId: string, - ): MetadataPolicyUpdate; + (path: "/metadataPolicies/{policyId}", policyId: string): MetadataPolicyUpdate; } export type PurviewMetadataPoliciesClient = Client & { diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts index e331601d86a8..302def64a01c 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts @@ -9,16 +9,5 @@ import * as OutputModels from "./outputModels"; import * as PaginateHelper from "./paginateHelper"; import * as UnexpectedHelper from "./isUnexpected"; -export { - createClient, - PurviewMetadataPoliciesClientOptions, -} from "./purviewMetadataPolicies"; -export { - Parameters, - Responses, - Client, - Models, - OutputModels, - PaginateHelper, - UnexpectedHelper, -}; +export { createClient, PurviewMetadataPoliciesClientOptions } from "./purviewMetadataPolicies"; +export { Parameters, Responses, Client, Models, OutputModels, PaginateHelper, UnexpectedHelper }; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/isUnexpected.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/isUnexpected.ts index 918a7a7b376d..ef196ee7622f 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/isUnexpected.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/isUnexpected.ts @@ -23,14 +23,10 @@ export function isUnexpected( response: MetadataRolesList200Response | MetadataRolesListDefaultResponse, ): response is MetadataRolesListDefaultResponse; export function isUnexpected( - response: - | MetadataPolicyListAll200Response - | MetadataPolicyListAllDefaultResponse, + response: MetadataPolicyListAll200Response | MetadataPolicyListAllDefaultResponse, ): response is MetadataPolicyListAllDefaultResponse; export function isUnexpected( - response: - | MetadataPolicyUpdate200Response - | MetadataPolicyUpdateDefaultResponse, + response: MetadataPolicyUpdate200Response | MetadataPolicyUpdateDefaultResponse, ): response is MetadataPolicyUpdateDefaultResponse; export function isUnexpected( response: MetadataPolicyGet200Response | MetadataPolicyGetDefaultResponse, @@ -82,24 +78,17 @@ function getParametrizedPathSuccess(method: string, path: string): string[] { // track if we have found a match to return the values found. let found = true; - for ( - let i = candidateParts.length - 1, j = pathParts.length - 1; - i >= 1 && j >= 1; - i--, j-- - ) { - if ( - candidateParts[i]?.startsWith("{") && - candidateParts[i]?.indexOf("}") !== -1 - ) { + for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { + if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { const start = candidateParts[i]!.indexOf("}") + 1, end = candidateParts[i]?.length; // If the current part of the candidate is a "template" part // Try to use the suffix of pattern to match the path // {guid} ==> $ // {guid}:export ==> :export$ - const isMatched = new RegExp( - `${candidateParts[i]?.slice(start, end)}`, - ).test(pathParts[j] || ""); + const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test( + pathParts[j] || "", + ); if (!isMatched) { found = false; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts index e06d305e58d0..a5795af011f7 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts @@ -1,11 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { - Client, - createRestError, - PathUncheckedResponse, -} from "@azure-rest/core-client"; +import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; /** * returns an async iterator that iterates over results. It also has a `byPage` @@ -22,9 +18,7 @@ function getPagedAsyncIterator< >( pagedResult: PagedResult, ): PagedAsyncIterableIterator { - const iter = getItemAsyncIterator( - pagedResult, - ); + const iter = getItemAsyncIterator(pagedResult); return { next() { return iter.next(); @@ -39,9 +33,7 @@ function getPagedAsyncIterator< return getPageAsyncIterator(pagedResult, { pageLink: continuationToken as unknown as TLink | undefined, }); - }) as unknown as ( - settings?: TPageSettings, - ) => AsyncIterableIterator), + }) as unknown as (settings?: TPageSettings) => AsyncIterableIterator), }; } @@ -81,9 +73,7 @@ async function* getPageAsyncIterator( } = {}, ): AsyncIterableIterator { const { pageLink } = options; - let response = await pagedResult.getPage( - pageLink ?? pagedResult.firstPageLink, - ); + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); if (!response) { return; } @@ -122,11 +112,7 @@ export interface PagedAsyncIterableIterator< /** * The connection to the async iterator, part of the iteration protocol */ - [Symbol.asyncIterator](): PagedAsyncIterableIterator< - TElement, - TPage, - TPageSettings - >; + [Symbol.asyncIterator](): PagedAsyncIterableIterator; /** * Return an AsyncIterableIterator that works a page at a time */ @@ -144,9 +130,7 @@ interface PagedResult { /** * A method that returns a page of results. */ - getPage: ( - pageLink: TLink, - ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; + getPage: (pageLink: TLink) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; /** * a function to implement the `byPage` method on the paged async iterator. */ @@ -224,9 +208,7 @@ export function paginate( typeof customGetPage === "function" ? customGetPage : async (pageLink: string) => { - const result = firstRun - ? initialResponse - : await client.pathUnchecked(pageLink).get(); + const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); firstRun = false; checkPagingRequest(result); const nextLink = getNextLink(result.body, nextLinkName); @@ -252,9 +234,7 @@ function getNextLink(body: unknown, nextLinkName?: string): string | undefined { const nextLink = (body as Record)[nextLinkName]; if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error( - `Body Property ${nextLinkName} should be a string or undefined`, - ); + throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); } return nextLink; @@ -282,18 +262,7 @@ function getElements(body: unknown, itemName: string): T[] { * Checks if a request failed */ function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = [ - "200", - "201", - "202", - "203", - "204", - "205", - "206", - "207", - "208", - "226", - ]; + const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; if (!Http2xxStatusCodes.includes(response.status)) { throw createRestError( `Pagination failed with unexpected statusCode ${response.status}`, @@ -316,9 +285,7 @@ function getPaginationProperties(initialResponse: PathUncheckedResponse) { let itemName: string | undefined; for (const name of nextLinkNames) { - const nextLink = (initialResponse.body as Record)[ - name - ] as string; + const nextLink = (initialResponse.body as Record)[name] as string; if (nextLink) { nextLinkName = name; break; @@ -326,9 +293,7 @@ function getPaginationProperties(initialResponse: PathUncheckedResponse) { } for (const name of itemNames) { - const item = (initialResponse.body as Record)[ - name - ] as string; + const item = (initialResponse.body as Record)[name] as string; if (item) { itemName = name; break; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts index 1b01d456c6c8..8bc1ce3885c7 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts @@ -15,8 +15,7 @@ export interface MetadataPolicyListAllQueryParam { queryParameters?: MetadataPolicyListAllQueryParamProperties; } -export type MetadataPolicyListAllParameters = MetadataPolicyListAllQueryParam & - RequestParameters; +export type MetadataPolicyListAllParameters = MetadataPolicyListAllQueryParam & RequestParameters; export interface MetadataPolicyUpdateBodyParam { /** Policy to be updated. */ @@ -28,8 +27,7 @@ export interface MetadataPolicyUpdateMediaTypesParam { contentType?: "application/json"; } -export type MetadataPolicyUpdateParameters = - MetadataPolicyUpdateMediaTypesParam & - MetadataPolicyUpdateBodyParam & - RequestParameters; +export type MetadataPolicyUpdateParameters = MetadataPolicyUpdateMediaTypesParam & + MetadataPolicyUpdateBodyParam & + RequestParameters; export type MetadataPolicyGetParameters = RequestParameters; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts index b9792abf6cee..6ac51939f4e1 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts @@ -21,13 +21,9 @@ export interface PurviewMetadataPoliciesClientOptions extends ClientOptions { export function createClient( endpoint: string, credentials: TokenCredential, - { - apiVersion = "2021-07-01-preview", - ...options - }: PurviewMetadataPoliciesClientOptions = {}, + { apiVersion = "2021-07-01-preview", ...options }: PurviewMetadataPoliciesClientOptions = {}, ): PurviewMetadataPoliciesClient { - const endpointUrl = - options.endpoint ?? options.baseUrl ?? `${endpoint}/policyStore`; + const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpoint}/policyStore`; const userAgentInfo = `azsdk-js-purview-administration-rest/1.0.0-beta.2`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix @@ -45,11 +41,7 @@ export function createClient( scopes: options.credentials?.scopes ?? ["user_impersonation"], }, }; - const client = getClient( - endpointUrl, - credentials, - options, - ) as PurviewMetadataPoliciesClient; + const client = getClient(endpointUrl, credentials, options) as PurviewMetadataPoliciesClient; client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); client.pipeline.addPolicy({ @@ -59,8 +51,9 @@ export function createClient( // Append one if there is no apiVersion and we have one at client options const url = new URL(req.url); if (!url.searchParams.get("api-version") && apiVersion) { - req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" - }api-version=${apiVersion}`; + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; } return next(req); diff --git a/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts b/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts index 9421b4625cc0..87ebb76e1b8b 100644 --- a/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts +++ b/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts @@ -4,10 +4,7 @@ /// import { env, Recorder, RecorderStartOptions } from "@azure-tools/test-recorder"; -import { - PurviewAccount, - PurviewMetadataPolicies, -} from "../../../src"; +import { PurviewAccount, PurviewMetadataPolicies } from "../../../src"; import { createTestCredential } from "@azure-tools/test-credential"; import { ClientOptions } from "@azure-rest/core-client"; From a60e5427c54cc53e9aa81faba814a0cc4e4c3a51 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:29:59 +0800 Subject: [PATCH 06/11] Update CHANGELOG.md --- sdk/purview/purview-administration-rest/CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/purview/purview-administration-rest/CHANGELOG.md b/sdk/purview/purview-administration-rest/CHANGELOG.md index e98fd452f7fb..e28fb20a09d2 100644 --- a/sdk/purview/purview-administration-rest/CHANGELOG.md +++ b/sdk/purview/purview-administration-rest/CHANGELOG.md @@ -5,8 +5,6 @@ ### Features Added - refresh @azure-rest/purview-administration sdk -### Other Changes - ## 1.0.0-beta.1 (2021-10-15) - This is the initial release of the Azure Purview Administration client sdk. From 582f671c9cf6a75e2d150a11ddda4b3ed0c13fde Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:33:45 +0800 Subject: [PATCH 07/11] update --- .../purview-administration-rest/src/account/purviewAccount.ts | 2 +- .../src/metadataPolicies/purviewMetadataPolicies.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts index 4b219ede238b..52a2e06a91d9 100644 --- a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts +++ b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts @@ -39,7 +39,7 @@ export function createClient( logger: options.loggingOptions?.logger ?? logger.info, }, credentials: { - scopes: options.credentials?.scopes ?? ["user_impersonation"], + scopes: ["https://purview.azure.net/.default"], }, }; const client = getClient(endpointUrl, credentials, options) as PurviewAccountClient; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts index fda79231f28b..a991c745ba8c 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts @@ -39,7 +39,7 @@ export function createClient( logger: options.loggingOptions?.logger ?? logger.info, }, credentials: { - scopes: options.credentials?.scopes ?? ["user_impersonation"], + scopes: ["https://purview.azure.net/.default"], }, }; const client = getClient(endpointUrl, credentials, options) as PurviewMetadataPoliciesClient; From 750c1f41fa7fe8e1287cb9935c14d0053f7e449e Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Thu, 28 Nov 2024 15:15:27 +0800 Subject: [PATCH 08/11] format --- .../src/account/purviewAccount.ts | 5 +++-- .../src/metadataPolicies/purviewMetadataPolicies.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts index 32547dc0622b..598616341dcc 100644 --- a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts +++ b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts @@ -52,8 +52,9 @@ export function createClient( // Append one if there is no apiVersion and we have one at client options const url = new URL(req.url); if (!url.searchParams.get("api-version") && apiVersion) { - req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" - }api-version=${apiVersion}`; + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; } return next(req); diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts index 54b8c86f2675..2cf364fb6cca 100644 --- a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts @@ -52,8 +52,9 @@ export function createClient( // Append one if there is no apiVersion and we have one at client options const url = new URL(req.url); if (!url.searchParams.get("api-version") && apiVersion) { - req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" - }api-version=${apiVersion}`; + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; } return next(req); From 2b4510c9eb7a671e21cb5e7a9dd67da3b7ec8da5 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:31:02 +0800 Subject: [PATCH 09/11] Update package.json --- sdk/purview/purview-administration-rest/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/purview/purview-administration-rest/package.json b/sdk/purview/purview-administration-rest/package.json index d47a2033ab88..cda9209b8a58 100644 --- a/sdk/purview/purview-administration-rest/package.json +++ b/sdk/purview/purview-administration-rest/package.json @@ -80,7 +80,6 @@ "dependencies": { "@azure-rest/core-client": "^2.3.1", "@azure/core-auth": "^1.9.0", - "@azure/core-paging": "^1.6.2", "@azure/core-rest-pipeline": "^1.18.0", "@azure/logger": "^1.1.4", "tslib": "^2.8.1" From 2c251202726ad0cff8f649ee80032fa26039fd72 Mon Sep 17 00:00:00 2001 From: ZiWei Chen <98569699+kazrael2119@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:06:54 +0800 Subject: [PATCH 10/11] Update sdk/purview/purview-administration-rest/CHANGELOG.md --- sdk/purview/purview-administration-rest/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/purview/purview-administration-rest/CHANGELOG.md b/sdk/purview/purview-administration-rest/CHANGELOG.md index e28fb20a09d2..72160a43785a 100644 --- a/sdk/purview/purview-administration-rest/CHANGELOG.md +++ b/sdk/purview/purview-administration-rest/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.0-beta.2 (2024-09-30) +## 1.0.0-beta.2 (2024-12-16) ### Features Added - refresh @azure-rest/purview-administration sdk From b7090190569f0ddcdf445cfd23d186058a19a393 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:07:20 +0800 Subject: [PATCH 11/11] Update CHANGELOG.md --- sdk/purview/purview-administration-rest/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/purview/purview-administration-rest/CHANGELOG.md b/sdk/purview/purview-administration-rest/CHANGELOG.md index 72160a43785a..4d79f91a865c 100644 --- a/sdk/purview/purview-administration-rest/CHANGELOG.md +++ b/sdk/purview/purview-administration-rest/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.0.0-beta.2 (2024-12-16) ### Features Added + - refresh @azure-rest/purview-administration sdk ## 1.0.0-beta.1 (2021-10-15)