diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index f91fdfc84299..b0cb68b513aa 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3784,7 +3784,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.0.0-dev.20221218 + typescript: 5.0.0-dev.20221219 dev: false /downlevel-dts/0.7.0: @@ -8488,8 +8488,8 @@ packages: hasBin: true dev: false - /typescript/5.0.0-dev.20221218: - resolution: {integrity: sha512-H9OjIoDzurBIgB+Gq/9aAudpSKtfaN+dRCwWc/Ugg8B6/p5VA5KFlnwm2sLjOyTzApusKKUJUpV+u/hXEfxaOA==} + /typescript/5.0.0-dev.20221219: + resolution: {integrity: sha512-/ZglDGQtpeVudCAVJuEdM8K8vUCA1yPMpsk3y08/ZXn6dxk/D1hy59FEI25/EHqsACElN++9CoKzkJS1wBTiRw==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -14022,7 +14022,7 @@ packages: dev: false file:projects/arm-search.tgz: - resolution: {integrity: sha512-iOwGP7Z5Vm24UkzTDGIpO5uMHmgdyZ+eADOwvuzoJvvZFGJ3Yokmza0LvOwSmR1ZUi9QhdHzxmcU8YIQ6Qltrw==, tarball: file:projects/arm-search.tgz} + resolution: {integrity: sha512-DI1uNXcsqTZ9Ck9yCPW2LKnZK3dON9+hDPsjIton0TyXpM1G9T4+3MIacE6Rm97PxliJccXNrwzg9Y88TiSTCg==, tarball: file:projects/arm-search.tgz} name: '@rush-temp/arm-search' version: 0.0.0 dependencies: @@ -14033,18 +14033,19 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.33 + chai: 4.3.7 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - - encoding - supports-color dev: false diff --git a/sdk/search/arm-search/CHANGELOG.md b/sdk/search/arm-search/CHANGELOG.md index a2099850b3e3..092fcf3eabd4 100644 --- a/sdk/search/arm-search/CHANGELOG.md +++ b/sdk/search/arm-search/CHANGELOG.md @@ -1,15 +1,24 @@ # Release History + +## 3.1.0 (2022-12-19) + +**Features** -## 3.0.2 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + - Added Interface DataPlaneAadOrApiKeyAuthOption + - Added Interface DataPlaneAuthOptions + - Added Interface PrivateEndpointConnection + - Added Interface PrivateLinkResource + - Added Interface SearchService + - Added Interface SearchServiceUpdate + - Added Interface SharedPrivateLinkResource + - Added Interface TrackedResource + - Added Type Alias AadAuthFailureMode + - Added Type Alias PrivateLinkServiceConnectionProvisioningState + - Interface PrivateEndpointConnectionProperties has a new optional parameter groupId + - Interface PrivateEndpointConnectionProperties has a new optional parameter provisioningState + - Added Enum KnownPrivateLinkServiceConnectionProvisioningState + - Added function getContinuationToken + ## 3.0.1 (2022-04-29) **Features** diff --git a/sdk/search/arm-search/_meta.json b/sdk/search/arm-search/_meta.json index 88d626dc7e40..1c69929b6cad 100644 --- a/sdk/search/arm-search/_meta.json +++ b/sdk/search/arm-search/_meta.json @@ -1,8 +1,8 @@ { - "commit": "0cd7b3e83d5e7e21222dcc4bdde4565562da0cdf", - "readme": "specification\\search\\resource-manager\\readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\search\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", + "commit": "da4ecb694176f1d7055f207283947cf81e7572dd", + "readme": "specification/search/resource-manager/readme.md", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/search/resource-manager/readme.md --use=@autorest/typescript@6.0.0-rc.5", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.3.0", - "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.5.4", + "use": "@autorest/typescript@6.0.0-rc.5" } \ No newline at end of file diff --git a/sdk/search/arm-search/package.json b/sdk/search/arm-search/package.json index 4bd2e152c7e5..7970b34a000c 100644 --- a/sdk/search/arm-search/package.json +++ b/sdk/search/arm-search/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for SearchManagementClient.", - "version": "3.0.2", + "version": "3.1.0", "engines": { "node": ">=14.0.0" }, @@ -11,7 +11,7 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.5.0", + "@azure/core-client": "^1.6.1", "@azure/core-auth": "^1.3.0", "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" @@ -36,13 +36,18 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/search/arm-search", "repository": { @@ -93,9 +98,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -106,13 +110,5 @@ } ] }, - "autoPublish": true, - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-search?view=azure-node-preview" - } -} + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/search/arm-search/review/arm-search.api.md b/sdk/search/arm-search/review/arm-search.api.md index 85cfcb7ccdcd..eb7a13551468 100644 --- a/sdk/search/arm-search/review/arm-search.api.md +++ b/sdk/search/arm-search/review/arm-search.api.md @@ -10,6 +10,9 @@ import { PagedAsyncIterableIterator } from '@azure/core-paging'; import { PollerLike } from '@azure/core-lro'; import { PollOperationState } from '@azure/core-lro'; +// @public +export type AadAuthFailureMode = "http403" | "http401WithBearerChallenge"; + // @public export type AdminKeyKind = "primary" | "secondary"; @@ -72,6 +75,20 @@ export interface CloudErrorBody { target?: string; } +// @public +export interface DataPlaneAadOrApiKeyAuthOption { + aadAuthFailureMode?: AadAuthFailureMode; +} + +// @public +export interface DataPlaneAuthOptions { + aadOrApiKey?: DataPlaneAadOrApiKeyAuthOption; + apiKeyOnly?: Record; +} + +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export type HostingMode = "default" | "highDensity"; @@ -90,21 +107,26 @@ export interface IpRule { value?: string; } +// @public +export enum KnownPrivateLinkServiceConnectionProvisioningState { + Canceled = "Canceled", + Deleting = "Deleting", + Failed = "Failed", + Incomplete = "Incomplete", + Succeeded = "Succeeded", + Updating = "Updating" +} + // @public export enum KnownSharedPrivateLinkResourceAsyncOperationResult { - // (undocumented) Failed = "Failed", - // (undocumented) Running = "Running", - // (undocumented) Succeeded = "Succeeded" } // @public export enum KnownUnavailableNameReason { - // (undocumented) AlreadyExists = "AlreadyExists", - // (undocumented) Invalid = "Invalid" } @@ -152,9 +174,9 @@ export interface OperationsListOptionalParams extends coreClient.OperationOption export type OperationsListResponse = OperationListResult; // @public -export type PrivateEndpointConnection = Resource & { +export interface PrivateEndpointConnection extends Resource { properties?: PrivateEndpointConnectionProperties; -}; +} // @public export interface PrivateEndpointConnectionListResult { @@ -164,8 +186,10 @@ export interface PrivateEndpointConnectionListResult { // @public export interface PrivateEndpointConnectionProperties { + groupId?: string; privateEndpoint?: PrivateEndpointConnectionPropertiesPrivateEndpoint; privateLinkServiceConnectionState?: PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState; + provisioningState?: PrivateLinkServiceConnectionProvisioningState; } // @public @@ -229,9 +253,9 @@ export interface PrivateEndpointConnectionsUpdateOptionalParams extends coreClie export type PrivateEndpointConnectionsUpdateResponse = PrivateEndpointConnection; // @public -export type PrivateLinkResource = Resource & { +export interface PrivateLinkResource extends Resource { readonly properties?: PrivateLinkResourceProperties; -}; +} // @public export interface PrivateLinkResourceProperties { @@ -259,6 +283,9 @@ export interface PrivateLinkResourcesResult { readonly value?: PrivateLinkResource[]; } +// @public +export type PrivateLinkServiceConnectionProvisioningState = string; + // @public export type PrivateLinkServiceConnectionStatus = "Pending" | "Approved" | "Rejected" | "Disconnected"; @@ -355,20 +382,22 @@ export interface SearchManagementRequestOptions { } // @public -export type SearchService = TrackedResource & { - sku?: Sku; +export interface SearchService extends TrackedResource { + authOptions?: DataPlaneAuthOptions; + disableLocalAuth?: boolean; + hostingMode?: HostingMode; identity?: Identity; - replicaCount?: number; + networkRuleSet?: NetworkRuleSet; partitionCount?: number; - hostingMode?: HostingMode; + readonly privateEndpointConnections?: PrivateEndpointConnection[]; + readonly provisioningState?: ProvisioningState; publicNetworkAccess?: PublicNetworkAccess; + replicaCount?: number; + readonly sharedPrivateLinkResources?: SharedPrivateLinkResource[]; + sku?: Sku; readonly status?: SearchServiceStatus; readonly statusDetails?: string; - readonly provisioningState?: ProvisioningState; - networkRuleSet?: NetworkRuleSet; - readonly privateEndpointConnections?: PrivateEndpointConnection[]; - readonly sharedPrivateLinkResources?: SharedPrivateLinkResource[]; -}; +} // @public export interface SearchServiceListResult { @@ -377,27 +406,29 @@ export interface SearchServiceListResult { } // @public -export type SearchServiceStatus = "running" | "provisioning" | "deleting" | "degraded" | "disabled" | "error"; +export type SearchServiceStatus = "running" | "provisioning" | "deleting" | "degraded" | "disabled" | "error" | "stopped"; // @public -export type SearchServiceUpdate = Resource & { - sku?: Sku; - location?: string; - tags?: { - [propertyName: string]: string; - }; +export interface SearchServiceUpdate extends Resource { + authOptions?: DataPlaneAuthOptions; + disableLocalAuth?: boolean; + hostingMode?: HostingMode; identity?: Identity; - replicaCount?: number; + location?: string; + networkRuleSet?: NetworkRuleSet; partitionCount?: number; - hostingMode?: HostingMode; + readonly privateEndpointConnections?: PrivateEndpointConnection[]; + readonly provisioningState?: ProvisioningState; publicNetworkAccess?: PublicNetworkAccess; + replicaCount?: number; + readonly sharedPrivateLinkResources?: SharedPrivateLinkResource[]; + sku?: Sku; readonly status?: SearchServiceStatus; readonly statusDetails?: string; - readonly provisioningState?: ProvisioningState; - networkRuleSet?: NetworkRuleSet; - readonly privateEndpointConnections?: PrivateEndpointConnection[]; - readonly sharedPrivateLinkResources?: SharedPrivateLinkResource[]; -}; + tags?: { + [propertyName: string]: string; + }; +} // @public export interface Services { @@ -496,9 +527,9 @@ export interface ShareablePrivateLinkResourceType { } // @public -export type SharedPrivateLinkResource = Resource & { +export interface SharedPrivateLinkResource extends Resource { properties?: SharedPrivateLinkResourceProperties; -}; +} // @public export type SharedPrivateLinkResourceAsyncOperationResult = string; @@ -585,12 +616,12 @@ export interface Sku { export type SkuName = "free" | "basic" | "standard" | "standard2" | "standard3" | "storage_optimized_l1" | "storage_optimized_l2"; // @public -export type TrackedResource = Resource & { +export interface TrackedResource extends Resource { + location: string; tags?: { [propertyName: string]: string; }; - location: string; -}; +} // @public export type UnavailableNameReason = string; diff --git a/sdk/search/arm-search/src/index.ts b/sdk/search/arm-search/src/index.ts index 416cd08df1e2..948e465676fd 100644 --- a/sdk/search/arm-search/src/index.ts +++ b/sdk/search/arm-search/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { SearchManagementClient } from "./searchManagementClient"; export * from "./operationsInterfaces"; diff --git a/sdk/search/arm-search/src/models/index.ts b/sdk/search/arm-search/src/models/index.ts index 0759705abc42..4da34cdeca70 100644 --- a/sdk/search/arm-search/src/models/index.ts +++ b/sdk/search/arm-search/src/models/index.ts @@ -132,12 +132,30 @@ export interface IpRule { value?: string; } +/** Defines the options for how the data plane API of a Search service authenticates requests. This cannot be set if 'disableLocalAuth' is set to true. */ +export interface DataPlaneAuthOptions { + /** Indicates that only the API key needs to be used for authentication. */ + apiKeyOnly?: Record; + /** Indicates that either the API key or an access token from Azure Active Directory can be used for authentication. */ + aadOrApiKey?: DataPlaneAadOrApiKeyAuthOption; +} + +/** Indicates that either the API key or an access token from Azure Active Directory can be used for authentication. */ +export interface DataPlaneAadOrApiKeyAuthOption { + /** Describes what response the data plane API of a Search service would send for requests that failed authentication. */ + aadAuthFailureMode?: AadAuthFailureMode; +} + /** Describes the properties of an existing Private Endpoint connection to the Azure Cognitive Search service. */ export interface PrivateEndpointConnectionProperties { /** The private endpoint resource from Microsoft.Network provider. */ privateEndpoint?: PrivateEndpointConnectionPropertiesPrivateEndpoint; /** Describes the current state of an existing Private Link Service connection to the Azure Private Endpoint. */ privateLinkServiceConnectionState?: PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState; + /** The group id from the provider of resource the private link service connection is for. */ + groupId?: string; + /** The provisioning state of the private link service connection. Can be Updating, Deleting, Failed, Succeeded, or Incomplete */ + provisioningState?: PrivateLinkServiceConnectionProvisioningState; } /** The private endpoint resource from Microsoft.Network provider. */ @@ -200,12 +218,12 @@ export interface Sku { /** Identity for the resource. */ export interface Identity { /** - * The principal ID of resource identity. + * The principal ID of the system-assigned identity of the search service. * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly principalId?: string; /** - * The tenant ID of resource. + * The tenant ID of the system-assigned identity of the search service. * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly tenantId?: string; @@ -216,7 +234,7 @@ export interface Identity { /** Response containing a list of Azure Cognitive Search services. */ export interface SearchServiceListResult { /** - * The list of search services. + * The list of Search services. * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly value?: SearchService[]; @@ -352,27 +370,27 @@ export interface AsyncOperationResult { } /** Describes an existing Private Endpoint connection to the Azure Cognitive Search service. */ -export type PrivateEndpointConnection = Resource & { +export interface PrivateEndpointConnection extends Resource { /** Describes the properties of an existing Private Endpoint connection to the Azure Cognitive Search service. */ properties?: PrivateEndpointConnectionProperties; -}; +} /** Describes a Shared Private Link Resource managed by the Azure Cognitive Search service. */ -export type SharedPrivateLinkResource = Resource & { +export interface SharedPrivateLinkResource extends Resource { /** Describes the properties of a Shared Private Link Resource managed by the Azure Cognitive Search service. */ properties?: SharedPrivateLinkResourceProperties; -}; +} /** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ -export type TrackedResource = Resource & { +export interface TrackedResource extends Resource { /** Resource tags. */ tags?: { [propertyName: string]: string }; /** The geo-location where the resource lives */ location: string; -}; +} /** The parameters used to update an Azure Cognitive Search service. */ -export type SearchServiceUpdate = Resource & { +export interface SearchServiceUpdate extends Resource { /** The SKU of the Search Service, which determines price tier and capacity limits. This property is required when creating a new Search Service. */ sku?: Sku; /** The geographic location of the resource. This must be one of the supported and registered Azure Geo Regions (for example, West US, East US, Southeast Asia, and so forth). This property is required when creating a new resource. */ @@ -406,6 +424,10 @@ export type SearchServiceUpdate = Resource & { readonly provisioningState?: ProvisioningState; /** Network specific rules that determine how the Azure Cognitive Search service may be reached. */ networkRuleSet?: NetworkRuleSet; + /** When set to true, calls to the search service will not be permitted to utilize API keys for authentication. This cannot be set to true if 'dataPlaneAuthOptions' are defined. */ + disableLocalAuth?: boolean; + /** Defines the options for how the data plane API of a search service authenticates requests. This cannot be set if 'disableLocalAuth' is set to true. */ + authOptions?: DataPlaneAuthOptions; /** * The list of private endpoint connections to the Azure Cognitive Search service. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -416,19 +438,19 @@ export type SearchServiceUpdate = Resource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly sharedPrivateLinkResources?: SharedPrivateLinkResource[]; -}; +} /** Describes a supported private link resource for the Azure Cognitive Search service. */ -export type PrivateLinkResource = Resource & { +export interface PrivateLinkResource extends Resource { /** * Describes the properties of a supported private link resource for the Azure Cognitive Search service. * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly properties?: PrivateLinkResourceProperties; -}; +} /** Describes an Azure Cognitive Search service and its current state. */ -export type SearchService = TrackedResource & { +export interface SearchService extends TrackedResource { /** The SKU of the Search Service, which determines price tier and capacity limits. This property is required when creating a new Search Service. */ sku?: Sku; /** The identity of the resource. */ @@ -458,6 +480,10 @@ export type SearchService = TrackedResource & { readonly provisioningState?: ProvisioningState; /** Network specific rules that determine how the Azure Cognitive Search service may be reached. */ networkRuleSet?: NetworkRuleSet; + /** When set to true, calls to the search service will not be permitted to utilize API keys for authentication. This cannot be set to true if 'dataPlaneAuthOptions' are defined. */ + disableLocalAuth?: boolean; + /** Defines the options for how the data plane API of a search service authenticates requests. This cannot be set if 'disableLocalAuth' is set to true. */ + authOptions?: DataPlaneAuthOptions; /** * The list of private endpoint connections to the Azure Cognitive Search service. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -468,7 +494,7 @@ export type SearchService = TrackedResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly sharedPrivateLinkResources?: SharedPrivateLinkResource[]; -}; +} /** Parameter group */ export interface SearchManagementRequestOptions { @@ -476,9 +502,41 @@ export interface SearchManagementRequestOptions { clientRequestId?: string; } +/** Known values of {@link PrivateLinkServiceConnectionProvisioningState} that the service accepts. */ +export enum KnownPrivateLinkServiceConnectionProvisioningState { + /** The private link service connection is in the process of being created along with other resources for it to be fully functional. */ + Updating = "Updating", + /** The private link service connection is in the process of being deleted. */ + Deleting = "Deleting", + /** The private link service connection has failed to be provisioned or deleted. */ + Failed = "Failed", + /** The private link service connection has finished provisioning and is ready for approval. */ + Succeeded = "Succeeded", + /** Provisioning request for the private link service connection resource has been accepted but the process of creation has not commenced yet. */ + Incomplete = "Incomplete", + /** Provisioning request for the private link service connection resource has been canceled */ + Canceled = "Canceled" +} + +/** + * Defines values for PrivateLinkServiceConnectionProvisioningState. \ + * {@link KnownPrivateLinkServiceConnectionProvisioningState} can be used interchangeably with PrivateLinkServiceConnectionProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Updating**: The private link service connection is in the process of being created along with other resources for it to be fully functional. \ + * **Deleting**: The private link service connection is in the process of being deleted. \ + * **Failed**: The private link service connection has failed to be provisioned or deleted. \ + * **Succeeded**: The private link service connection has finished provisioning and is ready for approval. \ + * **Incomplete**: Provisioning request for the private link service connection resource has been accepted but the process of creation has not commenced yet. \ + * **Canceled**: Provisioning request for the private link service connection resource has been canceled + */ +export type PrivateLinkServiceConnectionProvisioningState = string; + /** Known values of {@link UnavailableNameReason} that the service accepts. */ export enum KnownUnavailableNameReason { + /** The search service name does not match naming requirements. */ Invalid = "Invalid", + /** The search service name is already assigned to a different search service. */ AlreadyExists = "AlreadyExists" } @@ -487,15 +545,18 @@ export enum KnownUnavailableNameReason { * {@link KnownUnavailableNameReason} can be used interchangeably with UnavailableNameReason, * this enum contains the known values that the service supports. * ### Known values supported by the service - * **Invalid** \ - * **AlreadyExists** + * **Invalid**: The search service name does not match naming requirements. \ + * **AlreadyExists**: The search service name is already assigned to a different search service. */ export type UnavailableNameReason = string; /** Known values of {@link SharedPrivateLinkResourceAsyncOperationResult} that the service accepts. */ export enum KnownSharedPrivateLinkResourceAsyncOperationResult { + /** Running */ Running = "Running", + /** Succeeded */ Succeeded = "Succeeded", + /** Failed */ Failed = "Failed" } @@ -522,9 +583,12 @@ export type SearchServiceStatus = | "deleting" | "degraded" | "disabled" - | "error"; + | "error" + | "stopped"; /** Defines values for ProvisioningState. */ export type ProvisioningState = "succeeded" | "provisioning" | "failed"; +/** Defines values for AadAuthFailureMode. */ +export type AadAuthFailureMode = "http403" | "http401WithBearerChallenge"; /** Defines values for PrivateLinkServiceConnectionStatus. */ export type PrivateLinkServiceConnectionStatus = | "Pending" diff --git a/sdk/search/arm-search/src/models/mappers.ts b/sdk/search/arm-search/src/models/mappers.ts index 59fb037bccc8..7e876b341e7d 100644 --- a/sdk/search/arm-search/src/models/mappers.ts +++ b/sdk/search/arm-search/src/models/mappers.ts @@ -263,6 +263,45 @@ export const IpRule: coreClient.CompositeMapper = { } }; +export const DataPlaneAuthOptions: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DataPlaneAuthOptions", + modelProperties: { + apiKeyOnly: { + serializedName: "apiKeyOnly", + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + }, + aadOrApiKey: { + serializedName: "aadOrApiKey", + type: { + name: "Composite", + className: "DataPlaneAadOrApiKeyAuthOption" + } + } + } + } +}; + +export const DataPlaneAadOrApiKeyAuthOption: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DataPlaneAadOrApiKeyAuthOption", + modelProperties: { + aadAuthFailureMode: { + serializedName: "aadAuthFailureMode", + type: { + name: "Enum", + allowedValues: ["http403", "http401WithBearerChallenge"] + } + } + } + } +}; + export const PrivateEndpointConnectionProperties: coreClient.CompositeMapper = { type: { name: "Composite", @@ -282,6 +321,18 @@ export const PrivateEndpointConnectionProperties: coreClient.CompositeMapper = { className: "PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState" } + }, + groupId: { + serializedName: "groupId", + type: { + name: "String" + } + }, + provisioningState: { + serializedName: "provisioningState", + type: { + name: "String" + } } } } @@ -893,7 +944,8 @@ export const SearchServiceUpdate: coreClient.CompositeMapper = { "deleting", "degraded", "disabled", - "error" + "error", + "stopped" ] } }, @@ -919,6 +971,20 @@ export const SearchServiceUpdate: coreClient.CompositeMapper = { className: "NetworkRuleSet" } }, + disableLocalAuth: { + serializedName: "properties.disableLocalAuth", + nullable: true, + type: { + name: "Boolean" + } + }, + authOptions: { + serializedName: "properties.authOptions", + type: { + name: "Composite", + className: "DataPlaneAuthOptions" + } + }, privateEndpointConnections: { serializedName: "properties.privateEndpointConnections", readOnly: true, @@ -1035,7 +1101,8 @@ export const SearchService: coreClient.CompositeMapper = { "deleting", "degraded", "disabled", - "error" + "error", + "stopped" ] } }, @@ -1061,6 +1128,20 @@ export const SearchService: coreClient.CompositeMapper = { className: "NetworkRuleSet" } }, + disableLocalAuth: { + serializedName: "properties.disableLocalAuth", + nullable: true, + type: { + name: "Boolean" + } + }, + authOptions: { + serializedName: "properties.authOptions", + type: { + name: "Composite", + className: "DataPlaneAuthOptions" + } + }, privateEndpointConnections: { serializedName: "properties.privateEndpointConnections", readOnly: true, diff --git a/sdk/search/arm-search/src/models/parameters.ts b/sdk/search/arm-search/src/models/parameters.ts index 95860ef47819..ce3d455016e2 100644 --- a/sdk/search/arm-search/src/models/parameters.ts +++ b/sdk/search/arm-search/src/models/parameters.ts @@ -46,7 +46,7 @@ export const $host: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2020-08-01", + defaultValue: "2022-09-01", isConstant: true, serializedName: "api-version", type: { diff --git a/sdk/search/arm-search/src/operations/operations.ts b/sdk/search/arm-search/src/operations/operations.ts index 71528a64de6c..97a24c9dc8f7 100644 --- a/sdk/search/arm-search/src/operations/operations.ts +++ b/sdk/search/arm-search/src/operations/operations.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { Operations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -46,16 +46,21 @@ export class OperationsImpl implements Operations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: OperationsListOptionalParams + options?: OperationsListOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); + let result: OperationsListResponse; + result = await this._list(options); yield result.value || []; } diff --git a/sdk/search/arm-search/src/operations/privateEndpointConnections.ts b/sdk/search/arm-search/src/operations/privateEndpointConnections.ts index abe8cccf1600..0763faabb0f6 100644 --- a/sdk/search/arm-search/src/operations/privateEndpointConnections.ts +++ b/sdk/search/arm-search/src/operations/privateEndpointConnections.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { PrivateEndpointConnections } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,13 +17,13 @@ import { PrivateEndpointConnection, PrivateEndpointConnectionsListByServiceNextOptionalParams, PrivateEndpointConnectionsListByServiceOptionalParams, + PrivateEndpointConnectionsListByServiceResponse, PrivateEndpointConnectionsUpdateOptionalParams, PrivateEndpointConnectionsUpdateResponse, PrivateEndpointConnectionsGetOptionalParams, PrivateEndpointConnectionsGetResponse, PrivateEndpointConnectionsDeleteOptionalParams, PrivateEndpointConnectionsDeleteResponse, - PrivateEndpointConnectionsListByServiceResponse, PrivateEndpointConnectionsListByServiceNextResponse } from "../models"; @@ -65,11 +66,15 @@ export class PrivateEndpointConnectionsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listByServicePagingPage( resourceGroupName, searchServiceName, - options + options, + settings ); } }; @@ -78,15 +83,22 @@ export class PrivateEndpointConnectionsImpl private async *listByServicePagingPage( resourceGroupName: string, searchServiceName: string, - options?: PrivateEndpointConnectionsListByServiceOptionalParams + options?: PrivateEndpointConnectionsListByServiceOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByService( - resourceGroupName, - searchServiceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PrivateEndpointConnectionsListByServiceResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByService( + resourceGroupName, + searchServiceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByServiceNext( resourceGroupName, @@ -95,7 +107,9 @@ export class PrivateEndpointConnectionsImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -350,7 +364,6 @@ const listByServiceNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/search/arm-search/src/operations/privateLinkResources.ts b/sdk/search/arm-search/src/operations/privateLinkResources.ts index ed1fc907bb14..ccefb51c5798 100644 --- a/sdk/search/arm-search/src/operations/privateLinkResources.ts +++ b/sdk/search/arm-search/src/operations/privateLinkResources.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { PrivateLinkResources } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -56,11 +56,15 @@ export class PrivateLinkResourcesImpl implements PrivateLinkResources { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listSupportedPagingPage( resourceGroupName, searchServiceName, - options + options, + settings ); } }; @@ -69,9 +73,11 @@ export class PrivateLinkResourcesImpl implements PrivateLinkResources { private async *listSupportedPagingPage( resourceGroupName: string, searchServiceName: string, - options?: PrivateLinkResourcesListSupportedOptionalParams + options?: PrivateLinkResourcesListSupportedOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listSupported( + let result: PrivateLinkResourcesListSupportedResponse; + result = await this._listSupported( resourceGroupName, searchServiceName, options diff --git a/sdk/search/arm-search/src/operations/queryKeys.ts b/sdk/search/arm-search/src/operations/queryKeys.ts index e01301d546e6..4cb29f5000db 100644 --- a/sdk/search/arm-search/src/operations/queryKeys.ts +++ b/sdk/search/arm-search/src/operations/queryKeys.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { QueryKeys } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,9 +17,9 @@ import { QueryKey, QueryKeysListBySearchServiceNextOptionalParams, QueryKeysListBySearchServiceOptionalParams, + QueryKeysListBySearchServiceResponse, QueryKeysCreateOptionalParams, QueryKeysCreateResponse, - QueryKeysListBySearchServiceResponse, QueryKeysDeleteOptionalParams, QueryKeysListBySearchServiceNextResponse } from "../models"; @@ -61,11 +62,15 @@ export class QueryKeysImpl implements QueryKeys { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listBySearchServicePagingPage( resourceGroupName, searchServiceName, - options + options, + settings ); } }; @@ -74,15 +79,22 @@ export class QueryKeysImpl implements QueryKeys { private async *listBySearchServicePagingPage( resourceGroupName: string, searchServiceName: string, - options?: QueryKeysListBySearchServiceOptionalParams + options?: QueryKeysListBySearchServiceOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listBySearchService( - resourceGroupName, - searchServiceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: QueryKeysListBySearchServiceResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBySearchService( + resourceGroupName, + searchServiceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listBySearchServiceNext( resourceGroupName, @@ -91,7 +103,9 @@ export class QueryKeysImpl implements QueryKeys { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -275,7 +289,6 @@ const listBySearchServiceNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/search/arm-search/src/operations/services.ts b/sdk/search/arm-search/src/operations/services.ts index 121d8c740694..3a0e9cd9ba91 100644 --- a/sdk/search/arm-search/src/operations/services.ts +++ b/sdk/search/arm-search/src/operations/services.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Services } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,8 +19,10 @@ import { SearchService, ServicesListByResourceGroupNextOptionalParams, ServicesListByResourceGroupOptionalParams, + ServicesListByResourceGroupResponse, ServicesListBySubscriptionNextOptionalParams, ServicesListBySubscriptionOptionalParams, + ServicesListBySubscriptionResponse, ServicesCreateOrUpdateOptionalParams, ServicesCreateOrUpdateResponse, SearchServiceUpdate, @@ -28,8 +31,6 @@ import { ServicesGetOptionalParams, ServicesGetResponse, ServicesDeleteOptionalParams, - ServicesListByResourceGroupResponse, - ServicesListBySubscriptionResponse, ServicesCheckNameAvailabilityOptionalParams, ServicesCheckNameAvailabilityResponse, ServicesListByResourceGroupNextResponse, @@ -50,7 +51,7 @@ export class ServicesImpl implements Services { } /** - * Gets a list of all search services in the given resource group. + * Gets a list of all Search services in the given resource group. * @param resourceGroupName The name of the resource group within the current subscription. You can * obtain this value from the Azure Resource Manager API or the portal. * @param options The options parameters. @@ -67,19 +68,33 @@ export class ServicesImpl implements Services { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, - options?: ServicesListByResourceGroupOptionalParams + options?: ServicesListByResourceGroupOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResourceGroup(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ServicesListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByResourceGroupNext( resourceGroupName, @@ -87,7 +102,9 @@ export class ServicesImpl implements Services { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -104,7 +121,7 @@ export class ServicesImpl implements Services { } /** - * Gets a list of all search services in the given subscription. + * Gets a list of all Search services in the given subscription. * @param options The options parameters. */ public listBySubscription( @@ -118,22 +135,34 @@ export class ServicesImpl implements Services { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listBySubscriptionPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listBySubscriptionPagingPage(options, settings); } }; } private async *listBySubscriptionPagingPage( - options?: ServicesListBySubscriptionOptionalParams + options?: ServicesListBySubscriptionOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listBySubscription(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ServicesListBySubscriptionResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBySubscription(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listBySubscriptionNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -310,7 +339,7 @@ export class ServicesImpl implements Services { } /** - * Gets a list of all search services in the given resource group. + * Gets a list of all Search services in the given resource group. * @param resourceGroupName The name of the resource group within the current subscription. You can * obtain this value from the Azure Resource Manager API or the portal. * @param options The options parameters. @@ -326,7 +355,7 @@ export class ServicesImpl implements Services { } /** - * Gets a list of all search services in the given subscription. + * Gets a list of all Search services in the given subscription. * @param options The options parameters. */ private _listBySubscription( @@ -576,7 +605,6 @@ const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, @@ -597,7 +625,6 @@ const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/search/arm-search/src/operations/sharedPrivateLinkResources.ts b/sdk/search/arm-search/src/operations/sharedPrivateLinkResources.ts index a999b8b74c03..d72557fd58e8 100644 --- a/sdk/search/arm-search/src/operations/sharedPrivateLinkResources.ts +++ b/sdk/search/arm-search/src/operations/sharedPrivateLinkResources.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { SharedPrivateLinkResources } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,12 +19,12 @@ import { SharedPrivateLinkResource, SharedPrivateLinkResourcesListByServiceNextOptionalParams, SharedPrivateLinkResourcesListByServiceOptionalParams, + SharedPrivateLinkResourcesListByServiceResponse, SharedPrivateLinkResourcesCreateOrUpdateOptionalParams, SharedPrivateLinkResourcesCreateOrUpdateResponse, SharedPrivateLinkResourcesGetOptionalParams, SharedPrivateLinkResourcesGetResponse, SharedPrivateLinkResourcesDeleteOptionalParams, - SharedPrivateLinkResourcesListByServiceResponse, SharedPrivateLinkResourcesListByServiceNextResponse } from "../models"; @@ -66,11 +67,15 @@ export class SharedPrivateLinkResourcesImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listByServicePagingPage( resourceGroupName, searchServiceName, - options + options, + settings ); } }; @@ -79,15 +84,22 @@ export class SharedPrivateLinkResourcesImpl private async *listByServicePagingPage( resourceGroupName: string, searchServiceName: string, - options?: SharedPrivateLinkResourcesListByServiceOptionalParams + options?: SharedPrivateLinkResourcesListByServiceOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByService( - resourceGroupName, - searchServiceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: SharedPrivateLinkResourcesListByServiceResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByService( + resourceGroupName, + searchServiceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByServiceNext( resourceGroupName, @@ -96,7 +108,9 @@ export class SharedPrivateLinkResourcesImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -516,7 +530,6 @@ const listByServiceNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/search/arm-search/src/operationsInterfaces/services.ts b/sdk/search/arm-search/src/operationsInterfaces/services.ts index 68b1b3f3b6cb..416890a9fbcd 100644 --- a/sdk/search/arm-search/src/operationsInterfaces/services.ts +++ b/sdk/search/arm-search/src/operationsInterfaces/services.ts @@ -28,7 +28,7 @@ import { /** Interface representing a Services. */ export interface Services { /** - * Gets a list of all search services in the given resource group. + * Gets a list of all Search services in the given resource group. * @param resourceGroupName The name of the resource group within the current subscription. You can * obtain this value from the Azure Resource Manager API or the portal. * @param options The options parameters. @@ -38,7 +38,7 @@ export interface Services { options?: ServicesListByResourceGroupOptionalParams ): PagedAsyncIterableIterator; /** - * Gets a list of all search services in the given subscription. + * Gets a list of all Search services in the given subscription. * @param options The options parameters. */ listBySubscription( diff --git a/sdk/search/arm-search/src/pagingHelper.ts b/sdk/search/arm-search/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/search/arm-search/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/search/arm-search/src/searchManagementClient.ts b/sdk/search/arm-search/src/searchManagementClient.ts index eac7bb6b5b6f..3022164b2d5f 100644 --- a/sdk/search/arm-search/src/searchManagementClient.ts +++ b/sdk/search/arm-search/src/searchManagementClient.ts @@ -8,6 +8,11 @@ import * as coreClient from "@azure/core-client"; import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { OperationsImpl, @@ -62,54 +67,60 @@ export class SearchManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-search/3.0.2`; + const packageDetails = `azsdk-js-arm-search/3.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: + endpoint: options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + let bearerTokenAuthenticationPolicyFound: boolean = false; if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); - const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( (pipelinePolicy) => pipelinePolicy.name === coreRestPipeline.bearerTokenAuthenticationPolicyName ); - if (!bearerTokenAuthenticationPolicyFound) { - this.pipeline.removePolicy({ - name: coreRestPipeline.bearerTokenAuthenticationPolicyName - }); - this.pipeline.addPolicy( - coreRestPipeline.bearerTokenAuthenticationPolicy({ - scopes: `${optionsWithDefaults.baseUri}/.default`, - challengeCallbacks: { - authorizeRequestOnChallenge: - coreClient.authorizeRequestOnClaimChallenge - } - }) - ); - } + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); } // Parameter assignments this.subscriptionId = subscriptionId; // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2020-08-01"; + this.apiVersion = options.apiVersion || "2022-09-01"; this.operations = new OperationsImpl(this); this.adminKeys = new AdminKeysImpl(this); this.queryKeys = new QueryKeysImpl(this); @@ -117,6 +128,35 @@ export class SearchManagementClient extends coreClient.ServiceClient { this.privateLinkResources = new PrivateLinkResourcesImpl(this); this.privateEndpointConnections = new PrivateEndpointConnectionsImpl(this); this.sharedPrivateLinkResources = new SharedPrivateLinkResourcesImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } operations: Operations; diff --git a/sdk/search/arm-search/test/sampleTest.ts b/sdk/search/arm-search/test/sampleTest.ts new file mode 100644 index 000000000000..25aeb3ebcc36 --- /dev/null +++ b/sdk/search/arm-search/test/sampleTest.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + Recorder, + RecorderStartOptions, + env +} from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { Context } from "mocha"; + +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/search/arm-search/tsconfig.json b/sdk/search/arm-search/tsconfig.json index e1056465e215..3e6ae96443f3 100644 --- a/sdk/search/arm-search/tsconfig.json +++ b/sdk/search/arm-search/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-search": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"