From fd82c22ed7eac568bdedc591e90ded4f7fd5dcc9 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 14 Jul 2021 09:21:13 +0000 Subject: [PATCH] CodeGen from PR 14787 in Azure/azure-rest-api-specs Azure Health Bot MSI support (#14787) * Azure Health Bot - copy the existing version into new directory structure. * Azure Health Bot - Updates for new API, including: 1. Azure Health Bot MSI support in API 2021-06-10. 2. Examples fixes. 3. Azure Health Bot naming (not Microsoft Healthcare Bot). --- .../mgmt/2020-12-08/healthbot/CHANGELOG.md | 11 +- .../mgmt/2020-12-08/healthbot/_meta.json | 2 +- .../mgmt/2021-06-10/healthbot/CHANGELOG.md | 2 + .../mgmt/2021-06-10/healthbot/_meta.json | 11 + .../mgmt/2021-06-10/healthbot/bots.go | 634 ++++++++++++++++ .../mgmt/2021-06-10/healthbot/client.go | 42 ++ .../mgmt/2021-06-10/healthbot/enums.go | 62 ++ .../healthbot/healthbotapi/interfaces.go | 34 + .../mgmt/2021-06-10/healthbot/models.go | 689 ++++++++++++++++++ .../mgmt/2021-06-10/healthbot/operations.go | 142 ++++ .../mgmt/2021-06-10/healthbot/version.go | 19 + 11 files changed, 1637 insertions(+), 11 deletions(-) create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/CHANGELOG.md create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/_meta.json create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/bots.go create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/client.go create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/enums.go create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/healthbotapi/interfaces.go create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/models.go create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/operations.go create mode 100644 services/healthbot/mgmt/2021-06-10/healthbot/version.go diff --git a/services/healthbot/mgmt/2020-12-08/healthbot/CHANGELOG.md b/services/healthbot/mgmt/2020-12-08/healthbot/CHANGELOG.md index a9bc3b11ce8f..a1ecf841edb0 100644 --- a/services/healthbot/mgmt/2020-12-08/healthbot/CHANGELOG.md +++ b/services/healthbot/mgmt/2020-12-08/healthbot/CHANGELOG.md @@ -1,11 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### New Funcs - -1. BotResponseList.MarshalJSON() ([]byte, error) -1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) -1. ErrorError.MarshalJSON() ([]byte, error) -1. Properties.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) diff --git a/services/healthbot/mgmt/2020-12-08/healthbot/_meta.json b/services/healthbot/mgmt/2020-12-08/healthbot/_meta.json index 3f4415123075..b6857a877e97 100644 --- a/services/healthbot/mgmt/2020-12-08/healthbot/_meta.json +++ b/services/healthbot/mgmt/2020-12-08/healthbot/_meta.json @@ -1,5 +1,5 @@ { - "commit": "4c93f28f89435f6d244f4db61bbf810b5d20f09f", + "commit": "10873ac628ee703126f82974487d8a290e983f8c", "readme": "/_/azure-rest-api-specs/specification/healthbot/resource-manager/readme.md", "tag": "package-2020-12-08", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/CHANGELOG.md b/services/healthbot/mgmt/2021-06-10/healthbot/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/_meta.json b/services/healthbot/mgmt/2021-06-10/healthbot/_meta.json new file mode 100644 index 000000000000..44e69a5ac206 --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "10873ac628ee703126f82974487d8a290e983f8c", + "readme": "/_/azure-rest-api-specs/specification/healthbot/resource-manager/readme.md", + "tag": "package-2021-06-10", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-06-10 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/healthbot/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/bots.go b/services/healthbot/mgmt/2021-06-10/healthbot/bots.go new file mode 100644 index 000000000000..551159ec5453 --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/bots.go @@ -0,0 +1,634 @@ +package healthbot + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// BotsClient is the azure Health Bot is a cloud platform that empowers developers 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 BotsClient struct { + BaseClient +} + +// NewBotsClient creates an instance of the BotsClient client. +func NewBotsClient(subscriptionID string) BotsClient { + return NewBotsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBotsClientWithBaseURI creates an instance of the BotsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBotsClientWithBaseURI(baseURI string, subscriptionID string) BotsClient { + return BotsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a new Azure Health Bot. +// Parameters: +// resourceGroupName - the name of the Bot resource group in the user subscription. +// botName - the name of the Bot resource. +// parameters - the parameters to provide for the created Azure Health Bot. +func (client BotsClient) Create(ctx context.Context, resourceGroupName string, botName string, parameters HealthBot) (result BotsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotsClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: botName, + Constraints: []validation.Constraint{{Target: "botName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "botName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "botName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthbot.BotsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, botName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client BotsClient) CreatePreparer(ctx context.Context, resourceGroupName string, botName string, parameters HealthBot) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "botName": autorest.Encode("path", botName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client BotsClient) CreateSender(req *http.Request) (future BotsCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client BotsClient) CreateResponder(resp *http.Response) (result HealthBot, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a HealthBot. +// Parameters: +// resourceGroupName - the name of the Bot resource group in the user subscription. +// botName - the name of the Bot resource. +func (client BotsClient) Delete(ctx context.Context, resourceGroupName string, botName string) (result BotsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: botName, + Constraints: []validation.Constraint{{Target: "botName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "botName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "botName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthbot.BotsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, botName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client BotsClient) DeletePreparer(ctx context.Context, resourceGroupName string, botName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "botName": autorest.Encode("path", botName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BotsClient) DeleteSender(req *http.Request) (future BotsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BotsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a HealthBot. +// Parameters: +// resourceGroupName - the name of the Bot resource group in the user subscription. +// botName - the name of the Bot resource. +func (client BotsClient) Get(ctx context.Context, resourceGroupName string, botName string) (result HealthBot, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: botName, + Constraints: []validation.Constraint{{Target: "botName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "botName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "botName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthbot.BotsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, botName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BotsClient) GetPreparer(ctx context.Context, resourceGroupName string, botName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "botName": autorest.Encode("path", botName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BotsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BotsClient) GetResponder(resp *http.Response) (result HealthBot, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List returns all the resources of a particular type belonging to a subscription. +func (client BotsClient) List(ctx context.Context) (result BotResponseListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotsClient.List") + defer func() { + sc := -1 + if result.brl.Response.Response != nil { + sc = result.brl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.brl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "List", resp, "Failure sending request") + return + } + + result.brl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "List", resp, "Failure responding to request") + return + } + if result.brl.hasNextLink() && result.brl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client BotsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client BotsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client BotsClient) ListResponder(resp *http.Response) (result BotResponseList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client BotsClient) listNextResults(ctx context.Context, lastResults BotResponseList) (result BotResponseList, err error) { + req, err := lastResults.botResponseListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthbot.BotsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthbot.BotsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client BotsClient) ListComplete(ctx context.Context) (result BotResponseListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup returns all the resources of a particular type belonging to a resource group +// Parameters: +// resourceGroupName - the name of the Bot resource group in the user subscription. +func (client BotsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result BotResponseListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.brl.Response.Response != nil { + sc = result.brl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthbot.BotsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.brl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.brl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.brl.hasNextLink() && result.brl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client BotsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client BotsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client BotsClient) ListByResourceGroupResponder(resp *http.Response) (result BotResponseList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client BotsClient) listByResourceGroupNextResults(ctx context.Context, lastResults BotResponseList) (result BotResponseList, err error) { + req, err := lastResults.botResponseListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthbot.BotsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthbot.BotsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client BotsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result BotResponseListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update patch a HealthBot. +// Parameters: +// resourceGroupName - the name of the Bot resource group in the user subscription. +// botName - the name of the Bot resource. +// parameters - the parameters to provide for the required Azure Health Bot. +func (client BotsClient) Update(ctx context.Context, resourceGroupName string, botName string, parameters UpdateParameters) (result HealthBot, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: botName, + Constraints: []validation.Constraint{{Target: "botName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "botName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "botName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthbot.BotsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, botName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client BotsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, botName string, parameters UpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "botName": autorest.Encode("path", botName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client BotsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client BotsClient) UpdateResponder(resp *http.Response) (result HealthBot, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/client.go b/services/healthbot/mgmt/2021-06-10/healthbot/client.go new file mode 100644 index 000000000000..078472c4c498 --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/client.go @@ -0,0 +1,42 @@ +// Package healthbot implements the Azure ARM Healthbot service API version 2021-06-10. +// +// Azure Health Bot is a cloud platform that empowers developers 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. +package healthbot + +// 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Healthbot + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Healthbot. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/enums.go b/services/healthbot/mgmt/2021-06-10/healthbot/enums.go new file mode 100644 index 000000000000..6b521f867978 --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/enums.go @@ -0,0 +1,62 @@ +package healthbot + +// 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. + +// IdentityType enumerates the values for identity type. +type IdentityType string + +const ( + // Application ... + Application IdentityType = "Application" + // Key ... + Key IdentityType = "Key" + // ManagedIdentity ... + ManagedIdentity IdentityType = "ManagedIdentity" + // User ... + User IdentityType = "User" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{Application, Key, ManagedIdentity, User} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // None ... + None ResourceIdentityType = "None" + // SystemAssigned ... + SystemAssigned ResourceIdentityType = "SystemAssigned" + // SystemAssignedUserAssigned ... + SystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned, UserAssigned" + // UserAssigned ... + UserAssigned ResourceIdentityType = "UserAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{None, SystemAssigned, SystemAssignedUserAssigned, UserAssigned} +} + +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // C0 ... + C0 SkuName = "C0" + // F0 ... + F0 SkuName = "F0" + // S1 ... + S1 SkuName = "S1" +) + +// PossibleSkuNameValues returns an array of possible values for the SkuName const type. +func PossibleSkuNameValues() []SkuName { + return []SkuName{C0, F0, S1} +} diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/healthbotapi/interfaces.go b/services/healthbot/mgmt/2021-06-10/healthbot/healthbotapi/interfaces.go new file mode 100644 index 000000000000..79aafcc9fcae --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/healthbotapi/interfaces.go @@ -0,0 +1,34 @@ +package healthbotapi + +// 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/healthbot/mgmt/2021-06-10/healthbot" +) + +// BotsClientAPI contains the set of methods on the BotsClient type. +type BotsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, botName string, parameters healthbot.HealthBot) (result healthbot.BotsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, botName string) (result healthbot.BotsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, botName string) (result healthbot.HealthBot, err error) + List(ctx context.Context) (result healthbot.BotResponseListPage, err error) + ListComplete(ctx context.Context) (result healthbot.BotResponseListIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result healthbot.BotResponseListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result healthbot.BotResponseListIterator, err error) + Update(ctx context.Context, resourceGroupName string, botName string, parameters healthbot.UpdateParameters) (result healthbot.HealthBot, err error) +} + +var _ BotsClientAPI = (*healthbot.BotsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result healthbot.AvailableOperationsPage, err error) + ListComplete(ctx context.Context) (result healthbot.AvailableOperationsIterator, err error) +} + +var _ OperationsClientAPI = (*healthbot.OperationsClient)(nil) diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/models.go b/services/healthbot/mgmt/2021-06-10/healthbot/models.go new file mode 100644 index 000000000000..d14a713c3563 --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/models.go @@ -0,0 +1,689 @@ +package healthbot + +// 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/healthbot/mgmt/2021-06-10/healthbot" + +// AvailableOperations available operations of the service +type AvailableOperations struct { + autorest.Response `json:"-"` + // Value - Collection of available operation details + Value *[]OperationDetail `json:"value,omitempty"` + // NextLink - URL client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// AvailableOperationsIterator provides access to a complete listing of OperationDetail values. +type AvailableOperationsIterator struct { + i int + page AvailableOperationsPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AvailableOperationsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AvailableOperationsIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AvailableOperationsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AvailableOperationsIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AvailableOperationsIterator) Response() AvailableOperations { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AvailableOperationsIterator) Value() OperationDetail { + if !iter.page.NotDone() { + return OperationDetail{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AvailableOperationsIterator type. +func NewAvailableOperationsIterator(page AvailableOperationsPage) AvailableOperationsIterator { + return AvailableOperationsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ao AvailableOperations) IsEmpty() bool { + return ao.Value == nil || len(*ao.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ao AvailableOperations) hasNextLink() bool { + return ao.NextLink != nil && len(*ao.NextLink) != 0 +} + +// availableOperationsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ao AvailableOperations) availableOperationsPreparer(ctx context.Context) (*http.Request, error) { + if !ao.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ao.NextLink))) +} + +// AvailableOperationsPage contains a page of OperationDetail values. +type AvailableOperationsPage struct { + fn func(context.Context, AvailableOperations) (AvailableOperations, error) + ao AvailableOperations +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AvailableOperationsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AvailableOperationsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ao) + if err != nil { + return err + } + page.ao = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AvailableOperationsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AvailableOperationsPage) NotDone() bool { + return !page.ao.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AvailableOperationsPage) Response() AvailableOperations { + return page.ao +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AvailableOperationsPage) Values() []OperationDetail { + if page.ao.IsEmpty() { + return nil + } + return *page.ao.Value +} + +// Creates a new instance of the AvailableOperationsPage type. +func NewAvailableOperationsPage(cur AvailableOperations, getNextPage func(context.Context, AvailableOperations) (AvailableOperations, error)) AvailableOperationsPage { + return AvailableOperationsPage{ + fn: getNextPage, + ao: cur, + } +} + +// BotResponseList the list of Azure Health Bot operation response. +type BotResponseList struct { + autorest.Response `json:"-"` + // NextLink - READ-ONLY; The link used to get the next page of bot service resources. + NextLink *string `json:"nextLink,omitempty"` + // Value - READ-ONLY; Gets the list of Azure Health Bot results and their properties. + Value *[]HealthBot `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for BotResponseList. +func (brl BotResponseList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// BotResponseListIterator provides access to a complete listing of HealthBot values. +type BotResponseListIterator struct { + i int + page BotResponseListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *BotResponseListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotResponseListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *BotResponseListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter BotResponseListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter BotResponseListIterator) Response() BotResponseList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter BotResponseListIterator) Value() HealthBot { + if !iter.page.NotDone() { + return HealthBot{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the BotResponseListIterator type. +func NewBotResponseListIterator(page BotResponseListPage) BotResponseListIterator { + return BotResponseListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (brl BotResponseList) IsEmpty() bool { + return brl.Value == nil || len(*brl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (brl BotResponseList) hasNextLink() bool { + return brl.NextLink != nil && len(*brl.NextLink) != 0 +} + +// botResponseListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (brl BotResponseList) botResponseListPreparer(ctx context.Context) (*http.Request, error) { + if !brl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(brl.NextLink))) +} + +// BotResponseListPage contains a page of HealthBot values. +type BotResponseListPage struct { + fn func(context.Context, BotResponseList) (BotResponseList, error) + brl BotResponseList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *BotResponseListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BotResponseListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.brl) + if err != nil { + return err + } + page.brl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *BotResponseListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page BotResponseListPage) NotDone() bool { + return !page.brl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page BotResponseListPage) Response() BotResponseList { + return page.brl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page BotResponseListPage) Values() []HealthBot { + if page.brl.IsEmpty() { + return nil + } + return *page.brl.Value +} + +// Creates a new instance of the BotResponseListPage type. +func NewBotResponseListPage(cur BotResponseList, getNextPage func(context.Context, BotResponseList) (BotResponseList, error)) BotResponseListPage { + return BotResponseListPage{ + fn: getNextPage, + brl: cur, + } +} + +// BotsCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type BotsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BotsClient) (HealthBot, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BotsCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BotsCreateFuture.Result. +func (future *BotsCreateFuture) result(client BotsClient) (hb HealthBot, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + hb.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthbot.BotsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if hb.Response.Response, err = future.GetResult(sender); err == nil && hb.Response.Response.StatusCode != http.StatusNoContent { + hb, err = client.CreateResponder(hb.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsCreateFuture", "Result", hb.Response.Response, "Failure responding to request") + } + } + return +} + +// BotsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type BotsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BotsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BotsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BotsDeleteFuture.Result. +func (future *BotsDeleteFuture) result(client BotsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.BotsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthbot.BotsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// Error the resource management error response. +type Error struct { + // Error - The error object. + Error *ErrorError `json:"error,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorError the error object. +type ErrorError struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]Error `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorError. +func (e ErrorError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// HealthBot azure Health Bot resource definition +type HealthBot struct { + autorest.Response `json:"-"` + // Sku - SKU of the Azure Health Bot. + Sku *Sku `json:"sku,omitempty"` + // Identity - The identity of the Azure Health Bot. + Identity *Identity `json:"identity,omitempty"` + // Properties - The set of properties specific to Azure Health Bot resource. + Properties *Properties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for HealthBot. +func (hb HealthBot) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hb.Sku != nil { + objectMap["sku"] = hb.Sku + } + if hb.Identity != nil { + objectMap["identity"] = hb.Identity + } + if hb.Properties != nil { + objectMap["properties"] = hb.Properties + } + if hb.Tags != nil { + objectMap["tags"] = hb.Tags + } + if hb.Location != nil { + objectMap["location"] = hb.Location + } + return json.Marshal(objectMap) +} + +// Identity identity for the resource. +type Identity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. This property will only be provided for a system assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the Azure Health Bot. Possible values include: 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned', 'None' + Type ResourceIdentityType `json:"type,omitempty"` + // UserAssignedIdentities - The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities"` +} + +// MarshalJSON is the custom marshaler for Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.Type != "" { + objectMap["type"] = i.Type + } + if i.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = i.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// OperationDetail operation detail payload +type OperationDetail struct { + // Name - Name of the operation + Name *string `json:"name,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - Display of the operation + Display *OperationDisplay `json:"display,omitempty"` + // Origin - Origin of the operation + Origin *string `json:"origin,omitempty"` + // Properties - Additional properties. + Properties interface{} `json:"properties,omitempty"` +} + +// OperationDisplay operation display payload +type OperationDisplay struct { + // Provider - Resource provider of the operation + Provider *string `json:"provider,omitempty"` + // Resource - Resource of the operation + Resource *string `json:"resource,omitempty"` + // Operation - Localized friendly name for the operation + Operation *string `json:"operation,omitempty"` + // Description - Localized friendly description for the operation + Description *string `json:"description,omitempty"` +} + +// Properties the properties of a Azure Health Bot. The Health Bot Service is a cloud platform that +// empowers developers 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 { + // ProvisioningState - READ-ONLY; The provisioning state of the Azure Health Bot resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // BotManagementPortalLink - READ-ONLY; The link. + BotManagementPortalLink *string `json:"botManagementPortalLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource the resource model definition for a ARM tracked top level resource +type Resource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Sku the resource model definition representing SKU +type Sku struct { + // Name - The name of the Azure Health Bot SKU. Possible values include: 'F0', 'S1', 'C0' + Name SkuName `json:"name,omitempty"` +} + +// SystemData read only system data +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType IdentityType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC) + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType IdentityType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// UpdateParameters parameters for updating a Azure Health Bot. +type UpdateParameters struct { + // Tags - Tags for a Azure Health Bot. + Tags map[string]*string `json:"tags"` + // Sku - SKU of the Azure Health Bot. + Sku *Sku `json:"sku,omitempty"` + // Identity - The identity of the Azure Health Bot. + Identity *Identity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for UpdateParameters. +func (up UpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if up.Tags != nil { + objectMap["tags"] = up.Tags + } + if up.Sku != nil { + objectMap["sku"] = up.Sku + } + if up.Identity != nil { + objectMap["identity"] = up.Identity + } + return json.Marshal(objectMap) +} + +// UserAssignedIdentity the details of the user assigned managed identity used by the Video Analyzer +// resource. +type UserAssignedIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of user assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The client ID of user assigned identity. + ClientID *string `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserAssignedIdentity. +func (uai UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ValidationResult the response returned from validation process +type ValidationResult struct { + // Status - The status code of the response validation. + Status *string `json:"status,omitempty"` +} diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/operations.go b/services/healthbot/mgmt/2021-06-10/healthbot/operations.go new file mode 100644 index 000000000000..1cc819e56de0 --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/operations.go @@ -0,0 +1,142 @@ +package healthbot + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the azure Health Bot is a cloud platform that empowers developers 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 OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all the available Azure Health Bot operations. +func (client OperationsClient) List(ctx context.Context) (result AvailableOperationsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ao.Response.Response != nil { + sc = result.ao.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ao.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthbot.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ao, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.ao.hasNextLink() && result.ao.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.HealthBot/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result AvailableOperations, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults AvailableOperations) (result AvailableOperations, err error) { + req, err := lastResults.availableOperationsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthbot.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthbot.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthbot.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result AvailableOperationsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/healthbot/mgmt/2021-06-10/healthbot/version.go b/services/healthbot/mgmt/2021-06-10/healthbot/version.go new file mode 100644 index 000000000000..848cacc5e5d2 --- /dev/null +++ b/services/healthbot/mgmt/2021-06-10/healthbot/version.go @@ -0,0 +1,19 @@ +package healthbot + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " healthbot/2021-06-10" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}