diff --git a/profiles/latest/cognitiveservices/qnamaker/models.go b/profiles/latest/cognitiveservices/qnamaker/models.go index ce8833655e12..fefe9d56eef0 100644 --- a/profiles/latest/cognitiveservices/qnamaker/models.go +++ b/profiles/latest/cognitiveservices/qnamaker/models.go @@ -63,6 +63,7 @@ const ( Succeeded OperationStateType = original.Succeeded ) +type ActiveLearningSettingsDTO = original.ActiveLearningSettingsDTO type AlterationsClient = original.AlterationsClient type AlterationsDTO = original.AlterationsDTO type BaseClient = original.BaseClient @@ -72,6 +73,9 @@ type CreateKbInputDTO = original.CreateKbInputDTO type DeleteKbContentsDTO = original.DeleteKbContentsDTO type EndpointKeysClient = original.EndpointKeysClient type EndpointKeysDTO = original.EndpointKeysDTO +type EndpointSettingsClient = original.EndpointSettingsClient +type EndpointSettingsDTO = original.EndpointSettingsDTO +type EndpointSettingsDTOActiveLearning = original.EndpointSettingsDTOActiveLearning type Error = original.Error type ErrorResponse = original.ErrorResponse type ErrorResponseError = original.ErrorResponseError @@ -89,6 +93,7 @@ type QnADTO = original.QnADTO type QnADTOContext = original.QnADTOContext type QnADocumentsDTO = original.QnADocumentsDTO type ReplaceKbDTO = original.ReplaceKbDTO +type String = original.String type UpdateContextDTO = original.UpdateContextDTO type UpdateKbContentsDTO = original.UpdateKbContentsDTO type UpdateKbOperationDTO = original.UpdateKbOperationDTO @@ -112,6 +117,9 @@ func NewAlterationsClient(endpoint string) AlterationsClient { func NewEndpointKeysClient(endpoint string) EndpointKeysClient { return original.NewEndpointKeysClient(endpoint) } +func NewEndpointSettingsClient(endpoint string) EndpointSettingsClient { + return original.NewEndpointSettingsClient(endpoint) +} func NewKnowledgebaseClient(endpoint string) KnowledgebaseClient { return original.NewKnowledgebaseClient(endpoint) } diff --git a/profiles/latest/cognitiveservices/qnamaker/qnamakerapi/models.go b/profiles/latest/cognitiveservices/qnamaker/qnamakerapi/models.go index b1ca327587c4..012c60505bae 100644 --- a/profiles/latest/cognitiveservices/qnamaker/qnamakerapi/models.go +++ b/profiles/latest/cognitiveservices/qnamaker/qnamakerapi/models.go @@ -23,5 +23,6 @@ import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v4 type AlterationsClientAPI = original.AlterationsClientAPI type EndpointKeysClientAPI = original.EndpointKeysClientAPI +type EndpointSettingsClientAPI = original.EndpointSettingsClientAPI type KnowledgebaseClientAPI = original.KnowledgebaseClientAPI type OperationsClientAPI = original.OperationsClientAPI diff --git a/profiles/preview/cognitiveservices/qnamaker/models.go b/profiles/preview/cognitiveservices/qnamaker/models.go index d225e7a65b12..8c67cecde797 100644 --- a/profiles/preview/cognitiveservices/qnamaker/models.go +++ b/profiles/preview/cognitiveservices/qnamaker/models.go @@ -63,6 +63,7 @@ const ( Succeeded OperationStateType = original.Succeeded ) +type ActiveLearningSettingsDTO = original.ActiveLearningSettingsDTO type AlterationsClient = original.AlterationsClient type AlterationsDTO = original.AlterationsDTO type BaseClient = original.BaseClient @@ -72,6 +73,9 @@ type CreateKbInputDTO = original.CreateKbInputDTO type DeleteKbContentsDTO = original.DeleteKbContentsDTO type EndpointKeysClient = original.EndpointKeysClient type EndpointKeysDTO = original.EndpointKeysDTO +type EndpointSettingsClient = original.EndpointSettingsClient +type EndpointSettingsDTO = original.EndpointSettingsDTO +type EndpointSettingsDTOActiveLearning = original.EndpointSettingsDTOActiveLearning type Error = original.Error type ErrorResponse = original.ErrorResponse type ErrorResponseError = original.ErrorResponseError @@ -89,6 +93,7 @@ type QnADTO = original.QnADTO type QnADTOContext = original.QnADTOContext type QnADocumentsDTO = original.QnADocumentsDTO type ReplaceKbDTO = original.ReplaceKbDTO +type String = original.String type UpdateContextDTO = original.UpdateContextDTO type UpdateKbContentsDTO = original.UpdateKbContentsDTO type UpdateKbOperationDTO = original.UpdateKbOperationDTO @@ -112,6 +117,9 @@ func NewAlterationsClient(endpoint string) AlterationsClient { func NewEndpointKeysClient(endpoint string) EndpointKeysClient { return original.NewEndpointKeysClient(endpoint) } +func NewEndpointSettingsClient(endpoint string) EndpointSettingsClient { + return original.NewEndpointSettingsClient(endpoint) +} func NewKnowledgebaseClient(endpoint string) KnowledgebaseClient { return original.NewKnowledgebaseClient(endpoint) } diff --git a/profiles/preview/cognitiveservices/qnamaker/qnamakerapi/models.go b/profiles/preview/cognitiveservices/qnamaker/qnamakerapi/models.go index b1ca327587c4..012c60505bae 100644 --- a/profiles/preview/cognitiveservices/qnamaker/qnamakerapi/models.go +++ b/profiles/preview/cognitiveservices/qnamaker/qnamakerapi/models.go @@ -23,5 +23,6 @@ import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v4 type AlterationsClientAPI = original.AlterationsClientAPI type EndpointKeysClientAPI = original.EndpointKeysClientAPI +type EndpointSettingsClientAPI = original.EndpointSettingsClientAPI type KnowledgebaseClientAPI = original.KnowledgebaseClientAPI type OperationsClientAPI = original.OperationsClientAPI diff --git a/services/cognitiveservices/v4.0/qnamaker/endpointsettings.go b/services/cognitiveservices/v4.0/qnamaker/endpointsettings.go new file mode 100644 index 000000000000..2a54465b4bb3 --- /dev/null +++ b/services/cognitiveservices/v4.0/qnamaker/endpointsettings.go @@ -0,0 +1,172 @@ +package qnamaker + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" +) + +// EndpointSettingsClient is the an API for QnAMaker Service +type EndpointSettingsClient struct { + BaseClient +} + +// NewEndpointSettingsClient creates an instance of the EndpointSettingsClient client. +func NewEndpointSettingsClient(endpoint string) EndpointSettingsClient { + return EndpointSettingsClient{New(endpoint)} +} + +// GetSettings sends the get settings request. +func (client EndpointSettingsClient) GetSettings(ctx context.Context) (result EndpointSettingsDTO, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointSettingsClient.GetSettings") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetSettingsPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "qnamaker.EndpointSettingsClient", "GetSettings", nil, "Failure preparing request") + return + } + + resp, err := client.GetSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "qnamaker.EndpointSettingsClient", "GetSettings", resp, "Failure sending request") + return + } + + result, err = client.GetSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "qnamaker.EndpointSettingsClient", "GetSettings", resp, "Failure responding to request") + } + + return +} + +// GetSettingsPreparer prepares the GetSettings request. +func (client EndpointSettingsClient) GetSettingsPreparer(ctx context.Context) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/qnamaker/v4.0", urlParameters), + autorest.WithPath("/endpointSettings")) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSettingsSender sends the GetSettings request. The method will close the +// http.Response Body if it receives an error. +func (client EndpointSettingsClient) GetSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetSettingsResponder handles the response to the GetSettings request. The method always +// closes the http.Response Body. +func (client EndpointSettingsClient) GetSettingsResponder(resp *http.Response) (result EndpointSettingsDTO, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateSettings sends the update settings request. +// Parameters: +// endpointSettingsPayload - post body of the request. +func (client EndpointSettingsClient) UpdateSettings(ctx context.Context, endpointSettingsPayload EndpointSettingsDTO) (result String, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointSettingsClient.UpdateSettings") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateSettingsPreparer(ctx, endpointSettingsPayload) + if err != nil { + err = autorest.NewErrorWithError(err, "qnamaker.EndpointSettingsClient", "UpdateSettings", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "qnamaker.EndpointSettingsClient", "UpdateSettings", resp, "Failure sending request") + return + } + + result, err = client.UpdateSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "qnamaker.EndpointSettingsClient", "UpdateSettings", resp, "Failure responding to request") + } + + return +} + +// UpdateSettingsPreparer prepares the UpdateSettings request. +func (client EndpointSettingsClient) UpdateSettingsPreparer(ctx context.Context, endpointSettingsPayload EndpointSettingsDTO) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithCustomBaseURL("{Endpoint}/qnamaker/v4.0", urlParameters), + autorest.WithPath("/endpointSettings"), + autorest.WithJSON(endpointSettingsPayload)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSettingsSender sends the UpdateSettings request. The method will close the +// http.Response Body if it receives an error. +func (client EndpointSettingsClient) UpdateSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateSettingsResponder handles the response to the UpdateSettings request. The method always +// closes the http.Response Body. +func (client EndpointSettingsClient) UpdateSettingsResponder(resp *http.Response) (result String, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cognitiveservices/v4.0/qnamaker/models.go b/services/cognitiveservices/v4.0/qnamaker/models.go index fd8bd2199bb3..bf4f36a94223 100644 --- a/services/cognitiveservices/v4.0/qnamaker/models.go +++ b/services/cognitiveservices/v4.0/qnamaker/models.go @@ -112,6 +112,12 @@ func PossibleOperationStateTypeValues() []OperationStateType { return []OperationStateType{Failed, NotStarted, Running, Succeeded} } +// ActiveLearningSettingsDTO active Learning settings of the endpoint. +type ActiveLearningSettingsDTO struct { + // Enable - True/False string providing Active Learning + Enable *string `json:"enable,omitempty"` +} + // AlterationsDTO collection of words that are synonyms. type AlterationsDTO struct { // Alterations - Words that are synonymous with each other. @@ -171,6 +177,19 @@ type EndpointKeysDTO struct { LastStableVersion *string `json:"lastStableVersion,omitempty"` } +// EndpointSettingsDTO endpoint settings. +type EndpointSettingsDTO struct { + autorest.Response `json:"-"` + // ActiveLearning - Active Learning settings of the endpoint. + ActiveLearning *EndpointSettingsDTOActiveLearning `json:"activeLearning,omitempty"` +} + +// EndpointSettingsDTOActiveLearning active Learning settings of the endpoint. +type EndpointSettingsDTOActiveLearning struct { + // Enable - True/False string providing Active Learning + Enable *string `json:"enable,omitempty"` +} + // Error the error object. As per Microsoft One API guidelines - // https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. type Error struct { @@ -349,6 +368,12 @@ type ReplaceKbDTO struct { QnAList *[]QnADTO `json:"qnAList,omitempty"` } +// String ... +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` +} + // UpdateContextDTO update Body schema to represent context to be updated type UpdateContextDTO struct { // PromptsToDelete - List of prompts associated with qna to be deleted diff --git a/services/cognitiveservices/v4.0/qnamaker/qnamakerapi/interfaces.go b/services/cognitiveservices/v4.0/qnamaker/qnamakerapi/interfaces.go index 92f65896560a..04ab3aa23b3d 100644 --- a/services/cognitiveservices/v4.0/qnamaker/qnamakerapi/interfaces.go +++ b/services/cognitiveservices/v4.0/qnamaker/qnamakerapi/interfaces.go @@ -23,6 +23,14 @@ import ( "github.com/Azure/go-autorest/autorest" ) +// EndpointSettingsClientAPI contains the set of methods on the EndpointSettingsClient type. +type EndpointSettingsClientAPI interface { + GetSettings(ctx context.Context) (result qnamaker.EndpointSettingsDTO, err error) + UpdateSettings(ctx context.Context, endpointSettingsPayload qnamaker.EndpointSettingsDTO) (result qnamaker.String, err error) +} + +var _ EndpointSettingsClientAPI = (*qnamaker.EndpointSettingsClient)(nil) + // EndpointKeysClientAPI contains the set of methods on the EndpointKeysClient type. type EndpointKeysClientAPI interface { GetKeys(ctx context.Context) (result qnamaker.EndpointKeysDTO, err error)