Skip to content

Commit

Permalink
[AutoPR cognitiveservices/data-plane/QnAMaker] Adding missing docs fo…
Browse files Browse the repository at this point in the history
…r existing routes for QnA Maker APIM (#3393)

* Generated from 6d3acf9fe3af2f4fab75e59df444dfed9763cae1

fix metadata ref

* Generated from 8ae17e91d45e1fc5c0db23826c2c0ca20d3b886d

spellcheck
  • Loading branch information
AutorestCI authored Jun 3, 2019
1 parent 324b388 commit dc292c4
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 20 deletions.
57 changes: 40 additions & 17 deletions sdk/cognitiveservices/cognitiveservices-qnamaker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ npm install @azure/cognitiveservices-qnamaker

### How to use

#### nodejs - Authentication, client creation and getKeys endpointKeys as an example written in TypeScript.
#### nodejs - Authentication, client creation and getSettings endpointSettings as an example written in TypeScript.

##### Install @azure/ms-rest-nodeauth

```bash
npm install @azure/ms-rest-nodeauth
```

##### Sample code

Expand All @@ -24,21 +30,30 @@ import * as msRest from "@azure/ms-rest-js";
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
import { QnAMakerClient, QnAMakerModels, QnAMakerMappers } from "@azure/cognitiveservices-qnamaker";
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
const endpoint = "https://westus.api.cognitive.microsoft.com"; // OR some other endpoint.
const creds = new msRest.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': subscriptionId }});
const client = new QnAMakerClient(creds, endpoint);
client.endpointKeys.getKeys().then((result) => {
console.log("The result is:");
console.log(result);

msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new QnAMakerClient(creds, subscriptionId);
client.endpointSettings.getSettings().then((result) => {
console.log("The result is:");
console.log(result);
});
}).catch((err) => {
console.error(err);
});
```

#### browser - Authentication, client creation and getKeys endpointKeys as an example written in JavaScript.
#### browser - Authentication, client creation and getSettings endpointSettings as an example written in JavaScript.

##### Install @azure/ms-rest-browserauth

```bash
npm install @azure/ms-rest-browserauth
```

##### Sample code

See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.

- index.html
```html
<!DOCTYPE html>
Expand All @@ -50,15 +65,23 @@ client.endpointKeys.getKeys().then((result) => {
<script src="node_modules/@azure/cognitiveservices-qnamaker/dist/cognitiveservices-qnamaker.js"></script>
<script type="text/javascript">
const subscriptionId = "<Subscription_Id>";
const creds = new msRest.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': subscriptionId }});
const endpoint = "https://westus.api.cognitive.microsoft.com"; // OR some other endpoint.
const client = new Azure.CognitiveservicesQnamaker.QnAMakerClient(creds, endpoint);
client.endpointKeys.getKeys().then((result) => {
console.log("The result is:");
console.log(result);
}).catch((err) => {
console.log("An error occurred:");
console.error(err);
const authManager = new msAuth.AuthManager({
clientId: "<client id for your Azure AD app>",
tenant: "<optional tenant for your organization>"
});
authManager.finalizeLogin().then((res) => {
if (!res.isLoggedIn) {
// may cause redirects
authManager.login();
}
const client = new Azure.CognitiveservicesQnamaker.QnAMakerClient(res.creds, subscriptionId);
client.endpointSettings.getSettings().then((result) => {
console.log("The result is:");
console.log(result);
}).catch((err) => {
console.log("An error occurred:");
console.error(err);
});
});
</script>
</head>
Expand Down
4 changes: 2 additions & 2 deletions sdk/cognitiveservices/cognitiveservices-qnamaker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "QnAMakerClient Library with typescript type definitions for node.js and browser.",
"version": "2.0.0",
"dependencies": {
"@azure/ms-rest-js": "^1.8.4",
"@azure/ms-rest-js": "^1.8.1",
"tslib": "^1.9.3"
},
"keywords": [
Expand All @@ -25,7 +25,7 @@
"rollup-plugin-sourcemaps": "^0.4.2",
"uglify-js": "^3.4.9"
},
"homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-qnamaker",
"homepage": "https://github.com/azure/azure-sdk-for-js",
"repository": {
"type": "git",
"url": "https://github.com/azure/azure-sdk-for-js.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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 {
ActiveLearningSettingsDTO,
EndpointSettingsDTO,
EndpointSettingsDTOActiveLearning,
ErrorModel,
ErrorResponse,
ErrorResponseError,
InnerErrorModel
} from "../models/mappers";
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,32 @@ export interface KnowledgebasesDTO {
knowledgebases?: KnowledgebaseDTO[];
}

/**
* Active Learning settings of the endpoint.
*/
export interface ActiveLearningSettingsDTO {
/**
* True/False string providing Active Learning
*/
enable?: string;
}

/**
* Active Learning settings of the endpoint.
*/
export interface EndpointSettingsDTOActiveLearning extends ActiveLearningSettingsDTO {
}

/**
* Endpoint settings.
*/
export interface EndpointSettingsDTO {
/**
* Active Learning settings of the endpoint.
*/
activeLearning?: EndpointSettingsDTOActiveLearning;
}

/**
* Collection of words that are synonyms.
*/
Expand Down Expand Up @@ -592,6 +618,51 @@ export type OperationStateType = 'Failed' | 'NotStarted' | 'Running' | 'Succeede
*/
export type EnvironmentType = 'Prod' | 'Test';

/**
* Contains response data for the getSettings operation.
*/
export type EndpointSettingsGetSettingsResponse = EndpointSettingsDTO & {
/**
* The underlying HTTP response.
*/
_response: msRest.HttpResponse & {
/**
* The response body as text (string format)
*/
bodyAsText: string;

/**
* The response body as parsed JSON or XML
*/
parsedBody: EndpointSettingsDTO;
};
};

/**
* Contains response data for the updateSettings operation.
*/
export type EndpointSettingsUpdateSettingsResponse = {
/**
* The parsed response body.
*/
body: string;

/**
* The underlying HTTP response.
*/
_response: msRest.HttpResponse & {
/**
* The response body as text (string format)
*/
bodyAsText: string;

/**
* The response body as parsed JSON or XML
*/
parsedBody: string;
};
};

/**
* Contains response data for the getKeys operation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,50 @@ export const KnowledgebasesDTO: msRest.CompositeMapper = {
}
};

export const ActiveLearningSettingsDTO: msRest.CompositeMapper = {
serializedName: "ActiveLearningSettingsDTO",
type: {
name: "Composite",
className: "ActiveLearningSettingsDTO",
modelProperties: {
enable: {
serializedName: "enable",
type: {
name: "String"
}
}
}
}
};

export const EndpointSettingsDTOActiveLearning: msRest.CompositeMapper = {
serializedName: "EndpointSettingsDTO_activeLearning",
type: {
name: "Composite",
className: "EndpointSettingsDTOActiveLearning",
modelProperties: {
...ActiveLearningSettingsDTO.type.modelProperties
}
}
};

export const EndpointSettingsDTO: msRest.CompositeMapper = {
serializedName: "EndpointSettingsDTO",
type: {
name: "Composite",
className: "EndpointSettingsDTO",
modelProperties: {
activeLearning: {
serializedName: "activeLearning",
type: {
name: "Composite",
className: "EndpointSettingsDTOActiveLearning"
}
}
}
}
};

export const AlterationsDTO: msRest.CompositeMapper = {
serializedName: "AlterationsDTO",
type: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* 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 "@azure/ms-rest-js";
import * as Models from "../models";
import * as Mappers from "../models/endpointSettingsMappers";
import * as Parameters from "../models/parameters";
import { QnAMakerClientContext } from "../qnAMakerClientContext";

/** Class representing a EndpointSettings. */
export class EndpointSettings {
private readonly client: QnAMakerClientContext;

/**
* Create a EndpointSettings.
* @param {QnAMakerClientContext} client Reference to the service client.
*/
constructor(client: QnAMakerClientContext) {
this.client = client;
}

/**
* @summary Gets endpoint settings for an endpoint.
* @param [options] The optional parameters
* @returns Promise<Models.EndpointSettingsGetSettingsResponse>
*/
getSettings(options?: msRest.RequestOptionsBase): Promise<Models.EndpointSettingsGetSettingsResponse>;
/**
* @param callback The callback
*/
getSettings(callback: msRest.ServiceCallback<Models.EndpointSettingsDTO>): void;
/**
* @param options The optional parameters
* @param callback The callback
*/
getSettings(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.EndpointSettingsDTO>): void;
getSettings(options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.EndpointSettingsDTO>, callback?: msRest.ServiceCallback<Models.EndpointSettingsDTO>): Promise<Models.EndpointSettingsGetSettingsResponse> {
return this.client.sendOperationRequest(
{
options
},
getSettingsOperationSpec,
callback) as Promise<Models.EndpointSettingsGetSettingsResponse>;
}

/**
* @summary Updates endpoint settings for an endpoint.
* @param endpointSettingsPayload Post body of the request.
* @param [options] The optional parameters
* @returns Promise<Models.EndpointSettingsUpdateSettingsResponse>
*/
updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase): Promise<Models.EndpointSettingsUpdateSettingsResponse>;
/**
* @param endpointSettingsPayload Post body of the request.
* @param callback The callback
*/
updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, callback: msRest.ServiceCallback<string>): void;
/**
* @param endpointSettingsPayload Post body of the request.
* @param options The optional parameters
* @param callback The callback
*/
updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<string>): void;
updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<string>, callback?: msRest.ServiceCallback<string>): Promise<Models.EndpointSettingsUpdateSettingsResponse> {
return this.client.sendOperationRequest(
{
endpointSettingsPayload,
options
},
updateSettingsOperationSpec,
callback) as Promise<Models.EndpointSettingsUpdateSettingsResponse>;
}
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const getSettingsOperationSpec: msRest.OperationSpec = {
httpMethod: "GET",
path: "endpointSettings",
urlParameters: [
Parameters.endpoint
],
responses: {
200: {
bodyMapper: Mappers.EndpointSettingsDTO
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
serializer
};

const updateSettingsOperationSpec: msRest.OperationSpec = {
httpMethod: "PATCH",
path: "endpointSettings",
urlParameters: [
Parameters.endpoint
],
requestBody: {
parameterPath: "endpointSettingsPayload",
mapper: {
...Mappers.EndpointSettingsDTO,
required: true
}
},
responses: {
200: {
bodyMapper: {
serializedName: "parsedResponse",
type: {
name: "String"
}
}
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
serializer
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* regenerated.
*/

export * from "./endpointSettings";
export * from "./endpointKeys";
export * from "./alterations";
export * from "./knowledgebase";
Expand Down
Loading

0 comments on commit dc292c4

Please sign in to comment.