diff --git a/sdk/resourcemanager/botservice/armbotservice/CHANGELOG.md b/sdk/resourcemanager/botservice/armbotservice/CHANGELOG.md index 6ad7813be2c5..e565a5ea29a5 100644 --- a/sdk/resourcemanager/botservice/armbotservice/CHANGELOG.md +++ b/sdk/resourcemanager/botservice/armbotservice/CHANGELOG.md @@ -1,5 +1,122 @@ # Release History +## 2.0.0-beta.1 (2025-05-11) +### Breaking Changes + +- Type alias `EmailChannelAuthMethod` type has been changed from `float32` to `int32` +- Enum `ChannelName` has been removed +- Enum `RegenerateKeysChannelName` has been removed +- Function `NewBotConnectionClient` has been removed +- Function `*BotConnectionClient.Create` has been removed +- Function `*BotConnectionClient.Delete` has been removed +- Function `*BotConnectionClient.Get` has been removed +- Function `*BotConnectionClient.NewListByBotServicePager` has been removed +- Function `*BotConnectionClient.ListServiceProviders` has been removed +- Function `*BotConnectionClient.ListWithSecrets` has been removed +- Function `*BotConnectionClient.Update` has been removed +- Function `*BotsClient.GetCheckNameAvailability` has been removed +- Function `NewChannelsClient` has been removed +- Function `*ChannelsClient.Create` has been removed +- Function `*ChannelsClient.Delete` has been removed +- Function `*ChannelsClient.Get` has been removed +- Function `*ChannelsClient.NewListByResourceGroupPager` has been removed +- Function `*ChannelsClient.ListWithKeys` has been removed +- Function `*ChannelsClient.Update` has been removed +- Function `*ClientFactory.NewBotConnectionClient` has been removed +- Function `*ClientFactory.NewChannelsClient` has been removed +- Function `*ClientFactory.NewDirectLineClient` has been removed +- Function `*ClientFactory.NewEmailClient` has been removed +- Function `*ClientFactory.NewHostSettingsClient` has been removed +- Function `*ClientFactory.NewOperationResultsClient` has been removed +- Function `*ClientFactory.NewPrivateLinkResourcesClient` has been removed +- Function `*ClientFactory.NewQnAMakerEndpointKeysClient` has been removed +- Function `NewDirectLineClient` has been removed +- Function `*DirectLineClient.RegenerateKeys` has been removed +- Function `NewEmailClient` has been removed +- Function `*EmailClient.CreateSignInURL` has been removed +- Function `NewHostSettingsClient` has been removed +- Function `*HostSettingsClient.Get` has been removed +- Function `NewOperationResultsClient` has been removed +- Function `*OperationResultsClient.BeginGet` has been removed +- Function `NewPrivateLinkResourcesClient` has been removed +- Function `*PrivateLinkResourcesClient.ListByBotResource` has been removed +- Function `NewQnAMakerEndpointKeysClient` has been removed +- Function `*QnAMakerEndpointKeysClient.Get` has been removed +- Struct `ConnectionItemName` has been removed +- Struct `Error` has been removed +- Struct `ErrorBody` has been removed +- Struct `PrivateLinkResourceBase` has been removed +- Struct `Resource` has been removed + +### Features Added + +- New value `PublicNetworkAccessSecuredByPerimeter` added to enum type `PublicNetworkAccess` +- New enum type `AccessMode` with values `AccessModeAudit`, `AccessModeEnforced`, `AccessModeLearning` +- New enum type `CreatedByType` with values `CreatedByTypeApplication`, `CreatedByTypeKey`, `CreatedByTypeManagedIdentity`, `CreatedByTypeUser` +- New enum type `NspAccessRuleDirection` with values `NspAccessRuleDirectionInbound`, `NspAccessRuleDirectionOutbound` +- New enum type `ProvisioningState` with values `ProvisioningStateAccepted`, `ProvisioningStateCreating`, `ProvisioningStateDeleting`, `ProvisioningStateFailed`, `ProvisioningStateSucceeded`, `ProvisioningStateUpdating` +- New enum type `Severity` with values `SeverityError`, `SeverityWarning` +- New function `NewBotChannelsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*BotChannelsClient, error)` +- New function `*BotChannelsClient.Create(context.Context, string, string, string, BotChannel, *BotChannelsClientCreateOptions) (BotChannelsClientCreateResponse, error)` +- New function `*BotChannelsClient.Delete(context.Context, string, string, string, *BotChannelsClientDeleteOptions) (BotChannelsClientDeleteResponse, error)` +- New function `*BotChannelsClient.Get(context.Context, string, string, string, *BotChannelsClientGetOptions) (BotChannelsClientGetResponse, error)` +- New function `*BotChannelsClient.NewListByResourceGroupPager(string, string, *BotChannelsClientListByResourceGroupOptions) *runtime.Pager[BotChannelsClientListByResourceGroupResponse]` +- New function `*BotChannelsClient.ListWithKeys(context.Context, string, string, string, *BotChannelsClientListWithKeysOptions) (BotChannelsClientListWithKeysResponse, error)` +- New function `*BotChannelsClient.RegenerateKeys(context.Context, string, string, string, SiteInfo, *BotChannelsClientRegenerateKeysOptions) (BotChannelsClientRegenerateKeysResponse, error)` +- New function `*BotChannelsClient.Update(context.Context, string, string, string, BotChannel, *BotChannelsClientUpdateOptions) (BotChannelsClientUpdateResponse, error)` +- New function `NewBotConnectionOperationGroupClient(string, azcore.TokenCredential, *arm.ClientOptions) (*BotConnectionOperationGroupClient, error)` +- New function `*BotConnectionOperationGroupClient.ListServiceProviders(context.Context, *BotConnectionOperationGroupClientListServiceProvidersOptions) (BotConnectionOperationGroupClientListServiceProvidersResponse, error)` +- New function `*BotsClient.CreateSignInURL(context.Context, string, string, *BotsClientCreateSignInURLOptions) (BotsClientCreateSignInURLResponse, error)` +- New function `*BotsClient.ListByBotResource(context.Context, string, string, *BotsClientListByBotResourceOptions) (BotsClientListByBotResourceResponse, error)` +- New function `NewBotsOperationGroupClient(azcore.TokenCredential, *arm.ClientOptions) (*BotsOperationGroupClient, error)` +- New function `*BotsOperationGroupClient.GetCheckNameAvailability(context.Context, CheckNameAvailabilityRequestBody, *BotsOperationGroupClientGetCheckNameAvailabilityOptions) (BotsOperationGroupClientGetCheckNameAvailabilityResponse, error)` +- New function `*ClientFactory.NewBotChannelsClient() *BotChannelsClient` +- New function `*ClientFactory.NewBotConnectionOperationGroupClient() *BotConnectionOperationGroupClient` +- New function `*ClientFactory.NewBotsOperationGroupClient() *BotsOperationGroupClient` +- New function `*ClientFactory.NewConnectionSettingsClient() *ConnectionSettingsClient` +- New function `*ClientFactory.NewHostSettingsOperationGroupClient() *HostSettingsOperationGroupClient` +- New function `*ClientFactory.NewNetworkSecurityPerimeterConfigurationsClient() *NetworkSecurityPerimeterConfigurationsClient` +- New function `*ClientFactory.NewOperationResultsOperationGroupClient() *OperationResultsOperationGroupClient` +- New function `*ClientFactory.NewQnAMakerEndpointKeysOperationGroupClient() *QnAMakerEndpointKeysOperationGroupClient` +- New function `NewConnectionSettingsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ConnectionSettingsClient, error)` +- New function `*ConnectionSettingsClient.Create(context.Context, string, string, string, ConnectionSetting, *ConnectionSettingsClientCreateOptions) (ConnectionSettingsClientCreateResponse, error)` +- New function `*ConnectionSettingsClient.Delete(context.Context, string, string, string, *ConnectionSettingsClientDeleteOptions) (ConnectionSettingsClientDeleteResponse, error)` +- New function `*ConnectionSettingsClient.Get(context.Context, string, string, string, *ConnectionSettingsClientGetOptions) (ConnectionSettingsClientGetResponse, error)` +- New function `*ConnectionSettingsClient.NewListByBotServicePager(string, string, *ConnectionSettingsClientListByBotServiceOptions) *runtime.Pager[ConnectionSettingsClientListByBotServiceResponse]` +- New function `*ConnectionSettingsClient.ListWithSecrets(context.Context, string, string, string, *ConnectionSettingsClientListWithSecretsOptions) (ConnectionSettingsClientListWithSecretsResponse, error)` +- New function `*ConnectionSettingsClient.Update(context.Context, string, string, string, ConnectionSetting, *ConnectionSettingsClientUpdateOptions) (ConnectionSettingsClientUpdateResponse, error)` +- New function `NewHostSettingsOperationGroupClient(string, azcore.TokenCredential, *arm.ClientOptions) (*HostSettingsOperationGroupClient, error)` +- New function `*HostSettingsOperationGroupClient.Get(context.Context, *HostSettingsOperationGroupClientGetOptions) (HostSettingsOperationGroupClientGetResponse, error)` +- New function `NewOperationResultsOperationGroupClient(string, azcore.TokenCredential, *arm.ClientOptions) (*OperationResultsOperationGroupClient, error)` +- New function `*OperationResultsOperationGroupClient.BeginGet(context.Context, string, *OperationResultsOperationGroupClientBeginGetOptions) (*runtime.Poller[OperationResultsOperationGroupClientGetResponse], error)` +- New function `NewQnAMakerEndpointKeysOperationGroupClient(string, azcore.TokenCredential, *arm.ClientOptions) (*QnAMakerEndpointKeysOperationGroupClient, error)` +- New function `*QnAMakerEndpointKeysOperationGroupClient.Get(context.Context, QnAMakerEndpointKeysRequestBody, *QnAMakerEndpointKeysOperationGroupClientGetOptions) (QnAMakerEndpointKeysOperationGroupClientGetResponse, error)` +- New function `NewNetworkSecurityPerimeterConfigurationsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*NetworkSecurityPerimeterConfigurationsClient, error)` +- New function `*NetworkSecurityPerimeterConfigurationsClient.Get(context.Context, string, string, string, *NetworkSecurityPerimeterConfigurationsClientGetOptions) (NetworkSecurityPerimeterConfigurationsClientGetResponse, error)` +- New function `*NetworkSecurityPerimeterConfigurationsClient.NewListPager(string, string, *NetworkSecurityPerimeterConfigurationsClientListOptions) *runtime.Pager[NetworkSecurityPerimeterConfigurationsClientListResponse]` +- New function `*NetworkSecurityPerimeterConfigurationsClient.BeginReconcile(context.Context, string, string, string, *NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (*runtime.Poller[NetworkSecurityPerimeterConfigurationsClientReconcileResponse], error)` +- New struct `NetworkSecurityPerimeter` +- New struct `NetworkSecurityPerimeterConfiguration` +- New struct `NetworkSecurityPerimeterConfigurationList` +- New struct `NetworkSecurityPerimeterConfigurationProperties` +- New struct `NspAccessRule` +- New struct `NspAccessRuleProperties` +- New struct `NspAccessRulePropertiesSubscriptionsItem` +- New struct `Profile` +- New struct `ProvisioningIssue` +- New struct `ProvisioningIssueProperties` +- New struct `ResourceAssociation` +- New struct `SystemData` +- New field `SystemData` in struct `Bot` +- New field `SystemData` in struct `BotChannel` +- New field `NetworkSecurityPerimeterConfigurations` in struct `BotProperties` +- New field `SystemData` in struct `ConnectionSetting` +- New field `ID`, `Name` in struct `ConnectionSettingProperties` +- New field `SystemData` in struct `ListChannelWithKeysResponse` +- New field `SystemData` in struct `PrivateEndpointConnection` +- New field `NextLink` in struct `PrivateEndpointConnectionListResult` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/botservice/armbotservice/README.md b/sdk/resourcemanager/botservice/armbotservice/README.md index 41d718db6781..c6e57d2079af 100644 --- a/sdk/resourcemanager/botservice/armbotservice/README.md +++ b/sdk/resourcemanager/botservice/armbotservice/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Bot Service module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2 ``` ## Authorization @@ -55,7 +55,7 @@ clientFactory, err := armbotservice.NewClientFactory(, cred, &o A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewBotsClient() +client := clientFactory.NewBotChannelsClient() ``` ## Fakes diff --git a/sdk/resourcemanager/botservice/armbotservice/autorest.md b/sdk/resourcemanager/botservice/armbotservice/autorest.md deleted file mode 100644 index 6fc18ed9fd2b..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/autorest.md +++ /dev/null @@ -1,12 +0,0 @@ -### AutoRest Configuration - -> see https://aka.ms/autorest - -``` yaml -azure-arm: true -require: -- https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/readme.go.md -license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 -``` \ No newline at end of file diff --git a/sdk/resourcemanager/botservice/armbotservice/channels_client.go b/sdk/resourcemanager/botservice/armbotservice/botchannels_client.go similarity index 54% rename from sdk/resourcemanager/botservice/armbotservice/channels_client.go rename to sdk/resourcemanager/botservice/armbotservice/botchannels_client.go index 47e9ee6fb5be..f1654533a920 100644 --- a/sdk/resourcemanager/botservice/armbotservice/channels_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/botchannels_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -20,23 +16,23 @@ import ( "strings" ) -// ChannelsClient contains the methods for the Channels group. -// Don't use this type directly, use NewChannelsClient() instead. -type ChannelsClient struct { +// BotChannelsClient contains the methods for the BotChannels group. +// Don't use this type directly, use NewBotChannelsClient() instead. +type BotChannelsClient struct { internal *arm.Client subscriptionID string } -// NewChannelsClient creates a new instance of ChannelsClient with the specified values. -// - subscriptionID - Azure Subscription ID. +// NewBotChannelsClient creates a new instance of BotChannelsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewChannelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ChannelsClient, error) { +func NewBotChannelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BotChannelsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } - client := &ChannelsClient{ + client := &BotChannelsClient{ subscriptionID: subscriptionID, internal: cl, } @@ -46,37 +42,41 @@ func NewChannelsClient(subscriptionID string, credential azcore.TokenCredential, // Create - Creates a Channel registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. -// - channelName - The name of the Channel resource. +// - channelName - The name of the Bot resource. // - parameters - The parameters to provide for the created bot. -// - options - ChannelsClientCreateOptions contains the optional parameters for the ChannelsClient.Create method. -func (client *ChannelsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, parameters BotChannel, options *ChannelsClientCreateOptions) (ChannelsClientCreateResponse, error) { +// - options - BotChannelsClientCreateOptions contains the optional parameters for the BotChannelsClient.Create method. +func (client *BotChannelsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters BotChannel, options *BotChannelsClientCreateOptions) (BotChannelsClientCreateResponse, error) { var err error - const operationName = "ChannelsClient.Create" + const operationName = "BotChannelsClient.Create" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, channelName, parameters, options) if err != nil { - return ChannelsClientCreateResponse{}, err + return BotChannelsClientCreateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ChannelsClientCreateResponse{}, err + return BotChannelsClientCreateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return ChannelsClientCreateResponse{}, err + return BotChannelsClientCreateResponse{}, err } resp, err := client.createHandleResponse(httpResp) return resp, err } // createCreateRequest creates the Create request. -func (client *ChannelsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, parameters BotChannel, options *ChannelsClientCreateOptions) (*policy.Request, error) { +func (client *BotChannelsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters BotChannel, _ *BotChannelsClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -88,19 +88,16 @@ func (client *ChannelsClient) createCreateRequest(ctx context.Context, resourceG if channelName == "" { return nil, errors.New("parameter channelName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(string(channelName))) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -108,10 +105,10 @@ func (client *ChannelsClient) createCreateRequest(ctx context.Context, resourceG } // createHandleResponse handles the Create response. -func (client *ChannelsClient) createHandleResponse(resp *http.Response) (ChannelsClientCreateResponse, error) { - result := ChannelsClientCreateResponse{} +func (client *BotChannelsClient) createHandleResponse(resp *http.Response) (BotChannelsClientCreateResponse, error) { + result := BotChannelsClientCreateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.BotChannel); err != nil { - return ChannelsClientCreateResponse{}, err + return BotChannelsClientCreateResponse{}, err } return result, nil } @@ -119,35 +116,39 @@ func (client *ChannelsClient) createHandleResponse(resp *http.Response) (Channel // Delete - Deletes a Channel registration from a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - channelName - The name of the Bot resource. -// - options - ChannelsClientDeleteOptions contains the optional parameters for the ChannelsClient.Delete method. -func (client *ChannelsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *ChannelsClientDeleteOptions) (ChannelsClientDeleteResponse, error) { +// - options - BotChannelsClientDeleteOptions contains the optional parameters for the BotChannelsClient.Delete method. +func (client *BotChannelsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *BotChannelsClientDeleteOptions) (BotChannelsClientDeleteResponse, error) { var err error - const operationName = "ChannelsClient.Delete" + const operationName = "BotChannelsClient.Delete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, channelName, options) if err != nil { - return ChannelsClientDeleteResponse{}, err + return BotChannelsClientDeleteResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ChannelsClientDeleteResponse{}, err + return BotChannelsClientDeleteResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return ChannelsClientDeleteResponse{}, err + return BotChannelsClientDeleteResponse{}, err } - return ChannelsClientDeleteResponse{}, nil + return BotChannelsClientDeleteResponse{}, nil } // deleteCreateRequest creates the Delete request. -func (client *ChannelsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *ChannelsClientDeleteOptions) (*policy.Request, error) { +func (client *BotChannelsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName string, _ *BotChannelsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -160,16 +161,12 @@ func (client *ChannelsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter channelName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -178,36 +175,40 @@ func (client *ChannelsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Returns a BotService Channel registration specified by the parameters. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - channelName - The name of the Bot resource. -// - options - ChannelsClientGetOptions contains the optional parameters for the ChannelsClient.Get method. -func (client *ChannelsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *ChannelsClientGetOptions) (ChannelsClientGetResponse, error) { +// - options - BotChannelsClientGetOptions contains the optional parameters for the BotChannelsClient.Get method. +func (client *BotChannelsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *BotChannelsClientGetOptions) (BotChannelsClientGetResponse, error) { var err error - const operationName = "ChannelsClient.Get" + const operationName = "BotChannelsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, channelName, options) if err != nil { - return ChannelsClientGetResponse{}, err + return BotChannelsClientGetResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ChannelsClientGetResponse{}, err + return BotChannelsClientGetResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return ChannelsClientGetResponse{}, err + return BotChannelsClientGetResponse{}, err } resp, err := client.getHandleResponse(httpResp) return resp, err } // getCreateRequest creates the Get request. -func (client *ChannelsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *ChannelsClientGetOptions) (*policy.Request, error) { +func (client *BotChannelsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName string, _ *BotChannelsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -220,44 +221,40 @@ func (client *ChannelsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter channelName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getHandleResponse handles the Get response. -func (client *ChannelsClient) getHandleResponse(resp *http.Response) (ChannelsClientGetResponse, error) { - result := ChannelsClientGetResponse{} +func (client *BotChannelsClient) getHandleResponse(resp *http.Response) (BotChannelsClientGetResponse, error) { + result := BotChannelsClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.BotChannel); err != nil { - return ChannelsClientGetResponse{}, err + return BotChannelsClientGetResponse{}, err } return result, nil } // NewListByResourceGroupPager - Returns all the Channel registrations of a particular BotService resource // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. -// - options - ChannelsClientListByResourceGroupOptions contains the optional parameters for the ChannelsClient.NewListByResourceGroupPager +// - options - BotChannelsClientListByResourceGroupOptions contains the optional parameters for the BotChannelsClient.NewListByResourceGroupPager // method. -func (client *ChannelsClient) NewListByResourceGroupPager(resourceGroupName string, resourceName string, options *ChannelsClientListByResourceGroupOptions) *runtime.Pager[ChannelsClientListByResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[ChannelsClientListByResourceGroupResponse]{ - More: func(page ChannelsClientListByResourceGroupResponse) bool { +func (client *BotChannelsClient) NewListByResourceGroupPager(resourceGroupName string, resourceName string, options *BotChannelsClientListByResourceGroupOptions) *runtime.Pager[BotChannelsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[BotChannelsClientListByResourceGroupResponse]{ + More: func(page BotChannelsClientListByResourceGroupResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *ChannelsClientListByResourceGroupResponse) (ChannelsClientListByResourceGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ChannelsClient.NewListByResourceGroupPager") + Fetcher: func(ctx context.Context, page *BotChannelsClientListByResourceGroupResponse) (BotChannelsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BotChannelsClient.NewListByResourceGroupPager") nextLink := "" if page != nil { nextLink = *page.NextLink @@ -266,7 +263,7 @@ func (client *ChannelsClient) NewListByResourceGroupPager(resourceGroupName stri return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, resourceName, options) }, nil) if err != nil { - return ChannelsClientListByResourceGroupResponse{}, err + return BotChannelsClientListByResourceGroupResponse{}, err } return client.listByResourceGroupHandleResponse(resp) }, @@ -275,8 +272,12 @@ func (client *ChannelsClient) NewListByResourceGroupPager(resourceGroupName stri } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *ChannelsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ChannelsClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *BotChannelsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *BotChannelsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -285,26 +286,22 @@ func (client *ChannelsClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listByResourceGroupHandleResponse handles the ListByResourceGroup response. -func (client *ChannelsClient) listByResourceGroupHandleResponse(resp *http.Response) (ChannelsClientListByResourceGroupResponse, error) { - result := ChannelsClientListByResourceGroupResponse{} +func (client *BotChannelsClient) listByResourceGroupHandleResponse(resp *http.Response) (BotChannelsClientListByResourceGroupResponse, error) { + result := BotChannelsClientListByResourceGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ChannelResponseList); err != nil { - return ChannelsClientListByResourceGroupResponse{}, err + return BotChannelsClientListByResourceGroupResponse{}, err } return result, nil } @@ -312,36 +309,41 @@ func (client *ChannelsClient) listByResourceGroupHandleResponse(resp *http.Respo // ListWithKeys - Lists a Channel registration for a Bot Service including secrets // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. -// - channelName - The name of the Channel resource. -// - options - ChannelsClientListWithKeysOptions contains the optional parameters for the ChannelsClient.ListWithKeys method. -func (client *ChannelsClient) ListWithKeys(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, options *ChannelsClientListWithKeysOptions) (ChannelsClientListWithKeysResponse, error) { +// - channelName - The name of the Bot resource. +// - options - BotChannelsClientListWithKeysOptions contains the optional parameters for the BotChannelsClient.ListWithKeys +// method. +func (client *BotChannelsClient) ListWithKeys(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *BotChannelsClientListWithKeysOptions) (BotChannelsClientListWithKeysResponse, error) { var err error - const operationName = "ChannelsClient.ListWithKeys" + const operationName = "BotChannelsClient.ListWithKeys" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.listWithKeysCreateRequest(ctx, resourceGroupName, resourceName, channelName, options) if err != nil { - return ChannelsClientListWithKeysResponse{}, err + return BotChannelsClientListWithKeysResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ChannelsClientListWithKeysResponse{}, err + return BotChannelsClientListWithKeysResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return ChannelsClientListWithKeysResponse{}, err + return BotChannelsClientListWithKeysResponse{}, err } resp, err := client.listWithKeysHandleResponse(httpResp) return resp, err } // listWithKeysCreateRequest creates the ListWithKeys request. -func (client *ChannelsClient) listWithKeysCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, options *ChannelsClientListWithKeysOptions) (*policy.Request, error) { +func (client *BotChannelsClient) listWithKeysCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName string, _ *BotChannelsClientListWithKeysOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}/listChannelWithKeys" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -353,27 +355,98 @@ func (client *ChannelsClient) listWithKeysCreateRequest(ctx context.Context, res if channelName == "" { return nil, errors.New("parameter channelName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(string(channelName))) + urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listWithKeysHandleResponse handles the ListWithKeys response. +func (client *BotChannelsClient) listWithKeysHandleResponse(resp *http.Response) (BotChannelsClientListWithKeysResponse, error) { + result := BotChannelsClientListWithKeysResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListChannelWithKeysResponse); err != nil { + return BotChannelsClientListWithKeysResponse{}, err + } + return result, nil +} + +// RegenerateKeys - Regenerates secret keys and returns them for the DirectLine Channel of a particular BotService resource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the Bot resource. +// - channelName - The name of the Bot resource. +// - parameters - The parameters to provide for the created bot. +// - options - BotChannelsClientRegenerateKeysOptions contains the optional parameters for the BotChannelsClient.RegenerateKeys +// method. +func (client *BotChannelsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters SiteInfo, options *BotChannelsClientRegenerateKeysOptions) (BotChannelsClientRegenerateKeysResponse, error) { + var err error + const operationName = "BotChannelsClient.RegenerateKeys" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, resourceName, channelName, parameters, options) + if err != nil { + return BotChannelsClientRegenerateKeysResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BotChannelsClientRegenerateKeysResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BotChannelsClientRegenerateKeysResponse{}, err + } + resp, err := client.regenerateKeysHandleResponse(httpResp) + return resp, err +} + +// regenerateKeysCreateRequest creates the RegenerateKeys request. +func (client *BotChannelsClient) regenerateKeysCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters SiteInfo, _ *BotChannelsClientRegenerateKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}/regeneratekeys" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if channelName == "" { + return nil, errors.New("parameter channelName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } return req, nil } -// listWithKeysHandleResponse handles the ListWithKeys response. -func (client *ChannelsClient) listWithKeysHandleResponse(resp *http.Response) (ChannelsClientListWithKeysResponse, error) { - result := ChannelsClientListWithKeysResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ListChannelWithKeysResponse); err != nil { - return ChannelsClientListWithKeysResponse{}, err +// regenerateKeysHandleResponse handles the RegenerateKeys response. +func (client *BotChannelsClient) regenerateKeysHandleResponse(resp *http.Response) (BotChannelsClientRegenerateKeysResponse, error) { + result := BotChannelsClientRegenerateKeysResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BotChannel); err != nil { + return BotChannelsClientRegenerateKeysResponse{}, err } return result, nil } @@ -381,37 +454,41 @@ func (client *ChannelsClient) listWithKeysHandleResponse(resp *http.Response) (C // Update - Updates a Channel registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. -// - channelName - The name of the Channel resource. +// - channelName - The name of the Bot resource. // - parameters - The parameters to provide for the created bot. -// - options - ChannelsClientUpdateOptions contains the optional parameters for the ChannelsClient.Update method. -func (client *ChannelsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, parameters BotChannel, options *ChannelsClientUpdateOptions) (ChannelsClientUpdateResponse, error) { +// - options - BotChannelsClientUpdateOptions contains the optional parameters for the BotChannelsClient.Update method. +func (client *BotChannelsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters BotChannel, options *BotChannelsClientUpdateOptions) (BotChannelsClientUpdateResponse, error) { var err error - const operationName = "ChannelsClient.Update" + const operationName = "BotChannelsClient.Update" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, channelName, parameters, options) if err != nil { - return ChannelsClientUpdateResponse{}, err + return BotChannelsClientUpdateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ChannelsClientUpdateResponse{}, err + return BotChannelsClientUpdateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return ChannelsClientUpdateResponse{}, err + return BotChannelsClientUpdateResponse{}, err } resp, err := client.updateHandleResponse(httpResp) return resp, err } // updateCreateRequest creates the Update request. -func (client *ChannelsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, parameters BotChannel, options *ChannelsClientUpdateOptions) (*policy.Request, error) { +func (client *BotChannelsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters BotChannel, _ *BotChannelsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -423,19 +500,16 @@ func (client *ChannelsClient) updateCreateRequest(ctx context.Context, resourceG if channelName == "" { return nil, errors.New("parameter channelName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(string(channelName))) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -443,10 +517,10 @@ func (client *ChannelsClient) updateCreateRequest(ctx context.Context, resourceG } // updateHandleResponse handles the Update response. -func (client *ChannelsClient) updateHandleResponse(resp *http.Response) (ChannelsClientUpdateResponse, error) { - result := ChannelsClientUpdateResponse{} +func (client *BotChannelsClient) updateHandleResponse(resp *http.Response) (BotChannelsClientUpdateResponse, error) { + result := BotChannelsClientUpdateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.BotChannel); err != nil { - return ChannelsClientUpdateResponse{}, err + return BotChannelsClientUpdateResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/botservice/armbotservice/botchannels_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/botchannels_client_example_test.go new file mode 100644 index 000000000000..3284c3e3b352 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/botchannels_client_example_test.go @@ -0,0 +1,739 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" +) + +// Generated from example definition: 2023-09-15-preview/PutAlexaChannel.json +func ExampleBotChannelsClient_Create_createAlexaChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", "AlexaChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientCreateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.AlexaChannel{ + // ChannelName: to.Ptr("AlexaChannel"), + // Properties: &armbotservice.AlexaChannelProperties{ + // AlexaSkillID: to.Ptr("alexa skill id"), + // IsEnabled: to.Ptr(true), + // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), + // URLFragment: to.Ptr("XUrlFragmentX"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/PutChannel.json +func ExampleBotChannelsClient_Create_createChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientCreateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/PutDirectLineSpeechChannel.json +func ExampleBotChannelsClient_Create_createDirectLineSpeechChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientCreateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.DirectLineSpeechChannel{ + // ChannelName: to.Ptr("DirectLineSpeechChannel"), + // Properties: &armbotservice.DirectLineSpeechChannelProperties{ + // CognitiveServiceRegion: to.Ptr("XcognitiveServiceRegionX"), + // IsEnabled: to.Ptr(true), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/PutEmailChannel.json +func ExampleBotChannelsClient_Create_createEmailChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientCreateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // AuthMethod: to.Ptr( armbotservice.EmailChannelAuthMethodGraph), + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/PutLineChannel.json +func ExampleBotChannelsClient_Create_createLineChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", "LineChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientCreateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.LineChannel{ + // ChannelName: to.Ptr("LineChannel"), + // Properties: &armbotservice.LineChannelProperties{ + // CallbackURL: to.Ptr("http://callbackUrl"), + // IsValidated: to.Ptr(true), + // LineRegistrations: []*armbotservice.LineRegistration{ + // { + // GeneratedID: to.Ptr("id"), + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/DeleteChannel.json +func ExampleBotChannelsClient_Delete_deleteChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2023-09-15-preview/DeleteDirectLineSpeechChannel.json +func ExampleBotChannelsClient_Delete_deleteDirectLineSpeechChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2023-09-15-preview/GetAlexaChannel.json +func ExampleBotChannelsClient_Get_getAlexaChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "AlexaChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientGetResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.AlexaChannel{ + // ChannelName: to.Ptr("AlexaChannel"), + // Properties: &armbotservice.AlexaChannelProperties{ + // AlexaSkillID: to.Ptr("alexa skill id"), + // IsEnabled: to.Ptr(true), + // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), + // URLFragment: to.Ptr("XUrlFragmentX"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/GetChannel.json +func ExampleBotChannelsClient_Get_getChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientGetResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/GetDirectLineSpeechChannel.json +func ExampleBotChannelsClient_Get_getDirectLineSpeechChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientGetResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.DirectLineSpeechChannel{ + // ChannelName: to.Ptr("DirectLineSpeechChannel"), + // Properties: &armbotservice.DirectLineSpeechChannelProperties{ + // CognitiveServiceRegion: to.Ptr("Cognitive service region"), + // CustomSpeechModelID: to.Ptr("Custom speech model ID"), + // CustomVoiceDeploymentID: to.Ptr("Custom voice deployment ID"), + // IsDefaultBotForCogSvcAccount: to.Ptr(true), + // IsEnabled: to.Ptr(true), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/GetLineChannel.json +func ExampleBotChannelsClient_Get_getLineChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "LineChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientGetResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.LineChannel{ + // ChannelName: to.Ptr("LineChannel"), + // Properties: &armbotservice.LineChannelProperties{ + // CallbackURL: to.Ptr("http://callbackUrl"), + // IsValidated: to.Ptr(true), + // LineRegistrations: []*armbotservice.LineRegistration{ + // { + // GeneratedID: to.Ptr("id"), + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/ListChannelsByBotService.json +func ExampleBotChannelsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewBotChannelsClient().NewListByResourceGroupPager("OneResourceGroupName", "samplebotname", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armbotservice.BotChannelsClientListByResourceGroupResponse{ + // ChannelResponseList: armbotservice.ChannelResponseList{ + // Value: []*armbotservice.BotChannel{ + // { + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.FacebookChannel{ + // ChannelName: to.Ptr("FacebookChannel"), + // Properties: &armbotservice.FacebookChannelProperties{ + // AppID: to.Ptr("id"), + // CallbackURL: to.Ptr("appid"), + // IsEnabled: to.Ptr(true), + // Pages: []*armbotservice.FacebookPage{ + // { + // ID: to.Ptr("id"), + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2023-09-15-preview/ListChannel.json +func ExampleBotChannelsClient_ListWithKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().ListWithKeys(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientListWithKeysResponse{ + // ListChannelWithKeysResponse: &armbotservice.ListChannelWithKeysResponse{ + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // Resource: &armbotservice.DirectLineChannel{ + // ChannelName: to.Ptr("DirectLineChannel"), + // Etag: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Location: to.Ptr("aaaaaa"), + // Properties: &armbotservice.DirectLineChannelProperties{ + // Sites: []*armbotservice.DirectLineSite{ + // { + // IsBlockUserUploadEnabled: to.Ptr(false), + // IsEnabled: to.Ptr(true), + // IsSecureSiteEnabled: to.Ptr(false), + // IsV1Enabled: to.Ptr(true), + // IsV3Enabled: to.Ptr(true), + // Key: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Key2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // SiteID: to.Ptr("aaaaaaaaaaa"), + // SiteName: to.Ptr("aaaaaaaaaaaa"), + // TrustedOrigins: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // }, + // }, + // }, + // }, + // }, + // Setting: &armbotservice.ChannelSettings{ + // BotIconURL: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // BotID: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // ChannelDisplayName: to.Ptr("aaaaaaaaaaa"), + // ChannelID: to.Ptr("aaaaaaaaaa"), + // DisableLocalAuth: to.Ptr(false), + // ExtensionKey1: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // ExtensionKey2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // IsEnabled: to.Ptr(true), + // Sites: []*armbotservice.Site{ + // { + // ETag: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // IsBlockUserUploadEnabled: to.Ptr(false), + // IsEnabled: to.Ptr(true), + // IsSecureSiteEnabled: to.Ptr(false), + // IsTokenEnabled: to.Ptr(false), + // IsV1Enabled: to.Ptr(true), + // IsV3Enabled: to.Ptr(true), + // IsWebchatPreviewEnabled: to.Ptr(false), + // Key: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Key2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // SiteID: to.Ptr("aaaaaaaaaaa"), + // SiteName: to.Ptr("aaaaaaaaaaaa"), + // TrustedOrigins: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/DirectlineRegenerateKeys.json +func ExampleBotChannelsClient_RegenerateKeys_regenerateKeysForDirectLineChannelSite() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().RegenerateKeys(ctx, "OneResourceGroupName", "samplebotname", "DirectLineChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientRegenerateKeysResponse{ + // BotChannel: &armbotservice.BotChannel{ + // Location: to.Ptr("global"), + // Properties: &armbotservice.DirectLineChannel{ + // ChannelName: to.Ptr("DirectLineChannel"), + // Properties: &armbotservice.DirectLineChannelProperties{ + // Sites: []*armbotservice.DirectLineSite{ + // { + // IsEnabled: to.Ptr(true), + // IsV1Enabled: to.Ptr(true), + // IsV3Enabled: to.Ptr(true), + // Key: to.Ptr("key1"), + // Key2: to.Ptr("key2"), + // SiteID: to.Ptr("abcd"), + // SiteName: to.Ptr("Default Site"), + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/WebChatRegenerateKeys.json +func ExampleBotChannelsClient_RegenerateKeys_regenerateKeysForWebChatChannelSite() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().RegenerateKeys(ctx, "OneResourceGroupName", "samplebotname", "WebChatChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientRegenerateKeysResponse{ + // BotChannel: &armbotservice.BotChannel{ + // Location: to.Ptr("global"), + // Properties: &armbotservice.WebChatChannel{ + // ChannelName: to.Ptr("WebChatChannel"), + // Properties: &armbotservice.WebChatChannelProperties{ + // Sites: []*armbotservice.WebChatSite{ + // { + // IsEnabled: to.Ptr(true), + // IsWebchatPreviewEnabled: to.Ptr(true), + // Key: to.Ptr("key1"), + // Key2: to.Ptr("key2"), + // SiteID: to.Ptr("abcd"), + // SiteName: to.Ptr("Default Site"), + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/UpdateAlexaChannel.json +func ExampleBotChannelsClient_Update_updateAlexaChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", "AlexaChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientUpdateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.AlexaChannel{ + // ChannelName: to.Ptr("AlexaChannel"), + // Properties: &armbotservice.AlexaChannelProperties{ + // AlexaSkillID: to.Ptr("XAlexaSkillIdX"), + // IsEnabled: to.Ptr(true), + // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), + // URLFragment: to.Ptr("XUrlFragmentX"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/UpdateChannel.json +func ExampleBotChannelsClient_Update_updateChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientUpdateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/UpdateDirectLineSpeechChannel.json +func ExampleBotChannelsClient_Update_updateDirectLineSpeechChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientUpdateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.DirectLineSpeechChannel{ + // ChannelName: to.Ptr("DirectLineSpeechChannel"), + // Properties: &armbotservice.DirectLineSpeechChannelProperties{ + // CognitiveServiceRegion: to.Ptr("XcognitiveServiceRegionX"), + // IsEnabled: to.Ptr(true), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/UpdateLineChannel.json +func ExampleBotChannelsClient_Update_updateLineChannel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", "LineChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotChannelsClientUpdateResponse{ + // BotChannel: &armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.LineChannel{ + // ChannelName: to.Ptr("LineChannel"), + // Properties: &armbotservice.LineChannelProperties{ + // CallbackURL: to.Ptr("http://callbackUrl"), + // IsValidated: to.Ptr(true), + // LineRegistrations: []*armbotservice.LineRegistration{ + // { + // GeneratedID: to.Ptr("id"), + // }, + // }, + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/botconnection_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/botconnection_client_example_test.go deleted file mode 100644 index 9d00e11ef482..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/botconnection_client_example_test.go +++ /dev/null @@ -1,282 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbotservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListServiceProviders.json -func ExampleBotConnectionClient_ListServiceProviders() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBotConnectionClient().ListServiceProviders(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceProviderResponseList = armbotservice.ServiceProviderResponseList{ - // Value: []*armbotservice.ServiceProvider{ - // { - // Properties: &armbotservice.ServiceProviderProperties{ - // DevPortalURL: to.Ptr("sampleDevPortalUrl"), - // DisplayName: to.Ptr("sample service provider display name"), - // IconURL: to.Ptr("sampleIconUrl"), - // ID: to.Ptr("sampleServiceProviderId"), - // Parameters: []*armbotservice.ServiceProviderParameter{ - // { - // Name: to.Ptr("sampleParameterName"), - // Type: to.Ptr("sampleParameterType"), - // Description: to.Ptr("sampleDescription"), - // Default: to.Ptr("sampleDefaultValue"), - // DisplayName: to.Ptr("sampleDisplayName"), - // HelpURL: to.Ptr("sampleHelpUrl"), - // }}, - // ServiceProviderName: to.Ptr("sampleServiceProvider"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json -func ExampleBotConnectionClient_ListWithSecrets() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBotConnectionClient().ListWithSecrets(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ConnectionSetting = armbotservice.ConnectionSetting{ - // Name: to.Ptr("sampleConnection"), - // Etag: to.Ptr("etag1"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.ConnectionSettingProperties{ - // ClientID: to.Ptr("sampleclientid"), - // Parameters: []*armbotservice.ConnectionSettingParameter{ - // { - // Key: to.Ptr("key1"), - // Value: to.Ptr("value1"), - // }, - // { - // Key: to.Ptr("key2"), - // Value: to.Ptr("value2"), - // }}, - // Scopes: to.Ptr("samplescope"), - // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), - // ServiceProviderID: to.Ptr("serviceproviderid"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutConnection.json -func ExampleBotConnectionClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBotConnectionClient().Create(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", armbotservice.ConnectionSetting{ - Etag: to.Ptr("etag1"), - Location: to.Ptr("West US"), - Properties: &armbotservice.ConnectionSettingProperties{ - ClientID: to.Ptr("sampleclientid"), - ClientSecret: to.Ptr("samplesecret"), - Parameters: []*armbotservice.ConnectionSettingParameter{ - { - Key: to.Ptr("key1"), - Value: to.Ptr("value1"), - }, - { - Key: to.Ptr("key2"), - Value: to.Ptr("value2"), - }}, - Scopes: to.Ptr("samplescope"), - ServiceProviderID: to.Ptr("serviceproviderid"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ConnectionSetting = armbotservice.ConnectionSetting{ - // Name: to.Ptr("sampleConnection"), - // Etag: to.Ptr("etag1"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.ConnectionSettingProperties{ - // ClientID: to.Ptr("sampleclientid"), - // Parameters: []*armbotservice.ConnectionSettingParameter{ - // { - // Key: to.Ptr("key1"), - // Value: to.Ptr("value1"), - // }, - // { - // Key: to.Ptr("key2"), - // Value: to.Ptr("value2"), - // }}, - // Scopes: to.Ptr("samplescope"), - // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), - // ServiceProviderID: to.Ptr("serviceproviderid"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateConnection.json -func ExampleBotConnectionClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBotConnectionClient().Update(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", armbotservice.ConnectionSetting{ - Etag: to.Ptr("etag1"), - Location: to.Ptr("global"), - Properties: &armbotservice.ConnectionSettingProperties{ - ClientID: to.Ptr("sampleclientid"), - ClientSecret: to.Ptr("samplesecret"), - Parameters: []*armbotservice.ConnectionSettingParameter{ - { - Key: to.Ptr("key1"), - Value: to.Ptr("value1"), - }, - { - Key: to.Ptr("key2"), - Value: to.Ptr("value2"), - }}, - Scopes: to.Ptr("samplescope"), - ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), - ServiceProviderID: to.Ptr("serviceproviderid"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ConnectionSetting = armbotservice.ConnectionSetting{ - // Name: to.Ptr("sampleConnection"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.ConnectionSettingProperties{ - // ClientID: to.Ptr("sampleclientid"), - // Parameters: []*armbotservice.ConnectionSettingParameter{ - // { - // Key: to.Ptr("key1"), - // Value: to.Ptr("value1"), - // }, - // { - // Key: to.Ptr("key2"), - // Value: to.Ptr("value2"), - // }}, - // Scopes: to.Ptr("samplescope"), - // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), - // ServiceProviderID: to.Ptr("serviceproviderid"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteConnection.json -func ExampleBotConnectionClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewBotConnectionClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListConnectionsByBotService.json -func ExampleBotConnectionClient_NewListByBotServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBotConnectionClient().NewListByBotServicePager("OneResourceGroupName", "samplebotname", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ConnectionSettingResponseList = armbotservice.ConnectionSettingResponseList{ - // Value: []*armbotservice.ConnectionSetting{ - // { - // Name: to.Ptr("sampleConnection"), - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Properties: &armbotservice.ConnectionSettingProperties{ - // ClientID: to.Ptr("sampleclientid"), - // Parameters: []*armbotservice.ConnectionSettingParameter{ - // { - // Key: to.Ptr("key1"), - // Value: to.Ptr("value1"), - // }, - // { - // Key: to.Ptr("key2"), - // Value: to.Ptr("value2"), - // }}, - // Scopes: to.Ptr("samplescope"), - // ServiceProviderID: to.Ptr("serviceproviderid"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/botservice/armbotservice/botconnectionoperationgroup_client.go b/sdk/resourcemanager/botservice/armbotservice/botconnectionoperationgroup_client.go new file mode 100644 index 000000000000..135dff31a38f --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/botconnectionoperationgroup_client.go @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// BotConnectionOperationGroupClient contains the methods for the BotConnectionOperationGroup group. +// Don't use this type directly, use NewBotConnectionOperationGroupClient() instead. +type BotConnectionOperationGroupClient struct { + internal *arm.Client + subscriptionID string +} + +// NewBotConnectionOperationGroupClient creates a new instance of BotConnectionOperationGroupClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewBotConnectionOperationGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BotConnectionOperationGroupClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BotConnectionOperationGroupClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// ListServiceProviders - Lists the available Service Providers for creating Connection Settings +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-15-preview +// - options - BotConnectionOperationGroupClientListServiceProvidersOptions contains the optional parameters for the BotConnectionOperationGroupClient.ListServiceProviders +// method. +func (client *BotConnectionOperationGroupClient) ListServiceProviders(ctx context.Context, options *BotConnectionOperationGroupClientListServiceProvidersOptions) (BotConnectionOperationGroupClientListServiceProvidersResponse, error) { + var err error + const operationName = "BotConnectionOperationGroupClient.ListServiceProviders" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listServiceProvidersCreateRequest(ctx, options) + if err != nil { + return BotConnectionOperationGroupClientListServiceProvidersResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BotConnectionOperationGroupClientListServiceProvidersResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BotConnectionOperationGroupClientListServiceProvidersResponse{}, err + } + resp, err := client.listServiceProvidersHandleResponse(httpResp) + return resp, err +} + +// listServiceProvidersCreateRequest creates the ListServiceProviders request. +func (client *BotConnectionOperationGroupClient) listServiceProvidersCreateRequest(ctx context.Context, _ *BotConnectionOperationGroupClientListServiceProvidersOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.BotService/listAuthServiceProviders" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listServiceProvidersHandleResponse handles the ListServiceProviders response. +func (client *BotConnectionOperationGroupClient) listServiceProvidersHandleResponse(resp *http.Response) (BotConnectionOperationGroupClientListServiceProvidersResponse, error) { + result := BotConnectionOperationGroupClientListServiceProvidersResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ServiceProviderResponseList); err != nil { + return BotConnectionOperationGroupClientListServiceProvidersResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/botservice/armbotservice/botconnectionoperationgroup_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/botconnectionoperationgroup_client_example_test.go new file mode 100644 index 000000000000..b22b91178831 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/botconnectionoperationgroup_client_example_test.go @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" +) + +// Generated from example definition: 2023-09-15-preview/ListServiceProviders.json +func ExampleBotConnectionOperationGroupClient_ListServiceProviders() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotConnectionOperationGroupClient().ListServiceProviders(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotConnectionOperationGroupClientListServiceProvidersResponse{ + // ServiceProviderResponseList: &armbotservice.ServiceProviderResponseList{ + // Value: []*armbotservice.ServiceProvider{ + // { + // Properties: &armbotservice.ServiceProviderProperties{ + // DevPortalURL: to.Ptr("sampleDevPortalUrl"), + // DisplayName: to.Ptr("sample service provider display name"), + // IconURL: to.Ptr("sampleIconUrl"), + // ID: to.Ptr("sampleServiceProviderId"), + // Parameters: []*armbotservice.ServiceProviderParameter{ + // { + // Name: to.Ptr("sampleParameterName"), + // Type: to.Ptr("sampleParameterType"), + // Description: to.Ptr("sampleDescription"), + // Default: to.Ptr("sampleDefaultValue"), + // DisplayName: to.Ptr("sampleDisplayName"), + // HelpURL: to.Ptr("sampleHelpUrl"), + // }, + // }, + // ServiceProviderName: to.Ptr("sampleServiceProvider"), + // }, + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/bots_client.go b/sdk/resourcemanager/botservice/armbotservice/bots_client.go index cb61b5f3ebe3..397e272c9581 100644 --- a/sdk/resourcemanager/botservice/armbotservice/bots_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/bots_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -28,7 +24,7 @@ type BotsClient struct { } // NewBotsClient creates a new instance of BotsClient with the specified values. -// - subscriptionID - Azure Subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewBotsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BotsClient, error) { @@ -46,8 +42,8 @@ func NewBotsClient(subscriptionID string, credential azcore.TokenCredential, opt // Create - Creates a Bot Service. Bot Service is a resource group wide resource type. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - parameters - The parameters to provide for the created bot. // - options - BotsClientCreateOptions contains the optional parameters for the BotsClient.Create method. @@ -74,8 +70,12 @@ func (client *BotsClient) Create(ctx context.Context, resourceGroupName string, } // createCreateRequest creates the Create request. -func (client *BotsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters Bot, options *BotsClientCreateOptions) (*policy.Request, error) { +func (client *BotsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters Bot, _ *BotsClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -84,18 +84,15 @@ func (client *BotsClient) createCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -111,11 +108,75 @@ func (client *BotsClient) createHandleResponse(resp *http.Response) (BotsClientC return result, nil } +// CreateSignInURL - Creates an email channel sign in url for a Bot Service +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the Bot resource. +// - options - BotsClientCreateSignInURLOptions contains the optional parameters for the BotsClient.CreateSignInURL method. +func (client *BotsClient) CreateSignInURL(ctx context.Context, resourceGroupName string, resourceName string, options *BotsClientCreateSignInURLOptions) (BotsClientCreateSignInURLResponse, error) { + var err error + const operationName = "BotsClient.CreateSignInURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createSignInURLCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return BotsClientCreateSignInURLResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BotsClientCreateSignInURLResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BotsClientCreateSignInURLResponse{}, err + } + resp, err := client.createSignInURLHandleResponse(httpResp) + return resp, err +} + +// createSignInURLCreateRequest creates the CreateSignInURL request. +func (client *BotsClient) createSignInURLCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *BotsClientCreateSignInURLOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/createEmailSignInUrl" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// createSignInURLHandleResponse handles the CreateSignInURL response. +func (client *BotsClient) createSignInURLHandleResponse(resp *http.Response) (BotsClientCreateSignInURLResponse, error) { + result := BotsClientCreateSignInURLResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CreateEmailSignInURLResponse); err != nil { + return BotsClientCreateSignInURLResponse{}, err + } + return result, nil +} + // Delete - Deletes a Bot Service from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - options - BotsClientDeleteOptions contains the optional parameters for the BotsClient.Delete method. func (client *BotsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, options *BotsClientDeleteOptions) (BotsClientDeleteResponse, error) { @@ -140,8 +201,12 @@ func (client *BotsClient) Delete(ctx context.Context, resourceGroupName string, } // deleteCreateRequest creates the Delete request. -func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *BotsClientDeleteOptions) (*policy.Request, error) { +func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *BotsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -150,16 +215,12 @@ func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -168,8 +229,8 @@ func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroup // Get - Returns a BotService specified by the parameters. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - options - BotsClientGetOptions contains the optional parameters for the BotsClient.Get method. func (client *BotsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *BotsClientGetOptions) (BotsClientGetResponse, error) { @@ -195,8 +256,12 @@ func (client *BotsClient) Get(ctx context.Context, resourceGroupName string, res } // getCreateRequest creates the Get request. -func (client *BotsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *BotsClientGetOptions) (*policy.Request, error) { +func (client *BotsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *BotsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -205,16 +270,12 @@ func (client *BotsClient) getCreateRequest(ctx context.Context, resourceGroupNam return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -229,64 +290,9 @@ func (client *BotsClient) getHandleResponse(resp *http.Response) (BotsClientGetR return result, nil } -// GetCheckNameAvailability - Check whether a bot name is available. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-09-15 -// - parameters - The request body parameters to provide for the check name availability request -// - options - BotsClientGetCheckNameAvailabilityOptions contains the optional parameters for the BotsClient.GetCheckNameAvailability -// method. -func (client *BotsClient) GetCheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityRequestBody, options *BotsClientGetCheckNameAvailabilityOptions) (BotsClientGetCheckNameAvailabilityResponse, error) { - var err error - const operationName = "BotsClient.GetCheckNameAvailability" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCheckNameAvailabilityCreateRequest(ctx, parameters, options) - if err != nil { - return BotsClientGetCheckNameAvailabilityResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return BotsClientGetCheckNameAvailabilityResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return BotsClientGetCheckNameAvailabilityResponse{}, err - } - resp, err := client.getCheckNameAvailabilityHandleResponse(httpResp) - return resp, err -} - -// getCheckNameAvailabilityCreateRequest creates the GetCheckNameAvailability request. -func (client *BotsClient) getCheckNameAvailabilityCreateRequest(ctx context.Context, parameters CheckNameAvailabilityRequestBody, options *BotsClientGetCheckNameAvailabilityOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.BotService/checkNameAvailability" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// getCheckNameAvailabilityHandleResponse handles the GetCheckNameAvailability response. -func (client *BotsClient) getCheckNameAvailabilityHandleResponse(resp *http.Response) (BotsClientGetCheckNameAvailabilityResponse, error) { - result := BotsClientGetCheckNameAvailabilityResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponseBody); err != nil { - return BotsClientGetCheckNameAvailabilityResponse{}, err - } - return result, nil -} - // NewListPager - Returns all the resources of a particular type belonging to a subscription. // -// Generated from API version 2022-09-15 +// Generated from API version 2023-09-15-preview // - options - BotsClientListOptions contains the optional parameters for the BotsClient.NewListPager method. func (client *BotsClient) NewListPager(options *BotsClientListOptions) *runtime.Pager[BotsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[BotsClientListResponse]{ @@ -312,7 +318,7 @@ func (client *BotsClient) NewListPager(options *BotsClientListOptions) *runtime. } // listCreateRequest creates the List request. -func (client *BotsClient) listCreateRequest(ctx context.Context, options *BotsClientListOptions) (*policy.Request, error) { +func (client *BotsClient) listCreateRequest(ctx context.Context, _ *BotsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.BotService/botServices" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -323,7 +329,7 @@ func (client *BotsClient) listCreateRequest(ctx context.Context, options *BotsCl return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,10 +344,74 @@ func (client *BotsClient) listHandleResponse(resp *http.Response) (BotsClientLis return result, nil } +// ListByBotResource - Gets the private link resources that need to be created for a Bot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the Bot resource. +// - options - BotsClientListByBotResourceOptions contains the optional parameters for the BotsClient.ListByBotResource method. +func (client *BotsClient) ListByBotResource(ctx context.Context, resourceGroupName string, resourceName string, options *BotsClientListByBotResourceOptions) (BotsClientListByBotResourceResponse, error) { + var err error + const operationName = "BotsClient.ListByBotResource" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByBotResourceCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return BotsClientListByBotResourceResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BotsClientListByBotResourceResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BotsClientListByBotResourceResponse{}, err + } + resp, err := client.listByBotResourceHandleResponse(httpResp) + return resp, err +} + +// listByBotResourceCreateRequest creates the ListByBotResource request. +func (client *BotsClient) listByBotResourceCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *BotsClientListByBotResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/privateLinkResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBotResourceHandleResponse handles the ListByBotResource response. +func (client *BotsClient) listByBotResourceHandleResponse(resp *http.Response) (BotsClientListByBotResourceResponse, error) { + result := BotsClientListByBotResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkResourceListResult); err != nil { + return BotsClientListByBotResourceResponse{}, err + } + return result, nil +} + // NewListByResourceGroupPager - Returns all the resources of a particular type belonging to a resource group // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - BotsClientListByResourceGroupOptions contains the optional parameters for the BotsClient.NewListByResourceGroupPager // method. func (client *BotsClient) NewListByResourceGroupPager(resourceGroupName string, options *BotsClientListByResourceGroupOptions) *runtime.Pager[BotsClientListByResourceGroupResponse] { @@ -368,22 +438,22 @@ func (client *BotsClient) NewListByResourceGroupPager(resourceGroupName string, } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *BotsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *BotsClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *BotsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *BotsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -401,8 +471,8 @@ func (client *BotsClient) listByResourceGroupHandleResponse(resp *http.Response) // Update - Updates a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - parameters - The parameters to provide for the created bot. // - options - BotsClientUpdateOptions contains the optional parameters for the BotsClient.Update method. @@ -429,8 +499,12 @@ func (client *BotsClient) Update(ctx context.Context, resourceGroupName string, } // updateCreateRequest creates the Update request. -func (client *BotsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters Bot, options *BotsClientUpdateOptions) (*policy.Request, error) { +func (client *BotsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters Bot, _ *BotsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -439,18 +513,15 @@ func (client *BotsClient) updateCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/bots_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/bots_client_example_test.go index 24b92a0207bc..5dcc8da2b86e 100644 --- a/sdk/resourcemanager/botservice/armbotservice/bots_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/bots_client_example_test.go @@ -1,230 +1,138 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice_test import ( "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CreateBot.json +// Generated from example definition: 2023-09-15-preview/CreateBot.json func ExampleBotsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewBotsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.Bot{ - Etag: to.Ptr("etag1"), - Kind: to.Ptr(armbotservice.KindSdk), - Location: to.Ptr("West US"), - SKU: &armbotservice.SKU{ - Name: to.Ptr(armbotservice.SKUNameS1), - }, - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - Properties: &armbotservice.BotProperties{ - Description: to.Ptr("The description of the bot"), - CmekKeyVaultURL: to.Ptr("https://myCmekKey"), - DeveloperAppInsightKey: to.Ptr("appinsightskey"), - DeveloperAppInsightsAPIKey: to.Ptr("appinsightsapikey"), - DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), - DisableLocalAuth: to.Ptr(true), - DisplayName: to.Ptr("The Name of the bot"), - Endpoint: to.Ptr("http://mybot.coffee"), - IconURL: to.Ptr("http://myicon"), - IsCmekEnabled: to.Ptr(true), - LuisAppIDs: []*string{ - to.Ptr("luisappid1"), - to.Ptr("luisappid2")}, - LuisKey: to.Ptr("luiskey"), - MsaAppID: to.Ptr("exampleappid"), - MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), - MsaAppTenantID: to.Ptr("exampleapptenantid"), - MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), - PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), - SchemaTransformationVersion: to.Ptr("1.0"), - }, - }, nil) + res, err := clientFactory.NewBotsClient().Create(ctx, "OneResourceGroupName", "samplebotname", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Bot = armbotservice.Bot{ - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.BotService/botServices"), - // Etag: to.Ptr("etag1"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), - // Kind: to.Ptr(armbotservice.KindSdk), - // Location: to.Ptr("West US"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // Properties: &armbotservice.BotProperties{ - // Description: to.Ptr("The description of the bot"), - // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), - // ConfiguredChannels: []*string{ - // to.Ptr("facebook"), - // to.Ptr("groupme")}, + // res = armbotservice.BotsClientCreateResponse{ + // Bot: &armbotservice.Bot{ + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme"), + // }, // DeveloperAppInsightKey: to.Ptr("appinsightskey"), // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), // DisableLocalAuth: to.Ptr(true), // DisplayName: to.Ptr("The Name of the bot"), // EnabledChannels: []*string{ - // to.Ptr("facebook")}, - // Endpoint: to.Ptr("http://mybot.coffee"), - // EndpointVersion: to.Ptr("version"), - // IconURL: to.Ptr("http://myicon"), - // IsCmekEnabled: to.Ptr(true), - // LuisAppIDs: []*string{ - // to.Ptr("luisappid1"), - // to.Ptr("luisappid2")}, - // MsaAppID: to.Ptr("msaappid"), - // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), - // MsaAppTenantID: to.Ptr("msaapptenantid"), - // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), - // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), - // SchemaTransformationVersion: to.Ptr("1.0"), - // }, - // } + // to.Ptr("facebook"), + // }, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2"), + // }, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateBot.json -func ExampleBotsClient_Update() { +// Generated from example definition: 2023-09-15-preview/CreateEmailSignInUrl.json +func ExampleBotsClient_CreateSignInURL() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewBotsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.Bot{ - Etag: to.Ptr("etag1"), - Kind: to.Ptr(armbotservice.KindSdk), - Location: to.Ptr("West US"), - SKU: &armbotservice.SKU{ - Name: to.Ptr(armbotservice.SKUNameS1), - }, - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - Properties: &armbotservice.BotProperties{ - Description: to.Ptr("The description of the bot"), - CmekKeyVaultURL: to.Ptr("https://myCmekKey"), - DeveloperAppInsightKey: to.Ptr("appinsightskey"), - DeveloperAppInsightsAPIKey: to.Ptr("appinsightsapikey"), - DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), - DisableLocalAuth: to.Ptr(true), - DisplayName: to.Ptr("The Name of the bot"), - Endpoint: to.Ptr("http://mybot.coffee"), - IconURL: to.Ptr("http://myicon"), - IsCmekEnabled: to.Ptr(true), - LuisAppIDs: []*string{ - to.Ptr("luisappid1"), - to.Ptr("luisappid2")}, - LuisKey: to.Ptr("luiskey"), - MsaAppID: to.Ptr("msaappid"), - MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), - MsaAppTenantID: to.Ptr("msaapptenantid"), - MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), - PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), - SchemaTransformationVersion: to.Ptr("1.0"), - }, - }, nil) + res, err := clientFactory.NewBotsClient().CreateSignInURL(ctx, "OneResourceGroupName", "samplebotname", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Bot = armbotservice.Bot{ - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.BotService/botServices"), - // Etag: to.Ptr("etag1"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), - // Kind: to.Ptr(armbotservice.KindSdk), - // Location: to.Ptr("West US"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), + // res = armbotservice.BotsClientCreateSignInURLResponse{ + // CreateEmailSignInURLResponse: &armbotservice.CreateEmailSignInURLResponse{ + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.CreateEmailSignInURLResponseProperties{ + // URL: to.Ptr("https://token.botframework.com/api/oauth/signin?signin=XXX"), + // }, // }, - // Properties: &armbotservice.BotProperties{ - // Description: to.Ptr("The description of the bot"), - // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), - // ConfiguredChannels: []*string{ - // to.Ptr("facebook"), - // to.Ptr("groupme")}, - // DeveloperAppInsightKey: to.Ptr("appinsightskey"), - // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), - // DisableLocalAuth: to.Ptr(true), - // DisplayName: to.Ptr("The Name of the bot"), - // EnabledChannels: []*string{ - // to.Ptr("facebook")}, - // Endpoint: to.Ptr("http://mybot.coffee"), - // EndpointVersion: to.Ptr("version"), - // IconURL: to.Ptr("http://myicon"), - // IsCmekEnabled: to.Ptr(true), - // LuisAppIDs: []*string{ - // to.Ptr("luisappid1"), - // to.Ptr("luisappid2")}, - // MsaAppID: to.Ptr("msaappid"), - // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), - // MsaAppTenantID: to.Ptr("msaapptenantid"), - // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), - // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), - // SchemaTransformationVersion: to.Ptr("1.0"), - // }, - // } + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteBot.json +// Generated from example definition: 2023-09-15-preview/DeleteBot.json func ExampleBotsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewBotsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", nil) + res, err := clientFactory.NewBotsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotsClientDeleteResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetBot.json +// Generated from example definition: 2023-09-15-preview/GetBot.json func ExampleBotsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -235,73 +143,81 @@ func ExampleBotsClient_Get() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Bot = armbotservice.Bot{ - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.BotService/botServices"), - // Etag: to.Ptr("etag1"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), - // Kind: to.Ptr(armbotservice.KindSdk), - // Location: to.Ptr("West US"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // Properties: &armbotservice.BotProperties{ - // Description: to.Ptr("The description of the bot"), - // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), - // ConfiguredChannels: []*string{ - // to.Ptr("facebook"), - // to.Ptr("groupme")}, + // res = armbotservice.BotsClientGetResponse{ + // Bot: &armbotservice.Bot{ + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme"), + // }, // DeveloperAppInsightKey: to.Ptr("appinsightskey"), // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), // DisableLocalAuth: to.Ptr(true), // DisplayName: to.Ptr("The Name of the bot"), // EnabledChannels: []*string{ - // to.Ptr("facebook")}, - // Endpoint: to.Ptr("http://mybot.coffee"), - // EndpointVersion: to.Ptr("version"), - // IconURL: to.Ptr("http://myicon"), - // IsCmekEnabled: to.Ptr(true), - // LuisAppIDs: []*string{ - // to.Ptr("luisappid1"), - // to.Ptr("luisappid2")}, - // MsaAppID: to.Ptr("msaappid"), - // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), - // MsaAppTenantID: to.Ptr("msaapptenantid"), - // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), - // PrivateEndpointConnections: []*armbotservice.PrivateEndpointConnection{ - // { - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/privateEndpointConnections/privatelink"), - // Properties: &armbotservice.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armbotservice.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.Network/privateEndpoints/privatelink"), - // }, - // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }}, - // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), - // SchemaTransformationVersion: to.Ptr("1.0"), + // to.Ptr("facebook"), + // }, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2"), + // }, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // NetworkSecurityPerimeterConfigurations: []*armbotservice.NetworkSecurityPerimeterConfiguration{ + // }, + // PrivateEndpointConnections: []*armbotservice.PrivateEndpointConnection{ + // { + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/privateEndpointConnections/privatelink"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.Network/privateEndpoints/privatelink"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, // }, - // } + // }, + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsByResourceGroup.json -func ExampleBotsClient_NewListByResourceGroupPager() { +// Generated from example definition: 2023-09-15-preview/ListBotsBySubscription.json +func ExampleBotsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewBotsClient().NewListByResourceGroupPager("OneResourceGroupName", nil) + pager := clientFactory.NewBotsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -312,62 +228,108 @@ func ExampleBotsClient_NewListByResourceGroupPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BotResponseList = armbotservice.BotResponseList{ - // Value: []*armbotservice.Bot{ - // { - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.BotService/botServices"), - // Etag: to.Ptr("etag1"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices"), - // Kind: to.Ptr(armbotservice.KindSdk), - // Location: to.Ptr("West US"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // Properties: &armbotservice.BotProperties{ - // Description: to.Ptr("The description of the bot"), - // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), - // ConfiguredChannels: []*string{ - // to.Ptr("facebook"), - // to.Ptr("groupme")}, + // page = armbotservice.BotsClientListResponse{ + // BotResponseList: armbotservice.BotResponseList{ + // Value: []*armbotservice.Bot{ + // { + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme"), + // }, // DeveloperAppInsightKey: to.Ptr("appinsightskey"), // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), // DisableLocalAuth: to.Ptr(true), // DisplayName: to.Ptr("The Name of the bot"), // EnabledChannels: []*string{ - // to.Ptr("facebook")}, - // Endpoint: to.Ptr("http://mybot.coffee"), - // EndpointVersion: to.Ptr("version"), - // IconURL: to.Ptr("http://myicon"), - // IsCmekEnabled: to.Ptr(true), - // LuisAppIDs: []*string{ - // to.Ptr("luisappid1"), - // to.Ptr("luisappid2")}, - // MsaAppID: to.Ptr("msaappid"), - // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), - // MsaAppTenantID: to.Ptr("msaapptenantid"), - // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), - // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), - // SchemaTransformationVersion: to.Ptr("1.0"), - // }, - // }}, - // } + // to.Ptr("facebook"), + // }, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2"), + // }, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // }, + // }, + // }, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsBySubscription.json -func ExampleBotsClient_NewListPager() { +// Generated from example definition: 2023-09-15-preview/ListPrivateLinkResources.json +func ExampleBotsClient_ListByBotResource() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewBotsClient().NewListPager(nil) + res, err := clientFactory.NewBotsClient().ListByBotResource(ctx, "res6977", "sto2527", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotsClientListByBotResourceResponse{ + // PrivateLinkResourceListResult: &armbotservice.PrivateLinkResourceListResult{ + // Value: []*armbotservice.PrivateLinkResource{ + // { + // Name: to.Ptr("resource1"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateLinkResources"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res6977/providers/Microsoft.BotService/botServices/sto2527/privateLinkResources/resource1"), + // Properties: &armbotservice.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("bot"), + // RequiredMembers: []*string{ + // to.Ptr("bot"), + // }, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.botframework.com"), + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/ListBotsByResourceGroup.json +func ExampleBotsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewBotsClient().NewListByResourceGroupPager("OneResourceGroupName", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -378,73 +340,115 @@ func ExampleBotsClient_NewListPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BotResponseList = armbotservice.BotResponseList{ - // Value: []*armbotservice.Bot{ - // { - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.BotService/botServices"), - // Etag: to.Ptr("etag1"), - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Kind: to.Ptr(armbotservice.KindSdk), - // Location: to.Ptr("West US"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // Properties: &armbotservice.BotProperties{ - // Description: to.Ptr("The description of the bot"), - // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), - // ConfiguredChannels: []*string{ - // to.Ptr("facebook"), - // to.Ptr("groupme")}, + // page = armbotservice.BotsClientListByResourceGroupResponse{ + // BotResponseList: armbotservice.BotResponseList{ + // Value: []*armbotservice.Bot{ + // { + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme"), + // }, // DeveloperAppInsightKey: to.Ptr("appinsightskey"), // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), // DisableLocalAuth: to.Ptr(true), // DisplayName: to.Ptr("The Name of the bot"), // EnabledChannels: []*string{ - // to.Ptr("facebook")}, - // Endpoint: to.Ptr("http://mybot.coffee"), - // EndpointVersion: to.Ptr("version"), - // IconURL: to.Ptr("http://myicon"), - // IsCmekEnabled: to.Ptr(true), - // LuisAppIDs: []*string{ - // to.Ptr("luisappid1"), - // to.Ptr("luisappid2")}, - // MsaAppID: to.Ptr("msaappid"), - // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), - // MsaAppTenantID: to.Ptr("msaapptenantid"), - // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), - // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), - // SchemaTransformationVersion: to.Ptr("1.0"), - // }, - // }}, - // } + // to.Ptr("facebook"), + // }, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2"), + // }, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // }, + // }, + // }, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CheckNameAvailability.json -func ExampleBotsClient_GetCheckNameAvailability() { +// Generated from example definition: 2023-09-15-preview/UpdateBot.json +func ExampleBotsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewBotsClient().GetCheckNameAvailability(ctx, armbotservice.CheckNameAvailabilityRequestBody{ - Name: to.Ptr("testbotname"), - Type: to.Ptr("string"), - }, nil) + res, err := clientFactory.NewBotsClient().Update(ctx, "OneResourceGroupName", "samplebotname", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckNameAvailabilityResponseBody = armbotservice.CheckNameAvailabilityResponseBody{ - // Message: to.Ptr("custom message from server"), - // Valid: to.Ptr(true), + // res = armbotservice.BotsClientUpdateResponse{ + // Bot: &armbotservice.Bot{ + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme"), + // }, + // DeveloperAppInsightKey: to.Ptr("appinsightskey"), + // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), + // DisableLocalAuth: to.Ptr(true), + // DisplayName: to.Ptr("The Name of the bot"), + // EnabledChannels: []*string{ + // to.Ptr("facebook"), + // }, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2"), + // }, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // }, // } } diff --git a/sdk/resourcemanager/botservice/armbotservice/botservice_live_test.go b/sdk/resourcemanager/botservice/armbotservice/botservice_live_test.go index 6ded9ffa990b..ba8fa3902b30 100644 --- a/sdk/resourcemanager/botservice/armbotservice/botservice_live_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/botservice_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" diff --git a/sdk/resourcemanager/botservice/armbotservice/botsoperationgroup_client.go b/sdk/resourcemanager/botservice/armbotservice/botsoperationgroup_client.go new file mode 100644 index 000000000000..4023f001bef6 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/botsoperationgroup_client.go @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// BotsOperationGroupClient contains the methods for the BotsOperationGroup group. +// Don't use this type directly, use NewBotsOperationGroupClient() instead. +type BotsOperationGroupClient struct { + internal *arm.Client +} + +// NewBotsOperationGroupClient creates a new instance of BotsOperationGroupClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewBotsOperationGroupClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*BotsOperationGroupClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BotsOperationGroupClient{ + internal: cl, + } + return client, nil +} + +// GetCheckNameAvailability - Check whether a bot name is available. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-15-preview +// - parameters - The request body +// - options - BotsOperationGroupClientGetCheckNameAvailabilityOptions contains the optional parameters for the BotsOperationGroupClient.GetCheckNameAvailability +// method. +func (client *BotsOperationGroupClient) GetCheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityRequestBody, options *BotsOperationGroupClientGetCheckNameAvailabilityOptions) (BotsOperationGroupClientGetCheckNameAvailabilityResponse, error) { + var err error + const operationName = "BotsOperationGroupClient.GetCheckNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCheckNameAvailabilityCreateRequest(ctx, parameters, options) + if err != nil { + return BotsOperationGroupClientGetCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BotsOperationGroupClientGetCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BotsOperationGroupClientGetCheckNameAvailabilityResponse{}, err + } + resp, err := client.getCheckNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// getCheckNameAvailabilityCreateRequest creates the GetCheckNameAvailability request. +func (client *BotsOperationGroupClient) getCheckNameAvailabilityCreateRequest(ctx context.Context, parameters CheckNameAvailabilityRequestBody, _ *BotsOperationGroupClientGetCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BotService/checkNameAvailability" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// getCheckNameAvailabilityHandleResponse handles the GetCheckNameAvailability response. +func (client *BotsOperationGroupClient) getCheckNameAvailabilityHandleResponse(resp *http.Response) (BotsOperationGroupClientGetCheckNameAvailabilityResponse, error) { + result := BotsOperationGroupClientGetCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponseBody); err != nil { + return BotsOperationGroupClientGetCheckNameAvailabilityResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/botservice/armbotservice/botsoperationgroup_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/botsoperationgroup_client_example_test.go new file mode 100644 index 000000000000..9416ca53e1b1 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/botsoperationgroup_client_example_test.go @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" +) + +// Generated from example definition: 2023-09-15-preview/CheckNameAvailability.json +func ExampleBotsOperationGroupClient_GetCheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBotsOperationGroupClient().GetCheckNameAvailability(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.BotsOperationGroupClientGetCheckNameAvailabilityResponse{ + // CheckNameAvailabilityResponseBody: &armbotservice.CheckNameAvailabilityResponseBody{ + // Message: to.Ptr("custom message from server"), + // Valid: to.Ptr(true), + // }, + // } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/build.go b/sdk/resourcemanager/botservice/armbotservice/build.go deleted file mode 100644 index 015036fbe89a..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/build.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/botservice/armbotservice - -package armbotservice diff --git a/sdk/resourcemanager/botservice/armbotservice/channels_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/channels_client_example_test.go deleted file mode 100644 index aafa11d4684c..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/channels_client_example_test.go +++ /dev/null @@ -1,709 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbotservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutAlexaChannel.json -func ExampleChannelsClient_Create_createAlexaChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameAlexaChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.AlexaChannel{ - ChannelName: to.Ptr("AlexaChannel"), - Properties: &armbotservice.AlexaChannelProperties{ - AlexaSkillID: to.Ptr("XAlexaSkillIdX"), - IsEnabled: to.Ptr(true), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.AlexaChannel{ - // ChannelName: to.Ptr("AlexaChannel"), - // Properties: &armbotservice.AlexaChannelProperties{ - // AlexaSkillID: to.Ptr("alexa skill id"), - // IsEnabled: to.Ptr(true), - // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), - // URLFragment: to.Ptr("XUrlFragmentX"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutChannel.json -func ExampleChannelsClient_Create_createChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.EmailChannel{ - ChannelName: to.Ptr("EmailChannel"), - Properties: &armbotservice.EmailChannelProperties{ - EmailAddress: to.Ptr("a@b.com"), - IsEnabled: to.Ptr(true), - Password: to.Ptr("pwd"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.EmailChannel{ - // ChannelName: to.Ptr("EmailChannel"), - // Properties: &armbotservice.EmailChannelProperties{ - // EmailAddress: to.Ptr("a@b.com"), - // IsEnabled: to.Ptr(true), - // Password: to.Ptr("pwd"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutDirectLineSpeechChannel.json -func ExampleChannelsClient_Create_createDirectLineSpeechChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameDirectLineSpeechChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.DirectLineSpeechChannel{ - ChannelName: to.Ptr("DirectLineSpeechChannel"), - Properties: &armbotservice.DirectLineSpeechChannelProperties{ - CognitiveServiceRegion: to.Ptr("XcognitiveServiceRegionX"), - CognitiveServiceSubscriptionKey: to.Ptr("XcognitiveServiceSubscriptionKeyX"), - IsEnabled: to.Ptr(true), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.DirectLineSpeechChannel{ - // ChannelName: to.Ptr("DirectLineSpeechChannel"), - // Properties: &armbotservice.DirectLineSpeechChannelProperties{ - // CognitiveServiceRegion: to.Ptr("XcognitiveServiceRegionX"), - // IsEnabled: to.Ptr(true), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutEmailChannel.json -func ExampleChannelsClient_Create_createEmailChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.EmailChannel{ - ChannelName: to.Ptr("EmailChannel"), - Properties: &armbotservice.EmailChannelProperties{ - AuthMethod: to.Ptr(armbotservice.EmailChannelAuthMethodGraph), - EmailAddress: to.Ptr("a@b.com"), - IsEnabled: to.Ptr(true), - MagicCode: to.Ptr("000000"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.EmailChannel{ - // ChannelName: to.Ptr("EmailChannel"), - // Properties: &armbotservice.EmailChannelProperties{ - // AuthMethod: to.Ptr(armbotservice.EmailChannelAuthMethodGraph), - // EmailAddress: to.Ptr("a@b.com"), - // IsEnabled: to.Ptr(true), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutLineChannel.json -func ExampleChannelsClient_Create_createLineChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameLineChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.LineChannel{ - ChannelName: to.Ptr("LineChannel"), - Properties: &armbotservice.LineChannelProperties{ - LineRegistrations: []*armbotservice.LineRegistration{ - { - ChannelAccessToken: to.Ptr("channelAccessToken"), - ChannelSecret: to.Ptr("channelSecret"), - }}, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.LineChannel{ - // ChannelName: to.Ptr("LineChannel"), - // Properties: &armbotservice.LineChannelProperties{ - // CallbackURL: to.Ptr("http://callbackUrl"), - // IsValidated: to.Ptr(true), - // LineRegistrations: []*armbotservice.LineRegistration{ - // { - // GeneratedID: to.Ptr("id"), - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateAlexaChannel.json -func ExampleChannelsClient_Update_updateAlexaChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameAlexaChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.AlexaChannel{ - ChannelName: to.Ptr("AlexaChannel"), - Properties: &armbotservice.AlexaChannelProperties{ - AlexaSkillID: to.Ptr("XAlexaSkillIdX"), - IsEnabled: to.Ptr(true), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.AlexaChannel{ - // ChannelName: to.Ptr("AlexaChannel"), - // Properties: &armbotservice.AlexaChannelProperties{ - // AlexaSkillID: to.Ptr("XAlexaSkillIdX"), - // IsEnabled: to.Ptr(true), - // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), - // URLFragment: to.Ptr("XUrlFragmentX"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateChannel.json -func ExampleChannelsClient_Update_updateChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.EmailChannel{ - ChannelName: to.Ptr("EmailChannel"), - Properties: &armbotservice.EmailChannelProperties{ - EmailAddress: to.Ptr("a@b.com"), - IsEnabled: to.Ptr(true), - Password: to.Ptr("pwd"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.EmailChannel{ - // ChannelName: to.Ptr("EmailChannel"), - // Properties: &armbotservice.EmailChannelProperties{ - // EmailAddress: to.Ptr("a@b.com"), - // IsEnabled: to.Ptr(true), - // Password: to.Ptr("pwd"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateDirectLineSpeechChannel.json -func ExampleChannelsClient_Update_updateDirectLineSpeechChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameDirectLineSpeechChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.DirectLineSpeechChannel{ - ChannelName: to.Ptr("DirectLineSpeechChannel"), - Properties: &armbotservice.DirectLineSpeechChannelProperties{ - CognitiveServiceRegion: to.Ptr("XcognitiveServiceRegionX"), - CognitiveServiceSubscriptionKey: to.Ptr("XcognitiveServiceSubscriptionKeyX"), - IsEnabled: to.Ptr(true), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.DirectLineSpeechChannel{ - // ChannelName: to.Ptr("DirectLineSpeechChannel"), - // Properties: &armbotservice.DirectLineSpeechChannelProperties{ - // CognitiveServiceRegion: to.Ptr("XcognitiveServiceRegionX"), - // IsEnabled: to.Ptr(true), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateLineChannel.json -func ExampleChannelsClient_Update_updateLineChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameLineChannel, armbotservice.BotChannel{ - Location: to.Ptr("global"), - Properties: &armbotservice.LineChannel{ - ChannelName: to.Ptr("LineChannel"), - Properties: &armbotservice.LineChannelProperties{ - LineRegistrations: []*armbotservice.LineRegistration{ - { - ChannelAccessToken: to.Ptr("channelAccessToken"), - ChannelSecret: to.Ptr("channelSecret"), - }}, - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.LineChannel{ - // ChannelName: to.Ptr("LineChannel"), - // Properties: &armbotservice.LineChannelProperties{ - // CallbackURL: to.Ptr("http://callbackUrl"), - // IsValidated: to.Ptr(true), - // LineRegistrations: []*armbotservice.LineRegistration{ - // { - // GeneratedID: to.Ptr("id"), - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteChannel.json -func ExampleChannelsClient_Delete_deleteChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewChannelsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteDirectLineSpeechChannel.json -func ExampleChannelsClient_Delete_deleteDirectLineSpeechChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewChannelsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json -func ExampleChannelsClient_Get_getAlexaChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "AlexaChannel", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.AlexaChannel{ - // ChannelName: to.Ptr("AlexaChannel"), - // Properties: &armbotservice.AlexaChannelProperties{ - // AlexaSkillID: to.Ptr("alexa skill id"), - // IsEnabled: to.Ptr(true), - // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), - // URLFragment: to.Ptr("XUrlFragmentX"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json -func ExampleChannelsClient_Get_getChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.EmailChannel{ - // ChannelName: to.Ptr("EmailChannel"), - // Properties: &armbotservice.EmailChannelProperties{ - // EmailAddress: to.Ptr("a@b.com"), - // IsEnabled: to.Ptr(true), - // Password: to.Ptr("pwd"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json -func ExampleChannelsClient_Get_getDirectLineSpeechChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.DirectLineSpeechChannel{ - // ChannelName: to.Ptr("DirectLineSpeechChannel"), - // Properties: &armbotservice.DirectLineSpeechChannelProperties{ - // CognitiveServiceRegion: to.Ptr("Cognitive service region"), - // CustomSpeechModelID: to.Ptr("Custom speech model ID"), - // CustomVoiceDeploymentID: to.Ptr("Custom voice deployment ID"), - // IsDefaultBotForCogSvcAccount: to.Ptr(true), - // IsEnabled: to.Ptr(true), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json -func ExampleChannelsClient_Get_getLineChannel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "LineChannel", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.LineChannel{ - // ChannelName: to.Ptr("LineChannel"), - // Properties: &armbotservice.LineChannelProperties{ - // CallbackURL: to.Ptr("http://callbackUrl"), - // IsValidated: to.Ptr(true), - // LineRegistrations: []*armbotservice.LineRegistration{ - // { - // GeneratedID: to.Ptr("id"), - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListChannel.json -func ExampleChannelsClient_ListWithKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChannelsClient().ListWithKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ListChannelWithKeysResponse = armbotservice.ListChannelWithKeysResponse{ - // Location: to.Ptr("global"), - // Properties: &armbotservice.EmailChannel{ - // ChannelName: to.Ptr("EmailChannel"), - // Properties: &armbotservice.EmailChannelProperties{ - // EmailAddress: to.Ptr("a@b.com"), - // IsEnabled: to.Ptr(true), - // Password: to.Ptr("pwd"), - // }, - // }, - // Resource: &armbotservice.DirectLineChannel{ - // ChannelName: to.Ptr("DirectLineChannel"), - // Etag: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // Location: to.Ptr("aaaaaa"), - // Properties: &armbotservice.DirectLineChannelProperties{ - // Sites: []*armbotservice.DirectLineSite{ - // { - // IsBlockUserUploadEnabled: to.Ptr(false), - // IsEnabled: to.Ptr(true), - // IsSecureSiteEnabled: to.Ptr(false), - // IsV1Enabled: to.Ptr(true), - // IsV3Enabled: to.Ptr(true), - // Key: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // Key2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // SiteID: to.Ptr("aaaaaaaaaaa"), - // SiteName: to.Ptr("aaaaaaaaaaaa"), - // TrustedOrigins: []*string{ - // to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")}, - // }}, - // }, - // }, - // Setting: &armbotservice.ChannelSettings{ - // BotIconURL: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // BotID: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), - // ChannelDisplayName: to.Ptr("aaaaaaaaaaa"), - // ChannelID: to.Ptr("aaaaaaaaaa"), - // DisableLocalAuth: to.Ptr(false), - // ExtensionKey1: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // ExtensionKey2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // IsEnabled: to.Ptr(true), - // Sites: []*armbotservice.Site{ - // { - // ETag: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // IsBlockUserUploadEnabled: to.Ptr(false), - // IsEnabled: to.Ptr(true), - // IsSecureSiteEnabled: to.Ptr(false), - // IsTokenEnabled: to.Ptr(false), - // IsV1Enabled: to.Ptr(true), - // IsV3Enabled: to.Ptr(true), - // IsWebchatPreviewEnabled: to.Ptr(false), - // Key: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // Key2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // SiteID: to.Ptr("aaaaaaaaaaa"), - // SiteName: to.Ptr("aaaaaaaaaaaa"), - // TrustedOrigins: []*string{ - // to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")}, - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListChannelsByBotService.json -func ExampleChannelsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewChannelsClient().NewListByResourceGroupPager("OneResourceGroupName", "samplebotname", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ChannelResponseList = armbotservice.ChannelResponseList{ - // Value: []*armbotservice.BotChannel{ - // { - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.EmailChannel{ - // ChannelName: to.Ptr("EmailChannel"), - // Properties: &armbotservice.EmailChannelProperties{ - // EmailAddress: to.Ptr("a@b.com"), - // IsEnabled: to.Ptr(true), - // Password: to.Ptr("pwd"), - // }, - // }, - // }, - // { - // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.FacebookChannel{ - // ChannelName: to.Ptr("FacebookChannel"), - // Properties: &armbotservice.FacebookChannelProperties{ - // AppID: to.Ptr("id"), - // CallbackURL: to.Ptr("appid"), - // IsEnabled: to.Ptr(true), - // Pages: []*armbotservice.FacebookPage{ - // { - // ID: to.Ptr("id"), - // }}, - // }, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/botservice/armbotservice/client_factory.go b/sdk/resourcemanager/botservice/armbotservice/client_factory.go index 3ba9cf6f6eb0..a8055031b0dd 100644 --- a/sdk/resourcemanager/botservice/armbotservice/client_factory.go +++ b/sdk/resourcemanager/botservice/armbotservice/client_factory.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -17,88 +13,107 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - Azure Subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } -// NewBotConnectionClient creates a new instance of BotConnectionClient. -func (c *ClientFactory) NewBotConnectionClient() *BotConnectionClient { - subClient, _ := NewBotConnectionClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewBotChannelsClient creates a new instance of BotChannelsClient. +func (c *ClientFactory) NewBotChannelsClient() *BotChannelsClient { + return &BotChannelsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewBotConnectionOperationGroupClient creates a new instance of BotConnectionOperationGroupClient. +func (c *ClientFactory) NewBotConnectionOperationGroupClient() *BotConnectionOperationGroupClient { + return &BotConnectionOperationGroupClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewBotsClient creates a new instance of BotsClient. func (c *ClientFactory) NewBotsClient() *BotsClient { - subClient, _ := NewBotsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &BotsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } -// NewChannelsClient creates a new instance of ChannelsClient. -func (c *ClientFactory) NewChannelsClient() *ChannelsClient { - subClient, _ := NewChannelsClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewBotsOperationGroupClient creates a new instance of BotsOperationGroupClient. +func (c *ClientFactory) NewBotsOperationGroupClient() *BotsOperationGroupClient { + return &BotsOperationGroupClient{ + internal: c.internal, + } } -// NewDirectLineClient creates a new instance of DirectLineClient. -func (c *ClientFactory) NewDirectLineClient() *DirectLineClient { - subClient, _ := NewDirectLineClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewConnectionSettingsClient creates a new instance of ConnectionSettingsClient. +func (c *ClientFactory) NewConnectionSettingsClient() *ConnectionSettingsClient { + return &ConnectionSettingsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } -// NewEmailClient creates a new instance of EmailClient. -func (c *ClientFactory) NewEmailClient() *EmailClient { - subClient, _ := NewEmailClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewHostSettingsOperationGroupClient creates a new instance of HostSettingsOperationGroupClient. +func (c *ClientFactory) NewHostSettingsOperationGroupClient() *HostSettingsOperationGroupClient { + return &HostSettingsOperationGroupClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } -// NewHostSettingsClient creates a new instance of HostSettingsClient. -func (c *ClientFactory) NewHostSettingsClient() *HostSettingsClient { - subClient, _ := NewHostSettingsClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewNetworkSecurityPerimeterConfigurationsClient creates a new instance of NetworkSecurityPerimeterConfigurationsClient. +func (c *ClientFactory) NewNetworkSecurityPerimeterConfigurationsClient() *NetworkSecurityPerimeterConfigurationsClient { + return &NetworkSecurityPerimeterConfigurationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } -// NewOperationResultsClient creates a new instance of OperationResultsClient. -func (c *ClientFactory) NewOperationResultsClient() *OperationResultsClient { - subClient, _ := NewOperationResultsClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewOperationResultsOperationGroupClient creates a new instance of OperationResultsOperationGroupClient. +func (c *ClientFactory) NewOperationResultsOperationGroupClient() *OperationResultsOperationGroupClient { + return &OperationResultsOperationGroupClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { - subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) - return subClient -} - -// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. -func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { - subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateEndpointConnectionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } -// NewQnAMakerEndpointKeysClient creates a new instance of QnAMakerEndpointKeysClient. -func (c *ClientFactory) NewQnAMakerEndpointKeysClient() *QnAMakerEndpointKeysClient { - subClient, _ := NewQnAMakerEndpointKeysClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewQnAMakerEndpointKeysOperationGroupClient creates a new instance of QnAMakerEndpointKeysOperationGroupClient. +func (c *ClientFactory) NewQnAMakerEndpointKeysOperationGroupClient() *QnAMakerEndpointKeysOperationGroupClient { + return &QnAMakerEndpointKeysOperationGroupClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/botservice/armbotservice/botconnection_client.go b/sdk/resourcemanager/botservice/armbotservice/connectionsettings_client.go similarity index 57% rename from sdk/resourcemanager/botservice/armbotservice/botconnection_client.go rename to sdk/resourcemanager/botservice/armbotservice/connectionsettings_client.go index faa0b848c06e..ff959a30f3b8 100644 --- a/sdk/resourcemanager/botservice/armbotservice/botconnection_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/connectionsettings_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -20,23 +16,23 @@ import ( "strings" ) -// BotConnectionClient contains the methods for the BotConnection group. -// Don't use this type directly, use NewBotConnectionClient() instead. -type BotConnectionClient struct { +// ConnectionSettingsClient contains the methods for the ConnectionSettings group. +// Don't use this type directly, use NewConnectionSettingsClient() instead. +type ConnectionSettingsClient struct { internal *arm.Client subscriptionID string } -// NewBotConnectionClient creates a new instance of BotConnectionClient with the specified values. -// - subscriptionID - Azure Subscription ID. +// NewConnectionSettingsClient creates a new instance of ConnectionSettingsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewBotConnectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BotConnectionClient, error) { +func NewConnectionSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectionSettingsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } - client := &BotConnectionClient{ + client := &ConnectionSettingsClient{ subscriptionID: subscriptionID, internal: cl, } @@ -46,37 +42,42 @@ func NewBotConnectionClient(subscriptionID string, credential azcore.TokenCreden // Create - Register a new Auth Connection for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - connectionName - The name of the Bot Service Connection Setting resource. // - parameters - The parameters to provide for creating the Connection Setting. -// - options - BotConnectionClientCreateOptions contains the optional parameters for the BotConnectionClient.Create method. -func (client *BotConnectionClient) Create(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, options *BotConnectionClientCreateOptions) (BotConnectionClientCreateResponse, error) { +// - options - ConnectionSettingsClientCreateOptions contains the optional parameters for the ConnectionSettingsClient.Create +// method. +func (client *ConnectionSettingsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, options *ConnectionSettingsClientCreateOptions) (ConnectionSettingsClientCreateResponse, error) { var err error - const operationName = "BotConnectionClient.Create" + const operationName = "ConnectionSettingsClient.Create" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, connectionName, parameters, options) if err != nil { - return BotConnectionClientCreateResponse{}, err + return ConnectionSettingsClientCreateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return BotConnectionClientCreateResponse{}, err + return ConnectionSettingsClientCreateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return BotConnectionClientCreateResponse{}, err + return ConnectionSettingsClientCreateResponse{}, err } resp, err := client.createHandleResponse(httpResp) return resp, err } // createCreateRequest creates the Create request. -func (client *BotConnectionClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, options *BotConnectionClientCreateOptions) (*policy.Request, error) { +func (client *ConnectionSettingsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, _ *ConnectionSettingsClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/connections/{connectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -89,18 +90,15 @@ func (client *BotConnectionClient) createCreateRequest(ctx context.Context, reso return nil, errors.New("parameter connectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -108,10 +106,10 @@ func (client *BotConnectionClient) createCreateRequest(ctx context.Context, reso } // createHandleResponse handles the Create response. -func (client *BotConnectionClient) createHandleResponse(resp *http.Response) (BotConnectionClientCreateResponse, error) { - result := BotConnectionClientCreateResponse{} +func (client *ConnectionSettingsClient) createHandleResponse(resp *http.Response) (ConnectionSettingsClientCreateResponse, error) { + result := ConnectionSettingsClientCreateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionSetting); err != nil { - return BotConnectionClientCreateResponse{}, err + return ConnectionSettingsClientCreateResponse{}, err } return result, nil } @@ -119,35 +117,40 @@ func (client *BotConnectionClient) createHandleResponse(resp *http.Response) (Bo // Delete - Deletes a Connection Setting registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - connectionName - The name of the Bot Service Connection Setting resource. -// - options - BotConnectionClientDeleteOptions contains the optional parameters for the BotConnectionClient.Delete method. -func (client *BotConnectionClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientDeleteOptions) (BotConnectionClientDeleteResponse, error) { +// - options - ConnectionSettingsClientDeleteOptions contains the optional parameters for the ConnectionSettingsClient.Delete +// method. +func (client *ConnectionSettingsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *ConnectionSettingsClientDeleteOptions) (ConnectionSettingsClientDeleteResponse, error) { var err error - const operationName = "BotConnectionClient.Delete" + const operationName = "ConnectionSettingsClient.Delete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, connectionName, options) if err != nil { - return BotConnectionClientDeleteResponse{}, err + return ConnectionSettingsClientDeleteResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return BotConnectionClientDeleteResponse{}, err + return ConnectionSettingsClientDeleteResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return BotConnectionClientDeleteResponse{}, err + return ConnectionSettingsClientDeleteResponse{}, err } - return BotConnectionClientDeleteResponse{}, nil + return ConnectionSettingsClientDeleteResponse{}, nil } // deleteCreateRequest creates the Delete request. -func (client *BotConnectionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientDeleteOptions) (*policy.Request, error) { +func (client *ConnectionSettingsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, _ *ConnectionSettingsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/connections/{connectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -160,16 +163,12 @@ func (client *BotConnectionClient) deleteCreateRequest(ctx context.Context, reso return nil, errors.New("parameter connectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -178,36 +177,40 @@ func (client *BotConnectionClient) deleteCreateRequest(ctx context.Context, reso // Get - Get a Connection Setting registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - connectionName - The name of the Bot Service Connection Setting resource. -// - options - BotConnectionClientGetOptions contains the optional parameters for the BotConnectionClient.Get method. -func (client *BotConnectionClient) Get(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientGetOptions) (BotConnectionClientGetResponse, error) { +// - options - ConnectionSettingsClientGetOptions contains the optional parameters for the ConnectionSettingsClient.Get method. +func (client *ConnectionSettingsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *ConnectionSettingsClientGetOptions) (ConnectionSettingsClientGetResponse, error) { var err error - const operationName = "BotConnectionClient.Get" + const operationName = "ConnectionSettingsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, connectionName, options) if err != nil { - return BotConnectionClientGetResponse{}, err + return ConnectionSettingsClientGetResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return BotConnectionClientGetResponse{}, err + return ConnectionSettingsClientGetResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return BotConnectionClientGetResponse{}, err + return ConnectionSettingsClientGetResponse{}, err } resp, err := client.getHandleResponse(httpResp) return resp, err } // getCreateRequest creates the Get request. -func (client *BotConnectionClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientGetOptions) (*policy.Request, error) { +func (client *ConnectionSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, _ *ConnectionSettingsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/connections/{connectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -220,44 +223,40 @@ func (client *BotConnectionClient) getCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter connectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getHandleResponse handles the Get response. -func (client *BotConnectionClient) getHandleResponse(resp *http.Response) (BotConnectionClientGetResponse, error) { - result := BotConnectionClientGetResponse{} +func (client *ConnectionSettingsClient) getHandleResponse(resp *http.Response) (ConnectionSettingsClientGetResponse, error) { + result := ConnectionSettingsClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionSetting); err != nil { - return BotConnectionClientGetResponse{}, err + return ConnectionSettingsClientGetResponse{}, err } return result, nil } // NewListByBotServicePager - Returns all the Connection Settings registered to a particular BotService resource // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. -// - options - BotConnectionClientListByBotServiceOptions contains the optional parameters for the BotConnectionClient.NewListByBotServicePager +// - options - ConnectionSettingsClientListByBotServiceOptions contains the optional parameters for the ConnectionSettingsClient.NewListByBotServicePager // method. -func (client *BotConnectionClient) NewListByBotServicePager(resourceGroupName string, resourceName string, options *BotConnectionClientListByBotServiceOptions) *runtime.Pager[BotConnectionClientListByBotServiceResponse] { - return runtime.NewPager(runtime.PagingHandler[BotConnectionClientListByBotServiceResponse]{ - More: func(page BotConnectionClientListByBotServiceResponse) bool { +func (client *ConnectionSettingsClient) NewListByBotServicePager(resourceGroupName string, resourceName string, options *ConnectionSettingsClientListByBotServiceOptions) *runtime.Pager[ConnectionSettingsClientListByBotServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[ConnectionSettingsClientListByBotServiceResponse]{ + More: func(page ConnectionSettingsClientListByBotServiceResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *BotConnectionClientListByBotServiceResponse) (BotConnectionClientListByBotServiceResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BotConnectionClient.NewListByBotServicePager") + Fetcher: func(ctx context.Context, page *ConnectionSettingsClientListByBotServiceResponse) (ConnectionSettingsClientListByBotServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConnectionSettingsClient.NewListByBotServicePager") nextLink := "" if page != nil { nextLink = *page.NextLink @@ -266,7 +265,7 @@ func (client *BotConnectionClient) NewListByBotServicePager(resourceGroupName st return client.listByBotServiceCreateRequest(ctx, resourceGroupName, resourceName, options) }, nil) if err != nil { - return BotConnectionClientListByBotServiceResponse{}, err + return ConnectionSettingsClientListByBotServiceResponse{}, err } return client.listByBotServiceHandleResponse(resp) }, @@ -275,8 +274,12 @@ func (client *BotConnectionClient) NewListByBotServicePager(resourceGroupName st } // listByBotServiceCreateRequest creates the ListByBotService request. -func (client *BotConnectionClient) listByBotServiceCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *BotConnectionClientListByBotServiceOptions) (*policy.Request, error) { +func (client *ConnectionSettingsClient) listByBotServiceCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ConnectionSettingsClientListByBotServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/connections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -285,81 +288,22 @@ func (client *BotConnectionClient) listByBotServiceCreateRequest(ctx context.Con return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listByBotServiceHandleResponse handles the ListByBotService response. -func (client *BotConnectionClient) listByBotServiceHandleResponse(resp *http.Response) (BotConnectionClientListByBotServiceResponse, error) { - result := BotConnectionClientListByBotServiceResponse{} +func (client *ConnectionSettingsClient) listByBotServiceHandleResponse(resp *http.Response) (ConnectionSettingsClientListByBotServiceResponse, error) { + result := ConnectionSettingsClientListByBotServiceResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionSettingResponseList); err != nil { - return BotConnectionClientListByBotServiceResponse{}, err - } - return result, nil -} - -// ListServiceProviders - Lists the available Service Providers for creating Connection Settings -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-09-15 -// - options - BotConnectionClientListServiceProvidersOptions contains the optional parameters for the BotConnectionClient.ListServiceProviders -// method. -func (client *BotConnectionClient) ListServiceProviders(ctx context.Context, options *BotConnectionClientListServiceProvidersOptions) (BotConnectionClientListServiceProvidersResponse, error) { - var err error - const operationName = "BotConnectionClient.ListServiceProviders" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listServiceProvidersCreateRequest(ctx, options) - if err != nil { - return BotConnectionClientListServiceProvidersResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return BotConnectionClientListServiceProvidersResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return BotConnectionClientListServiceProvidersResponse{}, err - } - resp, err := client.listServiceProvidersHandleResponse(httpResp) - return resp, err -} - -// listServiceProvidersCreateRequest creates the ListServiceProviders request. -func (client *BotConnectionClient) listServiceProvidersCreateRequest(ctx context.Context, options *BotConnectionClientListServiceProvidersOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.BotService/listAuthServiceProviders" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listServiceProvidersHandleResponse handles the ListServiceProviders response. -func (client *BotConnectionClient) listServiceProvidersHandleResponse(resp *http.Response) (BotConnectionClientListServiceProvidersResponse, error) { - result := BotConnectionClientListServiceProvidersResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ServiceProviderResponseList); err != nil { - return BotConnectionClientListServiceProvidersResponse{}, err + return ConnectionSettingsClientListByBotServiceResponse{}, err } return result, nil } @@ -367,37 +311,41 @@ func (client *BotConnectionClient) listServiceProvidersHandleResponse(resp *http // ListWithSecrets - Get a Connection Setting registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - connectionName - The name of the Bot Service Connection Setting resource. -// - options - BotConnectionClientListWithSecretsOptions contains the optional parameters for the BotConnectionClient.ListWithSecrets +// - options - ConnectionSettingsClientListWithSecretsOptions contains the optional parameters for the ConnectionSettingsClient.ListWithSecrets // method. -func (client *BotConnectionClient) ListWithSecrets(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientListWithSecretsOptions) (BotConnectionClientListWithSecretsResponse, error) { +func (client *ConnectionSettingsClient) ListWithSecrets(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *ConnectionSettingsClientListWithSecretsOptions) (ConnectionSettingsClientListWithSecretsResponse, error) { var err error - const operationName = "BotConnectionClient.ListWithSecrets" + const operationName = "ConnectionSettingsClient.ListWithSecrets" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.listWithSecretsCreateRequest(ctx, resourceGroupName, resourceName, connectionName, options) if err != nil { - return BotConnectionClientListWithSecretsResponse{}, err + return ConnectionSettingsClientListWithSecretsResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return BotConnectionClientListWithSecretsResponse{}, err + return ConnectionSettingsClientListWithSecretsResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return BotConnectionClientListWithSecretsResponse{}, err + return ConnectionSettingsClientListWithSecretsResponse{}, err } resp, err := client.listWithSecretsHandleResponse(httpResp) return resp, err } // listWithSecretsCreateRequest creates the ListWithSecrets request. -func (client *BotConnectionClient) listWithSecretsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientListWithSecretsOptions) (*policy.Request, error) { +func (client *ConnectionSettingsClient) listWithSecretsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, _ *ConnectionSettingsClientListWithSecretsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/connections/{connectionName}/listWithSecrets" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -410,26 +358,22 @@ func (client *BotConnectionClient) listWithSecretsCreateRequest(ctx context.Cont return nil, errors.New("parameter connectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listWithSecretsHandleResponse handles the ListWithSecrets response. -func (client *BotConnectionClient) listWithSecretsHandleResponse(resp *http.Response) (BotConnectionClientListWithSecretsResponse, error) { - result := BotConnectionClientListWithSecretsResponse{} +func (client *ConnectionSettingsClient) listWithSecretsHandleResponse(resp *http.Response) (ConnectionSettingsClientListWithSecretsResponse, error) { + result := ConnectionSettingsClientListWithSecretsResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionSetting); err != nil { - return BotConnectionClientListWithSecretsResponse{}, err + return ConnectionSettingsClientListWithSecretsResponse{}, err } return result, nil } @@ -437,37 +381,42 @@ func (client *BotConnectionClient) listWithSecretsHandleResponse(resp *http.Resp // Update - Updates a Connection Setting registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - connectionName - The name of the Bot Service Connection Setting resource. // - parameters - The parameters to provide for updating the Connection Setting. -// - options - BotConnectionClientUpdateOptions contains the optional parameters for the BotConnectionClient.Update method. -func (client *BotConnectionClient) Update(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, options *BotConnectionClientUpdateOptions) (BotConnectionClientUpdateResponse, error) { +// - options - ConnectionSettingsClientUpdateOptions contains the optional parameters for the ConnectionSettingsClient.Update +// method. +func (client *ConnectionSettingsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, options *ConnectionSettingsClientUpdateOptions) (ConnectionSettingsClientUpdateResponse, error) { var err error - const operationName = "BotConnectionClient.Update" + const operationName = "ConnectionSettingsClient.Update" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, connectionName, parameters, options) if err != nil { - return BotConnectionClientUpdateResponse{}, err + return ConnectionSettingsClientUpdateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return BotConnectionClientUpdateResponse{}, err + return ConnectionSettingsClientUpdateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return BotConnectionClientUpdateResponse{}, err + return ConnectionSettingsClientUpdateResponse{}, err } resp, err := client.updateHandleResponse(httpResp) return resp, err } // updateCreateRequest creates the Update request. -func (client *BotConnectionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, options *BotConnectionClientUpdateOptions) (*policy.Request, error) { +func (client *ConnectionSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, _ *ConnectionSettingsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/connections/{connectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -480,18 +429,15 @@ func (client *BotConnectionClient) updateCreateRequest(ctx context.Context, reso return nil, errors.New("parameter connectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -499,10 +445,10 @@ func (client *BotConnectionClient) updateCreateRequest(ctx context.Context, reso } // updateHandleResponse handles the Update response. -func (client *BotConnectionClient) updateHandleResponse(resp *http.Response) (BotConnectionClientUpdateResponse, error) { - result := BotConnectionClientUpdateResponse{} +func (client *ConnectionSettingsClient) updateHandleResponse(resp *http.Response) (ConnectionSettingsClientUpdateResponse, error) { + result := ConnectionSettingsClientUpdateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionSetting); err != nil { - return BotConnectionClientUpdateResponse{}, err + return ConnectionSettingsClientUpdateResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/botservice/armbotservice/connectionsettings_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/connectionsettings_client_example_test.go new file mode 100644 index 000000000000..1770f28b65eb --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/connectionsettings_client_example_test.go @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" +) + +// Generated from example definition: 2023-09-15-preview/PutConnection.json +func ExampleConnectionSettingsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewConnectionSettingsClient().Create(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.ConnectionSettingsClientCreateResponse{ + // ConnectionSetting: &armbotservice.ConnectionSetting{ + // Name: to.Ptr("sampleConnection"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.ConnectionSettingProperties{ + // Name: to.Ptr("sampleConnection"), + // ClientID: to.Ptr("sampleclientid"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Parameters: []*armbotservice.ConnectionSettingParameter{ + // { + // Key: to.Ptr("key1"), + // Value: to.Ptr("value1"), + // }, + // { + // Key: to.Ptr("key2"), + // Value: to.Ptr("value2"), + // }, + // }, + // Scopes: to.Ptr("samplescope"), + // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), + // ServiceProviderID: to.Ptr("serviceproviderid"), + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/DeleteConnection.json +func ExampleConnectionSettingsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewConnectionSettingsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.ConnectionSettingsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2023-09-15-preview/ListConnectionsByBotService.json +func ExampleConnectionSettingsClient_NewListByBotServicePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewConnectionSettingsClient().NewListByBotServicePager("OneResourceGroupName", "samplebotname", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armbotservice.ConnectionSettingsClientListByBotServiceResponse{ + // ConnectionSettingResponseList: armbotservice.ConnectionSettingResponseList{ + // Value: []*armbotservice.ConnectionSetting{ + // { + // Name: to.Ptr("sampleConnection"), + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Properties: &armbotservice.ConnectionSettingProperties{ + // Name: to.Ptr("sampleConnection"), + // ClientID: to.Ptr("sampleclientid"), + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Parameters: []*armbotservice.ConnectionSettingParameter{ + // { + // Key: to.Ptr("key1"), + // Value: to.Ptr("value1"), + // }, + // { + // Key: to.Ptr("key2"), + // Value: to.Ptr("value2"), + // }, + // }, + // Scopes: to.Ptr("samplescope"), + // ServiceProviderID: to.Ptr("serviceproviderid"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2023-09-15-preview/GetConnection.json +func ExampleConnectionSettingsClient_ListWithSecrets() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewConnectionSettingsClient().ListWithSecrets(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.ConnectionSettingsClientListWithSecretsResponse{ + // ConnectionSetting: &armbotservice.ConnectionSetting{ + // Name: to.Ptr("sampleConnection"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.ConnectionSettingProperties{ + // Name: to.Ptr("sampleConnection"), + // ClientID: to.Ptr("sampleclientid"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Parameters: []*armbotservice.ConnectionSettingParameter{ + // { + // Key: to.Ptr("key1"), + // Value: to.Ptr("value1"), + // }, + // { + // Key: to.Ptr("key2"), + // Value: to.Ptr("value2"), + // }, + // }, + // Scopes: to.Ptr("samplescope"), + // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), + // ServiceProviderID: to.Ptr("serviceproviderid"), + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/UpdateConnection.json +func ExampleConnectionSettingsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewConnectionSettingsClient().Update(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.ConnectionSettingsClientUpdateResponse{ + // ConnectionSetting: &armbotservice.ConnectionSetting{ + // Name: to.Ptr("sampleConnection"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.ConnectionSettingProperties{ + // Name: to.Ptr("sampleConnection"), + // ClientID: to.Ptr("sampleclientid"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Parameters: []*armbotservice.ConnectionSettingParameter{ + // { + // Key: to.Ptr("key1"), + // Value: to.Ptr("value1"), + // }, + // { + // Key: to.Ptr("key2"), + // Value: to.Ptr("value2"), + // }, + // }, + // Scopes: to.Ptr("samplescope"), + // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), + // ServiceProviderID: to.Ptr("serviceproviderid"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/constants.go b/sdk/resourcemanager/botservice/armbotservice/constants.go index 149e38bcbfc3..f907cecaa0f2 100644 --- a/sdk/resourcemanager/botservice/armbotservice/constants.go +++ b/sdk/resourcemanager/botservice/armbotservice/constants.go @@ -1,69 +1,58 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" - moduleVersion = "v1.2.0" + moduleVersion = "v2.0.0-beta.1" ) -type ChannelName string +// AccessMode - Access Mode of the resource association +type AccessMode string const ( - ChannelNameAcsChatChannel ChannelName = "AcsChatChannel" - ChannelNameAlexaChannel ChannelName = "AlexaChannel" - ChannelNameDirectLineChannel ChannelName = "DirectLineChannel" - ChannelNameDirectLineSpeechChannel ChannelName = "DirectLineSpeechChannel" - ChannelNameEmailChannel ChannelName = "EmailChannel" - ChannelNameFacebookChannel ChannelName = "FacebookChannel" - ChannelNameKikChannel ChannelName = "KikChannel" - ChannelNameLineChannel ChannelName = "LineChannel" - ChannelNameM365Extensions ChannelName = "M365Extensions" - ChannelNameMsTeamsChannel ChannelName = "MsTeamsChannel" - ChannelNameOmnichannel ChannelName = "Omnichannel" - ChannelNameOutlookChannel ChannelName = "OutlookChannel" - ChannelNameSearchAssistant ChannelName = "SearchAssistant" - ChannelNameSkypeChannel ChannelName = "SkypeChannel" - ChannelNameSlackChannel ChannelName = "SlackChannel" - ChannelNameSmsChannel ChannelName = "SmsChannel" - ChannelNameTelegramChannel ChannelName = "TelegramChannel" - ChannelNameTelephonyChannel ChannelName = "TelephonyChannel" - ChannelNameWebChatChannel ChannelName = "WebChatChannel" + AccessModeAudit AccessMode = "Audit" + AccessModeEnforced AccessMode = "Enforced" + AccessModeLearning AccessMode = "Learning" ) -// PossibleChannelNameValues returns the possible values for the ChannelName const type. -func PossibleChannelNameValues() []ChannelName { - return []ChannelName{ - ChannelNameAcsChatChannel, - ChannelNameAlexaChannel, - ChannelNameDirectLineChannel, - ChannelNameDirectLineSpeechChannel, - ChannelNameEmailChannel, - ChannelNameFacebookChannel, - ChannelNameKikChannel, - ChannelNameLineChannel, - ChannelNameM365Extensions, - ChannelNameMsTeamsChannel, - ChannelNameOmnichannel, - ChannelNameOutlookChannel, - ChannelNameSearchAssistant, - ChannelNameSkypeChannel, - ChannelNameSlackChannel, - ChannelNameSmsChannel, - ChannelNameTelegramChannel, - ChannelNameTelephonyChannel, - ChannelNameWebChatChannel, +// PossibleAccessModeValues returns the possible values for the AccessMode const type. +func PossibleAccessModeValues() []AccessMode { + return []AccessMode{ + AccessModeAudit, + AccessModeEnforced, + AccessModeLearning, + } +} + +// CreatedByType - The kind of entity that created the resource. +type CreatedByType string + +const ( + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, } } // EmailChannelAuthMethod - Email channel auth method. 0 Password (Default); 1 Graph. -type EmailChannelAuthMethod float32 +type EmailChannelAuthMethod int32 const ( // EmailChannelAuthMethodGraph - Modern authentication. @@ -136,6 +125,22 @@ func PossibleMsaAppTypeValues() []MsaAppType { } } +// NspAccessRuleDirection - Direction of Access Rule +type NspAccessRuleDirection string + +const ( + NspAccessRuleDirectionInbound NspAccessRuleDirection = "Inbound" + NspAccessRuleDirectionOutbound NspAccessRuleDirection = "Outbound" +) + +// PossibleNspAccessRuleDirectionValues returns the possible values for the NspAccessRuleDirection const type. +func PossibleNspAccessRuleDirectionValues() []NspAccessRuleDirection { + return []NspAccessRuleDirection{ + NspAccessRuleDirectionInbound, + NspAccessRuleDirectionOutbound, + } +} + // OperationResultStatus - The status of the operation being performed. type OperationResultStatus string @@ -196,34 +201,44 @@ func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointSer } } -// PublicNetworkAccess - Whether the bot is in an isolated network -type PublicNetworkAccess string +type ProvisioningState string const ( - PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" ) -// PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. -func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { - return []PublicNetworkAccess{ - PublicNetworkAccessDisabled, - PublicNetworkAccessEnabled, +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, } } -type RegenerateKeysChannelName string +// PublicNetworkAccess - Whether the bot is in an isolated network +type PublicNetworkAccess string const ( - RegenerateKeysChannelNameDirectLineChannel RegenerateKeysChannelName = "DirectLineChannel" - RegenerateKeysChannelNameWebChatChannel RegenerateKeysChannelName = "WebChatChannel" + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" + PublicNetworkAccessSecuredByPerimeter PublicNetworkAccess = "SecuredByPerimeter" ) -// PossibleRegenerateKeysChannelNameValues returns the possible values for the RegenerateKeysChannelName const type. -func PossibleRegenerateKeysChannelNameValues() []RegenerateKeysChannelName { - return []RegenerateKeysChannelName{ - RegenerateKeysChannelNameDirectLineChannel, - RegenerateKeysChannelNameWebChatChannel, +// PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{ + PublicNetworkAccessDisabled, + PublicNetworkAccessEnabled, + PublicNetworkAccessSecuredByPerimeter, } } @@ -258,3 +273,19 @@ func PossibleSKUTierValues() []SKUTier { SKUTierStandard, } } + +// Severity - Provisioning state of Network Security Perimeter configuration propagation +type Severity string + +const ( + SeverityError Severity = "Error" + SeverityWarning Severity = "Warning" +) + +// PossibleSeverityValues returns the possible values for the Severity const type. +func PossibleSeverityValues() []Severity { + return []Severity{ + SeverityError, + SeverityWarning, + } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/directline_client.go b/sdk/resourcemanager/botservice/armbotservice/directline_client.go deleted file mode 100644 index 78469527b158..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/directline_client.go +++ /dev/null @@ -1,118 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armbotservice - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// DirectLineClient contains the methods for the DirectLine group. -// Don't use this type directly, use NewDirectLineClient() instead. -type DirectLineClient struct { - internal *arm.Client - subscriptionID string -} - -// NewDirectLineClient creates a new instance of DirectLineClient with the specified values. -// - subscriptionID - Azure Subscription ID. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewDirectLineClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DirectLineClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &DirectLineClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// RegenerateKeys - Regenerates secret keys and returns them for the DirectLine Channel of a particular BotService resource -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. -// - resourceName - The name of the Bot resource. -// - channelName - The name of the Channel resource for which keys are to be regenerated. -// - parameters - The parameters to provide for the created bot. -// - options - DirectLineClientRegenerateKeysOptions contains the optional parameters for the DirectLineClient.RegenerateKeys -// method. -func (client *DirectLineClient) RegenerateKeys(ctx context.Context, resourceGroupName string, resourceName string, channelName RegenerateKeysChannelName, parameters SiteInfo, options *DirectLineClientRegenerateKeysOptions) (DirectLineClientRegenerateKeysResponse, error) { - var err error - const operationName = "DirectLineClient.RegenerateKeys" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, resourceName, channelName, parameters, options) - if err != nil { - return DirectLineClientRegenerateKeysResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return DirectLineClientRegenerateKeysResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return DirectLineClientRegenerateKeysResponse{}, err - } - resp, err := client.regenerateKeysHandleResponse(httpResp) - return resp, err -} - -// regenerateKeysCreateRequest creates the RegenerateKeys request. -func (client *DirectLineClient) regenerateKeysCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, channelName RegenerateKeysChannelName, parameters SiteInfo, options *DirectLineClientRegenerateKeysOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/channels/{channelName}/regeneratekeys" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if resourceName == "" { - return nil, errors.New("parameter resourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if channelName == "" { - return nil, errors.New("parameter channelName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(string(channelName))) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// regenerateKeysHandleResponse handles the RegenerateKeys response. -func (client *DirectLineClient) regenerateKeysHandleResponse(resp *http.Response) (DirectLineClientRegenerateKeysResponse, error) { - result := DirectLineClientRegenerateKeysResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.BotChannel); err != nil { - return DirectLineClientRegenerateKeysResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/directline_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/directline_client_example_test.go deleted file mode 100644 index c7c230411c8d..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/directline_client_example_test.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbotservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DirectlineRegenerateKeys.json -func ExampleDirectLineClient_RegenerateKeys_regenerateKeysForDirectLineChannelSite() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDirectLineClient().RegenerateKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.RegenerateKeysChannelNameDirectLineChannel, armbotservice.SiteInfo{ - Key: to.Ptr(armbotservice.KeyKey1), - SiteName: to.Ptr("testSiteName"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // Location: to.Ptr("global"), - // Properties: &armbotservice.DirectLineChannel{ - // ChannelName: to.Ptr("DirectLineChannel"), - // Properties: &armbotservice.DirectLineChannelProperties{ - // Sites: []*armbotservice.DirectLineSite{ - // { - // IsEnabled: to.Ptr(true), - // IsV1Enabled: to.Ptr(true), - // IsV3Enabled: to.Ptr(true), - // Key: to.Ptr("key1"), - // Key2: to.Ptr("key2"), - // SiteID: to.Ptr("abcd"), - // SiteName: to.Ptr("Default Site"), - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/WebChatRegenerateKeys.json -func ExampleDirectLineClient_RegenerateKeys_regenerateKeysForWebChatChannelSite() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDirectLineClient().RegenerateKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.RegenerateKeysChannelNameWebChatChannel, armbotservice.SiteInfo{ - Key: to.Ptr(armbotservice.KeyKey1), - SiteName: to.Ptr("testSiteName"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BotChannel = armbotservice.BotChannel{ - // Location: to.Ptr("global"), - // Properties: &armbotservice.WebChatChannel{ - // ChannelName: to.Ptr("WebChatChannel"), - // Properties: &armbotservice.WebChatChannelProperties{ - // Sites: []*armbotservice.WebChatSite{ - // { - // IsEnabled: to.Ptr(true), - // IsWebchatPreviewEnabled: to.Ptr(true), - // Key: to.Ptr("key1"), - // Key2: to.Ptr("key2"), - // SiteID: to.Ptr("abcd"), - // SiteName: to.Ptr("Default Site"), - // }}, - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/botservice/armbotservice/email_client.go b/sdk/resourcemanager/botservice/armbotservice/email_client.go deleted file mode 100644 index 6e96e20bd8e6..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/email_client.go +++ /dev/null @@ -1,108 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armbotservice - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// EmailClient contains the methods for the Email group. -// Don't use this type directly, use NewEmailClient() instead. -type EmailClient struct { - internal *arm.Client - subscriptionID string -} - -// NewEmailClient creates a new instance of EmailClient with the specified values. -// - subscriptionID - Azure Subscription ID. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewEmailClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EmailClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &EmailClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateSignInURL - Creates an email channel sign in url for a Bot Service -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. -// - resourceName - The name of the Bot resource. -// - options - EmailClientCreateSignInURLOptions contains the optional parameters for the EmailClient.CreateSignInURL method. -func (client *EmailClient) CreateSignInURL(ctx context.Context, resourceGroupName string, resourceName string, options *EmailClientCreateSignInURLOptions) (EmailClientCreateSignInURLResponse, error) { - var err error - const operationName = "EmailClient.CreateSignInURL" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createSignInURLCreateRequest(ctx, resourceGroupName, resourceName, options) - if err != nil { - return EmailClientCreateSignInURLResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return EmailClientCreateSignInURLResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return EmailClientCreateSignInURLResponse{}, err - } - resp, err := client.createSignInURLHandleResponse(httpResp) - return resp, err -} - -// createSignInURLCreateRequest creates the CreateSignInURL request. -func (client *EmailClient) createSignInURLCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *EmailClientCreateSignInURLOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/createEmailSignInUrl" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if resourceName == "" { - return nil, errors.New("parameter resourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// createSignInURLHandleResponse handles the CreateSignInURL response. -func (client *EmailClient) createSignInURLHandleResponse(resp *http.Response) (EmailClientCreateSignInURLResponse, error) { - result := EmailClientCreateSignInURLResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.CreateEmailSignInURLResponse); err != nil { - return EmailClientCreateSignInURLResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/email_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/email_client_example_test.go deleted file mode 100644 index eefe5a663e05..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/email_client_example_test.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbotservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CreateEmailSignInUrl.json -func ExampleEmailClient_CreateSignInURL() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewEmailClient().CreateSignInURL(ctx, "OneResourceGroupName", "samplebotname", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CreateEmailSignInURLResponse = armbotservice.CreateEmailSignInURLResponse{ - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), - // Location: to.Ptr("global"), - // Properties: &armbotservice.CreateEmailSignInURLResponseProperties{ - // URL: to.Ptr("https://token.botframework.com/api/oauth/signin?signin=XXX"), - // }, - // } -} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/channels_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/botchannels_server.go similarity index 56% rename from sdk/resourcemanager/botservice/armbotservice/fake/channels_server.go rename to sdk/resourcemanager/botservice/armbotservice/fake/botchannels_server.go index dde4d08c2161..ba65368853a4 100644 --- a/sdk/resourcemanager/botservice/armbotservice/fake/channels_server.go +++ b/sdk/resourcemanager/botservice/armbotservice/fake/botchannels_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,99 +12,124 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" "net/http" "net/url" "regexp" ) -// ChannelsServer is a fake server for instances of the armbotservice.ChannelsClient type. -type ChannelsServer struct { - // Create is the fake for method ChannelsClient.Create +// BotChannelsServer is a fake server for instances of the armbotservice.BotChannelsClient type. +type BotChannelsServer struct { + // Create is the fake for method BotChannelsClient.Create // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - Create func(ctx context.Context, resourceGroupName string, resourceName string, channelName armbotservice.ChannelName, parameters armbotservice.BotChannel, options *armbotservice.ChannelsClientCreateOptions) (resp azfake.Responder[armbotservice.ChannelsClientCreateResponse], errResp azfake.ErrorResponder) + Create func(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters armbotservice.BotChannel, options *armbotservice.BotChannelsClientCreateOptions) (resp azfake.Responder[armbotservice.BotChannelsClientCreateResponse], errResp azfake.ErrorResponder) - // Delete is the fake for method ChannelsClient.Delete + // Delete is the fake for method BotChannelsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *armbotservice.ChannelsClientDeleteOptions) (resp azfake.Responder[armbotservice.ChannelsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *armbotservice.BotChannelsClientDeleteOptions) (resp azfake.Responder[armbotservice.BotChannelsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BotChannelsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *armbotservice.BotChannelsClientGetOptions) (resp azfake.Responder[armbotservice.BotChannelsClientGetResponse], errResp azfake.ErrorResponder) - // Get is the fake for method ChannelsClient.Get + // NewListByResourceGroupPager is the fake for method BotChannelsClient.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *armbotservice.ChannelsClientGetOptions) (resp azfake.Responder[armbotservice.ChannelsClientGetResponse], errResp azfake.ErrorResponder) + NewListByResourceGroupPager func(resourceGroupName string, resourceName string, options *armbotservice.BotChannelsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armbotservice.BotChannelsClientListByResourceGroupResponse]) - // NewListByResourceGroupPager is the fake for method ChannelsClient.NewListByResourceGroupPager + // ListWithKeys is the fake for method BotChannelsClient.ListWithKeys // HTTP status codes to indicate success: http.StatusOK - NewListByResourceGroupPager func(resourceGroupName string, resourceName string, options *armbotservice.ChannelsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armbotservice.ChannelsClientListByResourceGroupResponse]) + ListWithKeys func(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *armbotservice.BotChannelsClientListWithKeysOptions) (resp azfake.Responder[armbotservice.BotChannelsClientListWithKeysResponse], errResp azfake.ErrorResponder) - // ListWithKeys is the fake for method ChannelsClient.ListWithKeys + // RegenerateKeys is the fake for method BotChannelsClient.RegenerateKeys // HTTP status codes to indicate success: http.StatusOK - ListWithKeys func(ctx context.Context, resourceGroupName string, resourceName string, channelName armbotservice.ChannelName, options *armbotservice.ChannelsClientListWithKeysOptions) (resp azfake.Responder[armbotservice.ChannelsClientListWithKeysResponse], errResp azfake.ErrorResponder) + RegenerateKeys func(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters armbotservice.SiteInfo, options *armbotservice.BotChannelsClientRegenerateKeysOptions) (resp azfake.Responder[armbotservice.BotChannelsClientRegenerateKeysResponse], errResp azfake.ErrorResponder) - // Update is the fake for method ChannelsClient.Update + // Update is the fake for method BotChannelsClient.Update // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - Update func(ctx context.Context, resourceGroupName string, resourceName string, channelName armbotservice.ChannelName, parameters armbotservice.BotChannel, options *armbotservice.ChannelsClientUpdateOptions) (resp azfake.Responder[armbotservice.ChannelsClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, resourceGroupName string, resourceName string, channelName string, parameters armbotservice.BotChannel, options *armbotservice.BotChannelsClientUpdateOptions) (resp azfake.Responder[armbotservice.BotChannelsClientUpdateResponse], errResp azfake.ErrorResponder) } -// NewChannelsServerTransport creates a new instance of ChannelsServerTransport with the provided implementation. -// The returned ChannelsServerTransport instance is connected to an instance of armbotservice.ChannelsClient via the +// NewBotChannelsServerTransport creates a new instance of BotChannelsServerTransport with the provided implementation. +// The returned BotChannelsServerTransport instance is connected to an instance of armbotservice.BotChannelsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewChannelsServerTransport(srv *ChannelsServer) *ChannelsServerTransport { - return &ChannelsServerTransport{ +func NewBotChannelsServerTransport(srv *BotChannelsServer) *BotChannelsServerTransport { + return &BotChannelsServerTransport{ srv: srv, - newListByResourceGroupPager: newTracker[azfake.PagerResponder[armbotservice.ChannelsClientListByResourceGroupResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armbotservice.BotChannelsClientListByResourceGroupResponse]](), } } -// ChannelsServerTransport connects instances of armbotservice.ChannelsClient to instances of ChannelsServer. -// Don't use this type directly, use NewChannelsServerTransport instead. -type ChannelsServerTransport struct { - srv *ChannelsServer - newListByResourceGroupPager *tracker[azfake.PagerResponder[armbotservice.ChannelsClientListByResourceGroupResponse]] +// BotChannelsServerTransport connects instances of armbotservice.BotChannelsClient to instances of BotChannelsServer. +// Don't use this type directly, use NewBotChannelsServerTransport instead. +type BotChannelsServerTransport struct { + srv *BotChannelsServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armbotservice.BotChannelsClientListByResourceGroupResponse]] } -// Do implements the policy.Transporter interface for ChannelsServerTransport. -func (c *ChannelsServerTransport) Do(req *http.Request) (*http.Response, error) { +// Do implements the policy.Transporter interface for BotChannelsServerTransport. +func (b *BotChannelsServerTransport) Do(req *http.Request) (*http.Response, error) { rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) method, ok := rawMethod.(string) if !ok { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return b.dispatchToMethodFake(req, method) +} - switch method { - case "ChannelsClient.Create": - resp, err = c.dispatchCreate(req) - case "ChannelsClient.Delete": - resp, err = c.dispatchDelete(req) - case "ChannelsClient.Get": - resp, err = c.dispatchGet(req) - case "ChannelsClient.NewListByResourceGroupPager": - resp, err = c.dispatchNewListByResourceGroupPager(req) - case "ChannelsClient.ListWithKeys": - resp, err = c.dispatchListWithKeys(req) - case "ChannelsClient.Update": - resp, err = c.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (b *BotChannelsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if botChannelsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = botChannelsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BotChannelsClient.Create": + res.resp, res.err = b.dispatchCreate(req) + case "BotChannelsClient.Delete": + res.resp, res.err = b.dispatchDelete(req) + case "BotChannelsClient.Get": + res.resp, res.err = b.dispatchGet(req) + case "BotChannelsClient.NewListByResourceGroupPager": + res.resp, res.err = b.dispatchNewListByResourceGroupPager(req) + case "BotChannelsClient.ListWithKeys": + res.resp, res.err = b.dispatchListWithKeys(req) + case "BotChannelsClient.RegenerateKeys": + res.resp, res.err = b.dispatchRegenerateKeys(req) + case "BotChannelsClient.Update": + res.resp, res.err = b.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } -func (c *ChannelsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { - if c.srv.Create == nil { +func (b *BotChannelsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if b.srv.Create == nil { return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/channels/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armbotservice.BotChannel](req) @@ -123,17 +144,11 @@ func (c *ChannelsServerTransport) dispatchCreate(req *http.Request) (*http.Respo if err != nil { return nil, err } - channelNameParam, err := parseWithCast(matches[regex.SubexpIndex("channelName")], func(v string) (armbotservice.ChannelName, error) { - p, unescapeErr := url.PathUnescape(v) - if unescapeErr != nil { - return "", unescapeErr - } - return armbotservice.ChannelName(p), nil - }) + channelNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("channelName")]) if err != nil { return nil, err } - respr, errRespr := c.srv.Create(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, body, nil) + respr, errRespr := b.srv.Create(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -148,14 +163,14 @@ func (c *ChannelsServerTransport) dispatchCreate(req *http.Request) (*http.Respo return resp, nil } -func (c *ChannelsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if c.srv.Delete == nil { +func (b *BotChannelsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if b.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/channels/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -170,7 +185,7 @@ func (c *ChannelsServerTransport) dispatchDelete(req *http.Request) (*http.Respo if err != nil { return nil, err } - respr, errRespr := c.srv.Delete(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, nil) + respr, errRespr := b.srv.Delete(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -185,14 +200,14 @@ func (c *ChannelsServerTransport) dispatchDelete(req *http.Request) (*http.Respo return resp, nil } -func (c *ChannelsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if c.srv.Get == nil { +func (b *BotChannelsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/channels/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -207,7 +222,7 @@ func (c *ChannelsServerTransport) dispatchGet(req *http.Request) (*http.Response if err != nil { return nil, err } - respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, nil) + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -222,16 +237,16 @@ func (c *ChannelsServerTransport) dispatchGet(req *http.Request) (*http.Response return resp, nil } -func (c *ChannelsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { - if c.srv.NewListByResourceGroupPager == nil { +func (b *BotChannelsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListByResourceGroupPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} } - newListByResourceGroupPager := c.newListByResourceGroupPager.get(req) + newListByResourceGroupPager := b.newListByResourceGroupPager.get(req) if newListByResourceGroupPager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/channels` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -242,10 +257,10 @@ func (c *ChannelsServerTransport) dispatchNewListByResourceGroupPager(req *http. if err != nil { return nil, err } - resp := c.srv.NewListByResourceGroupPager(resourceGroupNameParam, resourceNameParam, nil) + resp := b.srv.NewListByResourceGroupPager(resourceGroupNameParam, resourceNameParam, nil) newListByResourceGroupPager = &resp - c.newListByResourceGroupPager.add(req, newListByResourceGroupPager) - server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armbotservice.ChannelsClientListByResourceGroupResponse, createLink func() string) { + b.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armbotservice.BotChannelsClientListByResourceGroupResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -254,23 +269,23 @@ func (c *ChannelsServerTransport) dispatchNewListByResourceGroupPager(req *http. return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - c.newListByResourceGroupPager.remove(req) + b.newListByResourceGroupPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListByResourceGroupPager) { - c.newListByResourceGroupPager.remove(req) + b.newListByResourceGroupPager.remove(req) } return resp, nil } -func (c *ChannelsServerTransport) dispatchListWithKeys(req *http.Request) (*http.Response, error) { - if c.srv.ListWithKeys == nil { +func (b *BotChannelsServerTransport) dispatchListWithKeys(req *http.Request) (*http.Response, error) { + if b.srv.ListWithKeys == nil { return nil, &nonRetriableError{errors.New("fake for method ListWithKeys not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/channels/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listChannelWithKeys` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -281,17 +296,11 @@ func (c *ChannelsServerTransport) dispatchListWithKeys(req *http.Request) (*http if err != nil { return nil, err } - channelNameParam, err := parseWithCast(matches[regex.SubexpIndex("channelName")], func(v string) (armbotservice.ChannelName, error) { - p, unescapeErr := url.PathUnescape(v) - if unescapeErr != nil { - return "", unescapeErr - } - return armbotservice.ChannelName(p), nil - }) + channelNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("channelName")]) if err != nil { return nil, err } - respr, errRespr := c.srv.ListWithKeys(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, nil) + respr, errRespr := b.srv.ListWithKeys(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -306,14 +315,55 @@ func (c *ChannelsServerTransport) dispatchListWithKeys(req *http.Request) (*http return resp, nil } -func (c *ChannelsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if c.srv.Update == nil { +func (b *BotChannelsServerTransport) dispatchRegenerateKeys(req *http.Request) (*http.Response, error) { + if b.srv.RegenerateKeys == nil { + return nil, &nonRetriableError{errors.New("fake for method RegenerateKeys not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/channels/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regeneratekeys` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbotservice.SiteInfo](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + channelNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("channelName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.RegenerateKeys(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BotChannel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BotChannelsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if b.srv.Update == nil { return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/channels/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armbotservice.BotChannel](req) @@ -328,17 +378,11 @@ func (c *ChannelsServerTransport) dispatchUpdate(req *http.Request) (*http.Respo if err != nil { return nil, err } - channelNameParam, err := parseWithCast(matches[regex.SubexpIndex("channelName")], func(v string) (armbotservice.ChannelName, error) { - p, unescapeErr := url.PathUnescape(v) - if unescapeErr != nil { - return "", unescapeErr - } - return armbotservice.ChannelName(p), nil - }) + channelNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("channelName")]) if err != nil { return nil, err } - respr, errRespr := c.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, body, nil) + respr, errRespr := b.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -352,3 +396,9 @@ func (c *ChannelsServerTransport) dispatchUpdate(req *http.Request) (*http.Respo } return resp, nil } + +// set this to conditionally intercept incoming requests to BotChannelsServerTransport +var botChannelsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/botconnectionoperationgroup_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/botconnectionoperationgroup_server.go new file mode 100644 index 000000000000..93010a525a75 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/fake/botconnectionoperationgroup_server.go @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "net/http" + "regexp" +) + +// BotConnectionOperationGroupServer is a fake server for instances of the armbotservice.BotConnectionOperationGroupClient type. +type BotConnectionOperationGroupServer struct { + // ListServiceProviders is the fake for method BotConnectionOperationGroupClient.ListServiceProviders + // HTTP status codes to indicate success: http.StatusOK + ListServiceProviders func(ctx context.Context, options *armbotservice.BotConnectionOperationGroupClientListServiceProvidersOptions) (resp azfake.Responder[armbotservice.BotConnectionOperationGroupClientListServiceProvidersResponse], errResp azfake.ErrorResponder) +} + +// NewBotConnectionOperationGroupServerTransport creates a new instance of BotConnectionOperationGroupServerTransport with the provided implementation. +// The returned BotConnectionOperationGroupServerTransport instance is connected to an instance of armbotservice.BotConnectionOperationGroupClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBotConnectionOperationGroupServerTransport(srv *BotConnectionOperationGroupServer) *BotConnectionOperationGroupServerTransport { + return &BotConnectionOperationGroupServerTransport{srv: srv} +} + +// BotConnectionOperationGroupServerTransport connects instances of armbotservice.BotConnectionOperationGroupClient to instances of BotConnectionOperationGroupServer. +// Don't use this type directly, use NewBotConnectionOperationGroupServerTransport instead. +type BotConnectionOperationGroupServerTransport struct { + srv *BotConnectionOperationGroupServer +} + +// Do implements the policy.Transporter interface for BotConnectionOperationGroupServerTransport. +func (b *BotConnectionOperationGroupServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return b.dispatchToMethodFake(req, method) +} + +func (b *BotConnectionOperationGroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if botConnectionOperationGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = botConnectionOperationGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BotConnectionOperationGroupClient.ListServiceProviders": + res.resp, res.err = b.dispatchListServiceProviders(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (b *BotConnectionOperationGroupServerTransport) dispatchListServiceProviders(req *http.Request) (*http.Response, error) { + if b.srv.ListServiceProviders == nil { + return nil, &nonRetriableError{errors.New("fake for method ListServiceProviders not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/listAuthServiceProviders` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.ListServiceProviders(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ServiceProviderResponseList, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to BotConnectionOperationGroupServerTransport +var botConnectionOperationGroupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/bots_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/bots_server.go index 7ad8c6f200ab..3967d780b23b 100644 --- a/sdk/resourcemanager/botservice/armbotservice/fake/bots_server.go +++ b/sdk/resourcemanager/botservice/armbotservice/fake/bots_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" "net/http" "net/url" "regexp" @@ -28,6 +24,10 @@ type BotsServer struct { // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated Create func(ctx context.Context, resourceGroupName string, resourceName string, parameters armbotservice.Bot, options *armbotservice.BotsClientCreateOptions) (resp azfake.Responder[armbotservice.BotsClientCreateResponse], errResp azfake.ErrorResponder) + // CreateSignInURL is the fake for method BotsClient.CreateSignInURL + // HTTP status codes to indicate success: http.StatusOK + CreateSignInURL func(ctx context.Context, resourceGroupName string, resourceName string, options *armbotservice.BotsClientCreateSignInURLOptions) (resp azfake.Responder[armbotservice.BotsClientCreateSignInURLResponse], errResp azfake.ErrorResponder) + // Delete is the fake for method BotsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent Delete func(ctx context.Context, resourceGroupName string, resourceName string, options *armbotservice.BotsClientDeleteOptions) (resp azfake.Responder[armbotservice.BotsClientDeleteResponse], errResp azfake.ErrorResponder) @@ -36,14 +36,14 @@ type BotsServer struct { // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, resourceName string, options *armbotservice.BotsClientGetOptions) (resp azfake.Responder[armbotservice.BotsClientGetResponse], errResp azfake.ErrorResponder) - // GetCheckNameAvailability is the fake for method BotsClient.GetCheckNameAvailability - // HTTP status codes to indicate success: http.StatusOK - GetCheckNameAvailability func(ctx context.Context, parameters armbotservice.CheckNameAvailabilityRequestBody, options *armbotservice.BotsClientGetCheckNameAvailabilityOptions) (resp azfake.Responder[armbotservice.BotsClientGetCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) - // NewListPager is the fake for method BotsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK NewListPager func(options *armbotservice.BotsClientListOptions) (resp azfake.PagerResponder[armbotservice.BotsClientListResponse]) + // ListByBotResource is the fake for method BotsClient.ListByBotResource + // HTTP status codes to indicate success: http.StatusOK + ListByBotResource func(ctx context.Context, resourceGroupName string, resourceName string, options *armbotservice.BotsClientListByBotResourceOptions) (resp azfake.Responder[armbotservice.BotsClientListByBotResourceResponse], errResp azfake.ErrorResponder) + // NewListByResourceGroupPager is the fake for method BotsClient.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK NewListByResourceGroupPager func(resourceGroupName string, options *armbotservice.BotsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armbotservice.BotsClientListByResourceGroupResponse]) @@ -80,33 +80,54 @@ func (b *BotsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return b.dispatchToMethodFake(req, method) +} - switch method { - case "BotsClient.Create": - resp, err = b.dispatchCreate(req) - case "BotsClient.Delete": - resp, err = b.dispatchDelete(req) - case "BotsClient.Get": - resp, err = b.dispatchGet(req) - case "BotsClient.GetCheckNameAvailability": - resp, err = b.dispatchGetCheckNameAvailability(req) - case "BotsClient.NewListPager": - resp, err = b.dispatchNewListPager(req) - case "BotsClient.NewListByResourceGroupPager": - resp, err = b.dispatchNewListByResourceGroupPager(req) - case "BotsClient.Update": - resp, err = b.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (b *BotsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if botsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = botsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BotsClient.Create": + res.resp, res.err = b.dispatchCreate(req) + case "BotsClient.CreateSignInURL": + res.resp, res.err = b.dispatchCreateSignInURL(req) + case "BotsClient.Delete": + res.resp, res.err = b.dispatchDelete(req) + case "BotsClient.Get": + res.resp, res.err = b.dispatchGet(req) + case "BotsClient.NewListPager": + res.resp, res.err = b.dispatchNewListPager(req) + case "BotsClient.ListByBotResource": + res.resp, res.err = b.dispatchListByBotResource(req) + case "BotsClient.NewListByResourceGroupPager": + res.resp, res.err = b.dispatchNewListByResourceGroupPager(req) + case "BotsClient.Update": + res.resp, res.err = b.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (b *BotsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { @@ -116,7 +137,7 @@ func (b *BotsServerTransport) dispatchCreate(req *http.Request) (*http.Response, const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armbotservice.Bot](req) @@ -146,14 +167,14 @@ func (b *BotsServerTransport) dispatchCreate(req *http.Request) (*http.Response, return resp, nil } -func (b *BotsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if b.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} +func (b *BotsServerTransport) dispatchCreateSignInURL(req *http.Request) (*http.Response, error) { + if b.srv.CreateSignInURL == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateSignInURL not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createEmailSignInUrl` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -164,29 +185,29 @@ func (b *BotsServerTransport) dispatchDelete(req *http.Request) (*http.Response, if err != nil { return nil, err } - respr, errRespr := b.srv.Delete(req.Context(), resourceGroupNameParam, resourceNameParam, nil) + respr, errRespr := b.srv.CreateSignInURL(req.Context(), resourceGroupNameParam, resourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.NewResponse(respContent, req, nil) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CreateEmailSignInURLResponse, req) if err != nil { return nil, err } return resp, nil } -func (b *BotsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if b.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} +func (b *BotsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if b.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -197,30 +218,40 @@ func (b *BotsServerTransport) dispatchGet(req *http.Request) (*http.Response, er if err != nil { return nil, err } - respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, nil) + respr, errRespr := b.srv.Delete(req.Context(), resourceGroupNameParam, resourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Bot, req) + resp, err := server.NewResponse(respContent, req, nil) if err != nil { return nil, err } return resp, nil } -func (b *BotsServerTransport) dispatchGetCheckNameAvailability(req *http.Request) (*http.Response, error) { - if b.srv.GetCheckNameAvailability == nil { - return nil, &nonRetriableError{errors.New("fake for method GetCheckNameAvailability not implemented")} +func (b *BotsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - body, err := server.UnmarshalRequestAsJSON[armbotservice.CheckNameAvailabilityRequestBody](req) + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } - respr, errRespr := b.srv.GetCheckNameAvailability(req.Context(), body, nil) + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -228,7 +259,7 @@ func (b *BotsServerTransport) dispatchGetCheckNameAvailability(req *http.Request if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckNameAvailabilityResponseBody, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Bot, req) if err != nil { return nil, err } @@ -244,7 +275,7 @@ func (b *BotsServerTransport) dispatchNewListPager(req *http.Request) (*http.Res const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resp := b.srv.NewListPager(nil) @@ -268,6 +299,39 @@ func (b *BotsServerTransport) dispatchNewListPager(req *http.Request) (*http.Res return resp, nil } +func (b *BotsServerTransport) dispatchListByBotResource(req *http.Request) (*http.Response, error) { + if b.srv.ListByBotResource == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByBotResource not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.ListByBotResource(req.Context(), resourceGroupNameParam, resourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrivateLinkResourceListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (b *BotsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { if b.srv.NewListByResourceGroupPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} @@ -277,7 +341,7 @@ func (b *BotsServerTransport) dispatchNewListByResourceGroupPager(req *http.Requ const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -312,7 +376,7 @@ func (b *BotsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armbotservice.Bot](req) @@ -341,3 +405,9 @@ func (b *BotsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, } return resp, nil } + +// set this to conditionally intercept incoming requests to BotsServerTransport +var botsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/botsoperationgroup_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/botsoperationgroup_server.go new file mode 100644 index 000000000000..8b011b0ffb71 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/fake/botsoperationgroup_server.go @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "net/http" +) + +// BotsOperationGroupServer is a fake server for instances of the armbotservice.BotsOperationGroupClient type. +type BotsOperationGroupServer struct { + // GetCheckNameAvailability is the fake for method BotsOperationGroupClient.GetCheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + GetCheckNameAvailability func(ctx context.Context, parameters armbotservice.CheckNameAvailabilityRequestBody, options *armbotservice.BotsOperationGroupClientGetCheckNameAvailabilityOptions) (resp azfake.Responder[armbotservice.BotsOperationGroupClientGetCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) +} + +// NewBotsOperationGroupServerTransport creates a new instance of BotsOperationGroupServerTransport with the provided implementation. +// The returned BotsOperationGroupServerTransport instance is connected to an instance of armbotservice.BotsOperationGroupClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBotsOperationGroupServerTransport(srv *BotsOperationGroupServer) *BotsOperationGroupServerTransport { + return &BotsOperationGroupServerTransport{srv: srv} +} + +// BotsOperationGroupServerTransport connects instances of armbotservice.BotsOperationGroupClient to instances of BotsOperationGroupServer. +// Don't use this type directly, use NewBotsOperationGroupServerTransport instead. +type BotsOperationGroupServerTransport struct { + srv *BotsOperationGroupServer +} + +// Do implements the policy.Transporter interface for BotsOperationGroupServerTransport. +func (b *BotsOperationGroupServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return b.dispatchToMethodFake(req, method) +} + +func (b *BotsOperationGroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if botsOperationGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = botsOperationGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BotsOperationGroupClient.GetCheckNameAvailability": + res.resp, res.err = b.dispatchGetCheckNameAvailability(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (b *BotsOperationGroupServerTransport) dispatchGetCheckNameAvailability(req *http.Request) (*http.Response, error) { + if b.srv.GetCheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method GetCheckNameAvailability not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armbotservice.CheckNameAvailabilityRequestBody](req) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.GetCheckNameAvailability(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckNameAvailabilityResponseBody, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to BotsOperationGroupServerTransport +var botsOperationGroupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/botconnection_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/connectionsettings_server.go similarity index 62% rename from sdk/resourcemanager/botservice/armbotservice/fake/botconnection_server.go rename to sdk/resourcemanager/botservice/armbotservice/fake/connectionsettings_server.go index bb83a5d26d82..8d2f10cc757c 100644 --- a/sdk/resourcemanager/botservice/armbotservice/fake/botconnection_server.go +++ b/sdk/resourcemanager/botservice/armbotservice/fake/connectionsettings_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,105 +12,118 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" "net/http" "net/url" "regexp" ) -// BotConnectionServer is a fake server for instances of the armbotservice.BotConnectionClient type. -type BotConnectionServer struct { - // Create is the fake for method BotConnectionClient.Create +// ConnectionSettingsServer is a fake server for instances of the armbotservice.ConnectionSettingsClient type. +type ConnectionSettingsServer struct { + // Create is the fake for method ConnectionSettingsClient.Create // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - Create func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters armbotservice.ConnectionSetting, options *armbotservice.BotConnectionClientCreateOptions) (resp azfake.Responder[armbotservice.BotConnectionClientCreateResponse], errResp azfake.ErrorResponder) + Create func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters armbotservice.ConnectionSetting, options *armbotservice.ConnectionSettingsClientCreateOptions) (resp azfake.Responder[armbotservice.ConnectionSettingsClientCreateResponse], errResp azfake.ErrorResponder) - // Delete is the fake for method BotConnectionClient.Delete + // Delete is the fake for method ConnectionSettingsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *armbotservice.BotConnectionClientDeleteOptions) (resp azfake.Responder[armbotservice.BotConnectionClientDeleteResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method BotConnectionClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *armbotservice.BotConnectionClientGetOptions) (resp azfake.Responder[armbotservice.BotConnectionClientGetResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *armbotservice.ConnectionSettingsClientDeleteOptions) (resp azfake.Responder[armbotservice.ConnectionSettingsClientDeleteResponse], errResp azfake.ErrorResponder) - // NewListByBotServicePager is the fake for method BotConnectionClient.NewListByBotServicePager + // Get is the fake for method ConnectionSettingsClient.Get // HTTP status codes to indicate success: http.StatusOK - NewListByBotServicePager func(resourceGroupName string, resourceName string, options *armbotservice.BotConnectionClientListByBotServiceOptions) (resp azfake.PagerResponder[armbotservice.BotConnectionClientListByBotServiceResponse]) + Get func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *armbotservice.ConnectionSettingsClientGetOptions) (resp azfake.Responder[armbotservice.ConnectionSettingsClientGetResponse], errResp azfake.ErrorResponder) - // ListServiceProviders is the fake for method BotConnectionClient.ListServiceProviders + // NewListByBotServicePager is the fake for method ConnectionSettingsClient.NewListByBotServicePager // HTTP status codes to indicate success: http.StatusOK - ListServiceProviders func(ctx context.Context, options *armbotservice.BotConnectionClientListServiceProvidersOptions) (resp azfake.Responder[armbotservice.BotConnectionClientListServiceProvidersResponse], errResp azfake.ErrorResponder) + NewListByBotServicePager func(resourceGroupName string, resourceName string, options *armbotservice.ConnectionSettingsClientListByBotServiceOptions) (resp azfake.PagerResponder[armbotservice.ConnectionSettingsClientListByBotServiceResponse]) - // ListWithSecrets is the fake for method BotConnectionClient.ListWithSecrets + // ListWithSecrets is the fake for method ConnectionSettingsClient.ListWithSecrets // HTTP status codes to indicate success: http.StatusOK - ListWithSecrets func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *armbotservice.BotConnectionClientListWithSecretsOptions) (resp azfake.Responder[armbotservice.BotConnectionClientListWithSecretsResponse], errResp azfake.ErrorResponder) + ListWithSecrets func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *armbotservice.ConnectionSettingsClientListWithSecretsOptions) (resp azfake.Responder[armbotservice.ConnectionSettingsClientListWithSecretsResponse], errResp azfake.ErrorResponder) - // Update is the fake for method BotConnectionClient.Update + // Update is the fake for method ConnectionSettingsClient.Update // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - Update func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters armbotservice.ConnectionSetting, options *armbotservice.BotConnectionClientUpdateOptions) (resp azfake.Responder[armbotservice.BotConnectionClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters armbotservice.ConnectionSetting, options *armbotservice.ConnectionSettingsClientUpdateOptions) (resp azfake.Responder[armbotservice.ConnectionSettingsClientUpdateResponse], errResp azfake.ErrorResponder) } -// NewBotConnectionServerTransport creates a new instance of BotConnectionServerTransport with the provided implementation. -// The returned BotConnectionServerTransport instance is connected to an instance of armbotservice.BotConnectionClient via the +// NewConnectionSettingsServerTransport creates a new instance of ConnectionSettingsServerTransport with the provided implementation. +// The returned ConnectionSettingsServerTransport instance is connected to an instance of armbotservice.ConnectionSettingsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewBotConnectionServerTransport(srv *BotConnectionServer) *BotConnectionServerTransport { - return &BotConnectionServerTransport{ +func NewConnectionSettingsServerTransport(srv *ConnectionSettingsServer) *ConnectionSettingsServerTransport { + return &ConnectionSettingsServerTransport{ srv: srv, - newListByBotServicePager: newTracker[azfake.PagerResponder[armbotservice.BotConnectionClientListByBotServiceResponse]](), + newListByBotServicePager: newTracker[azfake.PagerResponder[armbotservice.ConnectionSettingsClientListByBotServiceResponse]](), } } -// BotConnectionServerTransport connects instances of armbotservice.BotConnectionClient to instances of BotConnectionServer. -// Don't use this type directly, use NewBotConnectionServerTransport instead. -type BotConnectionServerTransport struct { - srv *BotConnectionServer - newListByBotServicePager *tracker[azfake.PagerResponder[armbotservice.BotConnectionClientListByBotServiceResponse]] +// ConnectionSettingsServerTransport connects instances of armbotservice.ConnectionSettingsClient to instances of ConnectionSettingsServer. +// Don't use this type directly, use NewConnectionSettingsServerTransport instead. +type ConnectionSettingsServerTransport struct { + srv *ConnectionSettingsServer + newListByBotServicePager *tracker[azfake.PagerResponder[armbotservice.ConnectionSettingsClientListByBotServiceResponse]] } -// Do implements the policy.Transporter interface for BotConnectionServerTransport. -func (b *BotConnectionServerTransport) Do(req *http.Request) (*http.Response, error) { +// Do implements the policy.Transporter interface for ConnectionSettingsServerTransport. +func (c *ConnectionSettingsServerTransport) Do(req *http.Request) (*http.Response, error) { rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) method, ok := rawMethod.(string) if !ok { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "BotConnectionClient.Create": - resp, err = b.dispatchCreate(req) - case "BotConnectionClient.Delete": - resp, err = b.dispatchDelete(req) - case "BotConnectionClient.Get": - resp, err = b.dispatchGet(req) - case "BotConnectionClient.NewListByBotServicePager": - resp, err = b.dispatchNewListByBotServicePager(req) - case "BotConnectionClient.ListServiceProviders": - resp, err = b.dispatchListServiceProviders(req) - case "BotConnectionClient.ListWithSecrets": - resp, err = b.dispatchListWithSecrets(req) - case "BotConnectionClient.Update": - resp, err = b.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ConnectionSettingsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if connectionSettingsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = connectionSettingsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConnectionSettingsClient.Create": + res.resp, res.err = c.dispatchCreate(req) + case "ConnectionSettingsClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "ConnectionSettingsClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ConnectionSettingsClient.NewListByBotServicePager": + res.resp, res.err = c.dispatchNewListByBotServicePager(req) + case "ConnectionSettingsClient.ListWithSecrets": + res.resp, res.err = c.dispatchListWithSecrets(req) + case "ConnectionSettingsClient.Update": + res.resp, res.err = c.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } -func (b *BotConnectionServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { - if b.srv.Create == nil { +func (c *ConnectionSettingsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if c.srv.Create == nil { return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armbotservice.ConnectionSetting](req) @@ -133,7 +142,7 @@ func (b *BotConnectionServerTransport) dispatchCreate(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := b.srv.Create(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, body, nil) + respr, errRespr := c.srv.Create(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -148,14 +157,14 @@ func (b *BotConnectionServerTransport) dispatchCreate(req *http.Request) (*http. return resp, nil } -func (b *BotConnectionServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if b.srv.Delete == nil { +func (c *ConnectionSettingsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if c.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -170,7 +179,7 @@ func (b *BotConnectionServerTransport) dispatchDelete(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := b.srv.Delete(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, nil) + respr, errRespr := c.srv.Delete(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -185,14 +194,14 @@ func (b *BotConnectionServerTransport) dispatchDelete(req *http.Request) (*http. return resp, nil } -func (b *BotConnectionServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if b.srv.Get == nil { +func (c *ConnectionSettingsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -207,7 +216,7 @@ func (b *BotConnectionServerTransport) dispatchGet(req *http.Request) (*http.Res if err != nil { return nil, err } - respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, nil) + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -222,16 +231,16 @@ func (b *BotConnectionServerTransport) dispatchGet(req *http.Request) (*http.Res return resp, nil } -func (b *BotConnectionServerTransport) dispatchNewListByBotServicePager(req *http.Request) (*http.Response, error) { - if b.srv.NewListByBotServicePager == nil { +func (c *ConnectionSettingsServerTransport) dispatchNewListByBotServicePager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByBotServicePager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByBotServicePager not implemented")} } - newListByBotServicePager := b.newListByBotServicePager.get(req) + newListByBotServicePager := c.newListByBotServicePager.get(req) if newListByBotServicePager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connections` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -242,10 +251,10 @@ func (b *BotConnectionServerTransport) dispatchNewListByBotServicePager(req *htt if err != nil { return nil, err } - resp := b.srv.NewListByBotServicePager(resourceGroupNameParam, resourceNameParam, nil) + resp := c.srv.NewListByBotServicePager(resourceGroupNameParam, resourceNameParam, nil) newListByBotServicePager = &resp - b.newListByBotServicePager.add(req, newListByBotServicePager) - server.PagerResponderInjectNextLinks(newListByBotServicePager, req, func(page *armbotservice.BotConnectionClientListByBotServiceResponse, createLink func() string) { + c.newListByBotServicePager.add(req, newListByBotServicePager) + server.PagerResponderInjectNextLinks(newListByBotServicePager, req, func(page *armbotservice.ConnectionSettingsClientListByBotServiceResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -254,48 +263,23 @@ func (b *BotConnectionServerTransport) dispatchNewListByBotServicePager(req *htt return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - b.newListByBotServicePager.remove(req) + c.newListByBotServicePager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListByBotServicePager) { - b.newListByBotServicePager.remove(req) - } - return resp, nil -} - -func (b *BotConnectionServerTransport) dispatchListServiceProviders(req *http.Request) (*http.Response, error) { - if b.srv.ListServiceProviders == nil { - return nil, &nonRetriableError{errors.New("fake for method ListServiceProviders not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/listAuthServiceProviders` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - respr, errRespr := b.srv.ListServiceProviders(req.Context(), nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ServiceProviderResponseList, req) - if err != nil { - return nil, err + c.newListByBotServicePager.remove(req) } return resp, nil } -func (b *BotConnectionServerTransport) dispatchListWithSecrets(req *http.Request) (*http.Response, error) { - if b.srv.ListWithSecrets == nil { +func (c *ConnectionSettingsServerTransport) dispatchListWithSecrets(req *http.Request) (*http.Response, error) { + if c.srv.ListWithSecrets == nil { return nil, &nonRetriableError{errors.New("fake for method ListWithSecrets not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listWithSecrets` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -310,7 +294,7 @@ func (b *BotConnectionServerTransport) dispatchListWithSecrets(req *http.Request if err != nil { return nil, err } - respr, errRespr := b.srv.ListWithSecrets(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, nil) + respr, errRespr := c.srv.ListWithSecrets(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -325,14 +309,14 @@ func (b *BotConnectionServerTransport) dispatchListWithSecrets(req *http.Request return resp, nil } -func (b *BotConnectionServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if b.srv.Update == nil { +func (c *ConnectionSettingsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if c.srv.Update == nil { return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armbotservice.ConnectionSetting](req) @@ -351,7 +335,7 @@ func (b *BotConnectionServerTransport) dispatchUpdate(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := b.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, body, nil) + respr, errRespr := c.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, connectionNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -365,3 +349,9 @@ func (b *BotConnectionServerTransport) dispatchUpdate(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to ConnectionSettingsServerTransport +var connectionSettingsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/directline_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/directline_server.go deleted file mode 100644 index d3d8a0683ff5..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/fake/directline_server.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" - "net/http" - "net/url" - "regexp" -) - -// DirectLineServer is a fake server for instances of the armbotservice.DirectLineClient type. -type DirectLineServer struct { - // RegenerateKeys is the fake for method DirectLineClient.RegenerateKeys - // HTTP status codes to indicate success: http.StatusOK - RegenerateKeys func(ctx context.Context, resourceGroupName string, resourceName string, channelName armbotservice.RegenerateKeysChannelName, parameters armbotservice.SiteInfo, options *armbotservice.DirectLineClientRegenerateKeysOptions) (resp azfake.Responder[armbotservice.DirectLineClientRegenerateKeysResponse], errResp azfake.ErrorResponder) -} - -// NewDirectLineServerTransport creates a new instance of DirectLineServerTransport with the provided implementation. -// The returned DirectLineServerTransport instance is connected to an instance of armbotservice.DirectLineClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewDirectLineServerTransport(srv *DirectLineServer) *DirectLineServerTransport { - return &DirectLineServerTransport{srv: srv} -} - -// DirectLineServerTransport connects instances of armbotservice.DirectLineClient to instances of DirectLineServer. -// Don't use this type directly, use NewDirectLineServerTransport instead. -type DirectLineServerTransport struct { - srv *DirectLineServer -} - -// Do implements the policy.Transporter interface for DirectLineServerTransport. -func (d *DirectLineServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "DirectLineClient.RegenerateKeys": - resp, err = d.dispatchRegenerateKeys(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (d *DirectLineServerTransport) dispatchRegenerateKeys(req *http.Request) (*http.Response, error) { - if d.srv.RegenerateKeys == nil { - return nil, &nonRetriableError{errors.New("fake for method RegenerateKeys not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/channels/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regeneratekeys` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armbotservice.SiteInfo](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - channelNameParam, err := parseWithCast(matches[regex.SubexpIndex("channelName")], func(v string) (armbotservice.RegenerateKeysChannelName, error) { - p, unescapeErr := url.PathUnescape(v) - if unescapeErr != nil { - return "", unescapeErr - } - return armbotservice.RegenerateKeysChannelName(p), nil - }) - if err != nil { - return nil, err - } - respr, errRespr := d.srv.RegenerateKeys(req.Context(), resourceGroupNameParam, resourceNameParam, channelNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BotChannel, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/email_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/email_server.go deleted file mode 100644 index 3557d7c80a7f..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/fake/email_server.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" - "net/http" - "net/url" - "regexp" -) - -// EmailServer is a fake server for instances of the armbotservice.EmailClient type. -type EmailServer struct { - // CreateSignInURL is the fake for method EmailClient.CreateSignInURL - // HTTP status codes to indicate success: http.StatusOK - CreateSignInURL func(ctx context.Context, resourceGroupName string, resourceName string, options *armbotservice.EmailClientCreateSignInURLOptions) (resp azfake.Responder[armbotservice.EmailClientCreateSignInURLResponse], errResp azfake.ErrorResponder) -} - -// NewEmailServerTransport creates a new instance of EmailServerTransport with the provided implementation. -// The returned EmailServerTransport instance is connected to an instance of armbotservice.EmailClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewEmailServerTransport(srv *EmailServer) *EmailServerTransport { - return &EmailServerTransport{srv: srv} -} - -// EmailServerTransport connects instances of armbotservice.EmailClient to instances of EmailServer. -// Don't use this type directly, use NewEmailServerTransport instead. -type EmailServerTransport struct { - srv *EmailServer -} - -// Do implements the policy.Transporter interface for EmailServerTransport. -func (e *EmailServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "EmailClient.CreateSignInURL": - resp, err = e.dispatchCreateSignInURL(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (e *EmailServerTransport) dispatchCreateSignInURL(req *http.Request) (*http.Response, error) { - if e.srv.CreateSignInURL == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateSignInURL not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createEmailSignInUrl` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.CreateSignInURL(req.Context(), resourceGroupNameParam, resourceNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CreateEmailSignInURLResponse, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/hostsettings_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/hostsettings_server.go deleted file mode 100644 index 4364c6b06d18..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/fake/hostsettings_server.go +++ /dev/null @@ -1,91 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" - "net/http" - "regexp" -) - -// HostSettingsServer is a fake server for instances of the armbotservice.HostSettingsClient type. -type HostSettingsServer struct { - // Get is the fake for method HostSettingsClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, options *armbotservice.HostSettingsClientGetOptions) (resp azfake.Responder[armbotservice.HostSettingsClientGetResponse], errResp azfake.ErrorResponder) -} - -// NewHostSettingsServerTransport creates a new instance of HostSettingsServerTransport with the provided implementation. -// The returned HostSettingsServerTransport instance is connected to an instance of armbotservice.HostSettingsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewHostSettingsServerTransport(srv *HostSettingsServer) *HostSettingsServerTransport { - return &HostSettingsServerTransport{srv: srv} -} - -// HostSettingsServerTransport connects instances of armbotservice.HostSettingsClient to instances of HostSettingsServer. -// Don't use this type directly, use NewHostSettingsServerTransport instead. -type HostSettingsServerTransport struct { - srv *HostSettingsServer -} - -// Do implements the policy.Transporter interface for HostSettingsServerTransport. -func (h *HostSettingsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "HostSettingsClient.Get": - resp, err = h.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (h *HostSettingsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if h.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/hostSettings` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - respr, errRespr := h.srv.Get(req.Context(), nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).HostSettingsResponse, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/hostsettingsoperationgroup_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/hostsettingsoperationgroup_server.go new file mode 100644 index 000000000000..66e2ac862f11 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/fake/hostsettingsoperationgroup_server.go @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "net/http" + "regexp" +) + +// HostSettingsOperationGroupServer is a fake server for instances of the armbotservice.HostSettingsOperationGroupClient type. +type HostSettingsOperationGroupServer struct { + // Get is the fake for method HostSettingsOperationGroupClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, options *armbotservice.HostSettingsOperationGroupClientGetOptions) (resp azfake.Responder[armbotservice.HostSettingsOperationGroupClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewHostSettingsOperationGroupServerTransport creates a new instance of HostSettingsOperationGroupServerTransport with the provided implementation. +// The returned HostSettingsOperationGroupServerTransport instance is connected to an instance of armbotservice.HostSettingsOperationGroupClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewHostSettingsOperationGroupServerTransport(srv *HostSettingsOperationGroupServer) *HostSettingsOperationGroupServerTransport { + return &HostSettingsOperationGroupServerTransport{srv: srv} +} + +// HostSettingsOperationGroupServerTransport connects instances of armbotservice.HostSettingsOperationGroupClient to instances of HostSettingsOperationGroupServer. +// Don't use this type directly, use NewHostSettingsOperationGroupServerTransport instead. +type HostSettingsOperationGroupServerTransport struct { + srv *HostSettingsOperationGroupServer +} + +// Do implements the policy.Transporter interface for HostSettingsOperationGroupServerTransport. +func (h *HostSettingsOperationGroupServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return h.dispatchToMethodFake(req, method) +} + +func (h *HostSettingsOperationGroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if hostSettingsOperationGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = hostSettingsOperationGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "HostSettingsOperationGroupClient.Get": + res.resp, res.err = h.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (h *HostSettingsOperationGroupServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if h.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/hostSettings` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := h.srv.Get(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).HostSettingsResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to HostSettingsOperationGroupServerTransport +var hostSettingsOperationGroupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/internal.go b/sdk/resourcemanager/botservice/armbotservice/fake/internal.go index be04ff43d678..7425b6a669e2 100644 --- a/sdk/resourcemanager/botservice/armbotservice/fake/internal.go +++ b/sdk/resourcemanager/botservice/armbotservice/fake/internal.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -14,6 +10,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } @@ -31,14 +32,6 @@ func contains[T comparable](s []T, v T) bool { return false } -func parseWithCast[T any](v string, parse func(v string) (T, error)) (T, error) { - t, err := parse(v) - if err != nil { - return *new(T), err - } - return t, err -} - func newTracker[T any]() *tracker[T] { return &tracker[T]{ items: map[string]*T{}, diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/networksecurityperimeterconfigurations_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/networksecurityperimeterconfigurations_server.go new file mode 100644 index 000000000000..405120120106 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/fake/networksecurityperimeterconfigurations_server.go @@ -0,0 +1,233 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "net/http" + "net/url" + "regexp" +) + +// NetworkSecurityPerimeterConfigurationsServer is a fake server for instances of the armbotservice.NetworkSecurityPerimeterConfigurationsClient type. +type NetworkSecurityPerimeterConfigurationsServer struct { + // Get is the fake for method NetworkSecurityPerimeterConfigurationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, resourceName string, networkSecurityPerimeterConfigurationName string, options *armbotservice.NetworkSecurityPerimeterConfigurationsClientGetOptions) (resp azfake.Responder[armbotservice.NetworkSecurityPerimeterConfigurationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method NetworkSecurityPerimeterConfigurationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, resourceName string, options *armbotservice.NetworkSecurityPerimeterConfigurationsClientListOptions) (resp azfake.PagerResponder[armbotservice.NetworkSecurityPerimeterConfigurationsClientListResponse]) + + // BeginReconcile is the fake for method NetworkSecurityPerimeterConfigurationsClient.BeginReconcile + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginReconcile func(ctx context.Context, resourceGroupName string, resourceName string, networkSecurityPerimeterConfigurationName string, options *armbotservice.NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (resp azfake.PollerResponder[armbotservice.NetworkSecurityPerimeterConfigurationsClientReconcileResponse], errResp azfake.ErrorResponder) +} + +// NewNetworkSecurityPerimeterConfigurationsServerTransport creates a new instance of NetworkSecurityPerimeterConfigurationsServerTransport with the provided implementation. +// The returned NetworkSecurityPerimeterConfigurationsServerTransport instance is connected to an instance of armbotservice.NetworkSecurityPerimeterConfigurationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewNetworkSecurityPerimeterConfigurationsServerTransport(srv *NetworkSecurityPerimeterConfigurationsServer) *NetworkSecurityPerimeterConfigurationsServerTransport { + return &NetworkSecurityPerimeterConfigurationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armbotservice.NetworkSecurityPerimeterConfigurationsClientListResponse]](), + beginReconcile: newTracker[azfake.PollerResponder[armbotservice.NetworkSecurityPerimeterConfigurationsClientReconcileResponse]](), + } +} + +// NetworkSecurityPerimeterConfigurationsServerTransport connects instances of armbotservice.NetworkSecurityPerimeterConfigurationsClient to instances of NetworkSecurityPerimeterConfigurationsServer. +// Don't use this type directly, use NewNetworkSecurityPerimeterConfigurationsServerTransport instead. +type NetworkSecurityPerimeterConfigurationsServerTransport struct { + srv *NetworkSecurityPerimeterConfigurationsServer + newListPager *tracker[azfake.PagerResponder[armbotservice.NetworkSecurityPerimeterConfigurationsClientListResponse]] + beginReconcile *tracker[azfake.PollerResponder[armbotservice.NetworkSecurityPerimeterConfigurationsClientReconcileResponse]] +} + +// Do implements the policy.Transporter interface for NetworkSecurityPerimeterConfigurationsServerTransport. +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return n.dispatchToMethodFake(req, method) +} + +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if networkSecurityPerimeterConfigurationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = networkSecurityPerimeterConfigurationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "NetworkSecurityPerimeterConfigurationsClient.Get": + res.resp, res.err = n.dispatchGet(req) + case "NetworkSecurityPerimeterConfigurationsClient.NewListPager": + res.resp, res.err = n.dispatchNewListPager(req) + case "NetworkSecurityPerimeterConfigurationsClient.BeginReconcile": + res.resp, res.err = n.dispatchBeginReconcile(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if n.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/networkSecurityPerimeterConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + networkSecurityPerimeterConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("networkSecurityPerimeterConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := n.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, networkSecurityPerimeterConfigurationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).NetworkSecurityPerimeterConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if n.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := n.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/networkSecurityPerimeterConfigurations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + resp := n.srv.NewListPager(resourceGroupNameParam, resourceNameParam, nil) + newListPager = &resp + n.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armbotservice.NetworkSecurityPerimeterConfigurationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + n.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + n.newListPager.remove(req) + } + return resp, nil +} + +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) dispatchBeginReconcile(req *http.Request) (*http.Response, error) { + if n.srv.BeginReconcile == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginReconcile not implemented")} + } + beginReconcile := n.beginReconcile.get(req) + if beginReconcile == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/networkSecurityPerimeterConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reconcile` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + networkSecurityPerimeterConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("networkSecurityPerimeterConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := n.srv.BeginReconcile(req.Context(), resourceGroupNameParam, resourceNameParam, networkSecurityPerimeterConfigurationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginReconcile = &respr + n.beginReconcile.add(req, beginReconcile) + } + + resp, err := server.PollerResponderNext(beginReconcile, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + n.beginReconcile.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginReconcile) { + n.beginReconcile.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to NetworkSecurityPerimeterConfigurationsServerTransport +var networkSecurityPerimeterConfigurationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/operationresults_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/operationresults_server.go deleted file mode 100644 index 06dd5c325606..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/fake/operationresults_server.go +++ /dev/null @@ -1,111 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" - "net/http" - "net/url" - "regexp" -) - -// OperationResultsServer is a fake server for instances of the armbotservice.OperationResultsClient type. -type OperationResultsServer struct { - // BeginGet is the fake for method OperationResultsClient.BeginGet - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginGet func(ctx context.Context, operationResultID string, options *armbotservice.OperationResultsClientBeginGetOptions) (resp azfake.PollerResponder[armbotservice.OperationResultsClientGetResponse], errResp azfake.ErrorResponder) -} - -// NewOperationResultsServerTransport creates a new instance of OperationResultsServerTransport with the provided implementation. -// The returned OperationResultsServerTransport instance is connected to an instance of armbotservice.OperationResultsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewOperationResultsServerTransport(srv *OperationResultsServer) *OperationResultsServerTransport { - return &OperationResultsServerTransport{ - srv: srv, - beginGet: newTracker[azfake.PollerResponder[armbotservice.OperationResultsClientGetResponse]](), - } -} - -// OperationResultsServerTransport connects instances of armbotservice.OperationResultsClient to instances of OperationResultsServer. -// Don't use this type directly, use NewOperationResultsServerTransport instead. -type OperationResultsServerTransport struct { - srv *OperationResultsServer - beginGet *tracker[azfake.PollerResponder[armbotservice.OperationResultsClientGetResponse]] -} - -// Do implements the policy.Transporter interface for OperationResultsServerTransport. -func (o *OperationResultsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "OperationResultsClient.BeginGet": - resp, err = o.dispatchBeginGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (o *OperationResultsServerTransport) dispatchBeginGet(req *http.Request) (*http.Response, error) { - if o.srv.BeginGet == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginGet not implemented")} - } - beginGet := o.beginGet.get(req) - if beginGet == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/operationresults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - operationResultIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationResultId")]) - if err != nil { - return nil, err - } - respr, errRespr := o.srv.BeginGet(req.Context(), operationResultIDParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginGet = &respr - o.beginGet.add(req, beginGet) - } - - resp, err := server.PollerResponderNext(beginGet, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - o.beginGet.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginGet) { - o.beginGet.remove(req) - } - - return resp, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/operationresultsoperationgroup_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/operationresultsoperationgroup_server.go new file mode 100644 index 000000000000..a1150a5a837b --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/fake/operationresultsoperationgroup_server.go @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "net/http" + "net/url" + "regexp" +) + +// OperationResultsOperationGroupServer is a fake server for instances of the armbotservice.OperationResultsOperationGroupClient type. +type OperationResultsOperationGroupServer struct { + // BeginGet is the fake for method OperationResultsOperationGroupClient.BeginGet + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGet func(ctx context.Context, operationResultID string, options *armbotservice.OperationResultsOperationGroupClientBeginGetOptions) (resp azfake.PollerResponder[armbotservice.OperationResultsOperationGroupClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationResultsOperationGroupServerTransport creates a new instance of OperationResultsOperationGroupServerTransport with the provided implementation. +// The returned OperationResultsOperationGroupServerTransport instance is connected to an instance of armbotservice.OperationResultsOperationGroupClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationResultsOperationGroupServerTransport(srv *OperationResultsOperationGroupServer) *OperationResultsOperationGroupServerTransport { + return &OperationResultsOperationGroupServerTransport{ + srv: srv, + beginGet: newTracker[azfake.PollerResponder[armbotservice.OperationResultsOperationGroupClientGetResponse]](), + } +} + +// OperationResultsOperationGroupServerTransport connects instances of armbotservice.OperationResultsOperationGroupClient to instances of OperationResultsOperationGroupServer. +// Don't use this type directly, use NewOperationResultsOperationGroupServerTransport instead. +type OperationResultsOperationGroupServerTransport struct { + srv *OperationResultsOperationGroupServer + beginGet *tracker[azfake.PollerResponder[armbotservice.OperationResultsOperationGroupClientGetResponse]] +} + +// Do implements the policy.Transporter interface for OperationResultsOperationGroupServerTransport. +func (o *OperationResultsOperationGroupServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationResultsOperationGroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationResultsOperationGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationResultsOperationGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationResultsOperationGroupClient.BeginGet": + res.resp, res.err = o.dispatchBeginGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (o *OperationResultsOperationGroupServerTransport) dispatchBeginGet(req *http.Request) (*http.Response, error) { + if o.srv.BeginGet == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGet not implemented")} + } + beginGet := o.beginGet.get(req) + if beginGet == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/operationresults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + operationResultIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationResultId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.BeginGet(req.Context(), operationResultIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGet = &respr + o.beginGet.add(req, beginGet) + } + + resp, err := server.PollerResponderNext(beginGet, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + o.beginGet.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGet) { + o.beginGet.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to OperationResultsOperationGroupServerTransport +var operationResultsOperationGroupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/operations_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/operations_server.go index a467dd6e6eab..3935037de88d 100644 --- a/sdk/resourcemanager/botservice/armbotservice/fake/operations_server.go +++ b/sdk/resourcemanager/botservice/armbotservice/fake/operations_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,7 +11,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" "net/http" ) @@ -51,21 +47,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +109,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/privateendpointconnections_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/privateendpointconnections_server.go index 17115bf5a29c..12aaf2cadeac 100644 --- a/sdk/resourcemanager/botservice/armbotservice/fake/privateendpointconnections_server.go +++ b/sdk/resourcemanager/botservice/armbotservice/fake/privateendpointconnections_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,7 +11,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" "net/http" "net/url" "regexp" @@ -65,27 +62,46 @@ func (p *PrivateEndpointConnectionsServerTransport) Do(req *http.Request) (*http return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PrivateEndpointConnectionsClient.Create": - resp, err = p.dispatchCreate(req) - case "PrivateEndpointConnectionsClient.Delete": - resp, err = p.dispatchDelete(req) - case "PrivateEndpointConnectionsClient.Get": - resp, err = p.dispatchGet(req) - case "PrivateEndpointConnectionsClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PrivateEndpointConnectionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if privateEndpointConnectionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = privateEndpointConnectionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrivateEndpointConnectionsClient.Create": + res.resp, res.err = p.dispatchCreate(req) + case "PrivateEndpointConnectionsClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "PrivateEndpointConnectionsClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.NewListPager": + res.resp, res.err = p.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PrivateEndpointConnectionsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { @@ -95,7 +111,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchCreate(req *http.Req const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armbotservice.PrivateEndpointConnection](req) @@ -136,7 +152,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchDelete(req *http.Req const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -173,7 +189,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Reques const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -212,7 +228,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -226,6 +242,9 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *ht resp := p.srv.NewListPager(resourceGroupNameParam, resourceNameParam, nil) newListPager = &resp p.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armbotservice.PrivateEndpointConnectionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -240,3 +259,9 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *ht } return resp, nil } + +// set this to conditionally intercept incoming requests to PrivateEndpointConnectionsServerTransport +var privateEndpointConnectionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/privatelinkresources_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/privatelinkresources_server.go deleted file mode 100644 index c34ec64a9952..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/fake/privatelinkresources_server.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" - "net/http" - "net/url" - "regexp" -) - -// PrivateLinkResourcesServer is a fake server for instances of the armbotservice.PrivateLinkResourcesClient type. -type PrivateLinkResourcesServer struct { - // ListByBotResource is the fake for method PrivateLinkResourcesClient.ListByBotResource - // HTTP status codes to indicate success: http.StatusOK - ListByBotResource func(ctx context.Context, resourceGroupName string, resourceName string, options *armbotservice.PrivateLinkResourcesClientListByBotResourceOptions) (resp azfake.Responder[armbotservice.PrivateLinkResourcesClientListByBotResourceResponse], errResp azfake.ErrorResponder) -} - -// NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. -// The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armbotservice.PrivateLinkResourcesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { - return &PrivateLinkResourcesServerTransport{srv: srv} -} - -// PrivateLinkResourcesServerTransport connects instances of armbotservice.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. -// Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. -type PrivateLinkResourcesServerTransport struct { - srv *PrivateLinkResourcesServer -} - -// Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. -func (p *PrivateLinkResourcesServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "PrivateLinkResourcesClient.ListByBotResource": - resp, err = p.dispatchListByBotResource(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (p *PrivateLinkResourcesServerTransport) dispatchListByBotResource(req *http.Request) (*http.Response, error) { - if p.srv.ListByBotResource == nil { - return nil, &nonRetriableError{errors.New("fake for method ListByBotResource not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/botServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - respr, errRespr := p.srv.ListByBotResource(req.Context(), resourceGroupNameParam, resourceNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrivateLinkResourceListResult, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/qnamakerendpointkeys_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/qnamakerendpointkeys_server.go deleted file mode 100644 index b38f932fcb7b..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/fake/qnamakerendpointkeys_server.go +++ /dev/null @@ -1,95 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" - "net/http" - "regexp" -) - -// QnAMakerEndpointKeysServer is a fake server for instances of the armbotservice.QnAMakerEndpointKeysClient type. -type QnAMakerEndpointKeysServer struct { - // Get is the fake for method QnAMakerEndpointKeysClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, parameters armbotservice.QnAMakerEndpointKeysRequestBody, options *armbotservice.QnAMakerEndpointKeysClientGetOptions) (resp azfake.Responder[armbotservice.QnAMakerEndpointKeysClientGetResponse], errResp azfake.ErrorResponder) -} - -// NewQnAMakerEndpointKeysServerTransport creates a new instance of QnAMakerEndpointKeysServerTransport with the provided implementation. -// The returned QnAMakerEndpointKeysServerTransport instance is connected to an instance of armbotservice.QnAMakerEndpointKeysClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewQnAMakerEndpointKeysServerTransport(srv *QnAMakerEndpointKeysServer) *QnAMakerEndpointKeysServerTransport { - return &QnAMakerEndpointKeysServerTransport{srv: srv} -} - -// QnAMakerEndpointKeysServerTransport connects instances of armbotservice.QnAMakerEndpointKeysClient to instances of QnAMakerEndpointKeysServer. -// Don't use this type directly, use NewQnAMakerEndpointKeysServerTransport instead. -type QnAMakerEndpointKeysServerTransport struct { - srv *QnAMakerEndpointKeysServer -} - -// Do implements the policy.Transporter interface for QnAMakerEndpointKeysServerTransport. -func (q *QnAMakerEndpointKeysServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "QnAMakerEndpointKeysClient.Get": - resp, err = q.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (q *QnAMakerEndpointKeysServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if q.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/listQnAMakerEndpointKeys` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armbotservice.QnAMakerEndpointKeysRequestBody](req) - if err != nil { - return nil, err - } - respr, errRespr := q.srv.Get(req.Context(), body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).QnAMakerEndpointKeysResponse, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/qnamakerendpointkeysoperationgroup_server.go b/sdk/resourcemanager/botservice/armbotservice/fake/qnamakerendpointkeysoperationgroup_server.go new file mode 100644 index 000000000000..ad06415f639b --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/fake/qnamakerendpointkeysoperationgroup_server.go @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "net/http" + "regexp" +) + +// QnAMakerEndpointKeysOperationGroupServer is a fake server for instances of the armbotservice.QnAMakerEndpointKeysOperationGroupClient type. +type QnAMakerEndpointKeysOperationGroupServer struct { + // Get is the fake for method QnAMakerEndpointKeysOperationGroupClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, parameters armbotservice.QnAMakerEndpointKeysRequestBody, options *armbotservice.QnAMakerEndpointKeysOperationGroupClientGetOptions) (resp azfake.Responder[armbotservice.QnAMakerEndpointKeysOperationGroupClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewQnAMakerEndpointKeysOperationGroupServerTransport creates a new instance of QnAMakerEndpointKeysOperationGroupServerTransport with the provided implementation. +// The returned QnAMakerEndpointKeysOperationGroupServerTransport instance is connected to an instance of armbotservice.QnAMakerEndpointKeysOperationGroupClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewQnAMakerEndpointKeysOperationGroupServerTransport(srv *QnAMakerEndpointKeysOperationGroupServer) *QnAMakerEndpointKeysOperationGroupServerTransport { + return &QnAMakerEndpointKeysOperationGroupServerTransport{srv: srv} +} + +// QnAMakerEndpointKeysOperationGroupServerTransport connects instances of armbotservice.QnAMakerEndpointKeysOperationGroupClient to instances of QnAMakerEndpointKeysOperationGroupServer. +// Don't use this type directly, use NewQnAMakerEndpointKeysOperationGroupServerTransport instead. +type QnAMakerEndpointKeysOperationGroupServerTransport struct { + srv *QnAMakerEndpointKeysOperationGroupServer +} + +// Do implements the policy.Transporter interface for QnAMakerEndpointKeysOperationGroupServerTransport. +func (q *QnAMakerEndpointKeysOperationGroupServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return q.dispatchToMethodFake(req, method) +} + +func (q *QnAMakerEndpointKeysOperationGroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if qnAMakerEndpointKeysOperationGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = qnAMakerEndpointKeysOperationGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "QnAMakerEndpointKeysOperationGroupClient.Get": + res.resp, res.err = q.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (q *QnAMakerEndpointKeysOperationGroupServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if q.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.BotService/listQnAMakerEndpointKeys` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armbotservice.QnAMakerEndpointKeysRequestBody](req) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Get(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).QnAMakerEndpointKeysResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to QnAMakerEndpointKeysOperationGroupServerTransport +var qnAMakerEndpointKeysOperationGroupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/server_factory.go b/sdk/resourcemanager/botservice/armbotservice/fake/server_factory.go index c98ddb569262..02fba233a0a0 100644 --- a/sdk/resourcemanager/botservice/armbotservice/fake/server_factory.go +++ b/sdk/resourcemanager/botservice/armbotservice/fake/server_factory.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,17 +15,38 @@ import ( // ServerFactory is a fake server for instances of the armbotservice.ClientFactory type. type ServerFactory struct { - BotConnectionServer BotConnectionServer - BotsServer BotsServer - ChannelsServer ChannelsServer - DirectLineServer DirectLineServer - EmailServer EmailServer - HostSettingsServer HostSettingsServer - OperationResultsServer OperationResultsServer - OperationsServer OperationsServer + // BotChannelsServer contains the fakes for client BotChannelsClient + BotChannelsServer BotChannelsServer + + // BotConnectionOperationGroupServer contains the fakes for client BotConnectionOperationGroupClient + BotConnectionOperationGroupServer BotConnectionOperationGroupServer + + // BotsServer contains the fakes for client BotsClient + BotsServer BotsServer + + // BotsOperationGroupServer contains the fakes for client BotsOperationGroupClient + BotsOperationGroupServer BotsOperationGroupServer + + // ConnectionSettingsServer contains the fakes for client ConnectionSettingsClient + ConnectionSettingsServer ConnectionSettingsServer + + // HostSettingsOperationGroupServer contains the fakes for client HostSettingsOperationGroupClient + HostSettingsOperationGroupServer HostSettingsOperationGroupServer + + // NetworkSecurityPerimeterConfigurationsServer contains the fakes for client NetworkSecurityPerimeterConfigurationsClient + NetworkSecurityPerimeterConfigurationsServer NetworkSecurityPerimeterConfigurationsServer + + // OperationResultsOperationGroupServer contains the fakes for client OperationResultsOperationGroupClient + OperationResultsOperationGroupServer OperationResultsOperationGroupServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // PrivateEndpointConnectionsServer contains the fakes for client PrivateEndpointConnectionsClient PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer - PrivateLinkResourcesServer PrivateLinkResourcesServer - QnAMakerEndpointKeysServer QnAMakerEndpointKeysServer + + // QnAMakerEndpointKeysOperationGroupServer contains the fakes for client QnAMakerEndpointKeysOperationGroupClient + QnAMakerEndpointKeysOperationGroupServer QnAMakerEndpointKeysOperationGroupServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -44,19 +61,19 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armbotservice.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trBotConnectionServer *BotConnectionServerTransport - trBotsServer *BotsServerTransport - trChannelsServer *ChannelsServerTransport - trDirectLineServer *DirectLineServerTransport - trEmailServer *EmailServerTransport - trHostSettingsServer *HostSettingsServerTransport - trOperationResultsServer *OperationResultsServerTransport - trOperationsServer *OperationsServerTransport - trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport - trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport - trQnAMakerEndpointKeysServer *QnAMakerEndpointKeysServerTransport + srv *ServerFactory + trMu sync.Mutex + trBotChannelsServer *BotChannelsServerTransport + trBotConnectionOperationGroupServer *BotConnectionOperationGroupServerTransport + trBotsServer *BotsServerTransport + trBotsOperationGroupServer *BotsOperationGroupServerTransport + trConnectionSettingsServer *ConnectionSettingsServerTransport + trHostSettingsOperationGroupServer *HostSettingsOperationGroupServerTransport + trNetworkSecurityPerimeterConfigurationsServer *NetworkSecurityPerimeterConfigurationsServerTransport + trOperationResultsOperationGroupServer *OperationResultsOperationGroupServerTransport + trOperationsServer *OperationsServerTransport + trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trQnAMakerEndpointKeysOperationGroupServer *QnAMakerEndpointKeysOperationGroupServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -72,31 +89,42 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { - case "BotConnectionClient": - initServer(s, &s.trBotConnectionServer, func() *BotConnectionServerTransport { - return NewBotConnectionServerTransport(&s.srv.BotConnectionServer) + case "BotChannelsClient": + initServer(s, &s.trBotChannelsServer, func() *BotChannelsServerTransport { return NewBotChannelsServerTransport(&s.srv.BotChannelsServer) }) + resp, err = s.trBotChannelsServer.Do(req) + case "BotConnectionOperationGroupClient": + initServer(s, &s.trBotConnectionOperationGroupServer, func() *BotConnectionOperationGroupServerTransport { + return NewBotConnectionOperationGroupServerTransport(&s.srv.BotConnectionOperationGroupServer) }) - resp, err = s.trBotConnectionServer.Do(req) + resp, err = s.trBotConnectionOperationGroupServer.Do(req) case "BotsClient": initServer(s, &s.trBotsServer, func() *BotsServerTransport { return NewBotsServerTransport(&s.srv.BotsServer) }) resp, err = s.trBotsServer.Do(req) - case "ChannelsClient": - initServer(s, &s.trChannelsServer, func() *ChannelsServerTransport { return NewChannelsServerTransport(&s.srv.ChannelsServer) }) - resp, err = s.trChannelsServer.Do(req) - case "DirectLineClient": - initServer(s, &s.trDirectLineServer, func() *DirectLineServerTransport { return NewDirectLineServerTransport(&s.srv.DirectLineServer) }) - resp, err = s.trDirectLineServer.Do(req) - case "EmailClient": - initServer(s, &s.trEmailServer, func() *EmailServerTransport { return NewEmailServerTransport(&s.srv.EmailServer) }) - resp, err = s.trEmailServer.Do(req) - case "HostSettingsClient": - initServer(s, &s.trHostSettingsServer, func() *HostSettingsServerTransport { return NewHostSettingsServerTransport(&s.srv.HostSettingsServer) }) - resp, err = s.trHostSettingsServer.Do(req) - case "OperationResultsClient": - initServer(s, &s.trOperationResultsServer, func() *OperationResultsServerTransport { - return NewOperationResultsServerTransport(&s.srv.OperationResultsServer) + case "BotsOperationGroupClient": + initServer(s, &s.trBotsOperationGroupServer, func() *BotsOperationGroupServerTransport { + return NewBotsOperationGroupServerTransport(&s.srv.BotsOperationGroupServer) + }) + resp, err = s.trBotsOperationGroupServer.Do(req) + case "ConnectionSettingsClient": + initServer(s, &s.trConnectionSettingsServer, func() *ConnectionSettingsServerTransport { + return NewConnectionSettingsServerTransport(&s.srv.ConnectionSettingsServer) }) - resp, err = s.trOperationResultsServer.Do(req) + resp, err = s.trConnectionSettingsServer.Do(req) + case "HostSettingsOperationGroupClient": + initServer(s, &s.trHostSettingsOperationGroupServer, func() *HostSettingsOperationGroupServerTransport { + return NewHostSettingsOperationGroupServerTransport(&s.srv.HostSettingsOperationGroupServer) + }) + resp, err = s.trHostSettingsOperationGroupServer.Do(req) + case "NetworkSecurityPerimeterConfigurationsClient": + initServer(s, &s.trNetworkSecurityPerimeterConfigurationsServer, func() *NetworkSecurityPerimeterConfigurationsServerTransport { + return NewNetworkSecurityPerimeterConfigurationsServerTransport(&s.srv.NetworkSecurityPerimeterConfigurationsServer) + }) + resp, err = s.trNetworkSecurityPerimeterConfigurationsServer.Do(req) + case "OperationResultsOperationGroupClient": + initServer(s, &s.trOperationResultsOperationGroupServer, func() *OperationResultsOperationGroupServerTransport { + return NewOperationResultsOperationGroupServerTransport(&s.srv.OperationResultsOperationGroupServer) + }) + resp, err = s.trOperationResultsOperationGroupServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) @@ -105,16 +133,11 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewPrivateEndpointConnectionsServerTransport(&s.srv.PrivateEndpointConnectionsServer) }) resp, err = s.trPrivateEndpointConnectionsServer.Do(req) - case "PrivateLinkResourcesClient": - initServer(s, &s.trPrivateLinkResourcesServer, func() *PrivateLinkResourcesServerTransport { - return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) - }) - resp, err = s.trPrivateLinkResourcesServer.Do(req) - case "QnAMakerEndpointKeysClient": - initServer(s, &s.trQnAMakerEndpointKeysServer, func() *QnAMakerEndpointKeysServerTransport { - return NewQnAMakerEndpointKeysServerTransport(&s.srv.QnAMakerEndpointKeysServer) + case "QnAMakerEndpointKeysOperationGroupClient": + initServer(s, &s.trQnAMakerEndpointKeysOperationGroupServer, func() *QnAMakerEndpointKeysOperationGroupServerTransport { + return NewQnAMakerEndpointKeysOperationGroupServerTransport(&s.srv.QnAMakerEndpointKeysOperationGroupServer) }) - resp, err = s.trQnAMakerEndpointKeysServer.Do(req) + resp, err = s.trQnAMakerEndpointKeysOperationGroupServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/botservice/armbotservice/fake/time_rfc3339.go b/sdk/resourcemanager/botservice/armbotservice/fake/time_rfc3339.go deleted file mode 100644 index b0535a7b63e6..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/fake/time_rfc3339.go +++ /dev/null @@ -1,86 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) - -const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { - layout = dateTimeJSON - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { - layout = time.RFC3339Nano - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/go.mod b/sdk/resourcemanager/botservice/armbotservice/go.mod index 650072b96a8f..04d11e345c42 100644 --- a/sdk/resourcemanager/botservice/armbotservice/go.mod +++ b/sdk/resourcemanager/botservice/armbotservice/go.mod @@ -1,4 +1,4 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2 go 1.23.0 diff --git a/sdk/resourcemanager/botservice/armbotservice/hostsettings_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/hostsettings_client_example_test.go deleted file mode 100644 index fb4ef845c7e7..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/hostsettings_client_example_test.go +++ /dev/null @@ -1,48 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbotservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetHostSettings.json -func ExampleHostSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHostSettingsClient().Get(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.HostSettingsResponse = armbotservice.HostSettingsResponse{ - // BotOpenIDMetadata: to.Ptr("https://login.botframework.com/v1/.well-known/openidconfiguration"), - // OAuthURL: to.Ptr("https://token.botframework.com/"), - // ToBotFromChannelOpenIDMetadataURL: to.Ptr("https://login.botframework.com/v1/.well-known/openidconfiguration"), - // ToBotFromChannelTokenIssuer: to.Ptr("https://api.botframework.com"), - // ToBotFromEmulatorOpenIDMetadataURL: to.Ptr("https://login.microsoftonline.com/botframework.com/v2.0/.well-known/openid-configuration"), - // ToChannelFromBotLoginURL: to.Ptr("https://login.microsoftonline.com/botframework.com"), - // ToChannelFromBotOAuthScope: to.Ptr("https://api.botframework.com"), - // ValidateAuthority: to.Ptr(true), - // } -} diff --git a/sdk/resourcemanager/botservice/armbotservice/hostsettings_client.go b/sdk/resourcemanager/botservice/armbotservice/hostsettingsoperationgroup_client.go similarity index 56% rename from sdk/resourcemanager/botservice/armbotservice/hostsettings_client.go rename to sdk/resourcemanager/botservice/armbotservice/hostsettingsoperationgroup_client.go index 6252608282e2..53b089cac41b 100644 --- a/sdk/resourcemanager/botservice/armbotservice/hostsettings_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/hostsettingsoperationgroup_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -20,23 +16,23 @@ import ( "strings" ) -// HostSettingsClient contains the methods for the HostSettings group. -// Don't use this type directly, use NewHostSettingsClient() instead. -type HostSettingsClient struct { +// HostSettingsOperationGroupClient contains the methods for the HostSettingsOperationGroup group. +// Don't use this type directly, use NewHostSettingsOperationGroupClient() instead. +type HostSettingsOperationGroupClient struct { internal *arm.Client subscriptionID string } -// NewHostSettingsClient creates a new instance of HostSettingsClient with the specified values. -// - subscriptionID - Azure Subscription ID. +// NewHostSettingsOperationGroupClient creates a new instance of HostSettingsOperationGroupClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewHostSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HostSettingsClient, error) { +func NewHostSettingsOperationGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HostSettingsOperationGroupClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } - client := &HostSettingsClient{ + client := &HostSettingsOperationGroupClient{ subscriptionID: subscriptionID, internal: cl, } @@ -46,32 +42,33 @@ func NewHostSettingsClient(subscriptionID string, credential azcore.TokenCredent // Get - Get per subscription settings needed to host bot in compute resource such as Azure App Service // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - options - HostSettingsClientGetOptions contains the optional parameters for the HostSettingsClient.Get method. -func (client *HostSettingsClient) Get(ctx context.Context, options *HostSettingsClientGetOptions) (HostSettingsClientGetResponse, error) { +// Generated from API version 2023-09-15-preview +// - options - HostSettingsOperationGroupClientGetOptions contains the optional parameters for the HostSettingsOperationGroupClient.Get +// method. +func (client *HostSettingsOperationGroupClient) Get(ctx context.Context, options *HostSettingsOperationGroupClientGetOptions) (HostSettingsOperationGroupClientGetResponse, error) { var err error - const operationName = "HostSettingsClient.Get" + const operationName = "HostSettingsOperationGroupClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, options) if err != nil { - return HostSettingsClientGetResponse{}, err + return HostSettingsOperationGroupClientGetResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return HostSettingsClientGetResponse{}, err + return HostSettingsOperationGroupClientGetResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return HostSettingsClientGetResponse{}, err + return HostSettingsOperationGroupClientGetResponse{}, err } resp, err := client.getHandleResponse(httpResp) return resp, err } // getCreateRequest creates the Get request. -func (client *HostSettingsClient) getCreateRequest(ctx context.Context, options *HostSettingsClientGetOptions) (*policy.Request, error) { +func (client *HostSettingsOperationGroupClient) getCreateRequest(ctx context.Context, _ *HostSettingsOperationGroupClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.BotService/hostSettings" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -82,17 +79,17 @@ func (client *HostSettingsClient) getCreateRequest(ctx context.Context, options return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getHandleResponse handles the Get response. -func (client *HostSettingsClient) getHandleResponse(resp *http.Response) (HostSettingsClientGetResponse, error) { - result := HostSettingsClientGetResponse{} +func (client *HostSettingsOperationGroupClient) getHandleResponse(resp *http.Response) (HostSettingsOperationGroupClientGetResponse, error) { + result := HostSettingsOperationGroupClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.HostSettingsResponse); err != nil { - return HostSettingsClientGetResponse{}, err + return HostSettingsOperationGroupClientGetResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/botservice/armbotservice/hostsettingsoperationgroup_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/hostsettingsoperationgroup_client_example_test.go new file mode 100644 index 000000000000..f035703f6129 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/hostsettingsoperationgroup_client_example_test.go @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" +) + +// Generated from example definition: 2023-09-15-preview/GetHostSettings.json +func ExampleHostSettingsOperationGroupClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewHostSettingsOperationGroupClient().Get(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.HostSettingsOperationGroupClientGetResponse{ + // HostSettingsResponse: &armbotservice.HostSettingsResponse{ + // BotOpenIDMetadata: to.Ptr("https://login.botframework.com/v1/.well-known/openidconfiguration"), + // OAuthURL: to.Ptr("https://token.botframework.com/"), + // ToBotFromChannelOpenIDMetadataURL: to.Ptr("https://login.botframework.com/v1/.well-known/openidconfiguration"), + // ToBotFromChannelTokenIssuer: to.Ptr("https://api.botframework.com"), + // ToBotFromEmulatorOpenIDMetadataURL: to.Ptr("https://login.microsoftonline.com/botframework.com/v2.0/.well-known/openid-configuration"), + // ToChannelFromBotLoginURL: to.Ptr("https://login.microsoftonline.com/botframework.com"), + // ToChannelFromBotOAuthScope: to.Ptr("https://api.botframework.com"), + // ValidateAuthority: to.Ptr(true), + // }, + // } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/interfaces.go b/sdk/resourcemanager/botservice/armbotservice/interfaces.go index 42a17dcbe22f..4357d8308486 100644 --- a/sdk/resourcemanager/botservice/armbotservice/interfaces.go +++ b/sdk/resourcemanager/botservice/armbotservice/interfaces.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice diff --git a/sdk/resourcemanager/botservice/armbotservice/models.go b/sdk/resourcemanager/botservice/armbotservice/models.go index 4d85c45a3d8f..329f47ce29ab 100644 --- a/sdk/resourcemanager/botservice/armbotservice/models.go +++ b/sdk/resourcemanager/botservice/armbotservice/models.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -12,7 +8,8 @@ import "time" // AcsChatChannel - AcsChat channel definition type AcsChatChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "AcsChatChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -37,7 +34,8 @@ func (a *AcsChatChannel) GetChannel() *Channel { // AlexaChannel - Alexa channel definition type AlexaChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "AlexaChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -80,31 +78,34 @@ type AlexaChannelProperties struct { // Bot resource definition type Bot struct { - // Entity Tag + // REQUIRED; The geo-location where the resource lives + Location *string + + // READ-ONLY; The name of the Bot resource. + Name *string + + // Entity Tag. Etag *string // Required. Gets or sets the Kind of the resource. Kind *Kind - // Specifies the location of the resource. - Location *string - // The set of properties specific to bot resource Properties *BotProperties // Gets or sets the SKU of the resource. SKU *SKU - // Contains resource tags defined as key/value pairs. + // Resource tags. Tags map[string]*string - // READ-ONLY; Specifies the resource ID. + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; Specifies the name of the resource. - Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; Specifies the type of the resource. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string // READ-ONLY; Entity zones @@ -113,31 +114,34 @@ type Bot struct { // BotChannel - Bot channel resource definition type BotChannel struct { - // Entity Tag + // REQUIRED; The geo-location where the resource lives + Location *string + + // READ-ONLY; The name of the Bot resource. + Name *string + + // Entity Tag. Etag *string // Required. Gets or sets the Kind of the resource. Kind *Kind - // Specifies the location of the resource. - Location *string - // The set of properties specific to bot channel resource Properties ChannelClassification // Gets or sets the SKU of the resource. SKU *SKU - // Contains resource tags defined as key/value pairs. + // Resource tags. Tags map[string]*string - // READ-ONLY; Specifies the resource ID. + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; Specifies the name of the resource. - Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; Specifies the type of the resource. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string // READ-ONLY; Entity zones @@ -245,6 +249,9 @@ type BotProperties struct { // READ-ONLY; Token used to migrate non Azure bot to azure subscription MigrationToken *string + // READ-ONLY; List of Network Security Perimeter configurations for the bot + NetworkSecurityPerimeterConfigurations []*NetworkSecurityPerimeterConfiguration + // READ-ONLY; List of Private Endpoint Connections configured for the bot PrivateEndpointConnections []*PrivateEndpointConnection @@ -254,11 +261,11 @@ type BotProperties struct { // BotResponseList - The list of bot service operation response. type BotResponseList struct { - // The link used to get the next page of bot service resources. - NextLink *string - - // READ-ONLY; Gets the list of bot service results and their properties. + // READ-ONLY; The Bot items on this page Value []*Bot + + // The link to the next page of items + NextLink *string } // Channel definition @@ -281,11 +288,11 @@ func (c *Channel) GetChannel() *Channel { return c } // ChannelResponseList - The list of bot service channel operation response. type ChannelResponseList struct { - // The link used to get the next page of bot service channel resources. - NextLink *string - - // READ-ONLY; Gets the list of bot service channel results and their properties. + // READ-ONLY; The BotChannel items on this page Value []*BotChannel + + // The link to the next page of items + NextLink *string } // ChannelSettings - Channel settings definition @@ -344,39 +351,36 @@ type CheckNameAvailabilityResponseBody struct { Valid *bool } -// ConnectionItemName - The display name of a connection Item Setting registered with the Bot -type ConnectionItemName struct { - // READ-ONLY; Connection Item name that has been added in the API - Name *string -} - // ConnectionSetting - Bot channel resource definition type ConnectionSetting struct { - // Entity Tag + // REQUIRED; The geo-location where the resource lives + Location *string + + // READ-ONLY; The name of the Bot Service Connection Setting resource. + Name *string + + // Entity Tag. Etag *string // Required. Gets or sets the Kind of the resource. Kind *Kind - // Specifies the location of the resource. - Location *string - // The set of properties specific to bot channel resource Properties *ConnectionSettingProperties // Gets or sets the SKU of the resource. SKU *SKU - // Contains resource tags defined as key/value pairs. + // Resource tags. Tags map[string]*string - // READ-ONLY; Specifies the resource ID. + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; Specifies the name of the resource. - Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; Specifies the type of the resource. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string // READ-ONLY; Entity zones @@ -400,6 +404,12 @@ type ConnectionSettingProperties struct { // Client Secret associated with the Connection Setting ClientSecret *string + // Id of the Connection Setting. + ID *string + + // Name of the Connection Setting. + Name *string + // Service Provider Parameters associated with the Connection Setting Parameters []*ConnectionSettingParameter @@ -421,11 +431,11 @@ type ConnectionSettingProperties struct { // ConnectionSettingResponseList - The list of bot service connection settings response. type ConnectionSettingResponseList struct { - // The link used to get the next page of bot service connection setting resources. - NextLink *string - - // READ-ONLY; Gets the list of bot service connection settings and their properties. + // READ-ONLY; The ConnectionSetting items on this page Value []*ConnectionSetting + + // The link to the next page of items + NextLink *string } // CreateEmailSignInURLResponse - The ARM create email sign in url operation response. @@ -448,7 +458,8 @@ type CreateEmailSignInURLResponseProperties struct { // DirectLineChannel - Direct Line channel definition type DirectLineChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "DirectLineChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -551,7 +562,8 @@ type DirectLineSite struct { // DirectLineSpeechChannel - DirectLine Speech channel definition type DirectLineSpeechChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "DirectLineSpeechChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -603,7 +615,8 @@ type DirectLineSpeechChannelProperties struct { // EmailChannel - Email channel definition type EmailChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "EmailChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -647,24 +660,10 @@ type EmailChannelProperties struct { Password *string } -// Error - Bot Service error object. -type Error struct { - // The error body. - Error *ErrorBody -} - -// ErrorBody - Bot Service error body. -type ErrorBody struct { - // REQUIRED; error code - Code *string - - // REQUIRED; error message - Message *string -} - // FacebookChannel - Facebook channel definition type FacebookChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "FacebookChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -749,7 +748,8 @@ type HostSettingsResponse struct { // KikChannel - Kik channel definition type KikChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "KikChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -792,7 +792,8 @@ type KikChannelProperties struct { // LineChannel - Line channel definition type LineChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "LineChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -844,21 +845,24 @@ type LineRegistration struct { // ListChannelWithKeysResponse - The ARM channel of list channel with keys operation response. type ListChannelWithKeysResponse struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // READ-ONLY; The name of the Bot resource. + Name *string + // Changed time of the resource ChangedTime *string // Entity tag of the resource EntityTag *string - // Entity Tag + // Entity Tag. Etag *string // Required. Gets or sets the Kind of the resource. Kind *Kind - // Specifies the location of the resource. - Location *string - // The set of properties specific to bot channel resource Properties ChannelClassification @@ -874,16 +878,16 @@ type ListChannelWithKeysResponse struct { // Channel settings Setting *ChannelSettings - // Contains resource tags defined as key/value pairs. + // Resource tags. Tags map[string]*string - // READ-ONLY; Specifies the resource ID. + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; Specifies the name of the resource. - Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; Specifies the type of the resource. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string // READ-ONLY; Entity zones @@ -892,7 +896,8 @@ type ListChannelWithKeysResponse struct { // M365Extensions - M365 Extensions definition type M365Extensions struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "M365Extensions", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -917,7 +922,8 @@ func (m *M365Extensions) GetChannel() *Channel { // MsTeamsChannel - Microsoft Teams channel definition type MsTeamsChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "MsTeamsChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -964,9 +970,104 @@ type MsTeamsChannelProperties struct { IncomingCallRoute *string } +// NetworkSecurityPerimeter - Information about Network Security Perimeter +type NetworkSecurityPerimeter struct { + // Location of the Network Security Perimeter + Location *string + + // Guid of the Network Security Perimeter + PerimeterGUID *string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string +} + +// NetworkSecurityPerimeterConfiguration - Network Security Perimeter configuration +type NetworkSecurityPerimeterConfiguration struct { + // Properties of the Network Security Perimeter configuration + Properties *NetworkSecurityPerimeterConfigurationProperties + + // READ-ONLY; The resource association Name. Composed of parameter guid and association name. + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// NetworkSecurityPerimeterConfigurationList - Result of the List NetworkSecurityPerimeterConfiguration operation. +type NetworkSecurityPerimeterConfigurationList struct { + // READ-ONLY; The NetworkSecurityPerimeterConfiguration items on this page + Value []*NetworkSecurityPerimeterConfiguration + + // The link to the next page of items + NextLink *string +} + +// NetworkSecurityPerimeterConfigurationProperties - Properties of Network Security Perimeter configuration +type NetworkSecurityPerimeterConfigurationProperties struct { + // List of Provisioning Issues if any + ProvisioningIssues []*ProvisioningIssue + ProvisioningState *ProvisioningState + + // READ-ONLY; Information about Network Security Perimeter + NetworkSecurityPerimeter *NetworkSecurityPerimeter + + // READ-ONLY; Information about profile + Profile *Profile + + // READ-ONLY; Information about resource association + ResourceAssociation *ResourceAssociation +} + +// NspAccessRule - Information of Access Rule in a profile +type NspAccessRule struct { + // Name of the access rule + Name *string + + // READ-ONLY; Properties of Access Rule + Properties *NspAccessRuleProperties +} + +// NspAccessRuleProperties - Properties of Access Rule +type NspAccessRuleProperties struct { + // Address prefixes in the CIDR format for inbound rules + AddressPrefixes []*string + + // Direction of Access Rule + Direction *NspAccessRuleDirection + + // Subscriptions for inbound rules + Subscriptions []*NspAccessRulePropertiesSubscriptionsItem + + // READ-ONLY; Email addresses for outbound rules + EmailAddresses []*string + + // READ-ONLY; FQDN for outbound rules + FullyQualifiedDomainNames []*string + + // READ-ONLY; NetworkSecurityPerimeters for inbound rules + NetworkSecurityPerimeters []*NetworkSecurityPerimeter + + // READ-ONLY; Phone numbers for outbound rules + PhoneNumbers []*string +} + +// NspAccessRulePropertiesSubscriptionsItem - Subscription for inbound rule +type NspAccessRulePropertiesSubscriptionsItem struct { + // Fully qualified identifier of subscription + ID *string +} + // Omnichannel channel definition type Omnichannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "Omnichannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -1021,11 +1122,11 @@ type OperationEntity struct { // OperationEntityListResult - The list of bot service operation response. type OperationEntityListResult struct { + // REQUIRED; The list of operations. + Value []*OperationEntity + // The link used to get the next page of operations. NextLink *string - - // The list of operations. - Value []*OperationEntity } // OperationResultsDescription - The properties indicating the operation result of an operation on a service. @@ -1045,7 +1146,8 @@ type OperationResultsDescription struct { // OutlookChannel - Outlook channel definition type OutlookChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "OutlookChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -1079,11 +1181,14 @@ type PrivateEndpointConnection struct { // Resource properties. Properties *PrivateEndpointConnectionProperties + // READ-ONLY; The name of the private endpoint connection associated with the Azure resource + Name *string + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource - Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string @@ -1091,6 +1196,9 @@ type PrivateEndpointConnection struct { // PrivateEndpointConnectionListResult - List of private endpoint connection associated with the specified storage account type PrivateEndpointConnectionListResult struct { + // The link used to get the next page of private endpoint connections. + NextLink *string + // Array of private endpoint connections Value []*PrivateEndpointConnection } @@ -1125,18 +1233,6 @@ type PrivateLinkResource struct { Type *string } -// PrivateLinkResourceBase - Common fields that are returned in the response for all BotService Private Link Resources -type PrivateLinkResourceBase struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - // PrivateLinkResourceListResult - A list of private link resources type PrivateLinkResourceListResult struct { // Array of private link resources @@ -1168,6 +1264,51 @@ type PrivateLinkServiceConnectionState struct { Status *PrivateEndpointServiceConnectionStatus } +// Profile - Information about profile +type Profile struct { + // List of Access Rules + AccessRules []*NspAccessRule + + // Current access rules version + AccessRulesVersion *int64 + + // Current diagnostic settings version + DiagnosticSettingsVersion *int64 + + // Name of the profile + Name *string + + // READ-ONLY; List of log categories + EnabledLogCategories []*string +} + +// ProvisioningIssue - Describes Provisioning issue for given Network Security Perimeter configuration +type ProvisioningIssue struct { + // Name of the issue + Name *string + + // READ-ONLY; Properties of Provisioning Issue + Properties *ProvisioningIssueProperties +} + +// ProvisioningIssueProperties - Properties of Provisioning Issue +type ProvisioningIssueProperties struct { + // Description of the issue + Description *string + + // Type of Issue + IssueType *string + + // Provisioning state of Network Security Perimeter configuration propagation + Severity *Severity + + // Access rules that can be added to the same profile to remediate the issue. + SuggestedAccessRules []*NspAccessRule + + // READ-ONLY; ARM IDs of resources that can be associated to the same perimeter to remediate the issue. + SuggestedResourceIDs []*string +} + // QnAMakerEndpointKeysRequestBody - The request body for a request to Bot Service Management to list QnA Maker endpoint keys. type QnAMakerEndpointKeysRequestBody struct { // Subscription key which provides access to this API. @@ -1192,34 +1333,13 @@ type QnAMakerEndpointKeysResponse struct { SecondaryEndpointKey *string } -// Resource - Azure resource -type Resource struct { - // Entity Tag - Etag *string - - // Required. Gets or sets the Kind of the resource. - Kind *Kind - - // Specifies the location of the resource. - Location *string - - // Gets or sets the SKU of the resource. - SKU *SKU - - // Contains resource tags defined as key/value pairs. - Tags map[string]*string +// ResourceAssociation - Information about resource association +type ResourceAssociation struct { + // Access Mode of the resource association + AccessMode *AccessMode - // READ-ONLY; Specifies the resource ID. - ID *string - - // READ-ONLY; Specifies the name of the resource. + // Name of the resource association Name *string - - // READ-ONLY; Specifies the type of the resource. - Type *string - - // READ-ONLY; Entity zones - Zones []*string } // SKU - The SKU of the cognitive services account. @@ -1233,7 +1353,8 @@ type SKU struct { // SearchAssistant definition type SearchAssistant struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "SearchAssistant", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -1399,7 +1520,8 @@ type SiteInfo struct { // SkypeChannel - Skype channel definition type SkypeChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "SkypeChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -1460,7 +1582,8 @@ type SkypeChannelProperties struct { // SlackChannel - Slack channel definition type SlackChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "SlackChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -1524,7 +1647,8 @@ type SlackChannelProperties struct { // SmsChannel - Sms channel definition type SmsChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "SmsChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -1568,9 +1692,31 @@ type SmsChannelProperties struct { IsValidated *bool } +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + // TelegramChannel - Telegram channel definition type TelegramChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "TelegramChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -1610,7 +1756,8 @@ type TelegramChannelProperties struct { // TelephonyChannel - Telephony channel definition type TelephonyChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "TelephonyChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource @@ -1716,7 +1863,8 @@ type TelephonyPhoneNumbers struct { // WebChatChannel - Web Chat channel definition type WebChatChannel struct { - // REQUIRED; The channel name + // CONSTANT; The channel name + // Field has constant value "WebChatChannel", any specified value is ignored. ChannelName *string // Entity Tag of the resource diff --git a/sdk/resourcemanager/botservice/armbotservice/models_serde.go b/sdk/resourcemanager/botservice/armbotservice/models_serde.go index f8b6f5b49f83..d40432f6cfc8 100644 --- a/sdk/resourcemanager/botservice/armbotservice/models_serde.go +++ b/sdk/resourcemanager/botservice/armbotservice/models_serde.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -146,6 +142,7 @@ func (b Bot) MarshalJSON() ([]byte, error) { populate(objectMap, "name", b.Name) populate(objectMap, "properties", b.Properties) populate(objectMap, "sku", b.SKU) + populate(objectMap, "systemData", b.SystemData) populate(objectMap, "tags", b.Tags) populate(objectMap, "type", b.Type) populate(objectMap, "zones", b.Zones) @@ -182,6 +179,9 @@ func (b *Bot) UnmarshalJSON(data []byte) error { case "sku": err = unpopulate(val, "SKU", &b.SKU) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &b.SystemData) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &b.Tags) delete(rawMsg, key) @@ -209,6 +209,7 @@ func (b BotChannel) MarshalJSON() ([]byte, error) { populate(objectMap, "name", b.Name) populate(objectMap, "properties", b.Properties) populate(objectMap, "sku", b.SKU) + populate(objectMap, "systemData", b.SystemData) populate(objectMap, "tags", b.Tags) populate(objectMap, "type", b.Type) populate(objectMap, "zones", b.Zones) @@ -245,6 +246,9 @@ func (b *BotChannel) UnmarshalJSON(data []byte) error { case "sku": err = unpopulate(val, "SKU", &b.SKU) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &b.SystemData) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &b.Tags) delete(rawMsg, key) @@ -291,6 +295,7 @@ func (b BotProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "msaAppMSIResourceId", b.MsaAppMSIResourceID) populate(objectMap, "msaAppTenantId", b.MsaAppTenantID) populate(objectMap, "msaAppType", b.MsaAppType) + populate(objectMap, "networkSecurityPerimeterConfigurations", b.NetworkSecurityPerimeterConfigurations) populate(objectMap, "openWithHint", b.OpenWithHint) populate(objectMap, "parameters", b.Parameters) populate(objectMap, "privateEndpointConnections", b.PrivateEndpointConnections) @@ -390,6 +395,9 @@ func (b *BotProperties) UnmarshalJSON(data []byte) error { case "msaAppType": err = unpopulate(val, "MsaAppType", &b.MsaAppType) delete(rawMsg, key) + case "networkSecurityPerimeterConfigurations": + err = unpopulate(val, "NetworkSecurityPerimeterConfigurations", &b.NetworkSecurityPerimeterConfigurations) + delete(rawMsg, key) case "openWithHint": err = unpopulate(val, "OpenWithHint", &b.OpenWithHint) delete(rawMsg, key) @@ -459,7 +467,7 @@ func (b *BotResponseList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Channel. func (c Channel) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["channelName"] = c.ChannelName + populate(objectMap, "channelName", c.ChannelName) populate(objectMap, "etag", c.Etag) populate(objectMap, "location", c.Location) populate(objectMap, "provisioningState", c.ProvisioningState) @@ -655,33 +663,6 @@ func (c *CheckNameAvailabilityResponseBody) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ConnectionItemName. -func (c ConnectionItemName) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "name", c.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectionItemName. -func (c *ConnectionItemName) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "name": - err = unpopulate(val, "Name", &c.Name) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ConnectionSetting. func (c ConnectionSetting) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -692,6 +673,7 @@ func (c ConnectionSetting) MarshalJSON() ([]byte, error) { populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) populate(objectMap, "sku", c.SKU) + populate(objectMap, "systemData", c.SystemData) populate(objectMap, "tags", c.Tags) populate(objectMap, "type", c.Type) populate(objectMap, "zones", c.Zones) @@ -728,6 +710,9 @@ func (c *ConnectionSetting) UnmarshalJSON(data []byte) error { case "sku": err = unpopulate(val, "SKU", &c.SKU) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &c.Tags) delete(rawMsg, key) @@ -781,6 +766,8 @@ func (c ConnectionSettingProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "clientId", c.ClientID) populate(objectMap, "clientSecret", c.ClientSecret) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) populate(objectMap, "parameters", c.Parameters) populate(objectMap, "provisioningState", c.ProvisioningState) populate(objectMap, "scopes", c.Scopes) @@ -805,6 +792,12 @@ func (c *ConnectionSettingProperties) UnmarshalJSON(data []byte) error { case "clientSecret": err = unpopulate(val, "ClientSecret", &c.ClientSecret) delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) case "parameters": err = unpopulate(val, "Parameters", &c.Parameters) delete(rawMsg, key) @@ -1285,64 +1278,6 @@ func (e *EmailChannelProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Error. -func (e Error) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", e.Error) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Error. -func (e *Error) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ErrorBody. -func (e ErrorBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", e.Code) - populate(objectMap, "message", e.Message) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorBody. -func (e *ErrorBody) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "code": - err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type FacebookChannel. func (f FacebookChannel) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1729,6 +1664,7 @@ func (l ListChannelWithKeysResponse) MarshalJSON() ([]byte, error) { populate(objectMap, "resource", l.Resource) populate(objectMap, "sku", l.SKU) populate(objectMap, "setting", l.Setting) + populate(objectMap, "systemData", l.SystemData) populate(objectMap, "tags", l.Tags) populate(objectMap, "type", l.Type) populate(objectMap, "zones", l.Zones) @@ -1780,6 +1716,9 @@ func (l *ListChannelWithKeysResponse) UnmarshalJSON(data []byte) error { case "setting": err = unpopulate(val, "Setting", &l.Setting) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &l.SystemData) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &l.Tags) delete(rawMsg, key) @@ -1926,6 +1865,267 @@ func (m *MsTeamsChannelProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeter. +func (n NetworkSecurityPerimeter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + populate(objectMap, "location", n.Location) + populate(objectMap, "perimeterGuid", n.PerimeterGUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeter. +func (n *NetworkSecurityPerimeter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "perimeterGuid": + err = unpopulate(val, "PerimeterGUID", &n.PerimeterGUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterConfiguration. +func (n NetworkSecurityPerimeterConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "systemData", n.SystemData) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterConfiguration. +func (n *NetworkSecurityPerimeterConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &n.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterConfigurationList. +func (n NetworkSecurityPerimeterConfigurationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterConfigurationList. +func (n *NetworkSecurityPerimeterConfigurationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &n.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &n.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterConfigurationProperties. +func (n NetworkSecurityPerimeterConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "networkSecurityPerimeter", n.NetworkSecurityPerimeter) + populate(objectMap, "profile", n.Profile) + populate(objectMap, "provisioningIssues", n.ProvisioningIssues) + populate(objectMap, "provisioningState", n.ProvisioningState) + populate(objectMap, "resourceAssociation", n.ResourceAssociation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterConfigurationProperties. +func (n *NetworkSecurityPerimeterConfigurationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "networkSecurityPerimeter": + err = unpopulate(val, "NetworkSecurityPerimeter", &n.NetworkSecurityPerimeter) + delete(rawMsg, key) + case "profile": + err = unpopulate(val, "Profile", &n.Profile) + delete(rawMsg, key) + case "provisioningIssues": + err = unpopulate(val, "ProvisioningIssues", &n.ProvisioningIssues) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) + delete(rawMsg, key) + case "resourceAssociation": + err = unpopulate(val, "ResourceAssociation", &n.ResourceAssociation) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NspAccessRule. +func (n NspAccessRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NspAccessRule. +func (n *NspAccessRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NspAccessRuleProperties. +func (n NspAccessRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressPrefixes", n.AddressPrefixes) + populate(objectMap, "direction", n.Direction) + populate(objectMap, "emailAddresses", n.EmailAddresses) + populate(objectMap, "fullyQualifiedDomainNames", n.FullyQualifiedDomainNames) + populate(objectMap, "networkSecurityPerimeters", n.NetworkSecurityPerimeters) + populate(objectMap, "phoneNumbers", n.PhoneNumbers) + populate(objectMap, "subscriptions", n.Subscriptions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NspAccessRuleProperties. +func (n *NspAccessRuleProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressPrefixes": + err = unpopulate(val, "AddressPrefixes", &n.AddressPrefixes) + delete(rawMsg, key) + case "direction": + err = unpopulate(val, "Direction", &n.Direction) + delete(rawMsg, key) + case "emailAddresses": + err = unpopulate(val, "EmailAddresses", &n.EmailAddresses) + delete(rawMsg, key) + case "fullyQualifiedDomainNames": + err = unpopulate(val, "FullyQualifiedDomainNames", &n.FullyQualifiedDomainNames) + delete(rawMsg, key) + case "networkSecurityPerimeters": + err = unpopulate(val, "NetworkSecurityPerimeters", &n.NetworkSecurityPerimeters) + delete(rawMsg, key) + case "phoneNumbers": + err = unpopulate(val, "PhoneNumbers", &n.PhoneNumbers) + delete(rawMsg, key) + case "subscriptions": + err = unpopulate(val, "Subscriptions", &n.Subscriptions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NspAccessRulePropertiesSubscriptionsItem. +func (n NspAccessRulePropertiesSubscriptionsItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NspAccessRulePropertiesSubscriptionsItem. +func (n *NspAccessRulePropertiesSubscriptionsItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Omnichannel. func (o Omnichannel) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2185,6 +2385,7 @@ func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } @@ -2207,6 +2408,9 @@ func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &p.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) @@ -2221,6 +2425,7 @@ func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } @@ -2234,6 +2439,9 @@ func (p *PrivateEndpointConnectionListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &p.Value) delete(rawMsg, key) @@ -2323,41 +2531,6 @@ func (p *PrivateLinkResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceBase. -func (p PrivateLinkResourceBase) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceBase. -func (p *PrivateLinkResourceBase) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2455,6 +2628,123 @@ func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Profile. +func (p Profile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessRules", p.AccessRules) + populate(objectMap, "accessRulesVersion", p.AccessRulesVersion) + populate(objectMap, "diagnosticSettingsVersion", p.DiagnosticSettingsVersion) + populate(objectMap, "enabledLogCategories", p.EnabledLogCategories) + populate(objectMap, "name", p.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Profile. +func (p *Profile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accessRules": + err = unpopulate(val, "AccessRules", &p.AccessRules) + delete(rawMsg, key) + case "accessRulesVersion": + err = unpopulate(val, "AccessRulesVersion", &p.AccessRulesVersion) + delete(rawMsg, key) + case "diagnosticSettingsVersion": + err = unpopulate(val, "DiagnosticSettingsVersion", &p.DiagnosticSettingsVersion) + delete(rawMsg, key) + case "enabledLogCategories": + err = unpopulate(val, "EnabledLogCategories", &p.EnabledLogCategories) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisioningIssue. +func (p ProvisioningIssue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisioningIssue. +func (p *ProvisioningIssue) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisioningIssueProperties. +func (p ProvisioningIssueProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", p.Description) + populate(objectMap, "issueType", p.IssueType) + populate(objectMap, "severity", p.Severity) + populate(objectMap, "suggestedAccessRules", p.SuggestedAccessRules) + populate(objectMap, "suggestedResourceIds", p.SuggestedResourceIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisioningIssueProperties. +func (p *ProvisioningIssueProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "issueType": + err = unpopulate(val, "IssueType", &p.IssueType) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &p.Severity) + delete(rawMsg, key) + case "suggestedAccessRules": + err = unpopulate(val, "SuggestedAccessRules", &p.SuggestedAccessRules) + delete(rawMsg, key) + case "suggestedResourceIds": + err = unpopulate(val, "SuggestedResourceIDs", &p.SuggestedResourceIDs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type QnAMakerEndpointKeysRequestBody. func (q QnAMakerEndpointKeysRequestBody) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2525,23 +2815,16 @@ func (q *QnAMakerEndpointKeysResponse) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ResourceAssociation. +func (r ResourceAssociation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "etag", r.Etag) - populate(objectMap, "id", r.ID) - populate(objectMap, "kind", r.Kind) - populate(objectMap, "location", r.Location) + populate(objectMap, "accessMode", r.AccessMode) populate(objectMap, "name", r.Name) - populate(objectMap, "sku", r.SKU) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - populate(objectMap, "zones", r.Zones) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceAssociation. +func (r *ResourceAssociation) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -2549,33 +2832,12 @@ func (r *Resource) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "etag": - err = unpopulate(val, "Etag", &r.Etag) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &r.Kind) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &r.Location) + case "accessMode": + err = unpopulate(val, "AccessMode", &r.AccessMode) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &r.SKU) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &r.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) - case "zones": - err = unpopulate(val, "Zones", &r.Zones) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -3296,6 +3558,53 @@ func (s *SmsChannelProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type TelegramChannel. func (t TelegramChannel) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3772,7 +4081,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/botservice/armbotservice/networksecurityperimeterconfigurations_client.go b/sdk/resourcemanager/botservice/armbotservice/networksecurityperimeterconfigurations_client.go new file mode 100644 index 000000000000..33a57cf66326 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/networksecurityperimeterconfigurations_client.go @@ -0,0 +1,256 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// NetworkSecurityPerimeterConfigurationsClient contains the methods for the NetworkSecurityPerimeterConfigurations group. +// Don't use this type directly, use NewNetworkSecurityPerimeterConfigurationsClient() instead. +type NetworkSecurityPerimeterConfigurationsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewNetworkSecurityPerimeterConfigurationsClient creates a new instance of NetworkSecurityPerimeterConfigurationsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewNetworkSecurityPerimeterConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NetworkSecurityPerimeterConfigurationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &NetworkSecurityPerimeterConfigurationsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets the specified Network Security Perimeter configuration associated with the Bot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the Bot resource. +// - networkSecurityPerimeterConfigurationName - The resource association Name. Composed of parameter guid and association name. +// - options - NetworkSecurityPerimeterConfigurationsClientGetOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.Get +// method. +func (client *NetworkSecurityPerimeterConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, networkSecurityPerimeterConfigurationName string, options *NetworkSecurityPerimeterConfigurationsClientGetOptions) (NetworkSecurityPerimeterConfigurationsClientGetResponse, error) { + var err error + const operationName = "NetworkSecurityPerimeterConfigurationsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, networkSecurityPerimeterConfigurationName, options) + if err != nil { + return NetworkSecurityPerimeterConfigurationsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return NetworkSecurityPerimeterConfigurationsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return NetworkSecurityPerimeterConfigurationsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *NetworkSecurityPerimeterConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, networkSecurityPerimeterConfigurationName string, _ *NetworkSecurityPerimeterConfigurationsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/networkSecurityPerimeterConfigurations/{networkSecurityPerimeterConfigurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if networkSecurityPerimeterConfigurationName == "" { + return nil, errors.New("parameter networkSecurityPerimeterConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkSecurityPerimeterConfigurationName}", url.PathEscape(networkSecurityPerimeterConfigurationName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *NetworkSecurityPerimeterConfigurationsClient) getHandleResponse(resp *http.Response) (NetworkSecurityPerimeterConfigurationsClientGetResponse, error) { + result := NetworkSecurityPerimeterConfigurationsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NetworkSecurityPerimeterConfiguration); err != nil { + return NetworkSecurityPerimeterConfigurationsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List Network Security Perimeter configurations associated with the Bot. +// +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the Bot resource. +// - options - NetworkSecurityPerimeterConfigurationsClientListOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.NewListPager +// method. +func (client *NetworkSecurityPerimeterConfigurationsClient) NewListPager(resourceGroupName string, resourceName string, options *NetworkSecurityPerimeterConfigurationsClientListOptions) *runtime.Pager[NetworkSecurityPerimeterConfigurationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[NetworkSecurityPerimeterConfigurationsClientListResponse]{ + More: func(page NetworkSecurityPerimeterConfigurationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *NetworkSecurityPerimeterConfigurationsClientListResponse) (NetworkSecurityPerimeterConfigurationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "NetworkSecurityPerimeterConfigurationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) + if err != nil { + return NetworkSecurityPerimeterConfigurationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *NetworkSecurityPerimeterConfigurationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *NetworkSecurityPerimeterConfigurationsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/networkSecurityPerimeterConfigurations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *NetworkSecurityPerimeterConfigurationsClient) listHandleResponse(resp *http.Response) (NetworkSecurityPerimeterConfigurationsClientListResponse, error) { + result := NetworkSecurityPerimeterConfigurationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NetworkSecurityPerimeterConfigurationList); err != nil { + return NetworkSecurityPerimeterConfigurationsClientListResponse{}, err + } + return result, nil +} + +// BeginReconcile - Reconcile the specified Network Security Perimeter configuration associated with the Bot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the Bot resource. +// - networkSecurityPerimeterConfigurationName - The resource association Name. Composed of parameter guid and association name. +// - options - NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.BeginReconcile +// method. +func (client *NetworkSecurityPerimeterConfigurationsClient) BeginReconcile(ctx context.Context, resourceGroupName string, resourceName string, networkSecurityPerimeterConfigurationName string, options *NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (*runtime.Poller[NetworkSecurityPerimeterConfigurationsClientReconcileResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.reconcile(ctx, resourceGroupName, resourceName, networkSecurityPerimeterConfigurationName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkSecurityPerimeterConfigurationsClientReconcileResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkSecurityPerimeterConfigurationsClientReconcileResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Reconcile - Reconcile the specified Network Security Perimeter configuration associated with the Bot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-15-preview +func (client *NetworkSecurityPerimeterConfigurationsClient) reconcile(ctx context.Context, resourceGroupName string, resourceName string, networkSecurityPerimeterConfigurationName string, options *NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (*http.Response, error) { + var err error + const operationName = "NetworkSecurityPerimeterConfigurationsClient.BeginReconcile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.reconcileCreateRequest(ctx, resourceGroupName, resourceName, networkSecurityPerimeterConfigurationName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// reconcileCreateRequest creates the Reconcile request. +func (client *NetworkSecurityPerimeterConfigurationsClient) reconcileCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, networkSecurityPerimeterConfigurationName string, _ *NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/networkSecurityPerimeterConfigurations/{networkSecurityPerimeterConfigurationName}/reconcile" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if networkSecurityPerimeterConfigurationName == "" { + return nil, errors.New("parameter networkSecurityPerimeterConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkSecurityPerimeterConfigurationName}", url.PathEscape(networkSecurityPerimeterConfigurationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} diff --git a/sdk/resourcemanager/botservice/armbotservice/networksecurityperimeterconfigurations_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/networksecurityperimeterconfigurations_client_example_test.go new file mode 100644 index 000000000000..221b039e5bbf --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/networksecurityperimeterconfigurations_client_example_test.go @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" +) + +// Generated from example definition: 2023-09-15-preview/GetNetworkSecurityPerimeterConfiguration.json +func ExampleNetworkSecurityPerimeterConfigurationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subId", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNetworkSecurityPerimeterConfigurationsClient().Get(ctx, "rgName", "botId", "00000000-0000-0000-0000-000000000000.associationName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.NetworkSecurityPerimeterConfigurationsClientGetResponse{ + // NetworkSecurityPerimeterConfiguration: &armbotservice.NetworkSecurityPerimeterConfiguration{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000000.associationName"), + // Type: to.Ptr("Microsoft.BotService/botServices/networkSecurityPerimeterConfigurations"), + // ID: to.Ptr("/subscriptions/subId/resourceGroups/rgName/providers/Microsoft.BotService/botServices/botId/networkSecurityPerimeterConfigurations/00000000-0000-0000-0000-000000000000.associationName"), + // Properties: &armbotservice.NetworkSecurityPerimeterConfigurationProperties{ + // NetworkSecurityPerimeter: &armbotservice.NetworkSecurityPerimeter{ + // ID: to.Ptr("/subscriptions/subId/resourceGroups/rgName/providers/Microsoft.Network/networkSecurityPerimeters/nspName"), + // Location: to.Ptr("westcentralus"), + // PerimeterGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Profile: &armbotservice.Profile{ + // Name: to.Ptr("defaultProfile"), + // AccessRules: []*armbotservice.NspAccessRule{ + // { + // Name: to.Ptr("Inbound1"), + // Properties: &armbotservice.NspAccessRuleProperties{ + // AddressPrefixes: []*string{ + // to.Ptr("10.0.0.0/16"), + // }, + // Direction: to.Ptr(armbotservice.NspAccessRuleDirectionInbound), + // EmailAddresses: []*string{ + // }, + // FullyQualifiedDomainNames: []*string{ + // }, + // NetworkSecurityPerimeters: []*armbotservice.NetworkSecurityPerimeter{ + // }, + // PhoneNumbers: []*string{ + // }, + // Subscriptions: []*armbotservice.NspAccessRulePropertiesSubscriptionsItem{ + // }, + // }, + // }, + // { + // Name: to.Ptr("Outbound1"), + // Properties: &armbotservice.NspAccessRuleProperties{ + // AddressPrefixes: []*string{ + // }, + // Direction: to.Ptr(armbotservice.NspAccessRuleDirectionOutbound), + // EmailAddresses: []*string{ + // }, + // FullyQualifiedDomainNames: []*string{ + // to.Ptr("*"), + // }, + // NetworkSecurityPerimeters: []*armbotservice.NetworkSecurityPerimeter{ + // }, + // PhoneNumbers: []*string{ + // }, + // Subscriptions: []*armbotservice.NspAccessRulePropertiesSubscriptionsItem{ + // }, + // }, + // }, + // }, + // AccessRulesVersion: to.Ptr[int64](2), + // DiagnosticSettingsVersion: to.Ptr[int64](0), + // EnabledLogCategories: []*string{ + // }, + // }, + // ProvisioningIssues: []*armbotservice.ProvisioningIssue{ + // }, + // ProvisioningState: to.Ptr(armbotservice.ProvisioningStateSucceeded), + // ResourceAssociation: &armbotservice.ResourceAssociation{ + // Name: to.Ptr("associationName"), + // AccessMode: to.Ptr(armbotservice.AccessModeLearning), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2023-09-15-preview/ListNetworkSecurityPerimeterConfigurations.json +func ExampleNetworkSecurityPerimeterConfigurationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subId", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewNetworkSecurityPerimeterConfigurationsClient().NewListPager("rgName", "botId", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armbotservice.NetworkSecurityPerimeterConfigurationsClientListResponse{ + // NetworkSecurityPerimeterConfigurationList: armbotservice.NetworkSecurityPerimeterConfigurationList{ + // Value: []*armbotservice.NetworkSecurityPerimeterConfiguration{ + // { + // Name: to.Ptr("00000000-0000-0000-0000-000000000000.associationName"), + // Type: to.Ptr("Microsoft.BotService/botServices/networkSecurityPerimeterConfigurations"), + // ID: to.Ptr("/subscriptions/subId/resourceGroups/rgName/providers/Microsoft.BotService/botServices/botId/networkSecurityPerimeterConfigurations/00000000-0000-0000-0000-000000000000.associationName"), + // Properties: &armbotservice.NetworkSecurityPerimeterConfigurationProperties{ + // NetworkSecurityPerimeter: &armbotservice.NetworkSecurityPerimeter{ + // ID: to.Ptr("/subscriptions/subId/resourceGroups/rgName/providers/Microsoft.Network/networkSecurityPerimeters/nspName"), + // Location: to.Ptr("westcentralus"), + // PerimeterGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Profile: &armbotservice.Profile{ + // Name: to.Ptr("defaultProfile"), + // AccessRules: []*armbotservice.NspAccessRule{ + // { + // Name: to.Ptr("Inbound1"), + // Properties: &armbotservice.NspAccessRuleProperties{ + // AddressPrefixes: []*string{ + // to.Ptr("10.0.0.0/16"), + // }, + // Direction: to.Ptr(armbotservice.NspAccessRuleDirectionInbound), + // EmailAddresses: []*string{ + // }, + // FullyQualifiedDomainNames: []*string{ + // }, + // NetworkSecurityPerimeters: []*armbotservice.NetworkSecurityPerimeter{ + // }, + // PhoneNumbers: []*string{ + // }, + // Subscriptions: []*armbotservice.NspAccessRulePropertiesSubscriptionsItem{ + // }, + // }, + // }, + // { + // Name: to.Ptr("Outbound1"), + // Properties: &armbotservice.NspAccessRuleProperties{ + // AddressPrefixes: []*string{ + // }, + // Direction: to.Ptr(armbotservice.NspAccessRuleDirectionOutbound), + // EmailAddresses: []*string{ + // }, + // FullyQualifiedDomainNames: []*string{ + // to.Ptr("*"), + // }, + // NetworkSecurityPerimeters: []*armbotservice.NetworkSecurityPerimeter{ + // }, + // PhoneNumbers: []*string{ + // }, + // Subscriptions: []*armbotservice.NspAccessRulePropertiesSubscriptionsItem{ + // }, + // }, + // }, + // }, + // AccessRulesVersion: to.Ptr[int64](2), + // DiagnosticSettingsVersion: to.Ptr[int64](0), + // EnabledLogCategories: []*string{ + // }, + // }, + // ProvisioningIssues: []*armbotservice.ProvisioningIssue{ + // }, + // ProvisioningState: to.Ptr(armbotservice.ProvisioningStateSucceeded), + // ResourceAssociation: &armbotservice.ResourceAssociation{ + // Name: to.Ptr("associationName"), + // AccessMode: to.Ptr(armbotservice.AccessModeLearning), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2023-09-15-preview/ReconcileNetworkSecurityPerimeterConfiguration.json +func ExampleNetworkSecurityPerimeterConfigurationsClient_BeginReconcile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subId", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewNetworkSecurityPerimeterConfigurationsClient().BeginReconcile(ctx, "rgName", "botId", "00000000-0000-0000-0000-000000000000.associationName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.NetworkSecurityPerimeterConfigurationsClientReconcileResponse{ + // NetworkSecurityPerimeterConfiguration: &armbotservice.NetworkSecurityPerimeterConfiguration{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000000.associationName"), + // Type: to.Ptr("Microsoft.BotService/botServices/networkSecurityPerimeterConfigurations"), + // ID: to.Ptr("/subscriptions/subId/resourceGroups/rgName/providers/Microsoft.BotService/botServices/botId/networkSecurityPerimeterConfigurations/00000000-0000-0000-0000-000000000000.associationName"), + // Properties: &armbotservice.NetworkSecurityPerimeterConfigurationProperties{ + // NetworkSecurityPerimeter: &armbotservice.NetworkSecurityPerimeter{ + // ID: to.Ptr("/subscriptions/subId/resourceGroups/rgName/providers/Microsoft.Network/networkSecurityPerimeters/nspName"), + // Location: to.Ptr("westcentralus"), + // PerimeterGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Profile: &armbotservice.Profile{ + // Name: to.Ptr("defaultProfile"), + // AccessRules: []*armbotservice.NspAccessRule{ + // { + // Name: to.Ptr("Inbound1"), + // Properties: &armbotservice.NspAccessRuleProperties{ + // AddressPrefixes: []*string{ + // to.Ptr("10.0.0.0/16"), + // }, + // Direction: to.Ptr(armbotservice.NspAccessRuleDirectionInbound), + // EmailAddresses: []*string{ + // }, + // FullyQualifiedDomainNames: []*string{ + // }, + // NetworkSecurityPerimeters: []*armbotservice.NetworkSecurityPerimeter{ + // }, + // PhoneNumbers: []*string{ + // }, + // Subscriptions: []*armbotservice.NspAccessRulePropertiesSubscriptionsItem{ + // }, + // }, + // }, + // { + // Name: to.Ptr("Outbound1"), + // Properties: &armbotservice.NspAccessRuleProperties{ + // AddressPrefixes: []*string{ + // }, + // Direction: to.Ptr(armbotservice.NspAccessRuleDirectionOutbound), + // EmailAddresses: []*string{ + // }, + // FullyQualifiedDomainNames: []*string{ + // to.Ptr("*"), + // }, + // NetworkSecurityPerimeters: []*armbotservice.NetworkSecurityPerimeter{ + // }, + // PhoneNumbers: []*string{ + // }, + // Subscriptions: []*armbotservice.NspAccessRulePropertiesSubscriptionsItem{ + // }, + // }, + // }, + // }, + // AccessRulesVersion: to.Ptr[int64](2), + // DiagnosticSettingsVersion: to.Ptr[int64](0), + // EnabledLogCategories: []*string{ + // }, + // }, + // ProvisioningIssues: []*armbotservice.ProvisioningIssue{ + // }, + // ProvisioningState: to.Ptr(armbotservice.ProvisioningStateSucceeded), + // ResourceAssociation: &armbotservice.ResourceAssociation{ + // Name: to.Ptr("associationName"), + // AccessMode: to.Ptr(armbotservice.AccessModeLearning), + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/operationresults_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/operationresults_client_example_test.go deleted file mode 100644 index de33e353c27a..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/operationresults_client_example_test.go +++ /dev/null @@ -1,48 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbotservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/OperationResultsGet.json -func ExampleOperationResultsClient_BeginGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewOperationResultsClient().BeginGet(ctx, "exampleid", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationResultsDescription = armbotservice.OperationResultsDescription{ - // Name: to.Ptr("servicename"), - // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.BotService/locations/westus/operationresults/exampleid"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T06:03:30.271Z"); return t}()), - // Status: to.Ptr(armbotservice.OperationResultStatusRequested), - // } -} diff --git a/sdk/resourcemanager/botservice/armbotservice/operationresults_client.go b/sdk/resourcemanager/botservice/armbotservice/operationresultsoperationgroup_client.go similarity index 61% rename from sdk/resourcemanager/botservice/armbotservice/operationresults_client.go rename to sdk/resourcemanager/botservice/armbotservice/operationresultsoperationgroup_client.go index 9530d65da7e9..7eafdaf74ad0 100644 --- a/sdk/resourcemanager/botservice/armbotservice/operationresults_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/operationresultsoperationgroup_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -20,23 +16,23 @@ import ( "strings" ) -// OperationResultsClient contains the methods for the OperationResults group. -// Don't use this type directly, use NewOperationResultsClient() instead. -type OperationResultsClient struct { +// OperationResultsOperationGroupClient contains the methods for the OperationResultsOperationGroup group. +// Don't use this type directly, use NewOperationResultsOperationGroupClient() instead. +type OperationResultsOperationGroupClient struct { internal *arm.Client subscriptionID string } -// NewOperationResultsClient creates a new instance of OperationResultsClient with the specified values. -// - subscriptionID - Azure Subscription ID. +// NewOperationResultsOperationGroupClient creates a new instance of OperationResultsOperationGroupClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationResultsClient, error) { +func NewOperationResultsOperationGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationResultsOperationGroupClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } - client := &OperationResultsClient{ + client := &OperationResultsOperationGroupClient{ subscriptionID: subscriptionID, internal: cl, } @@ -46,22 +42,22 @@ func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCre // BeginGet - Get the operation result for a long running operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 +// Generated from API version 2023-09-15-preview // - operationResultID - The ID of the operation result to get. -// - options - OperationResultsClientBeginGetOptions contains the optional parameters for the OperationResultsClient.BeginGet +// - options - OperationResultsOperationGroupClientBeginGetOptions contains the optional parameters for the OperationResultsOperationGroupClient.BeginGet // method. -func (client *OperationResultsClient) BeginGet(ctx context.Context, operationResultID string, options *OperationResultsClientBeginGetOptions) (*runtime.Poller[OperationResultsClientGetResponse], error) { +func (client *OperationResultsOperationGroupClient) BeginGet(ctx context.Context, operationResultID string, options *OperationResultsOperationGroupClientBeginGetOptions) (*runtime.Poller[OperationResultsOperationGroupClientGetResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.get(ctx, operationResultID, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OperationResultsClientGetResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OperationResultsOperationGroupClientGetResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[OperationResultsClientGetResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[OperationResultsOperationGroupClientGetResponse]{ Tracer: client.internal.Tracer(), }) } @@ -70,10 +66,10 @@ func (client *OperationResultsClient) BeginGet(ctx context.Context, operationRes // Get - Get the operation result for a long running operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -func (client *OperationResultsClient) get(ctx context.Context, operationResultID string, options *OperationResultsClientBeginGetOptions) (*http.Response, error) { +// Generated from API version 2023-09-15-preview +func (client *OperationResultsOperationGroupClient) get(ctx context.Context, operationResultID string, options *OperationResultsOperationGroupClientBeginGetOptions) (*http.Response, error) { var err error - const operationName = "OperationResultsClient.BeginGet" + const operationName = "OperationResultsOperationGroupClient.BeginGet" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -93,7 +89,7 @@ func (client *OperationResultsClient) get(ctx context.Context, operationResultID } // getCreateRequest creates the Get request. -func (client *OperationResultsClient) getCreateRequest(ctx context.Context, operationResultID string, options *OperationResultsClientBeginGetOptions) (*policy.Request, error) { +func (client *OperationResultsOperationGroupClient) getCreateRequest(ctx context.Context, operationResultID string, _ *OperationResultsOperationGroupClientBeginGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.BotService/operationresults/{operationResultId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -108,7 +104,7 @@ func (client *OperationResultsClient) getCreateRequest(ctx context.Context, oper return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/botservice/armbotservice/operationresultsoperationgroup_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/operationresultsoperationgroup_client_example_test.go new file mode 100644 index 000000000000..969dca457937 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/operationresultsoperationgroup_client_example_test.go @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" +) + +// Generated from example definition: 2023-09-15-preview/OperationResultsGet.json +func ExampleOperationResultsOperationGroupClient_BeginGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOperationResultsOperationGroupClient().BeginGet(ctx, "exampleid", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.OperationResultsOperationGroupClientGetResponse{ + // OperationResultsDescription: &armbotservice.OperationResultsDescription{ + // Name: to.Ptr("servicename"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.BotService/locations/westus/operationresults/exampleid"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T06:03:30.2716301Z"); return t}()), + // Status: to.Ptr(armbotservice.OperationResultStatusRequested), + // }, + // } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/operations_client.go b/sdk/resourcemanager/botservice/armbotservice/operations_client.go index c6e42780575e..2d8e436d2cf2 100644 --- a/sdk/resourcemanager/botservice/armbotservice/operations_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/operations_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -37,9 +33,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - Lists all the available BotService operations. +// NewListPager - List the operations for the provider // -// Generated from API version 2022-09-15 +// Generated from API version 2023-09-15-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -65,14 +61,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BotService/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/botservice/armbotservice/operations_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/operations_client_example_test.go index 0118d988c3f6..cc2941dd1737 100644 --- a/sdk/resourcemanager/botservice/armbotservice/operations_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/operations_client_example_test.go @@ -1,30 +1,24 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetOperations.json +// Generated from example definition: 2023-09-15-preview/GetOperations.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -39,48 +33,51 @@ func ExampleOperationsClient_NewListPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationEntityListResult = armbotservice.OperationEntityListResult{ - // Value: []*armbotservice.OperationEntity{ - // { - // Name: to.Ptr("Microsoft.BotService/botService/read"), - // Display: &armbotservice.OperationDisplayInfo{ - // Description: to.Ptr("Read Bot Service"), - // Operation: to.Ptr("Read Bot Service"), - // Provider: to.Ptr("Microsoft Bot Service"), - // Resource: to.Ptr("Bot Service"), + // page = armbotservice.OperationsClientListResponse{ + // OperationEntityListResult: armbotservice.OperationEntityListResult{ + // Value: []*armbotservice.OperationEntity{ + // { + // Name: to.Ptr("Microsoft.BotService/botService/read"), + // Display: &armbotservice.OperationDisplayInfo{ + // Description: to.Ptr("Read Bot Service"), + // Operation: to.Ptr("Read Bot Service"), + // Provider: to.Ptr("Microsoft Bot Service"), + // Resource: to.Ptr("Bot Service"), + // }, + // Origin: to.Ptr("user,system"), // }, - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.BotService/botService/write"), - // Display: &armbotservice.OperationDisplayInfo{ - // Description: to.Ptr("Writes Bot Service"), - // Operation: to.Ptr("Write Bot Service"), - // Provider: to.Ptr("Microsoft Bot Service"), - // Resource: to.Ptr("Bot Service"), + // { + // Name: to.Ptr("Microsoft.BotService/botService/write"), + // Display: &armbotservice.OperationDisplayInfo{ + // Description: to.Ptr("Writes Bot Service"), + // Operation: to.Ptr("Write Bot Service"), + // Provider: to.Ptr("Microsoft Bot Service"), + // Resource: to.Ptr("Bot Service"), + // }, + // Origin: to.Ptr("user,system"), // }, - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.BotService/botService/delete"), - // Display: &armbotservice.OperationDisplayInfo{ - // Description: to.Ptr("Deletes Bot Service"), - // Operation: to.Ptr("Delete Bot Service"), - // Provider: to.Ptr("Microsoft Bot Service"), - // Resource: to.Ptr("Bot Service"), + // { + // Name: to.Ptr("Microsoft.BotService/botService/delete"), + // Display: &armbotservice.OperationDisplayInfo{ + // Description: to.Ptr("Deletes Bot Service"), + // Operation: to.Ptr("Delete Bot Service"), + // Provider: to.Ptr("Microsoft Bot Service"), + // Resource: to.Ptr("Bot Service"), + // }, + // Origin: to.Ptr("user,system"), // }, - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.BotService/botService/botName/read"), - // Display: &armbotservice.OperationDisplayInfo{ - // Description: to.Ptr("Check bot name availability"), - // Operation: to.Ptr("Check bot name availability"), - // Provider: to.Ptr("Microsoft Bot Service"), - // Resource: to.Ptr("Bot Service name availability"), + // { + // Name: to.Ptr("Microsoft.BotService/botService/botName/read"), + // Display: &armbotservice.OperationDisplayInfo{ + // Description: to.Ptr("Check bot name availability"), + // Operation: to.Ptr("Check bot name availability"), + // Provider: to.Ptr("Microsoft Bot Service"), + // Resource: to.Ptr("Bot Service name availability"), + // }, + // Origin: to.Ptr("user,system"), // }, - // Origin: to.Ptr("user,system"), - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/botservice/armbotservice/options.go b/sdk/resourcemanager/botservice/armbotservice/options.go index 6763df9e8bf0..df8b4e8d00a6 100644 --- a/sdk/resourcemanager/botservice/armbotservice/options.go +++ b/sdk/resourcemanager/botservice/armbotservice/options.go @@ -1,48 +1,48 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice -// BotConnectionClientCreateOptions contains the optional parameters for the BotConnectionClient.Create method. -type BotConnectionClientCreateOptions struct { +// BotChannelsClientCreateOptions contains the optional parameters for the BotChannelsClient.Create method. +type BotChannelsClientCreateOptions struct { // placeholder for future optional parameters } -// BotConnectionClientDeleteOptions contains the optional parameters for the BotConnectionClient.Delete method. -type BotConnectionClientDeleteOptions struct { +// BotChannelsClientDeleteOptions contains the optional parameters for the BotChannelsClient.Delete method. +type BotChannelsClientDeleteOptions struct { // placeholder for future optional parameters } -// BotConnectionClientGetOptions contains the optional parameters for the BotConnectionClient.Get method. -type BotConnectionClientGetOptions struct { +// BotChannelsClientGetOptions contains the optional parameters for the BotChannelsClient.Get method. +type BotChannelsClientGetOptions struct { // placeholder for future optional parameters } -// BotConnectionClientListByBotServiceOptions contains the optional parameters for the BotConnectionClient.NewListByBotServicePager +// BotChannelsClientListByResourceGroupOptions contains the optional parameters for the BotChannelsClient.NewListByResourceGroupPager // method. -type BotConnectionClientListByBotServiceOptions struct { +type BotChannelsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// BotConnectionClientListServiceProvidersOptions contains the optional parameters for the BotConnectionClient.ListServiceProviders -// method. -type BotConnectionClientListServiceProvidersOptions struct { +// BotChannelsClientListWithKeysOptions contains the optional parameters for the BotChannelsClient.ListWithKeys method. +type BotChannelsClientListWithKeysOptions struct { // placeholder for future optional parameters } -// BotConnectionClientListWithSecretsOptions contains the optional parameters for the BotConnectionClient.ListWithSecrets -// method. -type BotConnectionClientListWithSecretsOptions struct { +// BotChannelsClientRegenerateKeysOptions contains the optional parameters for the BotChannelsClient.RegenerateKeys method. +type BotChannelsClientRegenerateKeysOptions struct { + // placeholder for future optional parameters +} + +// BotChannelsClientUpdateOptions contains the optional parameters for the BotChannelsClient.Update method. +type BotChannelsClientUpdateOptions struct { // placeholder for future optional parameters } -// BotConnectionClientUpdateOptions contains the optional parameters for the BotConnectionClient.Update method. -type BotConnectionClientUpdateOptions struct { +// BotConnectionOperationGroupClientListServiceProvidersOptions contains the optional parameters for the BotConnectionOperationGroupClient.ListServiceProviders +// method. +type BotConnectionOperationGroupClientListServiceProvidersOptions struct { // placeholder for future optional parameters } @@ -51,14 +51,13 @@ type BotsClientCreateOptions struct { // placeholder for future optional parameters } -// BotsClientDeleteOptions contains the optional parameters for the BotsClient.Delete method. -type BotsClientDeleteOptions struct { +// BotsClientCreateSignInURLOptions contains the optional parameters for the BotsClient.CreateSignInURL method. +type BotsClientCreateSignInURLOptions struct { // placeholder for future optional parameters } -// BotsClientGetCheckNameAvailabilityOptions contains the optional parameters for the BotsClient.GetCheckNameAvailability -// method. -type BotsClientGetCheckNameAvailabilityOptions struct { +// BotsClientDeleteOptions contains the optional parameters for the BotsClient.Delete method. +type BotsClientDeleteOptions struct { // placeholder for future optional parameters } @@ -67,6 +66,11 @@ type BotsClientGetOptions struct { // placeholder for future optional parameters } +// BotsClientListByBotResourceOptions contains the optional parameters for the BotsClient.ListByBotResource method. +type BotsClientListByBotResourceOptions struct { + // placeholder for future optional parameters +} + // BotsClientListByResourceGroupOptions contains the optional parameters for the BotsClient.NewListByResourceGroupPager method. type BotsClientListByResourceGroupOptions struct { // placeholder for future optional parameters @@ -82,55 +86,73 @@ type BotsClientUpdateOptions struct { // placeholder for future optional parameters } -// ChannelsClientCreateOptions contains the optional parameters for the ChannelsClient.Create method. -type ChannelsClientCreateOptions struct { +// BotsOperationGroupClientGetCheckNameAvailabilityOptions contains the optional parameters for the BotsOperationGroupClient.GetCheckNameAvailability +// method. +type BotsOperationGroupClientGetCheckNameAvailabilityOptions struct { // placeholder for future optional parameters } -// ChannelsClientDeleteOptions contains the optional parameters for the ChannelsClient.Delete method. -type ChannelsClientDeleteOptions struct { +// ConnectionSettingsClientCreateOptions contains the optional parameters for the ConnectionSettingsClient.Create method. +type ConnectionSettingsClientCreateOptions struct { // placeholder for future optional parameters } -// ChannelsClientGetOptions contains the optional parameters for the ChannelsClient.Get method. -type ChannelsClientGetOptions struct { +// ConnectionSettingsClientDeleteOptions contains the optional parameters for the ConnectionSettingsClient.Delete method. +type ConnectionSettingsClientDeleteOptions struct { // placeholder for future optional parameters } -// ChannelsClientListByResourceGroupOptions contains the optional parameters for the ChannelsClient.NewListByResourceGroupPager +// ConnectionSettingsClientGetOptions contains the optional parameters for the ConnectionSettingsClient.Get method. +type ConnectionSettingsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ConnectionSettingsClientListByBotServiceOptions contains the optional parameters for the ConnectionSettingsClient.NewListByBotServicePager // method. -type ChannelsClientListByResourceGroupOptions struct { +type ConnectionSettingsClientListByBotServiceOptions struct { // placeholder for future optional parameters } -// ChannelsClientListWithKeysOptions contains the optional parameters for the ChannelsClient.ListWithKeys method. -type ChannelsClientListWithKeysOptions struct { +// ConnectionSettingsClientListWithSecretsOptions contains the optional parameters for the ConnectionSettingsClient.ListWithSecrets +// method. +type ConnectionSettingsClientListWithSecretsOptions struct { // placeholder for future optional parameters } -// ChannelsClientUpdateOptions contains the optional parameters for the ChannelsClient.Update method. -type ChannelsClientUpdateOptions struct { +// ConnectionSettingsClientUpdateOptions contains the optional parameters for the ConnectionSettingsClient.Update method. +type ConnectionSettingsClientUpdateOptions struct { // placeholder for future optional parameters } -// DirectLineClientRegenerateKeysOptions contains the optional parameters for the DirectLineClient.RegenerateKeys method. -type DirectLineClientRegenerateKeysOptions struct { +// HostSettingsOperationGroupClientGetOptions contains the optional parameters for the HostSettingsOperationGroupClient.Get +// method. +type HostSettingsOperationGroupClientGetOptions struct { // placeholder for future optional parameters } -// EmailClientCreateSignInURLOptions contains the optional parameters for the EmailClient.CreateSignInURL method. -type EmailClientCreateSignInURLOptions struct { +// NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.BeginReconcile +// method. +type NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// NetworkSecurityPerimeterConfigurationsClientGetOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.Get +// method. +type NetworkSecurityPerimeterConfigurationsClientGetOptions struct { // placeholder for future optional parameters } -// HostSettingsClientGetOptions contains the optional parameters for the HostSettingsClient.Get method. -type HostSettingsClientGetOptions struct { +// NetworkSecurityPerimeterConfigurationsClientListOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.NewListPager +// method. +type NetworkSecurityPerimeterConfigurationsClientListOptions struct { // placeholder for future optional parameters } -// OperationResultsClientBeginGetOptions contains the optional parameters for the OperationResultsClient.BeginGet method. -type OperationResultsClientBeginGetOptions struct { - // Resumes the LRO from the provided token. +// OperationResultsOperationGroupClientBeginGetOptions contains the optional parameters for the OperationResultsOperationGroupClient.BeginGet +// method. +type OperationResultsOperationGroupClientBeginGetOptions struct { + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -163,13 +185,8 @@ type PrivateEndpointConnectionsClientListOptions struct { // placeholder for future optional parameters } -// PrivateLinkResourcesClientListByBotResourceOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByBotResource +// QnAMakerEndpointKeysOperationGroupClientGetOptions contains the optional parameters for the QnAMakerEndpointKeysOperationGroupClient.Get // method. -type PrivateLinkResourcesClientListByBotResourceOptions struct { - // placeholder for future optional parameters -} - -// QnAMakerEndpointKeysClientGetOptions contains the optional parameters for the QnAMakerEndpointKeysClient.Get method. -type QnAMakerEndpointKeysClientGetOptions struct { +type QnAMakerEndpointKeysOperationGroupClientGetOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/botservice/armbotservice/polymorphic_helpers.go b/sdk/resourcemanager/botservice/armbotservice/polymorphic_helpers.go index 6a816aaf5410..39ab9b26eab9 100644 --- a/sdk/resourcemanager/botservice/armbotservice/polymorphic_helpers.go +++ b/sdk/resourcemanager/botservice/armbotservice/polymorphic_helpers.go @@ -1,17 +1,13 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice import "encoding/json" func unmarshalChannelClassification(rawMsg json.RawMessage) (ChannelClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any diff --git a/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client.go b/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client.go index c56cb9f676a0..0089ea75f055 100644 --- a/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -28,7 +24,7 @@ type PrivateEndpointConnectionsClient struct { } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. -// - subscriptionID - Azure Subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { @@ -46,8 +42,8 @@ func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcor // Create - Update the state of specified private endpoint connection associated with the Bot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource // - properties - The private endpoint connection properties. @@ -76,8 +72,12 @@ func (client *PrivateEndpointConnectionsClient) Create(ctx context.Context, reso } // createCreateRequest creates the Create request. -func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsClientCreateOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, _ *PrivateEndpointConnectionsClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -86,10 +86,6 @@ func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context. return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -99,9 +95,10 @@ func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } @@ -120,8 +117,8 @@ func (client *PrivateEndpointConnectionsClient) createHandleResponse(resp *http. // Delete - Deletes the specified private endpoint connection associated with the Bot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource // - options - PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete @@ -148,8 +145,12 @@ func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, reso } // deleteCreateRequest creates the Delete request. -func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientDeleteOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -158,10 +159,6 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -171,7 +168,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -180,8 +177,8 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Gets the specified private endpoint connection associated with the Bot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource // - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get @@ -209,8 +206,12 @@ func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourc } // getCreateRequest creates the Get request. -func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -219,10 +220,6 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -232,7 +229,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,29 +246,28 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res // NewListPager - List all the private endpoint connections associated with the Bot. // -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2023-09-15-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Bot resource. // - options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListPager // method. func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName string, resourceName string, options *PrivateEndpointConnectionsClientListOptions) *runtime.Pager[PrivateEndpointConnectionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateEndpointConnectionsClientListResponse]{ More: func(page PrivateEndpointConnectionsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PrivateEndpointConnectionsClientListResponse) (PrivateEndpointConnectionsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateEndpointConnectionsClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, options) - if err != nil { - return PrivateEndpointConnectionsClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -279,8 +275,12 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s } // listCreateRequest creates the List request. -func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateEndpointConnectionsClientListOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *PrivateEndpointConnectionsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/privateEndpointConnections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -289,16 +289,12 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client_example_test.go index 458d69ebacd2..6421a5501d53 100644 --- a/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client_example_test.go @@ -1,175 +1,173 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice_test import ( "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListPrivateEndpointConnections.json -func ExamplePrivateEndpointConnectionsClient_NewListPager() { +// Generated from example definition: 2023-09-15-preview/PutPrivateEndpointConnection.json +func ExamplePrivateEndpointConnectionsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListPager("res6977", "sto2527", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PrivateEndpointConnectionListResult = armbotservice.PrivateEndpointConnectionListResult{ - // Value: []*armbotservice.PrivateEndpointConnection{ - // { - // Name: to.Ptr("{privateEndpointConnectionName}"), - // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), - // Properties: &armbotservice.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armbotservice.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), - // }, - // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }, - // { - // Name: to.Ptr("{privateEndpointConnectionName}"), - // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), - // Properties: &armbotservice.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armbotservice.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest02"), - // }, - // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }}, - // } + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Create(ctx, "res7687", "sto9699", "{privateEndpointConnectionName}", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.PrivateEndpointConnectionsClientCreateResponse{ + // PrivateEndpointConnection: &armbotservice.PrivateEndpointConnection{ + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetPrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionsClient_Get() { +// Generated from example definition: 2023-09-15-preview/DeletePrivateEndpointConnection.json +func ExamplePrivateEndpointConnectionsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Delete(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PrivateEndpointConnection = armbotservice.PrivateEndpointConnection{ - // Name: to.Ptr("{privateEndpointConnectionName}"), - // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), - // Properties: &armbotservice.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armbotservice.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), - // }, - // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, + // res = armbotservice.PrivateEndpointConnectionsClientDeleteResponse{ // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutPrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionsClient_Create() { +// Generated from example definition: 2023-09-15-preview/GetPrivateEndpointConnection.json +func ExamplePrivateEndpointConnectionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewPrivateEndpointConnectionsClient().Create(ctx, "res7687", "sto9699", "{privateEndpointConnectionName}", armbotservice.PrivateEndpointConnection{ - Properties: &armbotservice.PrivateEndpointConnectionProperties{ - PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ - Description: to.Ptr("Auto-Approved"), - Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), - }, - }, - }, nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PrivateEndpointConnection = armbotservice.PrivateEndpointConnection{ - // Name: to.Ptr("{privateEndpointConnectionName}"), - // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), - // Properties: &armbotservice.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armbotservice.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // res = armbotservice.PrivateEndpointConnectionsClientGetResponse{ + // PrivateEndpointConnection: &armbotservice.PrivateEndpointConnection{ + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), // }, - // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeletePrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionsClient_Delete() { +// Generated from example definition: 2023-09-15-preview/ListPrivateEndpointConnections.json +func ExamplePrivateEndpointConnectionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("{subscription-id}", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewPrivateEndpointConnectionsClient().Delete(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListPager("res6977", "sto2527", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armbotservice.PrivateEndpointConnectionsClientListResponse{ + // PrivateEndpointConnectionListResult: armbotservice.PrivateEndpointConnectionListResult{ + // Value: []*armbotservice.PrivateEndpointConnection{ + // { + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest02"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // }, + // }, + // } } } diff --git a/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client.go b/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client.go deleted file mode 100644 index 445c18c18c53..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client.go +++ /dev/null @@ -1,109 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armbotservice - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. -// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. -type PrivateLinkResourcesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. -// - subscriptionID - Azure Subscription ID. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &PrivateLinkResourcesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// ListByBotResource - Gets the private link resources that need to be created for a Bot. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-09-15 -// - resourceGroupName - The name of the Bot resource group in the user subscription. -// - resourceName - The name of the Bot resource. -// - options - PrivateLinkResourcesClientListByBotResourceOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByBotResource -// method. -func (client *PrivateLinkResourcesClient) ListByBotResource(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateLinkResourcesClientListByBotResourceOptions) (PrivateLinkResourcesClientListByBotResourceResponse, error) { - var err error - const operationName = "PrivateLinkResourcesClient.ListByBotResource" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listByBotResourceCreateRequest(ctx, resourceGroupName, resourceName, options) - if err != nil { - return PrivateLinkResourcesClientListByBotResourceResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PrivateLinkResourcesClientListByBotResourceResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return PrivateLinkResourcesClientListByBotResourceResponse{}, err - } - resp, err := client.listByBotResourceHandleResponse(httpResp) - return resp, err -} - -// listByBotResourceCreateRequest creates the ListByBotResource request. -func (client *PrivateLinkResourcesClient) listByBotResourceCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateLinkResourcesClientListByBotResourceOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{resourceName}/privateLinkResources" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if resourceName == "" { - return nil, errors.New("parameter resourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByBotResourceHandleResponse handles the ListByBotResource response. -func (client *PrivateLinkResourcesClient) listByBotResourceHandleResponse(resp *http.Response) (PrivateLinkResourcesClientListByBotResourceResponse, error) { - result := PrivateLinkResourcesClientListByBotResourceResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkResourceListResult); err != nil { - return PrivateLinkResourcesClientListByBotResourceResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client_example_test.go deleted file mode 100644 index 2ae0504011df..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client_example_test.go +++ /dev/null @@ -1,53 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbotservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListPrivateLinkResources.json -func ExamplePrivateLinkResourcesClient_ListByBotResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateLinkResourcesClient().ListByBotResource(ctx, "res6977", "sto2527", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PrivateLinkResourceListResult = armbotservice.PrivateLinkResourceListResult{ - // Value: []*armbotservice.PrivateLinkResource{ - // { - // Name: to.Ptr("resource1"), - // Type: to.Ptr("Microsoft.BotService/botServices/privateLinkResources"), - // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res6977/providers/Microsoft.BotService/botServices/sto2527/privateLinkResources/resource1"), - // Properties: &armbotservice.PrivateLinkResourceProperties{ - // GroupID: to.Ptr("bot"), - // RequiredMembers: []*string{ - // to.Ptr("bot")}, - // RequiredZoneNames: []*string{ - // to.Ptr("privatelink.botframework.com")}, - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client_example_test.go deleted file mode 100644 index 3837e13fea78..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client_example_test.go +++ /dev/null @@ -1,48 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armbotservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListQnAMakerEndpointKeys.json -func ExampleQnAMakerEndpointKeysClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armbotservice.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQnAMakerEndpointKeysClient().Get(ctx, armbotservice.QnAMakerEndpointKeysRequestBody{ - Authkey: to.Ptr("testAuthKey"), - Hostname: to.Ptr("https://xxx.cognitiveservices.azure.com/"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QnAMakerEndpointKeysResponse = armbotservice.QnAMakerEndpointKeysResponse{ - // InstalledVersion: to.Ptr("4.1.0"), - // LastStableVersion: to.Ptr("4.2.0"), - // PrimaryEndpointKey: to.Ptr("sample_primaryEndpointKey"), - // SecondaryEndpointKey: to.Ptr("sample_secondaryEndpointKey"), - // } -} diff --git a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client.go b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeysoperationgroup_client.go similarity index 52% rename from sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client.go rename to sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeysoperationgroup_client.go index aabf21bbba6e..97cf3376ba7d 100644 --- a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeysoperationgroup_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -20,23 +16,23 @@ import ( "strings" ) -// QnAMakerEndpointKeysClient contains the methods for the QnAMakerEndpointKeys group. -// Don't use this type directly, use NewQnAMakerEndpointKeysClient() instead. -type QnAMakerEndpointKeysClient struct { +// QnAMakerEndpointKeysOperationGroupClient contains the methods for the QnAMakerEndpointKeysOperationGroup group. +// Don't use this type directly, use NewQnAMakerEndpointKeysOperationGroupClient() instead. +type QnAMakerEndpointKeysOperationGroupClient struct { internal *arm.Client subscriptionID string } -// NewQnAMakerEndpointKeysClient creates a new instance of QnAMakerEndpointKeysClient with the specified values. -// - subscriptionID - Azure Subscription ID. +// NewQnAMakerEndpointKeysOperationGroupClient creates a new instance of QnAMakerEndpointKeysOperationGroupClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewQnAMakerEndpointKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QnAMakerEndpointKeysClient, error) { +func NewQnAMakerEndpointKeysOperationGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QnAMakerEndpointKeysOperationGroupClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } - client := &QnAMakerEndpointKeysClient{ + client := &QnAMakerEndpointKeysOperationGroupClient{ subscriptionID: subscriptionID, internal: cl, } @@ -46,34 +42,34 @@ func NewQnAMakerEndpointKeysClient(subscriptionID string, credential azcore.Toke // Get - Lists the QnA Maker endpoint keys // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-09-15 -// - parameters - The request body parameters to provide for the check name availability request -// - options - QnAMakerEndpointKeysClientGetOptions contains the optional parameters for the QnAMakerEndpointKeysClient.Get +// Generated from API version 2023-09-15-preview +// - parameters - The request body +// - options - QnAMakerEndpointKeysOperationGroupClientGetOptions contains the optional parameters for the QnAMakerEndpointKeysOperationGroupClient.Get // method. -func (client *QnAMakerEndpointKeysClient) Get(ctx context.Context, parameters QnAMakerEndpointKeysRequestBody, options *QnAMakerEndpointKeysClientGetOptions) (QnAMakerEndpointKeysClientGetResponse, error) { +func (client *QnAMakerEndpointKeysOperationGroupClient) Get(ctx context.Context, parameters QnAMakerEndpointKeysRequestBody, options *QnAMakerEndpointKeysOperationGroupClientGetOptions) (QnAMakerEndpointKeysOperationGroupClientGetResponse, error) { var err error - const operationName = "QnAMakerEndpointKeysClient.Get" + const operationName = "QnAMakerEndpointKeysOperationGroupClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, parameters, options) if err != nil { - return QnAMakerEndpointKeysClientGetResponse{}, err + return QnAMakerEndpointKeysOperationGroupClientGetResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return QnAMakerEndpointKeysClientGetResponse{}, err + return QnAMakerEndpointKeysOperationGroupClientGetResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return QnAMakerEndpointKeysClientGetResponse{}, err + return QnAMakerEndpointKeysOperationGroupClientGetResponse{}, err } resp, err := client.getHandleResponse(httpResp) return resp, err } // getCreateRequest creates the Get request. -func (client *QnAMakerEndpointKeysClient) getCreateRequest(ctx context.Context, parameters QnAMakerEndpointKeysRequestBody, options *QnAMakerEndpointKeysClientGetOptions) (*policy.Request, error) { +func (client *QnAMakerEndpointKeysOperationGroupClient) getCreateRequest(ctx context.Context, parameters QnAMakerEndpointKeysRequestBody, _ *QnAMakerEndpointKeysOperationGroupClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.BotService/listQnAMakerEndpointKeys" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -84,9 +80,10 @@ func (client *QnAMakerEndpointKeysClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-15") + reqQP.Set("api-version", "2023-09-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -94,10 +91,10 @@ func (client *QnAMakerEndpointKeysClient) getCreateRequest(ctx context.Context, } // getHandleResponse handles the Get response. -func (client *QnAMakerEndpointKeysClient) getHandleResponse(resp *http.Response) (QnAMakerEndpointKeysClientGetResponse, error) { - result := QnAMakerEndpointKeysClientGetResponse{} +func (client *QnAMakerEndpointKeysOperationGroupClient) getHandleResponse(resp *http.Response) (QnAMakerEndpointKeysOperationGroupClientGetResponse, error) { + result := QnAMakerEndpointKeysOperationGroupClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.QnAMakerEndpointKeysResponse); err != nil { - return QnAMakerEndpointKeysClientGetResponse{}, err + return QnAMakerEndpointKeysOperationGroupClientGetResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeysoperationgroup_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeysoperationgroup_client_example_test.go new file mode 100644 index 000000000000..9d44e3f23112 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeysoperationgroup_client_example_test.go @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2" + "log" +) + +// Generated from example definition: 2023-09-15-preview/ListQnAMakerEndpointKeys.json +func ExampleQnAMakerEndpointKeysOperationGroupClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armbotservice.NewClientFactory("subscription-id", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQnAMakerEndpointKeysOperationGroupClient().Get(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armbotservice.QnAMakerEndpointKeysOperationGroupClientGetResponse{ + // QnAMakerEndpointKeysResponse: &armbotservice.QnAMakerEndpointKeysResponse{ + // InstalledVersion: to.Ptr("4.1.0"), + // LastStableVersion: to.Ptr("4.2.0"), + // PrimaryEndpointKey: to.Ptr("sample_primaryEndpointKey"), + // SecondaryEndpointKey: to.Ptr("sample_secondaryEndpointKey"), + // }, + // } +} diff --git a/sdk/resourcemanager/botservice/armbotservice/response_types.go b/sdk/resourcemanager/botservice/armbotservice/response_types.go deleted file mode 100644 index 12d611860406..000000000000 --- a/sdk/resourcemanager/botservice/armbotservice/response_types.go +++ /dev/null @@ -1,191 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armbotservice - -// BotConnectionClientCreateResponse contains the response from method BotConnectionClient.Create. -type BotConnectionClientCreateResponse struct { - // Bot channel resource definition - ConnectionSetting -} - -// BotConnectionClientDeleteResponse contains the response from method BotConnectionClient.Delete. -type BotConnectionClientDeleteResponse struct { - // placeholder for future response values -} - -// BotConnectionClientGetResponse contains the response from method BotConnectionClient.Get. -type BotConnectionClientGetResponse struct { - // Bot channel resource definition - ConnectionSetting -} - -// BotConnectionClientListByBotServiceResponse contains the response from method BotConnectionClient.NewListByBotServicePager. -type BotConnectionClientListByBotServiceResponse struct { - // The list of bot service connection settings response. - ConnectionSettingResponseList -} - -// BotConnectionClientListServiceProvidersResponse contains the response from method BotConnectionClient.ListServiceProviders. -type BotConnectionClientListServiceProvidersResponse struct { - // The list of bot service providers response. - ServiceProviderResponseList -} - -// BotConnectionClientListWithSecretsResponse contains the response from method BotConnectionClient.ListWithSecrets. -type BotConnectionClientListWithSecretsResponse struct { - // Bot channel resource definition - ConnectionSetting -} - -// BotConnectionClientUpdateResponse contains the response from method BotConnectionClient.Update. -type BotConnectionClientUpdateResponse struct { - // Bot channel resource definition - ConnectionSetting -} - -// BotsClientCreateResponse contains the response from method BotsClient.Create. -type BotsClientCreateResponse struct { - // Bot resource definition - Bot -} - -// BotsClientDeleteResponse contains the response from method BotsClient.Delete. -type BotsClientDeleteResponse struct { - // placeholder for future response values -} - -// BotsClientGetCheckNameAvailabilityResponse contains the response from method BotsClient.GetCheckNameAvailability. -type BotsClientGetCheckNameAvailabilityResponse struct { - // The response body returned for a request to Bot Service Management to check availability of a bot name. - CheckNameAvailabilityResponseBody -} - -// BotsClientGetResponse contains the response from method BotsClient.Get. -type BotsClientGetResponse struct { - // Bot resource definition - Bot -} - -// BotsClientListByResourceGroupResponse contains the response from method BotsClient.NewListByResourceGroupPager. -type BotsClientListByResourceGroupResponse struct { - // The list of bot service operation response. - BotResponseList -} - -// BotsClientListResponse contains the response from method BotsClient.NewListPager. -type BotsClientListResponse struct { - // The list of bot service operation response. - BotResponseList -} - -// BotsClientUpdateResponse contains the response from method BotsClient.Update. -type BotsClientUpdateResponse struct { - // Bot resource definition - Bot -} - -// ChannelsClientCreateResponse contains the response from method ChannelsClient.Create. -type ChannelsClientCreateResponse struct { - // Bot channel resource definition - BotChannel -} - -// ChannelsClientDeleteResponse contains the response from method ChannelsClient.Delete. -type ChannelsClientDeleteResponse struct { - // placeholder for future response values -} - -// ChannelsClientGetResponse contains the response from method ChannelsClient.Get. -type ChannelsClientGetResponse struct { - // Bot channel resource definition - BotChannel -} - -// ChannelsClientListByResourceGroupResponse contains the response from method ChannelsClient.NewListByResourceGroupPager. -type ChannelsClientListByResourceGroupResponse struct { - // The list of bot service channel operation response. - ChannelResponseList -} - -// ChannelsClientListWithKeysResponse contains the response from method ChannelsClient.ListWithKeys. -type ChannelsClientListWithKeysResponse struct { - // The ARM channel of list channel with keys operation response. - ListChannelWithKeysResponse -} - -// ChannelsClientUpdateResponse contains the response from method ChannelsClient.Update. -type ChannelsClientUpdateResponse struct { - // Bot channel resource definition - BotChannel -} - -// DirectLineClientRegenerateKeysResponse contains the response from method DirectLineClient.RegenerateKeys. -type DirectLineClientRegenerateKeysResponse struct { - // Bot channel resource definition - BotChannel -} - -// EmailClientCreateSignInURLResponse contains the response from method EmailClient.CreateSignInURL. -type EmailClientCreateSignInURLResponse struct { - // The ARM create email sign in url operation response. - CreateEmailSignInURLResponse -} - -// HostSettingsClientGetResponse contains the response from method HostSettingsClient.Get. -type HostSettingsClientGetResponse struct { - // The response body returned for a request to Bot Service Management to check per subscription hostSettings - HostSettingsResponse -} - -// OperationResultsClientGetResponse contains the response from method OperationResultsClient.BeginGet. -type OperationResultsClientGetResponse struct { - // The properties indicating the operation result of an operation on a service. - OperationResultsDescription -} - -// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. -type OperationsClientListResponse struct { - // The list of bot service operation response. - OperationEntityListResult -} - -// PrivateEndpointConnectionsClientCreateResponse contains the response from method PrivateEndpointConnectionsClient.Create. -type PrivateEndpointConnectionsClientCreateResponse struct { - // The Private Endpoint Connection resource. - PrivateEndpointConnection -} - -// PrivateEndpointConnectionsClientDeleteResponse contains the response from method PrivateEndpointConnectionsClient.Delete. -type PrivateEndpointConnectionsClientDeleteResponse struct { - // placeholder for future response values -} - -// PrivateEndpointConnectionsClientGetResponse contains the response from method PrivateEndpointConnectionsClient.Get. -type PrivateEndpointConnectionsClientGetResponse struct { - // The Private Endpoint Connection resource. - PrivateEndpointConnection -} - -// PrivateEndpointConnectionsClientListResponse contains the response from method PrivateEndpointConnectionsClient.NewListPager. -type PrivateEndpointConnectionsClientListResponse struct { - // List of private endpoint connection associated with the specified storage account - PrivateEndpointConnectionListResult -} - -// PrivateLinkResourcesClientListByBotResourceResponse contains the response from method PrivateLinkResourcesClient.ListByBotResource. -type PrivateLinkResourcesClientListByBotResourceResponse struct { - // A list of private link resources - PrivateLinkResourceListResult -} - -// QnAMakerEndpointKeysClientGetResponse contains the response from method QnAMakerEndpointKeysClient.Get. -type QnAMakerEndpointKeysClientGetResponse struct { - // Schema for EndpointKeys generate/refresh operations. - QnAMakerEndpointKeysResponse -} diff --git a/sdk/resourcemanager/botservice/armbotservice/responses.go b/sdk/resourcemanager/botservice/armbotservice/responses.go new file mode 100644 index 000000000000..59bb7e6141a2 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/responses.go @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armbotservice + +// BotChannelsClientCreateResponse contains the response from method BotChannelsClient.Create. +type BotChannelsClientCreateResponse struct { + // Bot channel resource definition + BotChannel +} + +// BotChannelsClientDeleteResponse contains the response from method BotChannelsClient.Delete. +type BotChannelsClientDeleteResponse struct { + // placeholder for future response values +} + +// BotChannelsClientGetResponse contains the response from method BotChannelsClient.Get. +type BotChannelsClientGetResponse struct { + // Bot channel resource definition + BotChannel +} + +// BotChannelsClientListByResourceGroupResponse contains the response from method BotChannelsClient.NewListByResourceGroupPager. +type BotChannelsClientListByResourceGroupResponse struct { + // The list of bot service channel operation response. + ChannelResponseList +} + +// BotChannelsClientListWithKeysResponse contains the response from method BotChannelsClient.ListWithKeys. +type BotChannelsClientListWithKeysResponse struct { + // The ARM channel of list channel with keys operation response. + ListChannelWithKeysResponse +} + +// BotChannelsClientRegenerateKeysResponse contains the response from method BotChannelsClient.RegenerateKeys. +type BotChannelsClientRegenerateKeysResponse struct { + // Bot channel resource definition + BotChannel +} + +// BotChannelsClientUpdateResponse contains the response from method BotChannelsClient.Update. +type BotChannelsClientUpdateResponse struct { + // Bot channel resource definition + BotChannel +} + +// BotConnectionOperationGroupClientListServiceProvidersResponse contains the response from method BotConnectionOperationGroupClient.ListServiceProviders. +type BotConnectionOperationGroupClientListServiceProvidersResponse struct { + // The list of bot service providers response. + ServiceProviderResponseList +} + +// BotsClientCreateResponse contains the response from method BotsClient.Create. +type BotsClientCreateResponse struct { + // Bot resource definition + Bot +} + +// BotsClientCreateSignInURLResponse contains the response from method BotsClient.CreateSignInURL. +type BotsClientCreateSignInURLResponse struct { + // The ARM create email sign in url operation response. + CreateEmailSignInURLResponse +} + +// BotsClientDeleteResponse contains the response from method BotsClient.Delete. +type BotsClientDeleteResponse struct { + // placeholder for future response values +} + +// BotsClientGetResponse contains the response from method BotsClient.Get. +type BotsClientGetResponse struct { + // Bot resource definition + Bot +} + +// BotsClientListByBotResourceResponse contains the response from method BotsClient.ListByBotResource. +type BotsClientListByBotResourceResponse struct { + // A list of private link resources + PrivateLinkResourceListResult +} + +// BotsClientListByResourceGroupResponse contains the response from method BotsClient.NewListByResourceGroupPager. +type BotsClientListByResourceGroupResponse struct { + // The list of bot service operation response. + BotResponseList +} + +// BotsClientListResponse contains the response from method BotsClient.NewListPager. +type BotsClientListResponse struct { + // The list of bot service operation response. + BotResponseList +} + +// BotsClientUpdateResponse contains the response from method BotsClient.Update. +type BotsClientUpdateResponse struct { + // Bot resource definition + Bot +} + +// BotsOperationGroupClientGetCheckNameAvailabilityResponse contains the response from method BotsOperationGroupClient.GetCheckNameAvailability. +type BotsOperationGroupClientGetCheckNameAvailabilityResponse struct { + // The response body returned for a request to Bot Service Management to check availability of a bot name. + CheckNameAvailabilityResponseBody +} + +// ConnectionSettingsClientCreateResponse contains the response from method ConnectionSettingsClient.Create. +type ConnectionSettingsClientCreateResponse struct { + // Bot channel resource definition + ConnectionSetting +} + +// ConnectionSettingsClientDeleteResponse contains the response from method ConnectionSettingsClient.Delete. +type ConnectionSettingsClientDeleteResponse struct { + // placeholder for future response values +} + +// ConnectionSettingsClientGetResponse contains the response from method ConnectionSettingsClient.Get. +type ConnectionSettingsClientGetResponse struct { + // Bot channel resource definition + ConnectionSetting +} + +// ConnectionSettingsClientListByBotServiceResponse contains the response from method ConnectionSettingsClient.NewListByBotServicePager. +type ConnectionSettingsClientListByBotServiceResponse struct { + // The list of bot service connection settings response. + ConnectionSettingResponseList +} + +// ConnectionSettingsClientListWithSecretsResponse contains the response from method ConnectionSettingsClient.ListWithSecrets. +type ConnectionSettingsClientListWithSecretsResponse struct { + // Bot channel resource definition + ConnectionSetting +} + +// ConnectionSettingsClientUpdateResponse contains the response from method ConnectionSettingsClient.Update. +type ConnectionSettingsClientUpdateResponse struct { + // Bot channel resource definition + ConnectionSetting +} + +// HostSettingsOperationGroupClientGetResponse contains the response from method HostSettingsOperationGroupClient.Get. +type HostSettingsOperationGroupClientGetResponse struct { + // The response body returned for a request to Bot Service Management to check per subscription hostSettings + HostSettingsResponse +} + +// NetworkSecurityPerimeterConfigurationsClientGetResponse contains the response from method NetworkSecurityPerimeterConfigurationsClient.Get. +type NetworkSecurityPerimeterConfigurationsClientGetResponse struct { + // Network Security Perimeter configuration + NetworkSecurityPerimeterConfiguration +} + +// NetworkSecurityPerimeterConfigurationsClientListResponse contains the response from method NetworkSecurityPerimeterConfigurationsClient.NewListPager. +type NetworkSecurityPerimeterConfigurationsClientListResponse struct { + // Result of the List NetworkSecurityPerimeterConfiguration operation. + NetworkSecurityPerimeterConfigurationList +} + +// NetworkSecurityPerimeterConfigurationsClientReconcileResponse contains the response from method NetworkSecurityPerimeterConfigurationsClient.BeginReconcile. +type NetworkSecurityPerimeterConfigurationsClientReconcileResponse struct { + // Network Security Perimeter configuration + NetworkSecurityPerimeterConfiguration +} + +// OperationResultsOperationGroupClientGetResponse contains the response from method OperationResultsOperationGroupClient.BeginGet. +type OperationResultsOperationGroupClientGetResponse struct { + // The properties indicating the operation result of an operation on a service. + OperationResultsDescription +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // The list of bot service operation response. + OperationEntityListResult +} + +// PrivateEndpointConnectionsClientCreateResponse contains the response from method PrivateEndpointConnectionsClient.Create. +type PrivateEndpointConnectionsClientCreateResponse struct { + // The Private Endpoint Connection resource. + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsClientDeleteResponse contains the response from method PrivateEndpointConnectionsClient.Delete. +type PrivateEndpointConnectionsClientDeleteResponse struct { + // placeholder for future response values +} + +// PrivateEndpointConnectionsClientGetResponse contains the response from method PrivateEndpointConnectionsClient.Get. +type PrivateEndpointConnectionsClientGetResponse struct { + // The Private Endpoint Connection resource. + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsClientListResponse contains the response from method PrivateEndpointConnectionsClient.NewListPager. +type PrivateEndpointConnectionsClientListResponse struct { + // List of private endpoint connection associated with the specified storage account + PrivateEndpointConnectionListResult +} + +// QnAMakerEndpointKeysOperationGroupClientGetResponse contains the response from method QnAMakerEndpointKeysOperationGroupClient.Get. +type QnAMakerEndpointKeysOperationGroupClientGetResponse struct { + // Schema for EndpointKeys generate/refresh operations. + QnAMakerEndpointKeysResponse +} diff --git a/sdk/resourcemanager/botservice/armbotservice/time_rfc3339.go b/sdk/resourcemanager/botservice/armbotservice/time_rfc3339.go index c10212015fb2..3483a6cf5f81 100644 --- a/sdk/resourcemanager/botservice/armbotservice/time_rfc3339.go +++ b/sdk/resourcemanager/botservice/armbotservice/time_rfc3339.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armbotservice @@ -19,12 +15,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +40,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +80,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +97,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/botservice/armbotservice/tsp-location.yaml b/sdk/resourcemanager/botservice/armbotservice/tsp-location.yaml new file mode 100644 index 000000000000..a6937a17c515 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/botservice/BotService.Management +commit: 7be0444544b6bdd1aad8f9103f7620602aec7a1c +repo: Azure/azure-rest-api-specs +additionalDirectories: