diff --git a/packages/@azure/cognitiveservices-qnamaker/README.md b/packages/@azure/cognitiveservices-qnamaker/README.md index 9852b21a1779..e91e67e54ff9 100644 --- a/packages/@azure/cognitiveservices-qnamaker/README.md +++ b/packages/@azure/cognitiveservices-qnamaker/README.md @@ -16,7 +16,7 @@ npm install @azure/cognitiveservices-qnamaker ## How to use -### nodejs - Authentication, client creation and getKeys endpoint as an example written in TypeScript. +### nodejs - Authentication, client creation and getKeys endpointKeys as an example written in TypeScript. ```ts import * as msRest from "ms-rest-js"; @@ -26,7 +26,7 @@ const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; msRestNodeAuth.interactiveLogin().then((creds) => { const client = new QnAMakerClient(creds, subscriptionId); - client.endpoint.getKeys().then((result) => { + client.endpointKeys.getKeys().then((result) => { console.log("The result is:"); console.log(result); }); @@ -35,7 +35,7 @@ msRestNodeAuth.interactiveLogin().then((creds) => { }); ``` -### browser - Authentication, client creation and getKeys endpoint as an example written in javascript. +### browser - Authentication, client creation and getKeys endpointKeys as an example written in javascript. - index.html ```html @@ -58,7 +58,7 @@ msRestNodeAuth.interactiveLogin().then((creds) => { authManager.login(); } const client = new Azure.CognitiveservicesQnamaker.QnAMakerClient(res.creds, subscriptionId); - client.endpoint.getKeys().then((result) => { + client.endpointKeys.getKeys().then((result) => { console.log("The result is:"); console.log(result); }).catch((err) => { diff --git a/packages/@azure/cognitiveservices-qnamaker/lib/models/endpointKeysMappers.ts b/packages/@azure/cognitiveservices-qnamaker/lib/models/endpointKeysMappers.ts new file mode 100644 index 000000000000..2dc26823cf5b --- /dev/null +++ b/packages/@azure/cognitiveservices-qnamaker/lib/models/endpointKeysMappers.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export { + EndpointKeysDTO, + ErrorResponse, + ErrorResponseError, + ErrorModel, + InnerErrorModel +} from "../models/mappers"; + diff --git a/packages/@azure/cognitiveservices-qnamaker/lib/models/index.ts b/packages/@azure/cognitiveservices-qnamaker/lib/models/index.ts index 0c70559dd551..764e9271b9b8 100644 --- a/packages/@azure/cognitiveservices-qnamaker/lib/models/index.ts +++ b/packages/@azure/cognitiveservices-qnamaker/lib/models/index.ts @@ -642,7 +642,7 @@ export type EnvironmentType = 'Prod' | 'Test'; /** * Contains response data for the getKeys operation. */ -export type EndpointGetKeysResponse = EndpointKeysDTO & { +export type EndpointKeysGetKeysResponse = EndpointKeysDTO & { /** * The underlying HTTP response. */ @@ -661,7 +661,7 @@ export type EndpointGetKeysResponse = EndpointKeysDTO & { /** * Contains response data for the refreshKeys operation. */ -export type EndpointRefreshKeysResponse = EndpointKeysDTO & { +export type EndpointKeysRefreshKeysResponse = EndpointKeysDTO & { /** * The underlying HTTP response. */ diff --git a/packages/@azure/cognitiveservices-qnamaker/lib/operations/endpointKeys.ts b/packages/@azure/cognitiveservices-qnamaker/lib/operations/endpointKeys.ts new file mode 100644 index 000000000000..201659e8b66f --- /dev/null +++ b/packages/@azure/cognitiveservices-qnamaker/lib/operations/endpointKeys.ts @@ -0,0 +1,117 @@ +/* + * 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 * as msRest from "ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/endpointKeysMappers"; +import * as Parameters from "../models/parameters"; +import { QnAMakerClientContext } from "../qnAMakerClientContext"; + +/** Class representing a EndpointKeys. */ +export class EndpointKeys { + private readonly client: QnAMakerClientContext; + + /** + * Create a EndpointKeys. + * @param {QnAMakerClientContext} client Reference to the service client. + */ + constructor(client: QnAMakerClientContext) { + this.client = client; + } + + /** + * @summary Gets endpoint keys for an endpoint + * @param [options] The optional parameters + * @returns Promise + */ + getKeys(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + getKeys(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + getKeys(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getKeys(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getKeysOperationSpec, + callback) as Promise; + } + + /** + * @summary Re-generates an endpoint key. + * @param keyType Type of Key + * @param [options] The optional parameters + * @returns Promise + */ + refreshKeys(keyType: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param keyType Type of Key + * @param callback The callback + */ + refreshKeys(keyType: string, callback: msRest.ServiceCallback): void; + /** + * @param keyType Type of Key + * @param options The optional parameters + * @param callback The callback + */ + refreshKeys(keyType: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + refreshKeys(keyType: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + keyType, + options + }, + refreshKeysOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getKeysOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "endpointkeys", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.EndpointKeysDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const refreshKeysOperationSpec: msRest.OperationSpec = { + httpMethod: "PATCH", + path: "endpointkeys/{keyType}", + urlParameters: [ + Parameters.endpoint, + Parameters.keyType + ], + responses: { + 200: { + bodyMapper: Mappers.EndpointKeysDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/packages/@azure/cognitiveservices-qnamaker/lib/operations/index.ts b/packages/@azure/cognitiveservices-qnamaker/lib/operations/index.ts index 0fcd629017be..e46ec2db7f23 100644 --- a/packages/@azure/cognitiveservices-qnamaker/lib/operations/index.ts +++ b/packages/@azure/cognitiveservices-qnamaker/lib/operations/index.ts @@ -8,7 +8,7 @@ * regenerated. */ -export * from "./endpoint"; +export * from "./endpointKeys"; export * from "./alterations"; export * from "./knowledgebase"; export * from "./operations"; diff --git a/packages/@azure/cognitiveservices-qnamaker/lib/qnAMakerClient.ts b/packages/@azure/cognitiveservices-qnamaker/lib/qnAMakerClient.ts index 3a69815f61fc..8b326f08549d 100644 --- a/packages/@azure/cognitiveservices-qnamaker/lib/qnAMakerClient.ts +++ b/packages/@azure/cognitiveservices-qnamaker/lib/qnAMakerClient.ts @@ -16,7 +16,7 @@ import { QnAMakerClientContext } from "./qnAMakerClientContext"; class QnAMakerClient extends QnAMakerClientContext { // Operation groups - endpoint: operations.Endpoint; + endpointKeys: operations.EndpointKeys; alterations: operations.Alterations; knowledgebase: operations.Knowledgebase; operations: operations.Operations; @@ -30,7 +30,7 @@ class QnAMakerClient extends QnAMakerClientContext { */ constructor(endpoint: string, credentials: msRest.ServiceClientCredentials, options?: msRest.ServiceClientOptions) { super(endpoint, credentials, options); - this.endpoint = new operations.Endpoint(this); + this.endpointKeys = new operations.EndpointKeys(this); this.alterations = new operations.Alterations(this); this.knowledgebase = new operations.Knowledgebase(this); this.operations = new operations.Operations(this);