From 3f24f99e718adb7ba3d4343b1438d10025e4c1e2 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 1 Jul 2021 18:46:49 +0000 Subject: [PATCH] CodeGen from PR 15052 in Azure/azure-rest-api-specs Merge f8efff034bae8a19629f3d4d6abb6fd225385794 into 8f7e0b2d62e33916458b9138a0fcac8c64a7ac44 --- .../LICENSE.txt | 2 +- .../cognitiveservices-personalizer/README.md | 204 ++-- .../package.json | 13 +- .../rollup.config.js | 6 +- .../src/models/evaluationsMappers.ts | 20 + .../src/models/eventsMappers.ts | 4 +- .../src/models/index.ts | 838 +++++++++++++++- .../src/models/logMappers.ts | 16 + .../src/models/mappers.ts | 897 +++++++++++++++++- .../src/models/modelMappers.ts | 14 + .../src/models/multiSlotEventsMappers.ts | 15 + .../src/models/multiSlotMappers.ts | 18 + .../src/models/parameters.ts | 18 +- .../src/models/policyMappers.ts | 14 + .../serviceConfigurationOperationsMappers.ts | 15 + .../src/operations/evaluations.ts | 225 +++++ .../src/operations/events.ts | 34 +- .../src/operations/index.ts | 12 +- .../src/operations/log.ts | 109 +++ .../src/operations/model.ts | 154 +++ .../src/operations/multiSlot.ts | 84 ++ .../src/operations/multiSlotEvents.ts | 134 +++ .../src/operations/policy.ts | 162 ++++ .../serviceConfigurationOperations.ts | 173 ++++ .../src/personalizerBase.ts | 114 +++ .../src/personalizerBaseContext.ts | 54 ++ 26 files changed, 3100 insertions(+), 249 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/multiSlotEventsMappers.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/models/multiSlotMappers.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/multiSlot.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/multiSlotEvents.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/policy.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/serviceConfigurationOperations.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerBase.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerBaseContext.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..977054993499 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/README.md +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/README.md @@ -1,172 +1,96 @@ -## An isomorphic javascript sdk for - PersonalizerClient +## An isomorphic javascript sdk for - PersonalizerBase -This package contains an isomorphic SDK for PersonalizerClient. +This package contains an isomorphic SDK (runs both in node.js and in browsers) for PersonalizerBase. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/cognitiveservices-personalizer` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/cognitiveservices-personalizer +npm install --save @azure/cognitiveservices-personalizer @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. ### How to use -#### nodejs - Authentication, client creation and reward events as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-azure-js - -```bash -npm install @azure/ms-rest-azure-js -``` +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. +#### nodejs - Authentication, client creation, and get serviceConfiguration as an example written in JavaScript. ##### 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 -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 { DefaultAzureCredential } = require("@azure/identity"); +const { PersonalizerBase } = require("@azure/cognitiveservices-personalizer"); +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new PersonalizerBase(creds, subscriptionId); +client.serviceConfiguration.get().then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log("An error occurred:"); + 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. + +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code - index.html + ```html @azure/cognitiveservices-personalizer sample - @@ -177,4 +101,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/package.json b/sdk/cognitiveservices/cognitiveservices-personalizer/package.json index c739e09a553e..25f1e0800ea4 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/package.json +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/package.json @@ -1,10 +1,11 @@ { "name": "@azure/cognitiveservices-personalizer", "author": "Microsoft Corporation", - "description": "PersonalizerClient Library with typescript type definitions for node.js and browser.", + "description": "PersonalizerBase Library with typescript type definitions for node.js and browser.", "version": "2.0.1", "dependencies": { - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -16,16 +17,16 @@ ], "license": "MIT", "main": "./dist/cognitiveservices-personalizer.js", - "module": "./esm/personalizerClient.js", - "types": "./esm/personalizerClient.d.ts", + "module": "./esm/personalizerBase.js", + "types": "./esm/personalizerBase.d.ts", "devDependencies": { - "typescript": "^3.5.3", + "typescript": "^3.6.0", "rollup": "^1.18.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-sourcemaps": "^0.4.2", "uglify-js": "^3.6.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cognitiveservices/cognitiveservices-personalizer", + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-personalizer", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/rollup.config.js b/sdk/cognitiveservices/cognitiveservices-personalizer/rollup.config.js index ccb1c31cd803..237c8ecb4dd0 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/rollup.config.js +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/rollup.config.js @@ -6,7 +6,7 @@ import sourcemaps from "rollup-plugin-sourcemaps"; * @type {rollup.RollupFileOptions} */ const config = { - input: "./esm/personalizerClient.js", + input: "./esm/personalizerBase.js", external: [ "@azure/ms-rest-js", "@azure/ms-rest-azure-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..9cc2067d949a 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,77 @@ 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 + * and should be between 5 seconds and 2 days. + * 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; + /** + * Last time model training configuration was updated + */ + lastConfigurationEditDate?: Date; + /** + * Learning Modes for Personalizer. Possible values include: 'Online', 'Apprentice', + * 'LoggingOnly' + */ + learningMode?: LearningMode; + /** + * Flag indicating whether Personalizer will automatically optimize Learning Settings by running + * Offline Evaluations periodically. + */ + isAutoOptimizationEnabled?: boolean; + /** + * Frequency of automatic optimization. Only relevant if IsAutoOptimizationEnabled is true. + * For example, PT5M (5 mins). For information about the time format, + * \r\nsee http://en.wikipedia.org/wiki/ISO_8601#Durations + */ + autoOptimizationFrequency?: string; + /** + * Date when the first automatic optimization evaluation must be performed. Only relevant if + * IsAutoOptimizationEnabled is true. + */ + autoOptimizationStartDate?: Date; +} + /** * An object containing more specific information than the parent object about the error. */ @@ -17,9 +88,6 @@ export interface InternalError { * Detailed error code. */ code?: string; - /** - * The error object. - */ innererror?: InternalError; } @@ -28,10 +96,21 @@ export interface InternalError { */ export interface PersonalizerError { /** - * High level error code. Possible values include: 'BadRequest', 'ResourceNotFound', - * 'InternalServerError' + * Error Codes returned by Personalizer. Possible values include: 'BadRequest', + * 'InvalidServiceConfiguration', 'InvalidLearningModeServiceConfiguration', + * 'InvalidPolicyConfiguration', 'InvalidPolicyContract', 'InvalidEvaluationContract', + * 'DuplicateCustomPolicyNames', 'NoLogsExistInDateRange', 'LogsSizeExceedAllowedLimit', + * 'InvalidRewardRequest', 'InvalidEventIdToActivate', 'InvalidRankRequest', + * 'InvalidExportLogsRequest', 'InvalidContainer', 'InvalidModelMetadata', + * 'ApprenticeModeNeverTurnedOn', 'MissingAppId', 'InvalidRewardWaitTime', + * 'InvalidMultiSlotApiAccess', 'ModelFileAccessDenied', + * 'ProblemTypeIncompatibleWithAutoOptimization', 'ResourceNotFound', 'FrontEndNotFound', + * 'EvaluationNotFound', 'LearningSettingsNotFound', 'EvaluationModelNotFound', + * 'LogsPropertiesNotFound', 'ModelRankingError', 'InternalServerError', 'RankNullResponse', + * 'UpdateConfigurationFailed', 'ModelResetFailed', 'ModelPublishFailed', + * 'ModelMetadataUpdateFailed', 'OperationNotAllowed' */ - code: ErrorCode; + code: PersonalizerErrorCode; /** * A message explaining the error reported by the service. */ @@ -44,9 +123,6 @@ export interface PersonalizerError { * An array of details about specific errors that led to this reported error. */ details?: PersonalizerError[]; - /** - * Finer error details. - */ innerError?: InternalError; } @@ -54,10 +130,210 @@ export interface PersonalizerError { * Used to return an error to the client */ export interface ErrorResponse { + error: PersonalizerError; +} + +/** + * Learning settings specifying how to train the model. + */ +export interface PolicyContract { /** - * The error object. + * Name of the learning settings. */ - error: PersonalizerError; + name: string; + /** + * Arguments of the learning settings. + */ + argumentsProperty: string; +} + +/** + * Reference to the policy within the evaluation. + */ +export interface PolicyReferenceContract { + /** + * Evaluation Id of the evaluation. + */ + evaluationId: string; + /** + * Name of the learning settings. + */ + policyName: string; +} + +/** + * This class contains the summary of evaluating a policy on a counterfactual evaluation. + */ +export interface PolicyResultSummary { + /** + * Timestamp of the aggregation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly timeStamp?: Date; + /** + * Numerator for IPS estimator. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly ipsEstimatorNumerator?: number; + /** + * Denominator for IPS estimator. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly ipsEstimatorDenominator?: number; + /** + * Denominator for SNIPS estimator. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly snipsEstimatorDenominator?: number; + /** + * Time window for aggregation. + * For example, PT5M (5 mins). For information about the time format, + * see http://en.wikipedia.org/wiki/ISO_8601#Durations + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly aggregateTimeWindow?: string; + /** + * Probability of non-zero values for the Policy evaluation. + */ + nonZeroProbability?: number; + /** + * Sum of Squares for the Policy evaluation results. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly sumOfSquares?: number; + /** + * Gaussian confidence interval for the Policy evaluation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly confidenceInterval?: number; + /** + * Average reward. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly averageReward?: number; +} + +/** + * The aggregate total of the Offline Evaluation. + */ +export interface PolicyResultTotalSummary extends PolicyResultSummary { +} + +/** + * This class contains the Learning Settings information and the results of the Offline Evaluation + * using that policy. + */ +export interface PolicyResult { + /** + * The name of the Learning Settings. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly name?: string; + /** + * The arguments of the Learning Settings. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly argumentsProperty?: string; + /** + * The source of the Learning Settings. Possible values include: 'Online', 'Baseline', 'Random', + * 'Custom', 'OfflineExperimentation' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly policySource?: PolicySource; + /** + * The aggregate results of the Offline Evaluation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly summary?: PolicyResultSummary[]; + /** + * The aggregate total of the Offline Evaluation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly totalSummary?: PolicyResultTotalSummary; +} + +/** + * A Counterfactual Evaluation. + */ +export interface Evaluation { + /** + * The ID of the evaluation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly id?: string; + /** + * The name of the evaluation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly name?: string; + /** + * The start time of the evaluation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly startTime?: Date; + /** + * The end time of the evaluation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly endTime?: Date; + /** + * The ID of the job processing the evaluation. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly jobId?: string; + /** + * The status of the job processing the evaluation. Possible values include: 'completed', + * 'pending', 'failed', 'notSubmitted', 'timeout', 'optimalPolicyApplied', 'onlinePolicyRetained' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly status?: EvaluationJobStatus; + /** + * The results of the evaluation. + */ + policyResults?: PolicyResult[]; + /** + * Feature Importance. + */ + featureImportance?: string[][]; + /** + * Evaluation type (manual or through Automatic Optimization). Possible values include: 'Manual', + * 'Auto' + */ + evaluationType?: EvaluationType; + /** + * Thr optimal policy. + */ + optimalPolicy?: string; + /** + * Craetion time. + */ + creationTime?: Date; +} + +/** + * 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[]; } /** @@ -65,13 +341,87 @@ export interface ErrorResponse { */ export interface RewardRequest { /** - * Reward to be assigned to an action. Value should be between -1 and 1 inclusive. + * Reward to be assigned to an action. Value is a float calculated by your application, typically + * between 0 and 1, and must be between -1 and 1. + */ + value: number; +} + +/** + * A date range starting at From and ending at To. + */ +export interface DateRange { + /** + * Start date for the range. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly from?: Date; + /** + * End date for the range. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly to?: Date; +} + +/** + * Date range. + */ +export interface LogsPropertiesDateRange extends DateRange { +} + +/** + * Properties related to data used to train the model. + */ +export interface LogsProperties { + /** + * Date range. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly dateRange?: LogsPropertiesDateRange; +} + +/** + * Properties related to the trained model. + */ +export interface ModelProperties { + /** + * Creation time of the model. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly creationTime?: Date; + /** + * Last time the model was modified. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly lastModifiedTime?: Date; +} + +/** + * An interface representing SlotReward. + */ +export interface SlotReward { + /** + * Slot id for which we are sending the reward. + */ + slotId: string; + /** + * Reward to be assigned to slotId. Value should be between -1 and 1 inclusive. */ value: number; } /** - * An action with it's associated features used for ranking. + * Reward given to a list of slots. + */ +export interface MultiSlotRewardRequest { + /** + * List of SlotRewards + */ + reward: SlotReward[]; +} + +/** + * An action with its associated features used for ranking. */ export interface RankableAction { /** @@ -84,15 +434,124 @@ export interface RankableAction { features: any[]; } +/** + * A slot with it's associated features and list of excluded actions + */ +export interface SlotRequest { + /** + * Slot ID + */ + id: string; + /** + * List of dictionaries containing slot features. + */ + features?: any[]; + /** + * List of excluded action Ids. + */ + excludedActions?: string[]; + /** + * The 'baseline action' ID for the slot. + * The BaselineAction is the Id of the Action your application would use in that slot if + * Personalizer didn't exist. + * BaselineAction must be defined for every slot. + * BaselineAction should never be part of ExcludedActions. + * Each slot must have a unique BaselineAction which corresponds to an an action from the event's + * Actions list. + */ + baselineAction: string; +} + +/** + * An interface representing MultiSlotRankRequest. + */ +export interface MultiSlotRankRequest { + /** + * Features of the context used for Personalizer as a + * dictionary of dictionaries. This is determined by your application, and + * typically includes features about the current user, their + * 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[]; + /** + * The set of actions the Personalizer service can pick from. + * 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[]; + /** + * The set of slots the Personalizer service should select actions for. + * The set should not contain more than 50 slots. + */ + slots: SlotRequest[]; + /** + * Optionally pass an eventId that uniquely identifies this Rank event. + * If null, the service generates a unique eventId. The eventId will be used for + * associating this request with its reward, as well as seeding the pseudo-random + * generator when making a Personalizer call. + */ + eventId?: string; + /** + * 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 action specified in + * the rank results, + * (e.g. because the page is rendering later, or the Rank results may be overridden by code + * further downstream). + * You must call the Activate Event API if the event output is shown to users, otherwise Rewards + * will be ignored. Default value: false. + */ + deferActivation?: boolean; +} + +/** + * An interface representing SlotResponse. + */ +export interface SlotResponse { + /** + * Id is the slot ID. + */ + id: string; + /** + * RewardActionID is the action ID recommended by Personalizer. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly rewardActionId?: string; +} + +/** + * An interface representing MultiSlotRankResponse. + */ +export interface MultiSlotRankResponse { + /** + * Each slot has a corresponding rewardActionID which is the action ID recommended by + * Personalizer. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly slots?: SlotResponse[]; + /** + * The eventId for the round trip from request to response. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly eventId?: string; +} + /** * Request a set of actions to be ranked by the Personalizer service. */ export interface RankRequest { /** * Features of the context used for Personalizer as a - * dictionary of dictionaries. This depends on the application, and + * dictionary of dictionaries. This is determined by your 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,10 +559,13 @@ 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[]; /** * The set of action ids to exclude from ranking. + * Personalizer will consider the first non-excluded item in the array as the Baseline action + * when performing Offline Evaluations. */ excludedActions?: string[]; /** @@ -114,11 +576,15 @@ 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 - * overridden by code further downstream. Default value: false. + * Reward to the event. Send true if it is possible the user will not see the action specified in + * the rank results, + * (e.g. because the page is rendering later, or the Rank results may be overridden by code + * further downstream). + * You must call the Activate Event API if the event output is shown to users, otherwise Rewards + * will be ignored. Default value: false. */ deferActivation?: boolean; } @@ -140,7 +606,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,22 +621,335 @@ 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 - * first found in 'ranking' if an action in the request in first position was part of the - * excluded ids. + * 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'. * **NOTE: This property will not be serialized. It can only be populated by the server.** */ readonly rewardActionId?: string; } /** - * Defines values for ErrorCode. - * Possible values include: 'BadRequest', 'ResourceNotFound', 'InternalServerError' + * An interface representing ServiceStatus. + */ +export interface ServiceStatus { + service?: string; + apiStatus?: string; + apiStatusMessage?: string; +} + +/** + * Defines headers for Create operation. + */ +export interface EvaluationsCreateHeaders { + /** + * Location of the Offline Evaluation status and data. + */ + location: string; +} + +/** + * Defines values for LearningMode. + * Possible values include: 'Online', 'Apprentice', 'LoggingOnly' + * @readonly + * @enum {string} + */ +export type LearningMode = 'Online' | 'Apprentice' | 'LoggingOnly'; + +/** + * Defines values for PersonalizerErrorCode. + * Possible values include: 'BadRequest', 'InvalidServiceConfiguration', + * 'InvalidLearningModeServiceConfiguration', 'InvalidPolicyConfiguration', + * 'InvalidPolicyContract', 'InvalidEvaluationContract', 'DuplicateCustomPolicyNames', + * 'NoLogsExistInDateRange', 'LogsSizeExceedAllowedLimit', 'InvalidRewardRequest', + * 'InvalidEventIdToActivate', 'InvalidRankRequest', 'InvalidExportLogsRequest', + * 'InvalidContainer', 'InvalidModelMetadata', 'ApprenticeModeNeverTurnedOn', 'MissingAppId', + * 'InvalidRewardWaitTime', 'InvalidMultiSlotApiAccess', 'ModelFileAccessDenied', + * 'ProblemTypeIncompatibleWithAutoOptimization', 'ResourceNotFound', 'FrontEndNotFound', + * 'EvaluationNotFound', 'LearningSettingsNotFound', 'EvaluationModelNotFound', + * 'LogsPropertiesNotFound', 'ModelRankingError', 'InternalServerError', 'RankNullResponse', + * 'UpdateConfigurationFailed', 'ModelResetFailed', 'ModelPublishFailed', + * 'ModelMetadataUpdateFailed', 'OperationNotAllowed' + * @readonly + * @enum {string} + */ +export type PersonalizerErrorCode = 'BadRequest' | 'InvalidServiceConfiguration' | 'InvalidLearningModeServiceConfiguration' | 'InvalidPolicyConfiguration' | 'InvalidPolicyContract' | 'InvalidEvaluationContract' | 'DuplicateCustomPolicyNames' | 'NoLogsExistInDateRange' | 'LogsSizeExceedAllowedLimit' | 'InvalidRewardRequest' | 'InvalidEventIdToActivate' | 'InvalidRankRequest' | 'InvalidExportLogsRequest' | 'InvalidContainer' | 'InvalidModelMetadata' | 'ApprenticeModeNeverTurnedOn' | 'MissingAppId' | 'InvalidRewardWaitTime' | 'InvalidMultiSlotApiAccess' | 'ModelFileAccessDenied' | 'ProblemTypeIncompatibleWithAutoOptimization' | 'ResourceNotFound' | 'FrontEndNotFound' | 'EvaluationNotFound' | 'LearningSettingsNotFound' | 'EvaluationModelNotFound' | 'LogsPropertiesNotFound' | 'ModelRankingError' | 'InternalServerError' | 'RankNullResponse' | 'UpdateConfigurationFailed' | 'ModelResetFailed' | 'ModelPublishFailed' | 'ModelMetadataUpdateFailed' | 'OperationNotAllowed'; + +/** + * Defines values for PolicySource. + * Possible values include: 'Online', 'Baseline', 'Random', 'Custom', 'OfflineExperimentation' + * @readonly + * @enum {string} + */ +export type PolicySource = 'Online' | 'Baseline' | 'Random' | 'Custom' | 'OfflineExperimentation'; + +/** + * Defines values for EvaluationJobStatus. + * Possible values include: 'completed', 'pending', 'failed', 'notSubmitted', 'timeout', + * 'optimalPolicyApplied', 'onlinePolicyRetained' * @readonly * @enum {string} */ -export type ErrorCode = 'BadRequest' | 'ResourceNotFound' | 'InternalServerError'; +export type EvaluationJobStatus = 'completed' | 'pending' | 'failed' | 'notSubmitted' | 'timeout' | 'optimalPolicyApplied' | 'onlinePolicyRetained'; + +/** + * Defines values for EvaluationType. + * Possible values include: 'Manual', 'Auto' + * @readonly + * @enum {string} + */ +export type EvaluationType = 'Manual' | 'Auto'; + +/** + * 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 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 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. + */ +export type MultiSlotRankResponse2 = MultiSlotRankResponse & { + /** + * 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: MultiSlotRankResponse; + }; +}; /** * 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..3cc1c5b54a7b 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,115 @@ 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" + } + }, + lastConfigurationEditDate: { + serializedName: "lastConfigurationEditDate", + type: { + name: "DateTime" + } + }, + learningMode: { + serializedName: "learningMode", + type: { + name: "String" + } + }, + isAutoOptimizationEnabled: { + serializedName: "isAutoOptimizationEnabled", + type: { + name: "Boolean" + } + }, + autoOptimizationFrequency: { + serializedName: "autoOptimizationFrequency", + type: { + name: "TimeSpan" + } + }, + autoOptimizationStartDate: { + serializedName: "autoOptimizationStartDate", + type: { + name: "DateTime" + } + } + } + } +}; + export const InternalError: msRest.CompositeMapper = { serializedName: "InternalError", type: { @@ -18,109 +127,730 @@ export const InternalError: msRest.CompositeMapper = { code: { serializedName: "code", type: { - name: "String" + name: "String" + } + }, + innererror: { + serializedName: "innererror", + type: { + name: "Composite", + className: "InternalError" + } + } + } + } +}; + +export const PersonalizerError: msRest.CompositeMapper = { + serializedName: "PersonalizerError", + type: { + name: "Composite", + className: "PersonalizerError", + modelProperties: { + code: { + required: true, + serializedName: "code", + type: { + name: "String" + } + }, + message: { + required: true, + serializedName: "message", + type: { + name: "String" + } + }, + target: { + serializedName: "target", + type: { + name: "String" + } + }, + details: { + serializedName: "details", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PersonalizerError" + } + } + } + }, + innerError: { + serializedName: "innerError", + type: { + name: "Composite", + className: "InternalError" + } + } + } + } +}; + +export const ErrorResponse: msRest.CompositeMapper = { + serializedName: "ErrorResponse", + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + error: { + required: true, + serializedName: "error", + type: { + name: "Composite", + className: "PersonalizerError" + } + } + } + } +}; + +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 PolicyReferenceContract: msRest.CompositeMapper = { + serializedName: "PolicyReferenceContract", + type: { + name: "Composite", + className: "PolicyReferenceContract", + modelProperties: { + evaluationId: { + required: true, + serializedName: "evaluationId", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + }, + policyName: { + required: true, + serializedName: "policyName", + constraints: { + MaxLength: 256 + }, + 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" + } + }, + sumOfSquares: { + readOnly: true, + serializedName: "sumOfSquares", + type: { + name: "Number" + } + }, + confidenceInterval: { + readOnly: true, + serializedName: "confidenceInterval", + type: { + name: "Number" + } + }, + averageReward: { + readOnly: true, + serializedName: "averageReward", + 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" + } + }, + policySource: { + readOnly: true, + serializedName: "policySource", + 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" + } + } + } + } + } + }, + evaluationType: { + serializedName: "evaluationType", + type: { + name: "String" + } + }, + optimalPolicy: { + serializedName: "optimalPolicy", + type: { + name: "String" + } + }, + creationTime: { + serializedName: "creationTime", + type: { + name: "DateTime" + } + } + } + } +}; + +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: { + name: "Composite", + className: "RewardRequest", + modelProperties: { + value: { + required: true, + serializedName: "value", + type: { + name: "Number" + } + } + } + } +}; + +export const DateRange: msRest.CompositeMapper = { + serializedName: "DateRange", + type: { + name: "Composite", + className: "DateRange", + modelProperties: { + from: { + readOnly: true, + serializedName: "from", + type: { + name: "DateTime" } }, - innererror: { - serializedName: "innererror", + 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: "InternalError" + className: "LogsPropertiesDateRange" } } } } }; -export const PersonalizerError: msRest.CompositeMapper = { - serializedName: "PersonalizerError", +export const ModelProperties: msRest.CompositeMapper = { + serializedName: "ModelProperties", type: { name: "Composite", - className: "PersonalizerError", + className: "ModelProperties", modelProperties: { - code: { - required: true, - serializedName: "code", + creationTime: { + readOnly: true, + serializedName: "creationTime", type: { - name: "String" + name: "DateTime" } }, - message: { + lastModifiedTime: { + readOnly: true, + serializedName: "lastModifiedTime", + type: { + name: "DateTime" + } + } + } + } +}; + +export const SlotReward: msRest.CompositeMapper = { + serializedName: "SlotReward", + type: { + name: "Composite", + className: "SlotReward", + modelProperties: { + slotId: { required: true, - serializedName: "message", + serializedName: "slotId", + constraints: { + MaxLength: 256, + MinLength: 1 + }, type: { name: "String" } }, - target: { - serializedName: "target", + value: { + required: true, + serializedName: "value", type: { - name: "String" + name: "Number" } - }, - details: { - serializedName: "details", + } + } + } +}; + +export const MultiSlotRewardRequest: msRest.CompositeMapper = { + serializedName: "MultiSlotRewardRequest", + type: { + name: "Composite", + className: "MultiSlotRewardRequest", + modelProperties: { + reward: { + required: true, + serializedName: "reward", type: { name: "Sequence", element: { type: { name: "Composite", - className: "PersonalizerError" + className: "SlotReward" } } } + } + } + } +}; + +export const RankableAction: msRest.CompositeMapper = { + serializedName: "RankableAction", + type: { + name: "Composite", + className: "RankableAction", + modelProperties: { + id: { + required: true, + serializedName: "id", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } }, - innerError: { - serializedName: "innerError", + features: { + required: true, + serializedName: "features", type: { - name: "Composite", - className: "InternalError" + name: "Sequence", + element: { + type: { + name: "Object" + } + } } } } } }; -export const ErrorResponse: msRest.CompositeMapper = { - serializedName: "ErrorResponse", +export const SlotRequest: msRest.CompositeMapper = { + serializedName: "SlotRequest", type: { name: "Composite", - className: "ErrorResponse", + className: "SlotRequest", modelProperties: { - error: { + id: { required: true, - serializedName: "error", + serializedName: "id", type: { - name: "Composite", - className: "PersonalizerError" + name: "String" + } + }, + features: { + serializedName: "features", + type: { + name: "Sequence", + element: { + type: { + name: "Object" + } + } + } + }, + excludedActions: { + serializedName: "excludedActions", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + baselineAction: { + required: true, + serializedName: "baselineAction", + type: { + name: "String" } } } } }; -export const RewardRequest: msRest.CompositeMapper = { - serializedName: "RewardRequest", +export const MultiSlotRankRequest: msRest.CompositeMapper = { + serializedName: "MultiSlotRankRequest", type: { name: "Composite", - className: "RewardRequest", + className: "MultiSlotRankRequest", modelProperties: { - value: { + contextFeatures: { + serializedName: "contextFeatures", + type: { + name: "Sequence", + element: { + type: { + name: "Object" + } + } + } + }, + actions: { required: true, - serializedName: "value", + serializedName: "actions", type: { - name: "Number" + name: "Sequence", + element: { + type: { + name: "Composite", + className: "RankableAction" + } + } + } + }, + slots: { + required: true, + serializedName: "slots", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "SlotRequest" + } + } + } + }, + eventId: { + serializedName: "eventId", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + }, + deferActivation: { + serializedName: "deferActivation", + defaultValue: false, + type: { + name: "Boolean" } } } } }; -export const RankableAction: msRest.CompositeMapper = { - serializedName: "RankableAction", +export const SlotResponse: msRest.CompositeMapper = { + serializedName: "SlotResponse", type: { name: "Composite", - className: "RankableAction", + className: "SlotResponse", modelProperties: { id: { required: true, @@ -132,17 +862,48 @@ export const RankableAction: msRest.CompositeMapper = { name: "String" } }, - features: { - required: true, - serializedName: "features", + rewardActionId: { + readOnly: true, + serializedName: "rewardActionId", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } + } + } + } +}; + +export const MultiSlotRankResponse: msRest.CompositeMapper = { + serializedName: "MultiSlotRankResponse", + type: { + name: "Composite", + className: "MultiSlotRankResponse", + modelProperties: { + slots: { + readOnly: true, + serializedName: "slots", type: { name: "Sequence", element: { type: { - name: "Object" + name: "Composite", + className: "SlotResponse" } } } + }, + eventId: { + readOnly: true, + serializedName: "eventId", + constraints: { + MaxLength: 256 + }, + type: { + name: "String" + } } } } @@ -282,3 +1043,47 @@ export const RankResponse: msRest.CompositeMapper = { } } }; + +export const ServiceStatus: msRest.CompositeMapper = { + serializedName: "ServiceStatus", + type: { + name: "Composite", + className: "ServiceStatus", + 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/multiSlotEventsMappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/multiSlotEventsMappers.ts new file mode 100644 index 000000000000..0b5aba61cec9 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/multiSlotEventsMappers.ts @@ -0,0 +1,15 @@ +/* + * 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, + MultiSlotRewardRequest, + PersonalizerError, + SlotReward +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/multiSlotMappers.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/multiSlotMappers.ts new file mode 100644 index 000000000000..82bd5a5c2847 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/multiSlotMappers.ts @@ -0,0 +1,18 @@ +/* + * 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, + MultiSlotRankRequest, + MultiSlotRankResponse, + PersonalizerError, + RankableAction, + SlotRequest, + SlotResponse +} 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..deeb984de93b --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/models/serviceConfigurationOperationsMappers.ts @@ -0,0 +1,15 @@ +/* + * 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, + PolicyReferenceContract, + 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..1bce7e95302c --- /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 { PersonalizerBaseContext } from "../personalizerBaseContext"; + +/** Class representing a Evaluations. */ +export class Evaluations { + private readonly client: PersonalizerBaseContext; + + /** + * Create a Evaluations. + * @param {PersonalizerBaseContext} client Reference to the service client. + */ + constructor(client: PersonalizerBaseContext) { + this.client = client; + } + + /** + * Delete the Offline Evaluation associated with the Id. + * @summary Delete Evaluation. + * @param evaluationId Id of the Offline Evaluation to delete. + * @param [options] The optional parameters + * @returns Promise + */ + deleteMethod(evaluationId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param evaluationId Id of the Offline Evaluation to delete. + * @param callback The callback + */ + deleteMethod(evaluationId: string, callback: msRest.ServiceCallback): void; + /** + * @param evaluationId Id of the Offline 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); + } + + /** + * Get the Offline Evaluation associated with the Id. + * @summary Get Evaluation. + * @param evaluationId Id of the Offline Evaluation. + * @param [options] The optional parameters + * @returns Promise + */ + get(evaluationId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param evaluationId Id of the Offline Evaluation. + * @param callback The callback + */ + get(evaluationId: string, callback: msRest.ServiceCallback): void; + /** + * @param evaluationId Id of the Offline 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; + } + + /** + * List of all Offline Evaluations. + * @summary List Offline 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 Offline Evaluation job. + * @summary Create Offline Evaluation. + * @param evaluation The Offline Evaluation job definition. + * @param [options] The optional parameters + * @returns Promise + */ + create(evaluation: Models.EvaluationContract, options?: msRest.RequestOptionsBase): Promise; + /** + * @param evaluation The Offline Evaluation job definition. + * @param callback The callback + */ + create(evaluation: Models.EvaluationContract, callback: msRest.ServiceCallback): void; + /** + * @param evaluation The Offline 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 deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", + path: "evaluations/{evaluationId}", + urlParameters: [ + Parameters.endpoint, + Parameters.evaluationId + ], + responses: { + 204: {}, + default: {} + }, + serializer +}; + +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 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..f061c4ade41c 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 @@ -12,37 +11,39 @@ import * as msRest from "@azure/ms-rest-js"; import * as Models from "../models"; import * as Mappers from "../models/eventsMappers"; import * as Parameters from "../models/parameters"; -import { PersonalizerClientContext } from "../personalizerClientContext"; +import { PersonalizerBaseContext } from "../personalizerBaseContext"; /** Class representing a Events. */ export class Events { - private readonly client: PersonalizerClientContext; + private readonly client: PersonalizerBaseContext; /** * Create a Events. - * @param {PersonalizerClientContext} client Reference to the service client. + * @param {PersonalizerBaseContext} client Reference to the service client. */ - constructor(client: PersonalizerClientContext) { + constructor(client: PersonalizerBaseContext) { this.client = client; } /** - * @summary Report reward to allocate to the top ranked action for the specified event. + * Report reward between 0 and 1 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,20 +60,21 @@ export class Events { } /** - * @summary Report that the specified event was actually displayed to the user and a reward should - * be expected for it. - * @param eventId The event ID this activation applies to. + * Report that the specified event was actually used (e.g. by being displayed to the user) and a + * reward should be expected for it. + * @summary Activate Event. + * @param eventId The event ID to be activated. * @param [options] The optional parameters * @returns Promise */ activate(eventId: string, options?: msRest.RequestOptionsBase): Promise; /** - * @param eventId The event ID this activation applies to. + * @param eventId The event ID to be activated. * @param callback The callback */ activate(eventId: string, callback: msRest.ServiceCallback): void; /** - * @param eventId The event ID this activation applies to. + * @param eventId The event ID to be activated. * @param options The optional parameters * @param callback The callback */ diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/index.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/index.ts index 5b0540c9ee1d..fce2d7586fff 100644 --- a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/index.ts @@ -1,11 +1,17 @@ /* - * 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"; +export * from "./multiSlotEvents"; +export * from "./multiSlot"; 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..f6b9cefb5dfc --- /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 { PersonalizerBaseContext } from "../personalizerBaseContext"; + +/** Class representing a Log. */ +export class Log { + private readonly client: PersonalizerBaseContext; + + /** + * Create a Log. + * @param {PersonalizerBaseContext} client Reference to the service client. + */ + constructor(client: PersonalizerBaseContext) { + this.client = client; + } + + /** + * Delete all logs of Rank and Reward calls stored by Personalizer. + * @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 the Personalizer 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..40c954b1a576 --- /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 { PersonalizerBaseContext } from "../personalizerBaseContext"; + +/** Class representing a Model. */ +export class Model { + private readonly client: PersonalizerBaseContext; + + /** + * Create a Model. + * @param {PersonalizerBaseContext} client Reference to the service client. + */ + constructor(client: PersonalizerBaseContext) { + 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/multiSlot.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/multiSlot.ts new file mode 100644 index 000000000000..7e11e113bc07 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/multiSlot.ts @@ -0,0 +1,84 @@ +/* + * 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/multiSlotMappers"; +import * as Parameters from "../models/parameters"; +import { PersonalizerBaseContext } from "../personalizerBaseContext"; + +/** Class representing a MultiSlot. */ +export class MultiSlot { + private readonly client: PersonalizerBaseContext; + + /** + * Create a MultiSlot. + * @param {PersonalizerBaseContext} client Reference to the service client. + */ + constructor(client: PersonalizerBaseContext) { + this.client = client; + } + + /** + * Submit a Personalizer multi-slot rank request. Receives a context, a list of actions, and a list + * of slots. Returns which of the provided actions should be used in each slot, in each + * rewardActionId. + * @summary Post multi-slot Rank. + * @param body A Personalizer multi-slot Rank request. + * @param [options] The optional parameters + * @returns Promise + */ + rank(body: Models.MultiSlotRankRequest, options?: msRest.RequestOptionsBase): Promise; + /** + * @param body A Personalizer multi-slot Rank request. + * @param callback The callback + */ + rank(body: Models.MultiSlotRankRequest, callback: msRest.ServiceCallback): void; + /** + * @param body A Personalizer multi-slot Rank request. + * @param options The optional parameters + * @param callback The callback + */ + rank(body: Models.MultiSlotRankRequest, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + rank(body: Models.MultiSlotRankRequest, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + body, + options + }, + rankOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const rankOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "multislot/rank", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "body", + mapper: { + ...Mappers.MultiSlotRankRequest, + required: true + } + }, + responses: { + 201: { + bodyMapper: Mappers.MultiSlotRankResponse + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/multiSlotEvents.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/multiSlotEvents.ts new file mode 100644 index 000000000000..f9adff276e32 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/multiSlotEvents.ts @@ -0,0 +1,134 @@ +/* + * 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/multiSlotEventsMappers"; +import * as Parameters from "../models/parameters"; +import { PersonalizerBaseContext } from "../personalizerBaseContext"; + +/** Class representing a MultiSlotEvents. */ +export class MultiSlotEvents { + private readonly client: PersonalizerBaseContext; + + /** + * Create a MultiSlotEvents. + * @param {PersonalizerBaseContext} client Reference to the service client. + */ + constructor(client: PersonalizerBaseContext) { + this.client = client; + } + + /** + * Report reward that resulted from using the action specified in rewardActionId for the slot. + * @summary Post multi-slot Rewards. + * @param eventId The event id this reward applies to. + * @param body List of slot id and reward values. The reward should be a floating point number, + * typically between 0 and 1. + * @param [options] The optional parameters + * @returns Promise + */ + reward(eventId: string, body: Models.MultiSlotRewardRequest, options?: msRest.RequestOptionsBase): Promise; + /** + * @param eventId The event id this reward applies to. + * @param body List of slot id and reward values. The reward should be a floating point number, + * typically between 0 and 1. + * @param callback The callback + */ + reward(eventId: string, body: Models.MultiSlotRewardRequest, callback: msRest.ServiceCallback): void; + /** + * @param eventId The event id this reward applies to. + * @param body List of slot id and reward values. The reward should be a floating point number, + * typically between 0 and 1. + * @param options The optional parameters + * @param callback The callback + */ + reward(eventId: string, body: Models.MultiSlotRewardRequest, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + reward(eventId: string, body: Models.MultiSlotRewardRequest, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + eventId, + body, + options + }, + rewardOperationSpec, + callback); + } + + /** + * Report that the specified event was actually used or displayed to the user and a rewards should + * be expected for it. + * @summary Activate multi-slot Event. + * @param eventId The event ID this activation applies to. + * @param [options] The optional parameters + * @returns Promise + */ + activate(eventId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param eventId The event ID this activation applies to. + * @param callback The callback + */ + activate(eventId: string, callback: msRest.ServiceCallback): void; + /** + * @param eventId The event ID this activation applies to. + * @param options The optional parameters + * @param callback The callback + */ + activate(eventId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + activate(eventId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + eventId, + options + }, + activateOperationSpec, + callback); + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const rewardOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "multislot/events/{eventId}/reward", + urlParameters: [ + Parameters.endpoint, + Parameters.eventId + ], + requestBody: { + parameterPath: "body", + mapper: { + ...Mappers.MultiSlotRewardRequest, + required: true + } + }, + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const activateOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "multislot/events/{eventId}/activate", + urlParameters: [ + Parameters.endpoint, + Parameters.eventId + ], + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + 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..fd219821e25e --- /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 { PersonalizerBaseContext } from "../personalizerBaseContext"; + +/** Class representing a Policy. */ +export class Policy { + private readonly client: PersonalizerBaseContext; + + /** + * Create a Policy. + * @param {PersonalizerBaseContext} client Reference to the service client. + */ + constructor(client: PersonalizerBaseContext) { + 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..da918efdd65c --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/operations/serviceConfigurationOperations.ts @@ -0,0 +1,173 @@ +/* + * 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 { PersonalizerBaseContext } from "../personalizerBaseContext"; + +/** Class representing a ServiceConfigurationOperations. */ +export class ServiceConfigurationOperations { + private readonly client: PersonalizerBaseContext; + + /** + * Create a ServiceConfigurationOperations. + * @param {PersonalizerBaseContext} client Reference to the service client. + */ + constructor(client: PersonalizerBaseContext) { + this.client = client; + } + + /** + * 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; + } + + /** + * 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; + } + + /** + * @summary Apply Learning Settings and model from a pre-existing Offline Evaluation, making them + * the current online Learning Settings and model and replacing the previous ones. + * @param body + * @param [options] The optional parameters + * @returns Promise + */ + applyFromEvaluation(body: Models.PolicyReferenceContract, options?: msRest.RequestOptionsBase): Promise; + /** + * @param body + * @param callback The callback + */ + applyFromEvaluation(body: Models.PolicyReferenceContract, callback: msRest.ServiceCallback): void; + /** + * @param body + * @param options The optional parameters + * @param callback The callback + */ + applyFromEvaluation(body: Models.PolicyReferenceContract, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + applyFromEvaluation(body: Models.PolicyReferenceContract, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + body, + options + }, + applyFromEvaluationOperationSpec, + callback); + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +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 +}; + +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "configurations/service", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.ServiceConfiguration + }, + default: {} + }, + serializer +}; + +const applyFromEvaluationOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "configurations/applyFromEvaluation", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "body", + mapper: { + ...Mappers.PolicyReferenceContract, + required: true + } + }, + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerBase.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerBase.ts new file mode 100644 index 000000000000..c70af26d784b --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerBase.ts @@ -0,0 +1,114 @@ +/* + * 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/mappers"; +import * as Parameters from "./models/parameters"; +import * as operations from "./operations"; +import { PersonalizerBaseContext } from "./personalizerBaseContext"; + +class PersonalizerBase extends PersonalizerBaseContext { + // Operation groups + serviceConfiguration: operations.ServiceConfigurationOperations; + policy: operations.Policy; + evaluations: operations.Evaluations; + events: operations.Events; + log: operations.Log; + model: operations.Model; + multiSlotEvents: operations.MultiSlotEvents; + multiSlot: operations.MultiSlot; + + /** + * Initializes a new instance of the PersonalizerBase class. + * @param endpoint Supported Cognitive Services endpoint. + * @param credentials Subscription credentials which uniquely identify client subscription. + * Credentials implementing the TokenCredential interface from the @azure/identity package are + * recommended. For more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, 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); + this.multiSlotEvents = new operations.MultiSlotEvents(this); + this.multiSlot = new operations.MultiSlot(this); + } + + /** + * Submit a Personalizer rank request. Receives a context and a list of actions. Returns which of + * the provided actions should be used by your application, in rewardActionId. + * @summary Post Rank. + * @param rankRequest A Personalizer Rank request. + * @param [options] The optional parameters + * @returns Promise + */ + rank(rankRequest: Models.RankRequest, options?: msRest.RequestOptionsBase): Promise; + /** + * @param rankRequest A Personalizer Rank request. + * @param callback The callback + */ + rank(rankRequest: Models.RankRequest, callback: msRest.ServiceCallback): void; + /** + * @param rankRequest A Personalizer Rank request. + * @param options The optional parameters + * @param callback The callback + */ + rank(rankRequest: Models.RankRequest, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + rank(rankRequest: Models.RankRequest, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + rankRequest, + options + }, + rankOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const rankOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "rank", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "rankRequest", + mapper: { + ...Mappers.RankRequest, + required: true + } + }, + responses: { + 201: { + bodyMapper: Mappers.RankResponse + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +export { + PersonalizerBase, + PersonalizerBaseContext, + Models as PersonalizerBaseModels, + Mappers as PersonalizerBaseMappers +}; +export * from "./operations"; diff --git a/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerBaseContext.ts b/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerBaseContext.ts new file mode 100644 index 000000000000..be200cf6f28a --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-personalizer/src/personalizerBaseContext.ts @@ -0,0 +1,54 @@ +/* + * 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"; + +const packageName = "@azure/cognitiveservices-personalizer"; +const packageVersion = "2.0.1"; + +export class PersonalizerBaseContext extends msRest.ServiceClient { + endpoint: string; + credentials: msRest.ServiceClientCredentials | TokenCredential; + + /** + * Initializes a new instance of the PersonalizerBaseContext class. + * @param endpoint Supported Cognitive Services endpoint. + * @param credentials Subscription credentials which uniquely identify client subscription. + * Credentials implementing the TokenCredential interface from the @azure/identity package are + * recommended. For more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, endpoint: string, options?: msRest.ServiceClientOptions) { + if (endpoint == undefined) { + throw new Error("'endpoint' cannot be null."); + } + if (credentials == undefined) { + throw new Error("'credentials' cannot be null."); + } + + if (!options) { + options = {}; + } + + if (!options.userAgent) { + const defaultUserAgent = msRest.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.baseUri = "{Endpoint}/personalizer/v1.1-preview.1"; + this.requestContentType = "application/json; charset=utf-8"; + this.endpoint = endpoint; + this.credentials = credentials; + } +}