From a89342c3f905cda822bcfd7ed2b128448d70686d Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Fri, 9 Oct 2020 18:04:37 +0000 Subject: [PATCH] Generated from e29b0e04e7f0651323c6e67c5cf1eb81c2853ed5 --- .../v4.0/qnamaker/endpointsettings.go | 15 ++++++------- .../v4.0/qnamaker/knowledgebase.go | 22 +++++++++++++++---- .../cognitiveservices/v4.0/qnamaker/models.go | 8 +------ .../v4.0/qnamaker/qnamakerapi/interfaces.go | 4 ++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/services/cognitiveservices/v4.0/qnamaker/endpointsettings.go b/services/cognitiveservices/v4.0/qnamaker/endpointsettings.go index 8d43cafa21ec..61a0dc5f49ff 100644 --- a/services/cognitiveservices/v4.0/qnamaker/endpointsettings.go +++ b/services/cognitiveservices/v4.0/qnamaker/endpointsettings.go @@ -102,13 +102,13 @@ func (client EndpointSettingsClient) GetSettingsResponder(resp *http.Response) ( // 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) { +func (client EndpointSettingsClient) UpdateSettings(ctx context.Context, endpointSettingsPayload EndpointSettingsDTO) (result autorest.Response, 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 + if result.Response != nil { + sc = result.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -121,7 +121,7 @@ func (client EndpointSettingsClient) UpdateSettings(ctx context.Context, endpoin resp, err := client.UpdateSettingsSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.Response = resp err = autorest.NewErrorWithError(err, "qnamaker.EndpointSettingsClient", "UpdateSettings", resp, "Failure sending request") return } @@ -157,12 +157,11 @@ func (client EndpointSettingsClient) UpdateSettingsSender(req *http.Request) (*h // 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) { +func (client EndpointSettingsClient) UpdateSettingsResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Value), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} + result.Response = resp return } diff --git a/services/cognitiveservices/v4.0/qnamaker/knowledgebase.go b/services/cognitiveservices/v4.0/qnamaker/knowledgebase.go index 480700e4ef6b..1407c67b460e 100644 --- a/services/cognitiveservices/v4.0/qnamaker/knowledgebase.go +++ b/services/cognitiveservices/v4.0/qnamaker/knowledgebase.go @@ -194,7 +194,12 @@ func (client KnowledgebaseClient) DeleteResponder(resp *http.Response) (result a // Parameters: // kbID - knowledgebase id. // environment - specifies whether environment is Test or Prod. -func (client KnowledgebaseClient) Download(ctx context.Context, kbID string, environment EnvironmentType) (result QnADocumentsDTO, err error) { +// source - the source property filter to apply. Sample value: Editorial, smartLight%20FAQ.tsv . +// changedSince - changedSince property is used to return all QnAs created or updated after a specific time +// duration. The user can filter QnAs by seconds (s), minutes (m), hours (h) and days (d). The user may use any +// integral value along with the suffix for time. For instance, the value of 5m returns all QnA pairs updated +// or created in the last 5 minutes. +func (client KnowledgebaseClient) Download(ctx context.Context, kbID string, environment EnvironmentType, source string, changedSince string) (result QnADocumentsDTO, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/KnowledgebaseClient.Download") defer func() { @@ -205,7 +210,7 @@ func (client KnowledgebaseClient) Download(ctx context.Context, kbID string, env tracing.EndSpan(ctx, sc, err) }() } - req, err := client.DownloadPreparer(ctx, kbID, environment) + req, err := client.DownloadPreparer(ctx, kbID, environment, source, changedSince) if err != nil { err = autorest.NewErrorWithError(err, "qnamaker.KnowledgebaseClient", "Download", nil, "Failure preparing request") return @@ -227,7 +232,7 @@ func (client KnowledgebaseClient) Download(ctx context.Context, kbID string, env } // DownloadPreparer prepares the Download request. -func (client KnowledgebaseClient) DownloadPreparer(ctx context.Context, kbID string, environment EnvironmentType) (*http.Request, error) { +func (client KnowledgebaseClient) DownloadPreparer(ctx context.Context, kbID string, environment EnvironmentType, source string, changedSince string) (*http.Request, error) { urlParameters := map[string]interface{}{ "Endpoint": client.Endpoint, } @@ -237,10 +242,19 @@ func (client KnowledgebaseClient) DownloadPreparer(ctx context.Context, kbID str "kbId": autorest.Encode("path", kbID), } + queryParameters := map[string]interface{}{} + if len(source) > 0 { + queryParameters["source"] = autorest.Encode("query", source) + } + if len(changedSince) > 0 { + queryParameters["changedSince"] = autorest.Encode("query", changedSince) + } + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithCustomBaseURL("{Endpoint}/qnamaker/v4.0", urlParameters), - autorest.WithPathParameters("/knowledgebases/{kbId}/{environment}/qna", pathParameters)) + autorest.WithPathParameters("/knowledgebases/{kbId}/{environment}/qna", pathParameters), + autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } diff --git a/services/cognitiveservices/v4.0/qnamaker/models.go b/services/cognitiveservices/v4.0/qnamaker/models.go index 50b6c121208d..610f00209cb7 100644 --- a/services/cognitiveservices/v4.0/qnamaker/models.go +++ b/services/cognitiveservices/v4.0/qnamaker/models.go @@ -60,7 +60,7 @@ type CreateKbDTO struct { EnableHierarchicalExtraction *bool `json:"enableHierarchicalExtraction,omitempty"` // DefaultAnswerUsedForExtraction - Text string to be used as the answer in any Q-A which has no extracted answer from the document but has a hierarchy. Required when EnableHierarchicalExtraction field is set to True. DefaultAnswerUsedForExtraction *string `json:"defaultAnswerUsedForExtraction,omitempty"` - // Language - Language of the knowledgebase. + // Language - Language of the knowledgebase. Please find the list of supported languages here. Language *string `json:"language,omitempty"` } @@ -288,12 +288,6 @@ 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 04ab3aa23b3d..6f5a11c0e638 100644 --- a/services/cognitiveservices/v4.0/qnamaker/qnamakerapi/interfaces.go +++ b/services/cognitiveservices/v4.0/qnamaker/qnamakerapi/interfaces.go @@ -26,7 +26,7 @@ import ( // 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) + UpdateSettings(ctx context.Context, endpointSettingsPayload qnamaker.EndpointSettingsDTO) (result autorest.Response, err error) } var _ EndpointSettingsClientAPI = (*qnamaker.EndpointSettingsClient)(nil) @@ -51,7 +51,7 @@ var _ AlterationsClientAPI = (*qnamaker.AlterationsClient)(nil) type KnowledgebaseClientAPI interface { Create(ctx context.Context, createKbPayload qnamaker.CreateKbDTO) (result qnamaker.Operation, err error) Delete(ctx context.Context, kbID string) (result autorest.Response, err error) - Download(ctx context.Context, kbID string, environment qnamaker.EnvironmentType) (result qnamaker.QnADocumentsDTO, err error) + Download(ctx context.Context, kbID string, environment qnamaker.EnvironmentType, source string, changedSince string) (result qnamaker.QnADocumentsDTO, err error) GetDetails(ctx context.Context, kbID string) (result qnamaker.KnowledgebaseDTO, err error) ListAll(ctx context.Context) (result qnamaker.KnowledgebasesDTO, err error) Publish(ctx context.Context, kbID string) (result autorest.Response, err error)