diff --git a/sdk/resourcemanager/healthbot/armhealthbot/CHANGELOG.md b/sdk/resourcemanager/healthbot/armhealthbot/CHANGELOG.md index 54a3b6392a0b..968fac34a4b8 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/CHANGELOG.md +++ b/sdk/resourcemanager/healthbot/armhealthbot/CHANGELOG.md @@ -1,5 +1,30 @@ # Release History +## 2.0.0 (2025-05-08) +### Breaking Changes + +- Type of `Error.Error` has been changed from `*ErrorError` to `*ErrorDetail` +- Type of `SystemData.CreatedByType` has been changed from `*IdentityType` to `*CreatedByType` +- Type of `SystemData.LastModifiedByType` has been changed from `*IdentityType` to `*CreatedByType` +- Enum `IdentityType` has been removed +- Operation `*BotsClient.Update` has been changed to LRO, use `*BotsClient.BeginUpdate` instead. +- Struct `ErrorError` has been removed +- Struct `ValidationResult` has been removed + +### Features Added + +- New value `SKUNameC1`, `SKUNamePES` added to enum type `SKUName` +- New enum type `CreatedByType` with values `CreatedByTypeApplication`, `CreatedByTypeKey`, `CreatedByTypeManagedIdentity`, `CreatedByTypeUser` +- New function `*BotsClient.ListSecrets(context.Context, string, string, *BotsClientListSecretsOptions) (BotsClientListSecretsResponse, error)` +- New function `*BotsClient.RegenerateAPIJwtSecret(context.Context, string, string, *BotsClientRegenerateAPIJwtSecretOptions) (BotsClientRegenerateAPIJwtSecretResponse, error)` +- New struct `ErrorDetail` +- New struct `Key` +- New struct `KeyVaultProperties` +- New struct `KeysResponse` +- New field `KeyVaultProperties` in struct `Properties` +- New field `Properties` in struct `UpdateParameters` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/healthbot/armhealthbot/README.md b/sdk/resourcemanager/healthbot/armhealthbot/README.md index c5bba01ca516..4e6702ab861d 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/README.md +++ b/sdk/resourcemanager/healthbot/armhealthbot/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Health Bot module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot/v2 ``` ## Authorization diff --git a/sdk/resourcemanager/healthbot/armhealthbot/autorest.md b/sdk/resourcemanager/healthbot/armhealthbot/autorest.md index 1148e46585bf..2610996912c3 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/autorest.md +++ b/sdk/resourcemanager/healthbot/armhealthbot/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/healthbot/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/healthbot/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 2.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/healthbot/armhealthbot/bots_client.go b/sdk/resourcemanager/healthbot/armhealthbot/bots_client.go index 2e6be7c631a8..de167ae2a4fb 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/bots_client.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/bots_client.go @@ -1,6 +1,3 @@ -//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. @@ -28,7 +25,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. // - 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 +43,8 @@ func NewBotsClient(subscriptionID string, credential azcore.TokenCredential, opt // BeginCreate - Create a new Azure Health Bot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-10 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2024-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - botName - The name of the Bot resource. // - parameters - The parameters to provide for the created Azure Health Bot. // - options - BotsClientBeginCreateOptions contains the optional parameters for the BotsClient.BeginCreate method. @@ -72,7 +69,7 @@ func (client *BotsClient) BeginCreate(ctx context.Context, resourceGroupName str // Create - Create a new Azure Health Bot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-10 +// Generated from API version 2024-02-01 func (client *BotsClient) create(ctx context.Context, resourceGroupName string, botName string, parameters HealthBot, options *BotsClientBeginCreateOptions) (*http.Response, error) { var err error const operationName = "BotsClient.BeginCreate" @@ -95,7 +92,7 @@ func (client *BotsClient) create(ctx context.Context, resourceGroupName string, } // createCreateRequest creates the Create request. -func (client *BotsClient) createCreateRequest(ctx context.Context, resourceGroupName string, botName string, parameters HealthBot, options *BotsClientBeginCreateOptions) (*policy.Request, error) { +func (client *BotsClient) createCreateRequest(ctx context.Context, resourceGroupName string, botName string, parameters HealthBot, _ *BotsClientBeginCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -114,7 +111,7 @@ func (client *BotsClient) createCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-10") + reqQP.Set("api-version", "2024-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -126,8 +123,8 @@ func (client *BotsClient) createCreateRequest(ctx context.Context, resourceGroup // BeginDelete - Delete a HealthBot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-10 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2024-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - botName - The name of the Bot resource. // - options - BotsClientBeginDeleteOptions contains the optional parameters for the BotsClient.BeginDelete method. func (client *BotsClient) BeginDelete(ctx context.Context, resourceGroupName string, botName string, options *BotsClientBeginDeleteOptions) (*runtime.Poller[BotsClientDeleteResponse], error) { @@ -137,7 +134,8 @@ func (client *BotsClient) BeginDelete(ctx context.Context, resourceGroupName str return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BotsClientDeleteResponse]{ - Tracer: client.internal.Tracer(), + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -150,7 +148,7 @@ func (client *BotsClient) BeginDelete(ctx context.Context, resourceGroupName str // Delete - Delete a HealthBot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-10 +// Generated from API version 2024-02-01 func (client *BotsClient) deleteOperation(ctx context.Context, resourceGroupName string, botName string, options *BotsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "BotsClient.BeginDelete" @@ -173,7 +171,7 @@ func (client *BotsClient) deleteOperation(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, botName string, options *BotsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, botName string, _ *BotsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -192,7 +190,7 @@ func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-10") + reqQP.Set("api-version", "2024-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -201,8 +199,8 @@ func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroup // Get - Get a HealthBot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-10 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2024-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - botName - 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, botName string, options *BotsClientGetOptions) (BotsClientGetResponse, error) { @@ -228,7 +226,7 @@ func (client *BotsClient) Get(ctx context.Context, resourceGroupName string, bot } // getCreateRequest creates the Get request. -func (client *BotsClient) getCreateRequest(ctx context.Context, resourceGroupName string, botName string, options *BotsClientGetOptions) (*policy.Request, error) { +func (client *BotsClient) getCreateRequest(ctx context.Context, resourceGroupName string, botName string, _ *BotsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -247,7 +245,7 @@ func (client *BotsClient) getCreateRequest(ctx context.Context, resourceGroupNam return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-10") + reqQP.Set("api-version", "2024-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -264,7 +262,7 @@ func (client *BotsClient) getHandleResponse(resp *http.Response) (BotsClientGetR // NewListPager - Returns all the resources of a particular type belonging to a subscription. // -// Generated from API version 2021-06-10 +// Generated from API version 2024-02-01 // - 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]{ @@ -290,7 +288,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.HealthBot/healthBots" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -301,7 +299,7 @@ func (client *BotsClient) listCreateRequest(ctx context.Context, options *BotsCl return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-10") + reqQP.Set("api-version", "2024-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -318,8 +316,8 @@ func (client *BotsClient) listHandleResponse(resp *http.Response) (BotsClientLis // NewListByResourceGroupPager - Returns all the resources of a particular type belonging to a resource group // -// Generated from API version 2021-06-10 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2024-02-01 +// - 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] { @@ -346,22 +344,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.HealthBot/healthBots" - 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", "2021-06-10") + reqQP.Set("api-version", "2024-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -376,38 +374,188 @@ func (client *BotsClient) listByResourceGroupHandleResponse(resp *http.Response) return result, nil } -// Update - Patch a HealthBot. +// ListSecrets - List all secrets of a HealthBot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-10 -// - resourceGroupName - The name of the Bot resource group in the user subscription. +// Generated from API version 2024-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - botName - The name of the Bot resource. +// - options - BotsClientListSecretsOptions contains the optional parameters for the BotsClient.ListSecrets method. +func (client *BotsClient) ListSecrets(ctx context.Context, resourceGroupName string, botName string, options *BotsClientListSecretsOptions) (BotsClientListSecretsResponse, error) { + var err error + const operationName = "BotsClient.ListSecrets" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listSecretsCreateRequest(ctx, resourceGroupName, botName, options) + if err != nil { + return BotsClientListSecretsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BotsClientListSecretsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BotsClientListSecretsResponse{}, err + } + resp, err := client.listSecretsHandleResponse(httpResp) + return resp, err +} + +// listSecretsCreateRequest creates the ListSecrets request. +func (client *BotsClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, botName string, _ *BotsClientListSecretsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets" + 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 botName == "" { + return nil, errors.New("parameter botName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{botName}", url.PathEscape(botName)) + 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", "2024-02-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listSecretsHandleResponse handles the ListSecrets response. +func (client *BotsClient) listSecretsHandleResponse(resp *http.Response) (BotsClientListSecretsResponse, error) { + result := BotsClientListSecretsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.KeysResponse); err != nil { + return BotsClientListSecretsResponse{}, err + } + return result, nil +} + +// RegenerateAPIJwtSecret - Regenerate the API JWT Secret of a HealthBot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - botName - The name of the Bot resource. +// - options - BotsClientRegenerateAPIJwtSecretOptions contains the optional parameters for the BotsClient.RegenerateAPIJwtSecret +// method. +func (client *BotsClient) RegenerateAPIJwtSecret(ctx context.Context, resourceGroupName string, botName string, options *BotsClientRegenerateAPIJwtSecretOptions) (BotsClientRegenerateAPIJwtSecretResponse, error) { + var err error + const operationName = "BotsClient.RegenerateAPIJwtSecret" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.regenerateAPIJwtSecretCreateRequest(ctx, resourceGroupName, botName, options) + if err != nil { + return BotsClientRegenerateAPIJwtSecretResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BotsClientRegenerateAPIJwtSecretResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BotsClientRegenerateAPIJwtSecretResponse{}, err + } + resp, err := client.regenerateAPIJwtSecretHandleResponse(httpResp) + return resp, err +} + +// regenerateAPIJwtSecretCreateRequest creates the RegenerateAPIJwtSecret request. +func (client *BotsClient) regenerateAPIJwtSecretCreateRequest(ctx context.Context, resourceGroupName string, botName string, _ *BotsClientRegenerateAPIJwtSecretOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret" + 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 botName == "" { + return nil, errors.New("parameter botName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{botName}", url.PathEscape(botName)) + 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", "2024-02-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// regenerateAPIJwtSecretHandleResponse handles the RegenerateAPIJwtSecret response. +func (client *BotsClient) regenerateAPIJwtSecretHandleResponse(resp *http.Response) (BotsClientRegenerateAPIJwtSecretResponse, error) { + result := BotsClientRegenerateAPIJwtSecretResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Key); err != nil { + return BotsClientRegenerateAPIJwtSecretResponse{}, err + } + return result, nil +} + +// BeginUpdate - Patch a HealthBot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - botName - The name of the Bot resource. // - parameters - The parameters to provide for the required Azure Health Bot. -// - options - BotsClientUpdateOptions contains the optional parameters for the BotsClient.Update method. -func (client *BotsClient) Update(ctx context.Context, resourceGroupName string, botName string, parameters UpdateParameters, options *BotsClientUpdateOptions) (BotsClientUpdateResponse, error) { +// - options - BotsClientBeginUpdateOptions contains the optional parameters for the BotsClient.BeginUpdate method. +func (client *BotsClient) BeginUpdate(ctx context.Context, resourceGroupName string, botName string, parameters UpdateParameters, options *BotsClientBeginUpdateOptions) (*runtime.Poller[BotsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, botName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BotsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BotsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Patch a HealthBot. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-02-01 +func (client *BotsClient) update(ctx context.Context, resourceGroupName string, botName string, parameters UpdateParameters, options *BotsClientBeginUpdateOptions) (*http.Response, error) { var err error - const operationName = "BotsClient.Update" + const operationName = "BotsClient.BeginUpdate" 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, botName, parameters, options) if err != nil { - return BotsClientUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return BotsClientUpdateResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return BotsClientUpdateResponse{}, err + return nil, err } - resp, err := client.updateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // updateCreateRequest creates the Update request. -func (client *BotsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, botName string, parameters UpdateParameters, options *BotsClientUpdateOptions) (*policy.Request, error) { +func (client *BotsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, botName string, parameters UpdateParameters, _ *BotsClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -426,7 +574,7 @@ func (client *BotsClient) updateCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-10") + reqQP.Set("api-version", "2024-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -434,12 +582,3 @@ func (client *BotsClient) updateCreateRequest(ctx context.Context, resourceGroup } return req, nil } - -// updateHandleResponse handles the Update response. -func (client *BotsClient) updateHandleResponse(resp *http.Response) (BotsClientUpdateResponse, error) { - result := BotsClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.HealthBot); err != nil { - return BotsClientUpdateResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/healthbot/armhealthbot/bots_client_example_test.go b/sdk/resourcemanager/healthbot/armhealthbot/bots_client_example_test.go deleted file mode 100644 index 35535eb3bb33..000000000000 --- a/sdk/resourcemanager/healthbot/armhealthbot/bots_client_example_test.go +++ /dev/null @@ -1,351 +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 armhealthbot_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/healthbot/armhealthbot" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceCreationPut.json -func ExampleBotsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armhealthbot.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBotsClient().BeginCreate(ctx, "healthbotClient", "samplebotname", armhealthbot.HealthBot{ - Location: to.Ptr("East US"), - Identity: &armhealthbot.Identity{ - Type: to.Ptr(armhealthbot.ResourceIdentityTypeSystemAssignedUserAssigned), - UserAssignedIdentities: map[string]*armhealthbot.UserAssignedIdentity{ - "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": {}, - "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": {}, - }, - }, - SKU: &armhealthbot.SKU{ - Name: to.Ptr(armhealthbot.SKUNameF0), - }, - }, 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.HealthBot = armhealthbot.HealthBot{ - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.HealthBot/healthBots"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname"), - // SystemData: &armhealthbot.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-05T17:18:19.123Z"); return t}()), - // CreatedBy: to.Ptr("jack@outlook.com"), - // CreatedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-06T17:18:19.123Z"); return t}()), - // LastModifiedBy: to.Ptr("ryan@outlook.com"), - // LastModifiedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // }, - // Location: to.Ptr("East US"), - // Identity: &armhealthbot.Identity{ - // Type: to.Ptr(armhealthbot.ResourceIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("principalId"), - // TenantID: to.Ptr("tenantId"), - // UserAssignedIdentities: map[string]*armhealthbot.UserAssignedIdentity{ - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": &armhealthbot.UserAssignedIdentity{ - // }, - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": &armhealthbot.UserAssignedIdentity{ - // }, - // }, - // }, - // Properties: &armhealthbot.Properties{ - // BotManagementPortalLink: to.Ptr("https://us.healthbot.microsoft.com/account/contoso"), - // }, - // SKU: &armhealthbot.SKU{ - // Name: to.Ptr(armhealthbot.SKUNameF0), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceInfoGet.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 := armhealthbot.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBotsClient().Get(ctx, "healthbotClient", "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.HealthBot = armhealthbot.HealthBot{ - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.HealthBot/healthBots"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname"), - // SystemData: &armhealthbot.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-05T17:18:19.123Z"); return t}()), - // CreatedBy: to.Ptr("jack@outlook.com"), - // CreatedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-06T17:18:19.123Z"); return t}()), - // LastModifiedBy: to.Ptr("ryan@outlook.com"), - // LastModifiedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // }, - // Location: to.Ptr("East US"), - // Identity: &armhealthbot.Identity{ - // Type: to.Ptr(armhealthbot.ResourceIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("principalId"), - // TenantID: to.Ptr("tenantId"), - // UserAssignedIdentities: map[string]*armhealthbot.UserAssignedIdentity{ - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": &armhealthbot.UserAssignedIdentity{ - // }, - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": &armhealthbot.UserAssignedIdentity{ - // }, - // }, - // }, - // Properties: &armhealthbot.Properties{ - // BotManagementPortalLink: to.Ptr("https://us.healthbot.microsoft.com/account/contoso"), - // }, - // SKU: &armhealthbot.SKU{ - // Name: to.Ptr(armhealthbot.SKUNameF0), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceUpdatePatch.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 := armhealthbot.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBotsClient().Update(ctx, "healthbotClient", "samplebotname", armhealthbot.UpdateParameters{ - SKU: &armhealthbot.SKU{ - Name: to.Ptr(armhealthbot.SKUNameF0), - }, - }, 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.HealthBot = armhealthbot.HealthBot{ - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.HealthBot/healthBots"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname"), - // SystemData: &armhealthbot.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-05T17:18:19.123Z"); return t}()), - // CreatedBy: to.Ptr("jack@outlook.com"), - // CreatedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-06T17:18:19.123Z"); return t}()), - // LastModifiedBy: to.Ptr("ryan@outlook.com"), - // LastModifiedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // }, - // Location: to.Ptr("East US"), - // Identity: &armhealthbot.Identity{ - // Type: to.Ptr(armhealthbot.ResourceIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("principalId"), - // TenantID: to.Ptr("tenantId"), - // UserAssignedIdentities: map[string]*armhealthbot.UserAssignedIdentity{ - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": &armhealthbot.UserAssignedIdentity{ - // }, - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": &armhealthbot.UserAssignedIdentity{ - // }, - // }, - // }, - // Properties: &armhealthbot.Properties{ - // BotManagementPortalLink: to.Ptr("https://us.healthbot.microsoft.com/account/contoso"), - // }, - // SKU: &armhealthbot.SKU{ - // Name: to.Ptr(armhealthbot.SKUNameF0), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceDeletionDelete.json -func ExampleBotsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armhealthbot.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBotsClient().BeginDelete(ctx, "healthbotClient", "samplebotname", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/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 := armhealthbot.NewClientFactory("", 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 { - 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.BotResponseList = armhealthbot.BotResponseList{ - // Value: []*armhealthbot.HealthBot{ - // { - // Name: to.Ptr("samplebotname"), - // Type: to.Ptr("Microsoft.HealthBot/healthBots"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname"), - // SystemData: &armhealthbot.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-05T17:18:19.123Z"); return t}()), - // CreatedBy: to.Ptr("jack@outlook.com"), - // CreatedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-06T17:18:19.123Z"); return t}()), - // LastModifiedBy: to.Ptr("ryan@outlook.com"), - // LastModifiedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // }, - // Location: to.Ptr("East US"), - // Properties: &armhealthbot.Properties{ - // BotManagementPortalLink: to.Ptr("https://us.healthbot.microsoft.com/account/samplebotname-1yhd91k"), - // }, - // SKU: &armhealthbot.SKU{ - // Name: to.Ptr(armhealthbot.SKUNameF0), - // }, - // }, - // { - // Name: to.Ptr("samplebotname2"), - // Type: to.Ptr("Microsoft.HealthBot/healthBots"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname2"), - // SystemData: &armhealthbot.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-05T17:18:19.123Z"); return t}()), - // CreatedBy: to.Ptr("jack@outlook.com"), - // CreatedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-06T17:18:19.123Z"); return t}()), - // LastModifiedBy: to.Ptr("ryan@outlook.com"), - // LastModifiedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // }, - // Location: to.Ptr("East US"), - // Identity: &armhealthbot.Identity{ - // Type: to.Ptr(armhealthbot.ResourceIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("principalId"), - // TenantID: to.Ptr("tenantId"), - // UserAssignedIdentities: map[string]*armhealthbot.UserAssignedIdentity{ - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": &armhealthbot.UserAssignedIdentity{ - // }, - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": &armhealthbot.UserAssignedIdentity{ - // }, - // }, - // }, - // Properties: &armhealthbot.Properties{ - // BotManagementPortalLink: to.Ptr("https://us.healthbot.microsoft.com/account/samplebotname2-hdi1osc"), - // }, - // SKU: &armhealthbot.SKU{ - // Name: to.Ptr(armhealthbot.SKUNameS1), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/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 := armhealthbot.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBotsClient().NewListPager(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.BotResponseList = armhealthbot.BotResponseList{ - // Value: []*armhealthbot.HealthBot{ - // { - // Name: to.Ptr("samplebotname2"), - // Type: to.Ptr("Microsoft.HealthBot/healthBots"), - // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname2"), - // SystemData: &armhealthbot.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-05T17:18:19.123Z"); return t}()), - // CreatedBy: to.Ptr("jack@outlook.com"), - // CreatedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-06T17:18:19.123Z"); return t}()), - // LastModifiedBy: to.Ptr("ryan@outlook.com"), - // LastModifiedByType: to.Ptr(armhealthbot.IdentityTypeUser), - // }, - // Location: to.Ptr("East US"), - // Identity: &armhealthbot.Identity{ - // Type: to.Ptr(armhealthbot.ResourceIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("principalId"), - // TenantID: to.Ptr("tenantId"), - // UserAssignedIdentities: map[string]*armhealthbot.UserAssignedIdentity{ - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": &armhealthbot.UserAssignedIdentity{ - // }, - // "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": &armhealthbot.UserAssignedIdentity{ - // }, - // }, - // }, - // Properties: &armhealthbot.Properties{ - // BotManagementPortalLink: to.Ptr("https://us.healthbot.microsoft.com/account/samplebotname2-hdi1osc"), - // }, - // SKU: &armhealthbot.SKU{ - // Name: to.Ptr(armhealthbot.SKUNameS1), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/healthbot/armhealthbot/client_factory.go b/sdk/resourcemanager/healthbot/armhealthbot/client_factory.go index e4ca5c5cd605..5f99bd78cf66 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/client_factory.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/client_factory.go @@ -1,6 +1,3 @@ -//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. @@ -17,34 +14,36 @@ 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. // - 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 } // 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, + } } // 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, + } } diff --git a/sdk/resourcemanager/healthbot/armhealthbot/constants.go b/sdk/resourcemanager/healthbot/armhealthbot/constants.go index fa356da598b3..34813e7f6cfa 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/constants.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/constants.go @@ -1,6 +1,3 @@ -//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. @@ -10,26 +7,26 @@ package armhealthbot const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot" - moduleVersion = "v1.2.0" + moduleVersion = "v2.0.0" ) -// IdentityType - The type of identity that creates/modifies resources -type IdentityType string +// CreatedByType - The type of identity that created the resource. +type CreatedByType string const ( - IdentityTypeApplication IdentityType = "Application" - IdentityTypeKey IdentityType = "Key" - IdentityTypeManagedIdentity IdentityType = "ManagedIdentity" - IdentityTypeUser IdentityType = "User" + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" ) -// PossibleIdentityTypeValues returns the possible values for the IdentityType const type. -func PossibleIdentityTypeValues() []IdentityType { - return []IdentityType{ - IdentityTypeApplication, - IdentityTypeKey, - IdentityTypeManagedIdentity, - IdentityTypeUser, +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, } } @@ -59,16 +56,20 @@ func PossibleResourceIdentityTypeValues() []ResourceIdentityType { type SKUName string const ( - SKUNameC0 SKUName = "C0" - SKUNameF0 SKUName = "F0" - SKUNameS1 SKUName = "S1" + SKUNameC0 SKUName = "C0" + SKUNameC1 SKUName = "C1" + SKUNameF0 SKUName = "F0" + SKUNamePES SKUName = "PES" + SKUNameS1 SKUName = "S1" ) // PossibleSKUNameValues returns the possible values for the SKUName const type. func PossibleSKUNameValues() []SKUName { return []SKUName{ SKUNameC0, + SKUNameC1, SKUNameF0, + SKUNamePES, SKUNameS1, } } diff --git a/sdk/resourcemanager/healthbot/armhealthbot/fake/bots_server.go b/sdk/resourcemanager/healthbot/armhealthbot/fake/bots_server.go index 9a0fa035587d..99e7d93303c0 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/fake/bots_server.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/fake/bots_server.go @@ -1,6 +1,3 @@ -//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. @@ -16,7 +13,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/healthbot/armhealthbot" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot/v2" "net/http" "net/url" "regexp" @@ -44,9 +41,17 @@ type BotsServer struct { // HTTP status codes to indicate success: http.StatusOK NewListByResourceGroupPager func(resourceGroupName string, options *armhealthbot.BotsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armhealthbot.BotsClientListByResourceGroupResponse]) - // Update is the fake for method BotsClient.Update + // ListSecrets is the fake for method BotsClient.ListSecrets + // HTTP status codes to indicate success: http.StatusOK + ListSecrets func(ctx context.Context, resourceGroupName string, botName string, options *armhealthbot.BotsClientListSecretsOptions) (resp azfake.Responder[armhealthbot.BotsClientListSecretsResponse], errResp azfake.ErrorResponder) + + // RegenerateAPIJwtSecret is the fake for method BotsClient.RegenerateAPIJwtSecret + // HTTP status codes to indicate success: http.StatusOK + RegenerateAPIJwtSecret func(ctx context.Context, resourceGroupName string, botName string, options *armhealthbot.BotsClientRegenerateAPIJwtSecretOptions) (resp azfake.Responder[armhealthbot.BotsClientRegenerateAPIJwtSecretResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method BotsClient.BeginUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - Update func(ctx context.Context, resourceGroupName string, botName string, parameters armhealthbot.UpdateParameters, options *armhealthbot.BotsClientUpdateOptions) (resp azfake.Responder[armhealthbot.BotsClientUpdateResponse], errResp azfake.ErrorResponder) + BeginUpdate func(ctx context.Context, resourceGroupName string, botName string, parameters armhealthbot.UpdateParameters, options *armhealthbot.BotsClientBeginUpdateOptions) (resp azfake.PollerResponder[armhealthbot.BotsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewBotsServerTransport creates a new instance of BotsServerTransport with the provided implementation. @@ -59,6 +64,7 @@ func NewBotsServerTransport(srv *BotsServer) *BotsServerTransport { beginDelete: newTracker[azfake.PollerResponder[armhealthbot.BotsClientDeleteResponse]](), newListPager: newTracker[azfake.PagerResponder[armhealthbot.BotsClientListResponse]](), newListByResourceGroupPager: newTracker[azfake.PagerResponder[armhealthbot.BotsClientListByResourceGroupResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armhealthbot.BotsClientUpdateResponse]](), } } @@ -70,6 +76,7 @@ type BotsServerTransport struct { beginDelete *tracker[azfake.PollerResponder[armhealthbot.BotsClientDeleteResponse]] newListPager *tracker[azfake.PagerResponder[armhealthbot.BotsClientListResponse]] newListByResourceGroupPager *tracker[azfake.PagerResponder[armhealthbot.BotsClientListByResourceGroupResponse]] + beginUpdate *tracker[azfake.PollerResponder[armhealthbot.BotsClientUpdateResponse]] } // Do implements the policy.Transporter interface for BotsServerTransport. @@ -80,31 +87,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.BeginCreate": - resp, err = b.dispatchBeginCreate(req) - case "BotsClient.BeginDelete": - resp, err = b.dispatchBeginDelete(req) - case "BotsClient.Get": - resp, err = b.dispatchGet(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.BeginCreate": + res.resp, res.err = b.dispatchBeginCreate(req) + case "BotsClient.BeginDelete": + res.resp, res.err = b.dispatchBeginDelete(req) + case "BotsClient.Get": + res.resp, res.err = b.dispatchGet(req) + case "BotsClient.NewListPager": + res.resp, res.err = b.dispatchNewListPager(req) + case "BotsClient.NewListByResourceGroupPager": + res.resp, res.err = b.dispatchNewListByResourceGroupPager(req) + case "BotsClient.ListSecrets": + res.resp, res.err = b.dispatchListSecrets(req) + case "BotsClient.RegenerateAPIJwtSecret": + res.resp, res.err = b.dispatchRegenerateAPIJwtSecret(req) + case "BotsClient.BeginUpdate": + res.resp, res.err = b.dispatchBeginUpdate(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) dispatchBeginCreate(req *http.Request) (*http.Response, error) { @@ -302,20 +332,49 @@ func (b *BotsServerTransport) dispatchNewListByResourceGroupPager(req *http.Requ return resp, nil } -func (b *BotsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if b.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} +func (b *BotsServerTransport) dispatchListSecrets(req *http.Request) (*http.Response, error) { + if b.srv.ListSecrets == nil { + return nil, &nonRetriableError{errors.New("fake for method ListSecrets not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HealthBot/healthBots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HealthBot/healthBots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listSecrets` 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) } - body, err := server.UnmarshalRequestAsJSON[armhealthbot.UpdateParameters](req) + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } + botNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("botName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.ListSecrets(req.Context(), resourceGroupNameParam, botNameParam, 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).KeysResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BotsServerTransport) dispatchRegenerateAPIJwtSecret(req *http.Request) (*http.Response, error) { + if b.srv.RegenerateAPIJwtSecret == nil { + return nil, &nonRetriableError{errors.New("fake for method RegenerateAPIJwtSecret not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HealthBot/healthBots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regenerateApiJwtSecret` + 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 @@ -324,17 +383,71 @@ func (b *BotsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, if err != nil { return nil, err } - respr, errRespr := b.srv.Update(req.Context(), resourceGroupNameParam, botNameParam, body, nil) + respr, errRespr := b.srv.RegenerateAPIJwtSecret(req.Context(), resourceGroupNameParam, botNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", 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.MarshalResponseAsJSON(respContent, server.GetResponse(respr).HealthBot, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Key, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BotsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if b.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := b.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HealthBot/healthBots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armhealthbot.UpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + botNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("botName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginUpdate(req.Context(), resourceGroupNameParam, botNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + b.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) if err != nil { return nil, err } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + b.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + b.beginUpdate.remove(req) + } + 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/healthbot/armhealthbot/fake/internal.go b/sdk/resourcemanager/healthbot/armhealthbot/fake/internal.go index 5f75802a569e..4b65adc76adb 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/fake/internal.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/fake/internal.go @@ -1,6 +1,3 @@ -//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. @@ -14,6 +11,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/healthbot/armhealthbot/fake/operations_server.go b/sdk/resourcemanager/healthbot/armhealthbot/fake/operations_server.go index a91da32edbf5..2af9a8adca80 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/fake/operations_server.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/fake/operations_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,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/healthbot/armhealthbot" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot/v2" "net/http" ) @@ -51,21 +48,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 +110,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/healthbot/armhealthbot/fake/server_factory.go b/sdk/resourcemanager/healthbot/armhealthbot/fake/server_factory.go index c43985807344..7e0292e7fb5d 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/fake/server_factory.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. @@ -19,7 +16,10 @@ import ( // ServerFactory is a fake server for instances of the armhealthbot.ClientFactory type. type ServerFactory struct { - BotsServer BotsServer + // BotsServer contains the fakes for client BotsClient + BotsServer BotsServer + + // OperationsServer contains the fakes for client OperationsClient OperationsServer OperationsServer } diff --git a/sdk/resourcemanager/healthbot/armhealthbot/fake/time_rfc3339.go b/sdk/resourcemanager/healthbot/armhealthbot/fake/time_rfc3339.go deleted file mode 100644 index b0535a7b63e6..000000000000 --- a/sdk/resourcemanager/healthbot/armhealthbot/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/healthbot/armhealthbot/go.mod b/sdk/resourcemanager/healthbot/armhealthbot/go.mod index 6ca0ee894b5f..4514808d7d4b 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/go.mod +++ b/sdk/resourcemanager/healthbot/armhealthbot/go.mod @@ -1,21 +1,11 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot/v2 go 1.23.0 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.36.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect ) diff --git a/sdk/resourcemanager/healthbot/armhealthbot/go.sum b/sdk/resourcemanager/healthbot/armhealthbot/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/go.sum +++ b/sdk/resourcemanager/healthbot/armhealthbot/go.sum @@ -1,44 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/healthbot/armhealthbot/models.go b/sdk/resourcemanager/healthbot/armhealthbot/models.go index 7ffdea5cc29c..1c455d7cac0c 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/models.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/models.go @@ -1,6 +1,3 @@ -//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. @@ -10,41 +7,41 @@ package armhealthbot import "time" -// AvailableOperations - Available operations of the service +// AvailableOperations - Available operations of the service. type AvailableOperations struct { + // REQUIRED; Collection of available operation details. + Value []*OperationDetail + // URL client should use to fetch the next page (per server side paging). It's null for now, added for future use. NextLink *string - - // Collection of available operation details - Value []*OperationDetail } // BotResponseList - The list of Azure Health Bot operation response. type BotResponseList struct { - // READ-ONLY; The link used to get the next page of bot service resources. - NextLink *string - - // READ-ONLY; Gets the list of Azure Health Bot results and their properties. + // READ-ONLY; The HealthBot items on this page Value []*HealthBot + + // The link to the next page of items + NextLink *string } // Error - The resource management error response. type Error struct { // The error object. - Error *ErrorError + Error *ErrorDetail } -// ErrorAdditionalInfo - The resource management error additional info. +// ErrorAdditionalInfo - Additional information about an error. type ErrorAdditionalInfo struct { - // READ-ONLY; The additional info. + // READ-ONLY; The additional error information. Info any - // READ-ONLY; The additional info type. + // READ-ONLY; The type of the additional error information. Type *string } -// ErrorError - The error object. -type ErrorError struct { +// ErrorDetail - The error object detail. +type ErrorDetail struct { // READ-ONLY; The error additional info. AdditionalInfo []*ErrorAdditionalInfo @@ -78,16 +75,16 @@ type HealthBot struct { // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource Id for the resource. + // 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; Metadata pertaining to creation and last modification of the resource + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -110,6 +107,36 @@ type Identity struct { TenantID *string } +// Key - An entry of HealthBotKeysResponse +type Key struct { + // The name of the key. + KeyName *string + + // The value of the key. + Value *string +} + +// KeyVaultProperties - Properties of the key vault. +type KeyVaultProperties struct { + // REQUIRED; The name of the key vault key. + KeyName *string + + // REQUIRED; The Uri of the key vault. + KeyVaultURI *string + + // The version of the key vault key. + KeyVersion *string + + // The user assigned identity (ARM resource id) that has access to the key. + UserIdentity *string +} + +// KeysResponse - Health Bot Keys Response. +type KeysResponse struct { + // Array of Azure Health Bot Secrets. + Secrets []*Key +} + // OperationDetail - Operation detail payload type OperationDetail struct { // Display of the operation @@ -128,18 +155,19 @@ type OperationDetail struct { Properties any } -// OperationDisplay - Operation display payload +// OperationDisplay - Localized display information for and operation. type OperationDisplay struct { - // Localized friendly description for the operation + // The short, localized friendly description of the operation; suitable for tool tips and detailed views. Description *string - // Localized friendly name for the operation + // The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", + // "Restart Virtual Machine". Operation *string - // Resource provider of the operation + // The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". Provider *string - // Resource of the operation + // The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". Resource *string } @@ -147,6 +175,9 @@ type OperationDisplay struct { // in Healthcare organizations to build and deploy their compliant, AI-powered virtual health // assistants and health bots, that help them improve processes and reduce costs. type Properties struct { + // KeyVault properties for the resource encryption. + KeyVaultProperties *KeyVaultProperties + // READ-ONLY; The link. BotManagementPortalLink *string @@ -154,18 +185,18 @@ type Properties struct { ProvisioningState *string } -// Resource - The resource model definition for a ARM tracked top level resource +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { - // READ-ONLY; Fully qualified resource Id for the resource. + // 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; Metadata pertaining to creation and last modification of the resource + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -175,16 +206,16 @@ type SKU struct { Name *SKUName } -// SystemData - Read only system data +// SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { - // The timestamp of resource creation (UTC) + // 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 *IdentityType + // The type of identity that created the resource. + CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) LastModifiedAt *time.Time @@ -192,11 +223,12 @@ type SystemData struct { // The identity that last modified the resource. LastModifiedBy *string - // The type of identity that last modified the resource - LastModifiedByType *IdentityType + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType } -// TrackedResource - The resource model definition for a ARM tracked top level resource +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' +// and a 'location' type TrackedResource struct { // REQUIRED; The geo-location where the resource lives Location *string @@ -204,16 +236,16 @@ type TrackedResource struct { // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource Id for the resource. + // 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; Metadata pertaining to creation and last modification of the resource + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -223,6 +255,9 @@ type UpdateParameters struct { Identity *Identity Location *string + // Properties of Azure Health Bot. + Properties *Properties + // SKU of the Azure Health Bot. SKU *SKU @@ -230,17 +265,11 @@ type UpdateParameters struct { Tags map[string]*string } -// UserAssignedIdentity - The details of the user assigned managed identity used by the Video Analyzer resource. +// UserAssignedIdentity - Represents a user-assigned identity. type UserAssignedIdentity struct { - // READ-ONLY; The client ID of user assigned identity. + // READ-ONLY; The client ID of the user-assigned identity. ClientID *string - // READ-ONLY; The principal ID of user assigned identity. + // READ-ONLY; The principal ID of the user-assigned identity. PrincipalID *string } - -// ValidationResult - The response returned from validation process -type ValidationResult struct { - // The status code of the response validation. - Status *string -} diff --git a/sdk/resourcemanager/healthbot/armhealthbot/models_serde.go b/sdk/resourcemanager/healthbot/armhealthbot/models_serde.go index 4f172e332718..3298e8f87410 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/models_serde.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/models_serde.go @@ -1,6 +1,3 @@ -//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. @@ -135,8 +132,8 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorError. -func (e ErrorError) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) @@ -146,8 +143,8 @@ func (e ErrorError) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorError. -func (e *ErrorError) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) 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) @@ -276,6 +273,103 @@ func (i *Identity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Key. +func (k Key) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyName", k.KeyName) + populate(objectMap, "value", k.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Key. +func (k *Key) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyName": + err = unpopulate(val, "KeyName", &k.KeyName) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &k.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultProperties. +func (k KeyVaultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyName", k.KeyName) + populate(objectMap, "keyVaultUri", k.KeyVaultURI) + populate(objectMap, "keyVersion", k.KeyVersion) + populate(objectMap, "userIdentity", k.UserIdentity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultProperties. +func (k *KeyVaultProperties) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyName": + err = unpopulate(val, "KeyName", &k.KeyName) + delete(rawMsg, key) + case "keyVaultUri": + err = unpopulate(val, "KeyVaultURI", &k.KeyVaultURI) + delete(rawMsg, key) + case "keyVersion": + err = unpopulate(val, "KeyVersion", &k.KeyVersion) + delete(rawMsg, key) + case "userIdentity": + err = unpopulate(val, "UserIdentity", &k.UserIdentity) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeysResponse. +func (k KeysResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "secrets", k.Secrets) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeysResponse. +func (k *KeysResponse) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "secrets": + err = unpopulate(val, "Secrets", &k.Secrets) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OperationDetail. func (o OperationDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -362,6 +456,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { func (p Properties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "botManagementPortalLink", p.BotManagementPortalLink) + populate(objectMap, "keyVaultProperties", p.KeyVaultProperties) populate(objectMap, "provisioningState", p.ProvisioningState) return json.Marshal(objectMap) } @@ -378,6 +473,9 @@ func (p *Properties) UnmarshalJSON(data []byte) error { case "botManagementPortalLink": err = unpopulate(val, "BotManagementPortalLink", &p.BotManagementPortalLink) delete(rawMsg, key) + case "keyVaultProperties": + err = unpopulate(val, "KeyVaultProperties", &p.KeyVaultProperties) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) delete(rawMsg, key) @@ -554,6 +652,7 @@ func (u UpdateParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "identity", u.Identity) populate(objectMap, "location", u.Location) + populate(objectMap, "properties", u.Properties) populate(objectMap, "sku", u.SKU) populate(objectMap, "tags", u.Tags) return json.Marshal(objectMap) @@ -574,6 +673,9 @@ func (u *UpdateParameters) UnmarshalJSON(data []byte) error { case "location": err = unpopulate(val, "Location", &u.Location) delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &u.Properties) + delete(rawMsg, key) case "sku": err = unpopulate(val, "SKU", &u.SKU) delete(rawMsg, key) @@ -619,33 +721,6 @@ func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ValidationResult. -func (v ValidationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "status", v.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ValidationResult. -func (v *ValidationResult) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "status": - err = unpopulate(val, "Status", &v.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - func populate(m map[string]any, k string, v any) { if v == nil { return @@ -667,7 +742,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/healthbot/armhealthbot/operations_client.go b/sdk/resourcemanager/healthbot/armhealthbot/operations_client.go index cabea3268918..495a143825f6 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/operations_client.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/operations_client.go @@ -1,6 +1,3 @@ -//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. @@ -39,7 +36,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all the available Azure Health Bot operations. // -// Generated from API version 2021-06-10 +// Generated from API version 2024-02-01 // - 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 +62,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.HealthBot/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", "2021-06-10") + reqQP.Set("api-version", "2024-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/healthbot/armhealthbot/operations_client_example_test.go b/sdk/resourcemanager/healthbot/armhealthbot/operations_client_example_test.go deleted file mode 100644 index 0036e3709f6b..000000000000 --- a/sdk/resourcemanager/healthbot/armhealthbot/operations_client_example_test.go +++ /dev/null @@ -1,76 +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 armhealthbot_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/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 := armhealthbot.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(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.AvailableOperations = armhealthbot.AvailableOperations{ - // Value: []*armhealthbot.OperationDetail{ - // { - // Name: to.Ptr("Microsoft.Healthbot/healthbots/read"), - // Display: &armhealthbot.OperationDisplay{ - // Description: to.Ptr("Read Azure Health Bot"), - // Operation: to.Ptr("Read Azure Health Bot"), - // Provider: to.Ptr("Azure Health Bot"), - // Resource: to.Ptr("Azure Health Bot"), - // }, - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.Healthbot/healthbots/write"), - // Display: &armhealthbot.OperationDisplay{ - // Description: to.Ptr("Writes Azure Health Bot"), - // Operation: to.Ptr("Write Azure Health Bot"), - // Provider: to.Ptr("Azure Health Bot"), - // Resource: to.Ptr("Azure Health Bot"), - // }, - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.Healthbot/healthbots/delete"), - // Display: &armhealthbot.OperationDisplay{ - // Description: to.Ptr("Deletes Azure Health Bot"), - // Operation: to.Ptr("Delete Azure Health Bot"), - // Provider: to.Ptr("Azure Health Bot"), - // Resource: to.Ptr("Azure Health Bot"), - // }, - // Origin: to.Ptr("user,system"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/healthbot/armhealthbot/options.go b/sdk/resourcemanager/healthbot/armhealthbot/options.go index 68bf9ed5c14d..5901198fc203 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/options.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/options.go @@ -1,6 +1,3 @@ -//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. @@ -10,13 +7,19 @@ package armhealthbot // BotsClientBeginCreateOptions contains the optional parameters for the BotsClient.BeginCreate method. type BotsClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // BotsClientBeginDeleteOptions contains the optional parameters for the BotsClient.BeginDelete method. type BotsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// BotsClientBeginUpdateOptions contains the optional parameters for the BotsClient.BeginUpdate method. +type BotsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -35,8 +38,13 @@ type BotsClientListOptions struct { // placeholder for future optional parameters } -// BotsClientUpdateOptions contains the optional parameters for the BotsClient.Update method. -type BotsClientUpdateOptions struct { +// BotsClientListSecretsOptions contains the optional parameters for the BotsClient.ListSecrets method. +type BotsClientListSecretsOptions struct { + // placeholder for future optional parameters +} + +// BotsClientRegenerateAPIJwtSecretOptions contains the optional parameters for the BotsClient.RegenerateAPIJwtSecret method. +type BotsClientRegenerateAPIJwtSecretOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/healthbot/armhealthbot/response_types.go b/sdk/resourcemanager/healthbot/armhealthbot/responses.go similarity index 77% rename from sdk/resourcemanager/healthbot/armhealthbot/response_types.go rename to sdk/resourcemanager/healthbot/armhealthbot/responses.go index df325804373d..40f9fb276aac 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/response_types.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/responses.go @@ -1,6 +1,3 @@ -//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. @@ -37,7 +34,19 @@ type BotsClientListResponse struct { BotResponseList } -// BotsClientUpdateResponse contains the response from method BotsClient.Update. +// BotsClientListSecretsResponse contains the response from method BotsClient.ListSecrets. +type BotsClientListSecretsResponse struct { + // Health Bot Keys Response. + KeysResponse +} + +// BotsClientRegenerateAPIJwtSecretResponse contains the response from method BotsClient.RegenerateAPIJwtSecret. +type BotsClientRegenerateAPIJwtSecretResponse struct { + // An entry of HealthBotKeysResponse + Key +} + +// BotsClientUpdateResponse contains the response from method BotsClient.BeginUpdate. type BotsClientUpdateResponse struct { // Azure Health Bot resource definition HealthBot @@ -45,6 +54,6 @@ type BotsClientUpdateResponse struct { // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { - // Available operations of the service + // Available operations of the service. AvailableOperations } diff --git a/sdk/resourcemanager/healthbot/armhealthbot/time_rfc3339.go b/sdk/resourcemanager/healthbot/armhealthbot/time_rfc3339.go index 8b9524094c70..0b04ef32a787 100644 --- a/sdk/resourcemanager/healthbot/armhealthbot/time_rfc3339.go +++ b/sdk/resourcemanager/healthbot/armhealthbot/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. @@ -19,12 +16,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 +41,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 +81,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 +98,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