From 335005a53b760f61250be52ad194b83a4944a6cf Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 6 May 2021 19:48:51 +0000 Subject: [PATCH] CodeGen from PR 14289 in Azure/azure-rest-api-specs Merge 639a828df25669571d47073071595c0b3e2122ed into e401e457b5e95941f241f5c71bc56d42d431a4e0 --- .../LICENSE.txt | 2 +- .../cognitiveservices-personalizer/README.md | 169 ++---- .../rollup.config.js | 4 +- .../src/models/evaluationsMappers.ts | 20 + .../src/models/eventsMappers.ts | 4 +- .../src/models/index.ts | 524 +++++++++++++++++- .../src/models/logMappers.ts | 16 + .../src/models/mappers.ts | 494 ++++++++++++++++- .../src/models/modelMappers.ts | 14 + .../src/models/parameters.ts | 18 +- .../src/models/policyMappers.ts | 14 + .../serviceConfigurationOperationsMappers.ts | 14 + .../src/operations/evaluations.ts | 225 ++++++++ .../src/operations/events.ts | 20 +- .../src/operations/index.ts | 10 +- .../src/operations/log.ts | 109 ++++ .../src/operations/model.ts | 154 +++++ .../src/operations/policy.ts | 162 ++++++ .../serviceConfigurationOperations.ts | 122 ++++ .../src/personalizerClient.ts | 19 +- .../src/personalizerClientContext.ts | 5 +- 21 files changed, 1951 insertions(+), 168 deletions(-) create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/models/evaluationsMappers.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/models/logMappers.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/models/modelMappers.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/models/policyMappers.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/models/serviceConfigurationOperationsMappers.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/evaluations.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/log.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/model.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/policy.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/serviceConfigurationOperations.ts diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/LICENSE.txt b/sdk/cognitiveservices/cognitiveservices-personalizer/LICENSE.txt index b73b4a1293c3..2d3163745319 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/LICENSE.txt +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019 Microsoft +Copyright (c) 2021 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/README.md b/sdk/cognitiveservices/cognitiveservices-personalizer/README.md index f96361cdb7d1..f6bc0e953822 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/README.md +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/README.md @@ -15,90 +15,46 @@ npm install @azure/cognitiveservices-personalizer ### How to use -#### nodejs - Authentication, client creation and reward events as an example written in TypeScript. +#### nodejs - client creation and get serviceConfiguration as an example written in TypeScript. -##### Install @azure/ms-rest-azure-js +##### Install @azure/ms-rest-nodeauth +- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. ```bash -npm install @azure/ms-rest-azure-js +npm install @azure/ms-rest-nodeauth@"^3.0.0" ``` ##### Sample code -The following sample ranks a personalized request object. To know more, refer to the [Azure Documentation on Personalizer](https://docs.microsoft.com/azure/cognitive-services/personalizer/) -```javascript +While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package +```typescript +const msRestNodeAuth = require("@azure/ms-rest-nodeauth"); const { PersonalizerClient } = require("@azure/cognitiveservices-personalizer"); -const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js"); - -async function main() { - const personalizerKey = process.env["personalizerKey"] || ""; - const personalizerEndPoint = - process.env["personalizerEndPoint"] || ""; - const cognitiveServiceCredentials = new CognitiveServicesCredentials( - personalizerKey - ); - - const client = new PersonalizerClient( - cognitiveServiceCredentials, - personalizerEndPoint - ); - - const rankRequest = { - contextFeatures: [ - { - timeOfDay: "Morning" - } - ], - actions: [ - { - id: "NewsArticle", - features: [ - { - type: "News" - } - ] - }, - { - id: "SportsArticle", - features: [ - { - type: "Sports" - } - ] - }, - { - id: "EntertainmentArticle", - features: [ - { - type: "Entertainment" - } - ] - } - ], - excludedActions: ["SportsArticle"], - eventId: "75269AD0-BFEE-4598-8196-C57383D38E10", - deferActivation: false - }; - - client - .rank(rankRequest) - .then(result => { - console.log("The result is: "); - console.log(result); - }) - .catch(err => { - console.log("An error occurred:"); - console.error(err); - }); -} - -main(); +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new PersonalizerClient(creds, subscriptionId); + client.serviceConfiguration.get().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); ``` -#### browser - Authentication, client creation and reward events as an example written in JavaScript. +#### browser - Authentication, client creation and get serviceConfiguration 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 @@ -106,67 +62,28 @@ main(); @azure/cognitiveservices-personalizer sample + @@ -177,4 +94,4 @@ main(); - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcognitiveservices%2Fcognitiveservices-personalizer%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-personalizer/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/rollup.config.js b/sdk/cognitiveservices/cognitiveservices-personalizer/rollup.config.js index ccb1c31cd803..7ffac7c97d99 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/rollup.config.js +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/rollup.config.js @@ -21,8 +21,8 @@ const config = { "@azure/ms-rest-azure-js": "msRestAzure" }, banner: `/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/evaluationsMappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/evaluationsMappers.ts new file mode 100644 index 000000000000..f28d3aa54866 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/evaluationsMappers.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ErrorResponse, + Evaluation, + EvaluationContract, + EvaluationsCreateHeaders, + InternalError, + PersonalizerError, + PolicyContract, + PolicyResult, + PolicyResultSummary, + PolicyResultTotalSummary +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/eventsMappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/eventsMappers.ts index 37cc6b8a06f2..3fe8f56ca905 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/eventsMappers.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/eventsMappers.ts @@ -1,6 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/index.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/index.ts index 7b173da77f88..32b43a64b99b 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/index.ts @@ -1,6 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. @@ -9,6 +9,51 @@ import * as msRest from "@azure/ms-rest-js"; +/** + * The configuration of the service. + */ +export interface ServiceConfiguration { + /** + * The time span waited until a request is marked with the default reward. + * For example, PT5M (5 mins). For information about the time format, + * see http://en.wikipedia.org/wiki/ISO_8601#Durations + */ + rewardWaitTime: string; + /** + * The reward given if a reward is not received within the specified wait time. + */ + defaultReward: number; + /** + * The function used to process rewards, if multiple reward scores are received before + * rewardWaitTime is over. + */ + rewardAggregation: string; + /** + * The percentage of rank responses that will use exploration. + */ + explorationPercentage: number; + /** + * Personalizer will start using the most updated trained model for online ranks automatically + * every specified time period. + * For example, PT5M (5 mins). For information about the time format, + * see http://en.wikipedia.org/wiki/ISO_8601#Durations + */ + modelExportFrequency: string; + /** + * Flag indicates whether log mirroring is enabled. + */ + logMirrorEnabled?: boolean; + /** + * Azure storage account container SAS URI for log mirroring. + */ + logMirrorSasUri?: string; + /** + * Number of days historical logs are to be maintained. -1 implies the logs will never be + * deleted. + */ + logRetentionDays: number; +} + /** * An object containing more specific information than the parent object about the error. */ @@ -29,9 +74,13 @@ export interface InternalError { export interface PersonalizerError { /** * High level error code. Possible values include: 'BadRequest', 'ResourceNotFound', - * 'InternalServerError' + * 'InternalServerError', 'InvalidServiceConfiguration', 'InvalidPolicyConfiguration', + * 'InvalidPolicyContract', 'InvalidEvaluationContract', 'InvalidRewardRequest', + * 'InvalidEventIdToActivate', 'InvalidRankRequest', 'InvalidExportLogsRequest', + * 'InvalidContainer', 'FrontEndNotFound', 'EvaluationNotFound', 'LogsPropertiesNotFound', + * 'RankNullResponse', 'UpdateConfigurationFailed', 'ModelResetFailed' */ - code: ErrorCode; + code: PersonalizerErrorCode; /** * A message explaining the error reported by the service. */ @@ -60,6 +109,142 @@ export interface ErrorResponse { error: PersonalizerError; } +/** + * Learning settings specifying how to train the model. + */ +export interface PolicyContract { + /** + * Name of the Learning settings. + */ + name: string; + /** + * Arguments of the Learning settings. + */ + argumentsProperty: string; +} + +/** + * An interface representing PolicyResultSummary. + */ +export interface PolicyResultSummary { + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly timeStamp?: Date; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly ipsEstimatorNumerator?: number; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly ipsEstimatorDenominator?: number; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly snipsEstimatorDenominator?: number; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly aggregateTimeWindow?: string; + nonZeroProbability?: number; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly confidenceInterval?: number; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly sumOfSquares?: number; +} + +/** + * An interface representing PolicyResultTotalSummary. + */ +export interface PolicyResultTotalSummary extends PolicyResultSummary { +} + +/** + * An interface representing PolicyResult. + */ +export interface PolicyResult { + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly name?: string; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly argumentsProperty?: string; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly summary?: PolicyResultSummary[]; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly totalSummary?: PolicyResultTotalSummary; +} + +/** + * An interface representing Evaluation. + */ +export interface Evaluation { + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly id?: string; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly name?: string; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly startTime?: Date; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly endTime?: Date; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly jobId?: string; + /** + * Possible values include: 'completed', 'pending', 'failed', 'notSubmitted' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly status?: EvaluationJobStatus; + policyResults?: PolicyResult[]; + featureImportance?: string[][]; +} + +/** + * A counterfactual evaluation. + */ +export interface EvaluationContract { + /** + * True if the evaluation should explore for a more optimal Learning settings. + */ + enableOfflineExperimentation?: boolean; + /** + * The name of the evaluation. + */ + name: string; + /** + * The start time of the evaluation. + */ + startTime: Date; + /** + * The end time of the evaluation. + */ + endTime: Date; + /** + * Additional Learning settings to evaluate. + */ + policies: PolicyContract[]; +} + /** * Reward given to a rank response. */ @@ -70,6 +255,50 @@ export interface RewardRequest { value: number; } +/** + * An interface representing DateRange. + */ +export interface DateRange { + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly from?: Date; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly to?: Date; +} + +/** + * An interface representing LogsPropertiesDateRange. + */ +export interface LogsPropertiesDateRange extends DateRange { +} + +/** + * An interface representing LogsProperties. + */ +export interface LogsProperties { + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly dateRange?: LogsPropertiesDateRange; +} + +/** + * An interface representing ModelProperties. + */ +export interface ModelProperties { + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly creationTime?: Date; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly lastModifiedTime?: Date; +} + /** * An action with it's associated features used for ranking. */ @@ -92,7 +321,9 @@ export interface RankRequest { * Features of the context used for Personalizer as a * dictionary of dictionaries. This depends on the application, and * typically includes features about the current user, their - * device, profile information, data about time and date, etc. + * device, profile information, aggregated data about time and date, etc. + * Features should not include personally identifiable information (PII), + * unique UserIDs, or precise timestamps. */ contextFeatures?: any[]; /** @@ -100,6 +331,7 @@ export interface RankRequest { * The set should not contain more than 50 actions. * The order of the actions does not affect the rank result but the order * should match the sequence your application would have used to display them. + * The first item in the array will be used as Baseline item in Offline evaluations. */ actions: RankableAction[]; /** @@ -114,10 +346,12 @@ export interface RankRequest { */ eventId?: string; /** - * Send false if the user will see the rank results, therefore + * Send false if it is certain the rewardActionId in rank results will be shown to the user, + * therefore * Personalizer will expect a Reward call, otherwise it will assign the default * Reward to the event. Send true if it is possible the user will not see the - * rank results, because the page is rendering later, or the Rank results may be + * action specified in the rank results, because the page is rendering later, or the Rank results + * may be * overridden by code further downstream. Default value: false. */ deferActivation?: boolean; @@ -140,7 +374,8 @@ export interface RankedAction { } /** - * A resulting ordered list of actions that result from a rank request. + * Returns which action to use as rewardActionId, and additional information about each action as a + * result of a Rank request. */ export interface RankResponse { /** @@ -154,8 +389,8 @@ export interface RankResponse { */ readonly eventId?: string; /** - * The action chosen by the Personalizer service. This is the action for which to report the - * reward. This might not be the + * The action chosen by the Personalizer service. This is the action your application should + * display, and for which to report the reward. This might not be the * first found in 'ranking' if an action in the request in first position was part of the * excluded ids. * **NOTE: This property will not be serialized. It can only be populated by the server.** @@ -164,12 +399,275 @@ export interface RankResponse { } /** - * Defines values for ErrorCode. - * Possible values include: 'BadRequest', 'ResourceNotFound', 'InternalServerError' + * An interface representing ContainerStatus. + */ +export interface ContainerStatus { + service?: string; + apiStatus?: string; + apiStatusMessage?: string; +} + +/** + * Defines headers for Create operation. + */ +export interface EvaluationsCreateHeaders { + /** + * Location of the evaluation resource + */ + location: string; +} + +/** + * Defines values for PersonalizerErrorCode. + * Possible values include: 'BadRequest', 'ResourceNotFound', 'InternalServerError', + * 'InvalidServiceConfiguration', 'InvalidPolicyConfiguration', 'InvalidPolicyContract', + * 'InvalidEvaluationContract', 'InvalidRewardRequest', 'InvalidEventIdToActivate', + * 'InvalidRankRequest', 'InvalidExportLogsRequest', 'InvalidContainer', 'FrontEndNotFound', + * 'EvaluationNotFound', 'LogsPropertiesNotFound', 'RankNullResponse', 'UpdateConfigurationFailed', + * 'ModelResetFailed' + * @readonly + * @enum {string} + */ +export type PersonalizerErrorCode = 'BadRequest' | 'ResourceNotFound' | 'InternalServerError' | 'InvalidServiceConfiguration' | 'InvalidPolicyConfiguration' | 'InvalidPolicyContract' | 'InvalidEvaluationContract' | 'InvalidRewardRequest' | 'InvalidEventIdToActivate' | 'InvalidRankRequest' | 'InvalidExportLogsRequest' | 'InvalidContainer' | 'FrontEndNotFound' | 'EvaluationNotFound' | 'LogsPropertiesNotFound' | 'RankNullResponse' | 'UpdateConfigurationFailed' | 'ModelResetFailed'; + +/** + * Defines values for EvaluationJobStatus. + * Possible values include: 'completed', 'pending', 'failed', 'notSubmitted' * @readonly * @enum {string} */ -export type ErrorCode = 'BadRequest' | 'ResourceNotFound' | 'InternalServerError'; +export type EvaluationJobStatus = 'completed' | 'pending' | 'failed' | 'notSubmitted'; + +/** + * Contains response data for the get operation. + */ +export type ServiceConfigurationGetResponse = ServiceConfiguration & { + /** + * 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: ServiceConfiguration; + }; +}; + +/** + * Contains response data for the update operation. + */ +export type ServiceConfigurationUpdateResponse = ServiceConfiguration & { + /** + * 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: ServiceConfiguration; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type PolicyGetResponse = PolicyContract & { + /** + * 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: PolicyContract; + }; +}; + +/** + * Contains response data for the update operation. + */ +export type PolicyUpdateResponse = PolicyContract & { + /** + * 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: PolicyContract; + }; +}; + +/** + * Contains response data for the reset operation. + */ +export type PolicyResetResponse = PolicyContract & { + /** + * 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: PolicyContract; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type EvaluationsGetResponse = Evaluation & { + /** + * 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: Evaluation; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type EvaluationsListResponse = Array & { + /** + * 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: Evaluation[]; + }; +}; + +/** + * Contains response data for the create operation. + */ +export type EvaluationsCreateResponse = Evaluation & EvaluationsCreateHeaders & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: EvaluationsCreateHeaders; + + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: Evaluation; + }; +}; + +/** + * Contains response data for the getProperties operation. + */ +export type LogGetPropertiesResponse = LogsProperties & { + /** + * 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: LogsProperties; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type ModelGetResponse = { + /** + * BROWSER ONLY + * + * The response body as a browser Blob. + * Always undefined in node.js. + */ + blobBody?: Promise; + + /** + * NODEJS ONLY + * + * The response body as a node.js Readable stream. + * Always undefined in the browser. + */ + readableStreamBody?: NodeJS.ReadableStream; + + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse; +}; + +/** + * Contains response data for the getProperties operation. + */ +export type ModelGetPropertiesResponse = ModelProperties & { + /** + * 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: ModelProperties; + }; +}; /** * Contains response data for the rank operation. diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/logMappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/logMappers.ts new file mode 100644 index 000000000000..b0847796a61c --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/logMappers.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + DateRange, + ErrorResponse, + InternalError, + LogsProperties, + LogsPropertiesDateRange, + PersonalizerError +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/mappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/mappers.ts index fe24cff0985f..fb1b0d954e91 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/mappers.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/mappers.ts @@ -1,6 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. @@ -9,6 +9,85 @@ import * as msRest from "@azure/ms-rest-js"; +export const ServiceConfiguration: msRest.CompositeMapper = { + serializedName: "ServiceConfiguration", + type: { + name: "Composite", + className: "ServiceConfiguration", + modelProperties: { + rewardWaitTime: { + required: true, + serializedName: "rewardWaitTime", + type: { + name: "TimeSpan" + } + }, + defaultReward: { + required: true, + serializedName: "defaultReward", + constraints: { + InclusiveMaximum: 1, + InclusiveMinimum: -1 + }, + type: { + name: "Number" + } + }, + rewardAggregation: { + required: true, + serializedName: "rewardAggregation", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + }, + explorationPercentage: { + required: true, + serializedName: "explorationPercentage", + constraints: { + InclusiveMaximum: 1, + InclusiveMinimum: 0 + }, + type: { + name: "Number" + } + }, + modelExportFrequency: { + required: true, + serializedName: "modelExportFrequency", + type: { + name: "TimeSpan" + } + }, + logMirrorEnabled: { + serializedName: "logMirrorEnabled", + type: { + name: "Boolean" + } + }, + logMirrorSasUri: { + serializedName: "logMirrorSasUri", + type: { + name: "String" + } + }, + logRetentionDays: { + required: true, + serializedName: "logRetentionDays", + constraints: { + InclusiveMaximum: 2147483647, + InclusiveMinimum: -1 + }, + type: { + name: "Number" + } + } + } + } +}; + export const InternalError: msRest.CompositeMapper = { serializedName: "InternalError", type: { @@ -99,6 +178,296 @@ export const ErrorResponse: msRest.CompositeMapper = { } }; +export const PolicyContract: msRest.CompositeMapper = { + serializedName: "PolicyContract", + type: { + name: "Composite", + className: "PolicyContract", + modelProperties: { + name: { + required: true, + serializedName: "name", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + }, + argumentsProperty: { + required: true, + serializedName: "arguments", + constraints: { + MaxLength: 1024 + }, + type: { + name: "String" + } + } + } + } +}; + +export const PolicyResultSummary: msRest.CompositeMapper = { + serializedName: "PolicyResultSummary", + type: { + name: "Composite", + className: "PolicyResultSummary", + modelProperties: { + timeStamp: { + readOnly: true, + serializedName: "timeStamp", + type: { + name: "DateTime" + } + }, + ipsEstimatorNumerator: { + readOnly: true, + serializedName: "ipsEstimatorNumerator", + type: { + name: "Number" + } + }, + ipsEstimatorDenominator: { + readOnly: true, + serializedName: "ipsEstimatorDenominator", + type: { + name: "Number" + } + }, + snipsEstimatorDenominator: { + readOnly: true, + serializedName: "snipsEstimatorDenominator", + type: { + name: "Number" + } + }, + aggregateTimeWindow: { + readOnly: true, + serializedName: "aggregateTimeWindow", + type: { + name: "TimeSpan" + } + }, + nonZeroProbability: { + serializedName: "nonZeroProbability", + type: { + name: "Number" + } + }, + confidenceInterval: { + readOnly: true, + serializedName: "confidenceInterval", + type: { + name: "Number" + } + }, + sumOfSquares: { + readOnly: true, + serializedName: "sumOfSquares", + type: { + name: "Number" + } + } + } + } +}; + +export const PolicyResultTotalSummary: msRest.CompositeMapper = { + serializedName: "PolicyResult_totalSummary", + type: { + name: "Composite", + className: "PolicyResultTotalSummary", + modelProperties: { + ...PolicyResultSummary.type.modelProperties + } + } +}; + +export const PolicyResult: msRest.CompositeMapper = { + serializedName: "PolicyResult", + type: { + name: "Composite", + className: "PolicyResult", + modelProperties: { + name: { + readOnly: true, + serializedName: "name", + type: { + name: "String" + } + }, + argumentsProperty: { + readOnly: true, + serializedName: "arguments", + type: { + name: "String" + } + }, + summary: { + readOnly: true, + serializedName: "summary", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PolicyResultSummary" + } + } + } + }, + totalSummary: { + readOnly: true, + serializedName: "totalSummary", + type: { + name: "Composite", + className: "PolicyResultTotalSummary" + } + } + } + } +}; + +export const Evaluation: msRest.CompositeMapper = { + serializedName: "Evaluation", + type: { + name: "Composite", + className: "Evaluation", + modelProperties: { + id: { + readOnly: true, + serializedName: "id", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + }, + name: { + readOnly: true, + serializedName: "name", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + }, + startTime: { + readOnly: true, + serializedName: "startTime", + type: { + name: "DateTime" + } + }, + endTime: { + readOnly: true, + serializedName: "endTime", + type: { + name: "DateTime" + } + }, + jobId: { + readOnly: true, + serializedName: "jobId", + type: { + name: "String" + } + }, + status: { + readOnly: true, + serializedName: "status", + type: { + name: "String" + } + }, + policyResults: { + serializedName: "policyResults", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PolicyResult" + } + } + } + }, + featureImportance: { + serializedName: "featureImportance", + type: { + name: "Sequence", + element: { + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } + } + } +}; + +export const EvaluationContract: msRest.CompositeMapper = { + serializedName: "EvaluationContract", + type: { + name: "Composite", + className: "EvaluationContract", + modelProperties: { + enableOfflineExperimentation: { + serializedName: "enableOfflineExperimentation", + type: { + name: "Boolean" + } + }, + name: { + required: true, + serializedName: "name", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + }, + startTime: { + required: true, + serializedName: "startTime", + type: { + name: "DateTime" + } + }, + endTime: { + required: true, + serializedName: "endTime", + type: { + name: "DateTime" + } + }, + policies: { + required: true, + serializedName: "policies", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PolicyContract" + } + } + } + } + } + } +}; + export const RewardRequest: msRest.CompositeMapper = { serializedName: "RewardRequest", type: { @@ -116,6 +485,83 @@ export const RewardRequest: msRest.CompositeMapper = { } }; +export const DateRange: msRest.CompositeMapper = { + serializedName: "DateRange", + type: { + name: "Composite", + className: "DateRange", + modelProperties: { + from: { + readOnly: true, + serializedName: "from", + type: { + name: "DateTime" + } + }, + to: { + readOnly: true, + serializedName: "to", + type: { + name: "DateTime" + } + } + } + } +}; + +export const LogsPropertiesDateRange: msRest.CompositeMapper = { + serializedName: "LogsProperties_dateRange", + type: { + name: "Composite", + className: "LogsPropertiesDateRange", + modelProperties: { + ...DateRange.type.modelProperties + } + } +}; + +export const LogsProperties: msRest.CompositeMapper = { + serializedName: "LogsProperties", + type: { + name: "Composite", + className: "LogsProperties", + modelProperties: { + dateRange: { + readOnly: true, + serializedName: "dateRange", + type: { + name: "Composite", + className: "LogsPropertiesDateRange" + } + } + } + } +}; + +export const ModelProperties: msRest.CompositeMapper = { + serializedName: "ModelProperties", + type: { + name: "Composite", + className: "ModelProperties", + modelProperties: { + creationTime: { + readOnly: true, + serializedName: "creationTime", + type: { + name: "DateTime" + } + }, + lastModifiedTime: { + readOnly: true, + serializedName: "lastModifiedTime", + type: { + name: "DateTime" + } + } + } + } +}; + export const RankableAction: msRest.CompositeMapper = { serializedName: "RankableAction", type: { @@ -282,3 +728,47 @@ export const RankResponse: msRest.CompositeMapper = { } } }; + +export const ContainerStatus: msRest.CompositeMapper = { + serializedName: "ContainerStatus", + type: { + name: "Composite", + className: "ContainerStatus", + modelProperties: { + service: { + serializedName: "service", + type: { + name: "String" + } + }, + apiStatus: { + serializedName: "apiStatus", + type: { + name: "String" + } + }, + apiStatusMessage: { + serializedName: "apiStatusMessage", + type: { + name: "String" + } + } + } + } +}; + +export const EvaluationsCreateHeaders: msRest.CompositeMapper = { + serializedName: "evaluations-create-headers", + type: { + name: "Composite", + className: "EvaluationsCreateHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/modelMappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/modelMappers.ts new file mode 100644 index 000000000000..9e6b79d593a7 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/modelMappers.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ErrorResponse, + InternalError, + ModelProperties, + PersonalizerError +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/parameters.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/parameters.ts index bf2e18e1e097..53fd742177d4 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/parameters.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/parameters.ts @@ -1,7 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is @@ -22,6 +21,19 @@ export const endpoint: msRest.OperationURLParameter = { }, skipEncoding: true }; +export const evaluationId: msRest.OperationURLParameter = { + parameterPath: "evaluationId", + mapper: { + required: true, + serializedName: "evaluationId", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + } +}; export const eventId: msRest.OperationURLParameter = { parameterPath: "eventId", mapper: { diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/policyMappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/policyMappers.ts new file mode 100644 index 000000000000..4ee658baa540 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/policyMappers.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ErrorResponse, + InternalError, + PersonalizerError, + PolicyContract +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/serviceConfigurationOperationsMappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/serviceConfigurationOperationsMappers.ts new file mode 100644 index 000000000000..587cb3f8b2f7 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/serviceConfigurationOperationsMappers.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ErrorResponse, + InternalError, + PersonalizerError, + ServiceConfiguration +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/evaluations.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/evaluations.ts new file mode 100644 index 000000000000..d16bdbd33c11 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/evaluations.ts @@ -0,0 +1,225 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * 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/evaluationsMappers"; +import * as Parameters from "../models/parameters"; +import { PersonalizerClientContext } from "../personalizerClientContext"; + +/** Class representing a Evaluations. */ +export class Evaluations { + private readonly client: PersonalizerClientContext; + + /** + * Create a Evaluations. + * @param {PersonalizerClientContext} client Reference to the service client. + */ + constructor(client: PersonalizerClientContext) { + this.client = client; + } + + /** + * Get the evaluation associated with the Id. + * @summary Get Evaluation. + * @param evaluationId Id of the evaluation. + * @param [options] The optional parameters + * @returns Promise + */ + get(evaluationId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param evaluationId Id of the evaluation. + * @param callback The callback + */ + get(evaluationId: string, callback: msRest.ServiceCallback): void; + /** + * @param evaluationId Id of the evaluation. + * @param options The optional parameters + * @param callback The callback + */ + get(evaluationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(evaluationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + evaluationId, + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Delete the evaluation associated with the Id. + * @summary Delete Evaluation. + * @param evaluationId Id of the evaluation to delete. + * @param [options] The optional parameters + * @returns Promise + */ + deleteMethod(evaluationId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param evaluationId Id of the evaluation to delete. + * @param callback The callback + */ + deleteMethod(evaluationId: string, callback: msRest.ServiceCallback): void; + /** + * @param evaluationId Id of the evaluation to delete. + * @param options The optional parameters + * @param callback The callback + */ + deleteMethod(evaluationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + deleteMethod(evaluationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + evaluationId, + options + }, + deleteMethodOperationSpec, + callback); + } + + /** + * List all the submitted evaluations. + * @summary List Evaluations. + * @param [options] The optional parameters + * @returns Promise + */ + list(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + list(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listOperationSpec, + callback) as Promise; + } + + /** + * Submit a new evaluation job. + * @summary Create Evaluation. + * @param evaluation The evaluation job definition. + * @param [options] The optional parameters + * @returns Promise + */ + create(evaluation: Models.EvaluationContract, options?: msRest.RequestOptionsBase): Promise; + /** + * @param evaluation The evaluation job definition. + * @param callback The callback + */ + create(evaluation: Models.EvaluationContract, callback: msRest.ServiceCallback): void; + /** + * @param evaluation The evaluation job definition. + * @param options The optional parameters + * @param callback The callback + */ + create(evaluation: Models.EvaluationContract, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + create(evaluation: Models.EvaluationContract, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + evaluation, + options + }, + createOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "evaluations/{evaluationId}", + urlParameters: [ + Parameters.endpoint, + Parameters.evaluationId + ], + responses: { + 200: { + bodyMapper: Mappers.Evaluation + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "evaluations/{evaluationId}", + urlParameters: [ + Parameters.endpoint, + Parameters.evaluationId + ], + responses: { + 204: {}, + default: {} + }, + serializer +}; + +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "evaluations", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: { + serializedName: "parsedResponse", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Evaluation" + } + } + } + } + }, + default: {} + }, + serializer +}; + +const createOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "evaluations", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "evaluation", + mapper: { + ...Mappers.EvaluationContract, + required: true + } + }, + responses: { + 201: { + bodyMapper: Mappers.Evaluation, + headersMapper: Mappers.EvaluationsCreateHeaders + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: Mappers.EvaluationsCreateHeaders + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/events.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/events.ts index d93f6e869966..85dda5374fb1 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/events.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/events.ts @@ -1,7 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is @@ -27,22 +26,24 @@ export class Events { } /** - * @summary Report reward to allocate to the top ranked action for the specified event. + * Report reward that resulted from using the action specified in rewardActionId for the specified + * event. + * @summary Post Reward. * @param eventId The event id this reward applies to. - * @param rewardParameter The reward should be a floating point number. + * @param rewardParameter The reward should be a floating point number, typically between 0 and 1. * @param [options] The optional parameters * @returns Promise */ reward(eventId: string, rewardParameter: Models.RewardRequest, options?: msRest.RequestOptionsBase): Promise; /** * @param eventId The event id this reward applies to. - * @param rewardParameter The reward should be a floating point number. + * @param rewardParameter The reward should be a floating point number, typically between 0 and 1. * @param callback The callback */ reward(eventId: string, rewardParameter: Models.RewardRequest, callback: msRest.ServiceCallback): void; /** * @param eventId The event id this reward applies to. - * @param rewardParameter The reward should be a floating point number. + * @param rewardParameter The reward should be a floating point number, typically between 0 and 1. * @param options The optional parameters * @param callback The callback */ @@ -59,8 +60,9 @@ export class Events { } /** - * @summary Report that the specified event was actually displayed to the user and a reward should - * be expected for it. + * Report that the specified event was actually displayed to the user and a reward should be + * expected for it + * @summary Activate Event. * @param eventId The event ID this activation applies to. * @param [options] The optional parameters * @returns Promise diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/index.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/index.ts index 5b0540c9ee1d..861d1b4c0cb8 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/index.ts @@ -1,11 +1,15 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ +export * from "./serviceConfigurationOperations"; +export * from "./policy"; +export * from "./evaluations"; export * from "./events"; +export * from "./log"; +export * from "./model"; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/log.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/log.ts new file mode 100644 index 000000000000..9231a413bf5e --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/log.ts @@ -0,0 +1,109 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * 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/logMappers"; +import * as Parameters from "../models/parameters"; +import { PersonalizerClientContext } from "../personalizerClientContext"; + +/** Class representing a Log. */ +export class Log { + private readonly client: PersonalizerClientContext; + + /** + * Create a Log. + * @param {PersonalizerClientContext} client Reference to the service client. + */ + constructor(client: PersonalizerClientContext) { + this.client = client; + } + + /** + * Delete all generated logs. + * @summary Deletes Logs. + * @param [options] The optional parameters + * @returns Promise + */ + deleteMethod(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + deleteMethod(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + deleteMethod(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + deleteMethod(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + deleteMethodOperationSpec, + callback); + } + + /** + * Get properties of generated logs. + * @summary Get Log Properties. + * @param [options] The optional parameters + * @returns Promise + */ + getProperties(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + getProperties(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + getProperties(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getProperties(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getPropertiesOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "logs", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 204: {}, + default: {} + }, + serializer +}; + +const getPropertiesOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "logs/properties", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.LogsProperties + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/model.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/model.ts new file mode 100644 index 000000000000..edf46d0ef78a --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/model.ts @@ -0,0 +1,154 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * 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/modelMappers"; +import * as Parameters from "../models/parameters"; +import { PersonalizerClientContext } from "../personalizerClientContext"; + +/** Class representing a Model. */ +export class Model { + private readonly client: PersonalizerClientContext; + + /** + * Create a Model. + * @param {PersonalizerClientContext} client Reference to the service client. + */ + constructor(client: PersonalizerClientContext) { + this.client = client; + } + + /** + * Get the model file generated by Personalizer service. + * @summary Get Model. + * @param [options] The optional parameters + * @returns Promise + */ + get(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + get(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + get(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Resets the model file generated by Personalizer service. + * @summary Reset Model. + * @param [options] The optional parameters + * @returns Promise + */ + reset(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + reset(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + reset(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + reset(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + resetOperationSpec, + callback); + } + + /** + * Get properties of the model file generated by Personalizer service. + * @summary Get Model Properties. + * @param [options] The optional parameters + * @returns Promise + */ + getProperties(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + getProperties(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + getProperties(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getProperties(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getPropertiesOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "model", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: { + serializedName: "parsedResponse", + type: { + name: "Stream" + } + } + }, + default: {} + }, + serializer +}; + +const resetOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "model", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const getPropertiesOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "model/properties", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.ModelProperties + }, + default: {} + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/policy.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/policy.ts new file mode 100644 index 000000000000..a5d2808b928f --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/policy.ts @@ -0,0 +1,162 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * 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/policyMappers"; +import * as Parameters from "../models/parameters"; +import { PersonalizerClientContext } from "../personalizerClientContext"; + +/** Class representing a Policy. */ +export class Policy { + private readonly client: PersonalizerClientContext; + + /** + * Create a Policy. + * @param {PersonalizerClientContext} client Reference to the service client. + */ + constructor(client: PersonalizerClientContext) { + this.client = client; + } + + /** + * Get the Learning settings currently used by the Personalizer service. + * @summary Get Policy. + * @param [options] The optional parameters + * @returns Promise + */ + get(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + get(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + get(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Update the Learning settings that the Personalizer service will use to train models. + * @summary Update Policy. + * @param policy The Learning settings. + * @param [options] The optional parameters + * @returns Promise + */ + update(policy: Models.PolicyContract, options?: msRest.RequestOptionsBase): Promise; + /** + * @param policy The Learning settings. + * @param callback The callback + */ + update(policy: Models.PolicyContract, callback: msRest.ServiceCallback): void; + /** + * @param policy The Learning settings. + * @param options The optional parameters + * @param callback The callback + */ + update(policy: Models.PolicyContract, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + update(policy: Models.PolicyContract, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + policy, + options + }, + updateOperationSpec, + callback) as Promise; + } + + /** + * Resets the Learning settings of the Personalizer service to default. + * @summary Reset Policy. + * @param [options] The optional parameters + * @returns Promise + */ + reset(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + reset(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + reset(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + reset(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + resetOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "configurations/policy", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.PolicyContract + }, + default: {} + }, + serializer +}; + +const updateOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "configurations/policy", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "policy", + mapper: { + ...Mappers.PolicyContract, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.PolicyContract + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const resetOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "configurations/policy", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.PolicyContract + }, + default: {} + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/serviceConfigurationOperations.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/serviceConfigurationOperations.ts new file mode 100644 index 000000000000..c1efced76190 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/serviceConfigurationOperations.ts @@ -0,0 +1,122 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * 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/serviceConfigurationOperationsMappers"; +import * as Parameters from "../models/parameters"; +import { PersonalizerClientContext } from "../personalizerClientContext"; + +/** Class representing a ServiceConfigurationOperations. */ +export class ServiceConfigurationOperations { + private readonly client: PersonalizerClientContext; + + /** + * Create a ServiceConfigurationOperations. + * @param {PersonalizerClientContext} client Reference to the service client. + */ + constructor(client: PersonalizerClientContext) { + this.client = client; + } + + /** + * Get the Personalizer service configuration. + * @summary Get Service Configuration. + * @param [options] The optional parameters + * @returns Promise + */ + get(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + get(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + get(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Update the Personalizer service configuration. + * @summary Update Service Configuration. + * @param config The personalizer service configuration. + * @param [options] The optional parameters + * @returns Promise + */ + update(config: Models.ServiceConfiguration, options?: msRest.RequestOptionsBase): Promise; + /** + * @param config The personalizer service configuration. + * @param callback The callback + */ + update(config: Models.ServiceConfiguration, callback: msRest.ServiceCallback): void; + /** + * @param config The personalizer service configuration. + * @param options The optional parameters + * @param callback The callback + */ + update(config: Models.ServiceConfiguration, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + update(config: Models.ServiceConfiguration, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + config, + options + }, + updateOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "configurations/service", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.ServiceConfiguration + }, + default: {} + }, + serializer +}; + +const updateOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", + path: "configurations/service", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "config", + mapper: { + ...Mappers.ServiceConfiguration, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.ServiceConfiguration + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerClient.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerClient.ts index 4f5c5a5c19fc..b2ba1a1792b8 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerClient.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerClient.ts @@ -1,7 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is @@ -17,7 +16,12 @@ import { PersonalizerClientContext } from "./personalizerClientContext"; class PersonalizerClient extends PersonalizerClientContext { // Operation groups + serviceConfiguration: operations.ServiceConfigurationOperations; + policy: operations.Policy; + evaluations: operations.Evaluations; events: operations.Events; + log: operations.Log; + model: operations.Model; /** * Initializes a new instance of the PersonalizerClient class. @@ -27,11 +31,18 @@ class PersonalizerClient extends PersonalizerClientContext { */ constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { super(credentials, endpoint, options); + this.serviceConfiguration = new operations.ServiceConfigurationOperations(this); + this.policy = new operations.Policy(this); + this.evaluations = new operations.Evaluations(this); this.events = new operations.Events(this); + this.log = new operations.Log(this); + this.model = new operations.Model(this); } /** - * @summary A Personalizer rank request. + * Submit a Personalizer rank request, to get which of the provided actions should be used in the + * provided context. + * @summary Post Rank. * @param rankRequest A Personalizer request. * @param [options] The optional parameters * @returns Promise diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerClientContext.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerClientContext.ts index d5c4a880206e..cb512a325ecf 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerClientContext.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerClientContext.ts @@ -1,7 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is