diff --git a/profiles/latest/cognitiveservices/qnamakerruntime/models.go b/profiles/latest/cognitiveservices/qnamakerruntime/models.go new file mode 100644 index 000000000000..b73874a95dfc --- /dev/null +++ b/profiles/latest/cognitiveservices/qnamakerruntime/models.go @@ -0,0 +1,81 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package qnamakerruntime + +import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v4.0/qnamakerruntime" + +type ErrorCodeType = original.ErrorCodeType + +const ( + BadArgument ErrorCodeType = original.BadArgument + EndpointKeysError ErrorCodeType = original.EndpointKeysError + ExtractionFailure ErrorCodeType = original.ExtractionFailure + Forbidden ErrorCodeType = original.Forbidden + KbNotFound ErrorCodeType = original.KbNotFound + NotFound ErrorCodeType = original.NotFound + OperationNotFound ErrorCodeType = original.OperationNotFound + QnaRuntimeError ErrorCodeType = original.QnaRuntimeError + QuotaExceeded ErrorCodeType = original.QuotaExceeded + ServiceError ErrorCodeType = original.ServiceError + SKULimitExceeded ErrorCodeType = original.SKULimitExceeded + Unauthorized ErrorCodeType = original.Unauthorized + Unspecified ErrorCodeType = original.Unspecified + ValidationFailure ErrorCodeType = original.ValidationFailure +) + +type BaseClient = original.BaseClient +type ContextDTO = original.ContextDTO +type Error = original.Error +type ErrorResponse = original.ErrorResponse +type ErrorResponseError = original.ErrorResponseError +type FeedbackRecordDTO = original.FeedbackRecordDTO +type FeedbackRecordsDTO = original.FeedbackRecordsDTO +type InnerErrorModel = original.InnerErrorModel +type MetadataDTO = original.MetadataDTO +type PromptDTO = original.PromptDTO +type PromptDTOQna = original.PromptDTOQna +type QnADTO = original.QnADTO +type QnADTOContext = original.QnADTOContext +type QnASearchResult = original.QnASearchResult +type QnASearchResultContext = original.QnASearchResultContext +type QnASearchResultList = original.QnASearchResultList +type QueryContextDTO = original.QueryContextDTO +type QueryDTO = original.QueryDTO +type QueryDTOContext = original.QueryDTOContext +type RuntimeClient = original.RuntimeClient + +func New(runtimeEndpoint string) BaseClient { + return original.New(runtimeEndpoint) +} +func NewRuntimeClient(runtimeEndpoint string) RuntimeClient { + return original.NewRuntimeClient(runtimeEndpoint) +} +func NewWithoutDefaults(runtimeEndpoint string) BaseClient { + return original.NewWithoutDefaults(runtimeEndpoint) +} +func PossibleErrorCodeTypeValues() []ErrorCodeType { + return original.PossibleErrorCodeTypeValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/latest" +} +func Version() string { + return original.Version() +} diff --git a/profiles/latest/cognitiveservices/qnamakerruntime/qnamakerruntimeapi/models.go b/profiles/latest/cognitiveservices/qnamakerruntime/qnamakerruntimeapi/models.go new file mode 100644 index 000000000000..b2f6ac1d9100 --- /dev/null +++ b/profiles/latest/cognitiveservices/qnamakerruntime/qnamakerruntimeapi/models.go @@ -0,0 +1,24 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package qnamakerruntimeapi + +import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v4.0/qnamakerruntime/qnamakerruntimeapi" + +type RuntimeClientAPI = original.RuntimeClientAPI diff --git a/profiles/preview/cognitiveservices/qnamakerruntime/models.go b/profiles/preview/cognitiveservices/qnamakerruntime/models.go new file mode 100644 index 000000000000..3989b963093d --- /dev/null +++ b/profiles/preview/cognitiveservices/qnamakerruntime/models.go @@ -0,0 +1,81 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package qnamakerruntime + +import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v4.0/qnamakerruntime" + +type ErrorCodeType = original.ErrorCodeType + +const ( + BadArgument ErrorCodeType = original.BadArgument + EndpointKeysError ErrorCodeType = original.EndpointKeysError + ExtractionFailure ErrorCodeType = original.ExtractionFailure + Forbidden ErrorCodeType = original.Forbidden + KbNotFound ErrorCodeType = original.KbNotFound + NotFound ErrorCodeType = original.NotFound + OperationNotFound ErrorCodeType = original.OperationNotFound + QnaRuntimeError ErrorCodeType = original.QnaRuntimeError + QuotaExceeded ErrorCodeType = original.QuotaExceeded + ServiceError ErrorCodeType = original.ServiceError + SKULimitExceeded ErrorCodeType = original.SKULimitExceeded + Unauthorized ErrorCodeType = original.Unauthorized + Unspecified ErrorCodeType = original.Unspecified + ValidationFailure ErrorCodeType = original.ValidationFailure +) + +type BaseClient = original.BaseClient +type ContextDTO = original.ContextDTO +type Error = original.Error +type ErrorResponse = original.ErrorResponse +type ErrorResponseError = original.ErrorResponseError +type FeedbackRecordDTO = original.FeedbackRecordDTO +type FeedbackRecordsDTO = original.FeedbackRecordsDTO +type InnerErrorModel = original.InnerErrorModel +type MetadataDTO = original.MetadataDTO +type PromptDTO = original.PromptDTO +type PromptDTOQna = original.PromptDTOQna +type QnADTO = original.QnADTO +type QnADTOContext = original.QnADTOContext +type QnASearchResult = original.QnASearchResult +type QnASearchResultContext = original.QnASearchResultContext +type QnASearchResultList = original.QnASearchResultList +type QueryContextDTO = original.QueryContextDTO +type QueryDTO = original.QueryDTO +type QueryDTOContext = original.QueryDTOContext +type RuntimeClient = original.RuntimeClient + +func New(runtimeEndpoint string) BaseClient { + return original.New(runtimeEndpoint) +} +func NewRuntimeClient(runtimeEndpoint string) RuntimeClient { + return original.NewRuntimeClient(runtimeEndpoint) +} +func NewWithoutDefaults(runtimeEndpoint string) BaseClient { + return original.NewWithoutDefaults(runtimeEndpoint) +} +func PossibleErrorCodeTypeValues() []ErrorCodeType { + return original.PossibleErrorCodeTypeValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/profiles/preview/cognitiveservices/qnamakerruntime/qnamakerruntimeapi/models.go b/profiles/preview/cognitiveservices/qnamakerruntime/qnamakerruntimeapi/models.go new file mode 100644 index 000000000000..b2f6ac1d9100 --- /dev/null +++ b/profiles/preview/cognitiveservices/qnamakerruntime/qnamakerruntimeapi/models.go @@ -0,0 +1,24 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package qnamakerruntimeapi + +import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v4.0/qnamakerruntime/qnamakerruntimeapi" + +type RuntimeClientAPI = original.RuntimeClientAPI diff --git a/services/cognitiveservices/v4.0/qnamakerruntime/client.go b/services/cognitiveservices/v4.0/qnamakerruntime/client.go new file mode 100644 index 000000000000..50ed286cc1d0 --- /dev/null +++ b/services/cognitiveservices/v4.0/qnamakerruntime/client.go @@ -0,0 +1,44 @@ +// Package qnamakerruntime implements the Azure ARM Qnamakerruntime service API version 4.0. +// +// An API for QnAMaker runtime +package qnamakerruntime + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +// BaseClient is the base client for Qnamakerruntime. +type BaseClient struct { + autorest.Client + RuntimeEndpoint string +} + +// New creates an instance of the BaseClient client. +func New(runtimeEndpoint string) BaseClient { + return NewWithoutDefaults(runtimeEndpoint) +} + +// NewWithoutDefaults creates an instance of the BaseClient client. +func NewWithoutDefaults(runtimeEndpoint string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + RuntimeEndpoint: runtimeEndpoint, + } +} diff --git a/services/cognitiveservices/v4.0/qnamakerruntime/models.go b/services/cognitiveservices/v4.0/qnamakerruntime/models.go new file mode 100644 index 000000000000..eeb9d3630178 --- /dev/null +++ b/services/cognitiveservices/v4.0/qnamakerruntime/models.go @@ -0,0 +1,269 @@ +package qnamakerruntime + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v4.0/qnamakerruntime" + +// ErrorCodeType enumerates the values for error code type. +type ErrorCodeType string + +const ( + // BadArgument ... + BadArgument ErrorCodeType = "BadArgument" + // EndpointKeysError ... + EndpointKeysError ErrorCodeType = "EndpointKeysError" + // ExtractionFailure ... + ExtractionFailure ErrorCodeType = "ExtractionFailure" + // Forbidden ... + Forbidden ErrorCodeType = "Forbidden" + // KbNotFound ... + KbNotFound ErrorCodeType = "KbNotFound" + // NotFound ... + NotFound ErrorCodeType = "NotFound" + // OperationNotFound ... + OperationNotFound ErrorCodeType = "OperationNotFound" + // QnaRuntimeError ... + QnaRuntimeError ErrorCodeType = "QnaRuntimeError" + // QuotaExceeded ... + QuotaExceeded ErrorCodeType = "QuotaExceeded" + // ServiceError ... + ServiceError ErrorCodeType = "ServiceError" + // SKULimitExceeded ... + SKULimitExceeded ErrorCodeType = "SKULimitExceeded" + // Unauthorized ... + Unauthorized ErrorCodeType = "Unauthorized" + // Unspecified ... + Unspecified ErrorCodeType = "Unspecified" + // ValidationFailure ... + ValidationFailure ErrorCodeType = "ValidationFailure" +) + +// PossibleErrorCodeTypeValues returns an array of possible values for the ErrorCodeType const type. +func PossibleErrorCodeTypeValues() []ErrorCodeType { + return []ErrorCodeType{BadArgument, EndpointKeysError, ExtractionFailure, Forbidden, KbNotFound, NotFound, OperationNotFound, QnaRuntimeError, QuotaExceeded, ServiceError, SKULimitExceeded, Unauthorized, Unspecified, ValidationFailure} +} + +// ContextDTO context associated with Qna. +type ContextDTO struct { + // IsContextOnly - To mark if a prompt is relevant only with a previous question or not. + // true - Do not include this QnA as search result for queries without context + // false - ignores context and includes this QnA in search result + IsContextOnly *bool `json:"isContextOnly,omitempty"` + // Prompts - List of prompts associated with the answer. + Prompts *[]PromptDTO `json:"prompts,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 { + // Code - One of a server-defined set of error codes. Possible values include: 'BadArgument', 'Forbidden', 'NotFound', 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', 'OperationNotFound', 'ServiceError', 'ValidationFailure', 'ExtractionFailure' + Code ErrorCodeType `json:"code,omitempty"` + // Message - A human-readable representation of the error. + Message *string `json:"message,omitempty"` + // Target - The target of the error. + Target *string `json:"target,omitempty"` + // Details - An array of details about specific errors that led to this reported error. + Details *[]Error `json:"details,omitempty"` + // InnerError - An object containing more specific information than the current object about the error. + InnerError *InnerErrorModel `json:"innerError,omitempty"` +} + +// ErrorResponse error response. As per Microsoft One API guidelines - +// https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. +type ErrorResponse struct { + // Error - The error object. + Error *ErrorResponseError `json:"error,omitempty"` +} + +// ErrorResponseError the error object. +type ErrorResponseError struct { + // Code - One of a server-defined set of error codes. Possible values include: 'BadArgument', 'Forbidden', 'NotFound', 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', 'OperationNotFound', 'ServiceError', 'ValidationFailure', 'ExtractionFailure' + Code ErrorCodeType `json:"code,omitempty"` + // Message - A human-readable representation of the error. + Message *string `json:"message,omitempty"` + // Target - The target of the error. + Target *string `json:"target,omitempty"` + // Details - An array of details about specific errors that led to this reported error. + Details *[]Error `json:"details,omitempty"` + // InnerError - An object containing more specific information than the current object about the error. + InnerError *InnerErrorModel `json:"innerError,omitempty"` +} + +// FeedbackRecordDTO active learning feedback record. +type FeedbackRecordDTO struct { + // UserID - Unique identifier for the user. + UserID *string `json:"userId,omitempty"` + // UserQuestion - The suggested question being provided as feedback. + UserQuestion *string `json:"userQuestion,omitempty"` + // QnaID - The qnaId for which the suggested question is provided as feedback. + QnaID *int32 `json:"qnaId,omitempty"` +} + +// FeedbackRecordsDTO active learning feedback records. +type FeedbackRecordsDTO struct { + // FeedbackRecords - List of feedback records. + FeedbackRecords *[]FeedbackRecordDTO `json:"feedbackRecords,omitempty"` +} + +// InnerErrorModel an object containing more specific information about the error. As per Microsoft One API +// guidelines - +// https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. +type InnerErrorModel struct { + // Code - A more specific error code than was provided by the containing error. + Code *string `json:"code,omitempty"` + // InnerError - An object containing more specific information than the current object about the error. + InnerError *InnerErrorModel `json:"innerError,omitempty"` +} + +// MetadataDTO name - value pair of metadata. +type MetadataDTO struct { + // Name - Metadata name. + Name *string `json:"name,omitempty"` + // Value - Metadata value. + Value *string `json:"value,omitempty"` +} + +// PromptDTO prompt for an answer. +type PromptDTO struct { + // DisplayOrder - Index of the prompt - used in ordering of the prompts + DisplayOrder *int32 `json:"displayOrder,omitempty"` + // QnaID - Qna id corresponding to the prompt - if QnaId is present, QnADTO object is ignored. + QnaID *int32 `json:"qnaId,omitempty"` + // Qna - QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object + Qna *PromptDTOQna `json:"qna,omitempty"` + // DisplayText - Text displayed to represent a follow up question prompt + DisplayText *string `json:"displayText,omitempty"` +} + +// PromptDTOQna qnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object +type PromptDTOQna struct { + // ID - Unique id for the Q-A. + ID *int32 `json:"id,omitempty"` + // Answer - Answer text + Answer *string `json:"answer,omitempty"` + // Source - Source from which Q-A was indexed. eg. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + Source *string `json:"source,omitempty"` + // Questions - List of questions associated with the answer. + Questions *[]string `json:"questions,omitempty"` + // Metadata - List of metadata associated with the answer. + Metadata *[]MetadataDTO `json:"metadata,omitempty"` + // Context - Context of a QnA + Context *QnADTOContext `json:"context,omitempty"` +} + +// QnADTO q-A object. +type QnADTO struct { + // ID - Unique id for the Q-A. + ID *int32 `json:"id,omitempty"` + // Answer - Answer text + Answer *string `json:"answer,omitempty"` + // Source - Source from which Q-A was indexed. eg. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs + Source *string `json:"source,omitempty"` + // Questions - List of questions associated with the answer. + Questions *[]string `json:"questions,omitempty"` + // Metadata - List of metadata associated with the answer. + Metadata *[]MetadataDTO `json:"metadata,omitempty"` + // Context - Context of a QnA + Context *QnADTOContext `json:"context,omitempty"` +} + +// QnADTOContext context of a QnA +type QnADTOContext struct { + // IsContextOnly - To mark if a prompt is relevant only with a previous question or not. + // true - Do not include this QnA as search result for queries without context + // false - ignores context and includes this QnA in search result + IsContextOnly *bool `json:"isContextOnly,omitempty"` + // Prompts - List of prompts associated with the answer. + Prompts *[]PromptDTO `json:"prompts,omitempty"` +} + +// QnASearchResult represents Search Result. +type QnASearchResult struct { + // Questions - List of questions. + Questions *[]string `json:"questions,omitempty"` + // Answer - Answer. + Answer *string `json:"answer,omitempty"` + // Score - Search result score. + Score *float64 `json:"score,omitempty"` + // ID - Id of the QnA result. + ID *int32 `json:"id,omitempty"` + // Source - Source of QnA result. + Source *string `json:"source,omitempty"` + // Metadata - List of metadata. + Metadata *[]MetadataDTO `json:"metadata,omitempty"` + // Context - Context object of the QnA + Context *QnASearchResultContext `json:"context,omitempty"` +} + +// QnASearchResultContext context object of the QnA +type QnASearchResultContext struct { + // IsContextOnly - To mark if a prompt is relevant only with a previous question or not. + // true - Do not include this QnA as search result for queries without context + // false - ignores context and includes this QnA in search result + IsContextOnly *bool `json:"isContextOnly,omitempty"` + // Prompts - List of prompts associated with the answer. + Prompts *[]PromptDTO `json:"prompts,omitempty"` +} + +// QnASearchResultList represents List of Question Answers. +type QnASearchResultList struct { + autorest.Response `json:"-"` + // Answers - Represents Search Result list. + Answers *[]QnASearchResult `json:"answers,omitempty"` +} + +// QueryContextDTO context object with previous QnA's information. +type QueryContextDTO struct { + // PreviousQnaID - Previous QnA Id - qnaId of the top result. + PreviousQnaID *string `json:"previousQnaId,omitempty"` + // PreviousUserQuery - Previous user query. + PreviousUserQuery *string `json:"previousUserQuery,omitempty"` +} + +// QueryDTO POST body schema to query the knowledgebase. +type QueryDTO struct { + // QnaID - Exact qnaId to fetch from the knowledgebase, this field takes priority over question. + QnaID *string `json:"qnaId,omitempty"` + // Question - User question to query against the knowledge base. + Question *string `json:"question,omitempty"` + // Top - Max number of answers to be returned for the question. + Top *int32 `json:"top,omitempty"` + // UserID - Unique identifier for the user. + UserID *string `json:"userId,omitempty"` + // IsTest - Query against the test index. + IsTest *bool `json:"isTest,omitempty"` + // ScoreThreshold - Threshold for answers returned based on score. + ScoreThreshold *float64 `json:"scoreThreshold,omitempty"` + // Context - Context object with previous QnA's information. + Context *QueryDTOContext `json:"context,omitempty"` + // StrictFilters - Find only answers that contain these metadata. + StrictFilters *[]MetadataDTO `json:"strictFilters,omitempty"` +} + +// QueryDTOContext context object with previous QnA's information. +type QueryDTOContext struct { + // PreviousQnaID - Previous QnA Id - qnaId of the top result. + PreviousQnaID *string `json:"previousQnaId,omitempty"` + // PreviousUserQuery - Previous user query. + PreviousUserQuery *string `json:"previousUserQuery,omitempty"` +} diff --git a/services/cognitiveservices/v4.0/qnamakerruntime/qnamakerruntimeapi/interfaces.go b/services/cognitiveservices/v4.0/qnamakerruntime/qnamakerruntimeapi/interfaces.go new file mode 100644 index 000000000000..a62214d0f2e7 --- /dev/null +++ b/services/cognitiveservices/v4.0/qnamakerruntime/qnamakerruntimeapi/interfaces.go @@ -0,0 +1,32 @@ +package qnamakerruntimeapi + +// 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/azure-sdk-for-go/services/cognitiveservices/v4.0/qnamakerruntime" + "github.com/Azure/go-autorest/autorest" +) + +// RuntimeClientAPI contains the set of methods on the RuntimeClient type. +type RuntimeClientAPI interface { + GenerateAnswer(ctx context.Context, kbID string, generateAnswerPayload qnamakerruntime.QueryDTO) (result qnamakerruntime.QnASearchResultList, err error) + Train(ctx context.Context, kbID string, trainPayload qnamakerruntime.FeedbackRecordsDTO) (result autorest.Response, err error) +} + +var _ RuntimeClientAPI = (*qnamakerruntime.RuntimeClient)(nil) diff --git a/services/cognitiveservices/v4.0/qnamakerruntime/runtime.go b/services/cognitiveservices/v4.0/qnamakerruntime/runtime.go new file mode 100644 index 000000000000..052fca0d6ed1 --- /dev/null +++ b/services/cognitiveservices/v4.0/qnamakerruntime/runtime.go @@ -0,0 +1,185 @@ +package qnamakerruntime + +// 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" +) + +// RuntimeClient is the an API for QnAMaker runtime +type RuntimeClient struct { + BaseClient +} + +// NewRuntimeClient creates an instance of the RuntimeClient client. +func NewRuntimeClient(runtimeEndpoint string) RuntimeClient { + return RuntimeClient{New(runtimeEndpoint)} +} + +// GenerateAnswer sends the generate answer request. +// Parameters: +// kbID - knowledgebase id. +// generateAnswerPayload - post body of the request. +func (client RuntimeClient) GenerateAnswer(ctx context.Context, kbID string, generateAnswerPayload QueryDTO) (result QnASearchResultList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RuntimeClient.GenerateAnswer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GenerateAnswerPreparer(ctx, kbID, generateAnswerPayload) + if err != nil { + err = autorest.NewErrorWithError(err, "qnamakerruntime.RuntimeClient", "GenerateAnswer", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateAnswerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "qnamakerruntime.RuntimeClient", "GenerateAnswer", resp, "Failure sending request") + return + } + + result, err = client.GenerateAnswerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "qnamakerruntime.RuntimeClient", "GenerateAnswer", resp, "Failure responding to request") + } + + return +} + +// GenerateAnswerPreparer prepares the GenerateAnswer request. +func (client RuntimeClient) GenerateAnswerPreparer(ctx context.Context, kbID string, generateAnswerPayload QueryDTO) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "RuntimeEndpoint": client.RuntimeEndpoint, + } + + pathParameters := map[string]interface{}{ + "kbId": autorest.Encode("path", kbID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithCustomBaseURL("{RuntimeEndpoint}/qnamaker", urlParameters), + autorest.WithPathParameters("/knowledgebases/{kbId}/generateAnswer", pathParameters), + autorest.WithJSON(generateAnswerPayload)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateAnswerSender sends the GenerateAnswer request. The method will close the +// http.Response Body if it receives an error. +func (client RuntimeClient) GenerateAnswerSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// GenerateAnswerResponder handles the response to the GenerateAnswer request. The method always +// closes the http.Response Body. +func (client RuntimeClient) GenerateAnswerResponder(resp *http.Response) (result QnASearchResultList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Train sends the train request. +// Parameters: +// kbID - knowledgebase id. +// trainPayload - post body of the request. +func (client RuntimeClient) Train(ctx context.Context, kbID string, trainPayload FeedbackRecordsDTO) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RuntimeClient.Train") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.TrainPreparer(ctx, kbID, trainPayload) + if err != nil { + err = autorest.NewErrorWithError(err, "qnamakerruntime.RuntimeClient", "Train", nil, "Failure preparing request") + return + } + + resp, err := client.TrainSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "qnamakerruntime.RuntimeClient", "Train", resp, "Failure sending request") + return + } + + result, err = client.TrainResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "qnamakerruntime.RuntimeClient", "Train", resp, "Failure responding to request") + } + + return +} + +// TrainPreparer prepares the Train request. +func (client RuntimeClient) TrainPreparer(ctx context.Context, kbID string, trainPayload FeedbackRecordsDTO) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "RuntimeEndpoint": client.RuntimeEndpoint, + } + + pathParameters := map[string]interface{}{ + "kbId": autorest.Encode("path", kbID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithCustomBaseURL("{RuntimeEndpoint}/qnamaker", urlParameters), + autorest.WithPathParameters("/knowledgebases/{kbId}/train", pathParameters), + autorest.WithJSON(trainPayload)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TrainSender sends the Train request. The method will close the +// http.Response Body if it receives an error. +func (client RuntimeClient) TrainSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// TrainResponder handles the response to the Train request. The method always +// closes the http.Response Body. +func (client RuntimeClient) TrainResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/cognitiveservices/v4.0/qnamakerruntime/version.go b/services/cognitiveservices/v4.0/qnamakerruntime/version.go new file mode 100644 index 000000000000..978022bca72d --- /dev/null +++ b/services/cognitiveservices/v4.0/qnamakerruntime/version.go @@ -0,0 +1,30 @@ +package qnamakerruntime + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " qnamakerruntime/4.0" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}