azure_cognitiveservices_personalizer 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/azure_cognitiveservices_personalizer.rb +6 -0
  4. data/lib/module_definition.rb +7 -0
  5. data/lib/profiles/latest/modules/personalizer_profile_module.rb +95 -0
  6. data/lib/profiles/latest/personalizer_latest_profile_client.rb +38 -0
  7. data/lib/profiles/latest/personalizer_module_definition.rb +8 -0
  8. data/lib/v1.0/generated/azure_cognitiveservices_personalizer.rb +37 -0
  9. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/events.rb +204 -0
  10. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/error_code.rb +17 -0
  11. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/error_response.rb +47 -0
  12. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/internal_error.rb +59 -0
  13. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/personalizer_error.rb +103 -0
  14. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/rank_request.rb +141 -0
  15. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/rank_response.rb +91 -0
  16. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/rankable_action.rb +68 -0
  17. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/ranked_action.rb +66 -0
  18. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/models/reward_request.rb +47 -0
  19. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/module_definition.rb +9 -0
  20. data/lib/v1.0/generated/azure_cognitiveservices_personalizer/personalizer_client.rb +226 -0
  21. data/lib/version.rb +7 -0
  22. metadata +137 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9d6df87294302fc4c15b2bfdd225f0ee6bdaa7e5
4
+ data.tar.gz: 90bbb9abc52238be90f78ac4f741df7069a46579
5
+ SHA512:
6
+ metadata.gz: 0a65157b50c8140e9eef4bc8898a4f1d52cd789d460688110b458bb11e2ef4f18fdeb30fc6c5ccc6e69619a9afbe8c9b6c2d74c5b3275a69b9f9992a68112381
7
+ data.tar.gz: 13cf89f61fb9cfe8d84ebe4c2185209408205e6bba9ee9f8e06132cefe95da38c936b8fa960a1034c3da996082a777be14dde87eaa854e608aa012d313e37efe
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Microsoft Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ require 'v1.0/generated/azure_cognitiveservices_personalizer'
6
+ require 'profiles/latest/personalizer_latest_profile_client'
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ module Azure end
6
+ module Azure::CognitiveServices end
7
+ module Azure::CognitiveServices::Personalizer end
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ require 'azure_cognitiveservices_personalizer'
6
+
7
+ module Azure::Personalizer::Profiles::Latest
8
+ Events = Azure::CognitiveServices::Personalizer::V1_0::Events
9
+
10
+ module Models
11
+ RankableAction = Azure::CognitiveServices::Personalizer::V1_0::Models::RankableAction
12
+ InternalError = Azure::CognitiveServices::Personalizer::V1_0::Models::InternalError
13
+ RankRequest = Azure::CognitiveServices::Personalizer::V1_0::Models::RankRequest
14
+ ErrorResponse = Azure::CognitiveServices::Personalizer::V1_0::Models::ErrorResponse
15
+ RankedAction = Azure::CognitiveServices::Personalizer::V1_0::Models::RankedAction
16
+ PersonalizerError = Azure::CognitiveServices::Personalizer::V1_0::Models::PersonalizerError
17
+ RankResponse = Azure::CognitiveServices::Personalizer::V1_0::Models::RankResponse
18
+ RewardRequest = Azure::CognitiveServices::Personalizer::V1_0::Models::RewardRequest
19
+ ErrorCode = Azure::CognitiveServices::Personalizer::V1_0::Models::ErrorCode
20
+ end
21
+
22
+ #
23
+ # PersonalizerDataClass
24
+ #
25
+ class PersonalizerDataClass
26
+ attr_reader :events, :configurable, :base_url, :options, :model_classes
27
+
28
+ def initialize(options = {})
29
+ if options.is_a?(Hash) && options.length == 0
30
+ @options = setup_default_options
31
+ else
32
+ @options = options
33
+ end
34
+
35
+ reset!(options)
36
+
37
+ @configurable = self
38
+ @base_url = options[:base_url].nil? ? nil:options[:base_url]
39
+ @options = options[:options].nil? ? nil:options[:options]
40
+
41
+ @client_0 = Azure::CognitiveServices::Personalizer::V1_0::PersonalizerClient.new(configurable.credentials, options)
42
+ if(@client_0.respond_to?(:subscription_id))
43
+ @client_0.subscription_id = configurable.subscription_id
44
+ end
45
+ add_telemetry(@client_0)
46
+ @events = @client_0.events
47
+
48
+ @model_classes = ModelClasses.new
49
+ end
50
+
51
+ def add_telemetry(client)
52
+ profile_information = 'Profiles/Latest/Personalizer'
53
+ client.add_user_agent_information(profile_information)
54
+ end
55
+
56
+ def method_missing(method, *args)
57
+ if @client_0.respond_to?method
58
+ @client_0.send(method, *args)
59
+ else
60
+ super
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ class ModelClasses
67
+ def rankable_action
68
+ Azure::CognitiveServices::Personalizer::V1_0::Models::RankableAction
69
+ end
70
+ def internal_error
71
+ Azure::CognitiveServices::Personalizer::V1_0::Models::InternalError
72
+ end
73
+ def rank_request
74
+ Azure::CognitiveServices::Personalizer::V1_0::Models::RankRequest
75
+ end
76
+ def error_response
77
+ Azure::CognitiveServices::Personalizer::V1_0::Models::ErrorResponse
78
+ end
79
+ def ranked_action
80
+ Azure::CognitiveServices::Personalizer::V1_0::Models::RankedAction
81
+ end
82
+ def personalizer_error
83
+ Azure::CognitiveServices::Personalizer::V1_0::Models::PersonalizerError
84
+ end
85
+ def rank_response
86
+ Azure::CognitiveServices::Personalizer::V1_0::Models::RankResponse
87
+ end
88
+ def reward_request
89
+ Azure::CognitiveServices::Personalizer::V1_0::Models::RewardRequest
90
+ end
91
+ def error_code
92
+ Azure::CognitiveServices::Personalizer::V1_0::Models::ErrorCode
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ require 'profiles/latest/personalizer_module_definition'
6
+ require 'profiles/latest/modules/personalizer_profile_module'
7
+
8
+ module Azure::Personalizer::Profiles::Latest
9
+ #
10
+ # Client class for the Latest profile SDK.
11
+ #
12
+ class Client < PersonalizerDataClass
13
+ include MsRestAzure::Common::Configurable
14
+
15
+ #
16
+ # Initializes a new instance of the Client class.
17
+ # @param options [Hash] hash of client options.
18
+ # options = {
19
+ # tenant_id: 'YOUR TENANT ID',
20
+ # client_id: 'YOUR CLIENT ID',
21
+ # client_secret: 'YOUR CLIENT SECRET',
22
+ # subscription_id: 'YOUR SUBSCRIPTION ID',
23
+ # credentials: credentials,
24
+ # active_directory_settings: active_directory_settings,
25
+ # base_url: 'YOUR BASE URL',
26
+ # options: options
27
+ # }
28
+ # 'credentials' are optional and if not passed in the hash, will be obtained
29
+ # from MsRest::TokenCredentials using MsRestAzure::ApplicationTokenProvider.
30
+ #
31
+ # Also, base_url, active_directory_settings & options are optional.
32
+ #
33
+ def initialize(options = {})
34
+ super(options)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ module Azure end
6
+ module Azure::Personalizer end
7
+ module Azure::Personalizer::Profiles end
8
+ module Azure::Personalizer::Profiles::Latest end
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ require 'uri'
7
+ require 'cgi'
8
+ require 'date'
9
+ require 'json'
10
+ require 'base64'
11
+ require 'erb'
12
+ require 'securerandom'
13
+ require 'time'
14
+ require 'timeliness'
15
+ require 'faraday'
16
+ require 'faraday-cookie_jar'
17
+ require 'concurrent'
18
+ require 'ms_rest'
19
+ require 'v1.0/generated/azure_cognitiveservices_personalizer/module_definition'
20
+ require 'ms_rest_azure'
21
+
22
+ module Azure::CognitiveServices::Personalizer::V1_0
23
+ autoload :Events, 'v1.0/generated/azure_cognitiveservices_personalizer/events.rb'
24
+ autoload :PersonalizerClient, 'v1.0/generated/azure_cognitiveservices_personalizer/personalizer_client.rb'
25
+
26
+ module Models
27
+ autoload :RankableAction, 'v1.0/generated/azure_cognitiveservices_personalizer/models/rankable_action.rb'
28
+ autoload :InternalError, 'v1.0/generated/azure_cognitiveservices_personalizer/models/internal_error.rb'
29
+ autoload :RankRequest, 'v1.0/generated/azure_cognitiveservices_personalizer/models/rank_request.rb'
30
+ autoload :ErrorResponse, 'v1.0/generated/azure_cognitiveservices_personalizer/models/error_response.rb'
31
+ autoload :RankedAction, 'v1.0/generated/azure_cognitiveservices_personalizer/models/ranked_action.rb'
32
+ autoload :PersonalizerError, 'v1.0/generated/azure_cognitiveservices_personalizer/models/personalizer_error.rb'
33
+ autoload :RankResponse, 'v1.0/generated/azure_cognitiveservices_personalizer/models/rank_response.rb'
34
+ autoload :RewardRequest, 'v1.0/generated/azure_cognitiveservices_personalizer/models/reward_request.rb'
35
+ autoload :ErrorCode, 'v1.0/generated/azure_cognitiveservices_personalizer/models/error_code.rb'
36
+ end
37
+ end
@@ -0,0 +1,204 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::CognitiveServices::Personalizer::V1_0
7
+ #
8
+ # Personalizer Service is an Azure Cognitive Service that makes it easy to
9
+ # target content and experiences without complex pre-analysis or cleanup of
10
+ # past data. Given a context and featurized content, the Personalizer Service
11
+ # returns your content in a ranked list. As rewards are sent in response to
12
+ # the ranked list, the reinforcement learning algorithm will improve the
13
+ # model and improve performance of future rank calls.
14
+ #
15
+ class Events
16
+ include MsRestAzure
17
+
18
+ #
19
+ # Creates and initializes a new instance of the Events class.
20
+ # @param client service class for accessing basic functionality.
21
+ #
22
+ def initialize(client)
23
+ @client = client
24
+ end
25
+
26
+ # @return [PersonalizerClient] reference to the PersonalizerClient
27
+ attr_reader :client
28
+
29
+ #
30
+ # Report reward to allocate to the top ranked action for the specified event.
31
+ #
32
+ # @param event_id [String] The event id this reward applies to.
33
+ # @param reward [RewardRequest] The reward should be a floating point number.
34
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
35
+ # will be added to the HTTP request.
36
+ #
37
+ #
38
+ def reward(event_id, reward, custom_headers:nil)
39
+ response = reward_async(event_id, reward, custom_headers:custom_headers).value!
40
+ nil
41
+ end
42
+
43
+ #
44
+ # Report reward to allocate to the top ranked action for the specified event.
45
+ #
46
+ # @param event_id [String] The event id this reward applies to.
47
+ # @param reward [RewardRequest] The reward should be a floating point number.
48
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
49
+ # will be added to the HTTP request.
50
+ #
51
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
52
+ #
53
+ def reward_with_http_info(event_id, reward, custom_headers:nil)
54
+ reward_async(event_id, reward, custom_headers:custom_headers).value!
55
+ end
56
+
57
+ #
58
+ # Report reward to allocate to the top ranked action for the specified event.
59
+ #
60
+ # @param event_id [String] The event id this reward applies to.
61
+ # @param reward [RewardRequest] The reward should be a floating point number.
62
+ # @param [Hash{String => String}] A hash of custom headers that will be added
63
+ # to the HTTP request.
64
+ #
65
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
66
+ #
67
+ def reward_async(event_id, reward, custom_headers:nil)
68
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
69
+ fail ArgumentError, "'endpoint' should satisfy the constraint - 'MaxLength': '1024'" if !endpoint.nil? && endpoint.length > 1024
70
+ fail ArgumentError, 'event_id is nil' if event_id.nil?
71
+ fail ArgumentError, "'event_id' should satisfy the constraint - 'MaxLength': '256'" if !event_id.nil? && event_id.length > 256
72
+ fail ArgumentError, 'reward is nil' if reward.nil?
73
+
74
+
75
+ request_headers = {}
76
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
77
+
78
+ # Set Headers
79
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
80
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
81
+
82
+ # Serialize Request
83
+ request_mapper = Azure::CognitiveServices::Personalizer::V1_0::Models::RewardRequest.mapper()
84
+ request_content = @client.serialize(request_mapper, reward)
85
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
86
+
87
+ path_template = 'events/{eventId}/reward'
88
+
89
+ request_url = @base_url || @client.base_url
90
+ request_url = request_url.gsub('{Endpoint}', endpoint)
91
+
92
+ options = {
93
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
94
+ path_params: {'eventId' => event_id},
95
+ body: request_content,
96
+ headers: request_headers.merge(custom_headers || {}),
97
+ base_url: request_url
98
+ }
99
+ promise = @client.make_request_async(:post, path_template, options)
100
+
101
+ promise = promise.then do |result|
102
+ http_response = result.response
103
+ status_code = http_response.status
104
+ response_content = http_response.body
105
+ unless status_code == 204
106
+ error_model = JSON.load(response_content)
107
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
108
+ end
109
+
110
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
111
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
112
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
113
+
114
+ result
115
+ end
116
+
117
+ promise.execute
118
+ end
119
+
120
+ #
121
+ # Report that the specified event was actually displayed to the user and a
122
+ # reward should be expected for it.
123
+ #
124
+ # @param event_id [String] The event ID this activation applies to.
125
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
126
+ # will be added to the HTTP request.
127
+ #
128
+ #
129
+ def activate(event_id, custom_headers:nil)
130
+ response = activate_async(event_id, custom_headers:custom_headers).value!
131
+ nil
132
+ end
133
+
134
+ #
135
+ # Report that the specified event was actually displayed to the user and a
136
+ # reward should be expected for it.
137
+ #
138
+ # @param event_id [String] The event ID this activation applies to.
139
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
140
+ # will be added to the HTTP request.
141
+ #
142
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
143
+ #
144
+ def activate_with_http_info(event_id, custom_headers:nil)
145
+ activate_async(event_id, custom_headers:custom_headers).value!
146
+ end
147
+
148
+ #
149
+ # Report that the specified event was actually displayed to the user and a
150
+ # reward should be expected for it.
151
+ #
152
+ # @param event_id [String] The event ID this activation applies to.
153
+ # @param [Hash{String => String}] A hash of custom headers that will be added
154
+ # to the HTTP request.
155
+ #
156
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
157
+ #
158
+ def activate_async(event_id, custom_headers:nil)
159
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
160
+ fail ArgumentError, "'endpoint' should satisfy the constraint - 'MaxLength': '1024'" if !endpoint.nil? && endpoint.length > 1024
161
+ fail ArgumentError, 'event_id is nil' if event_id.nil?
162
+ fail ArgumentError, "'event_id' should satisfy the constraint - 'MaxLength': '256'" if !event_id.nil? && event_id.length > 256
163
+
164
+
165
+ request_headers = {}
166
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
167
+
168
+ # Set Headers
169
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
170
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
171
+ path_template = 'events/{eventId}/activate'
172
+
173
+ request_url = @base_url || @client.base_url
174
+ request_url = request_url.gsub('{Endpoint}', endpoint)
175
+
176
+ options = {
177
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
178
+ path_params: {'eventId' => event_id},
179
+ headers: request_headers.merge(custom_headers || {}),
180
+ base_url: request_url
181
+ }
182
+ promise = @client.make_request_async(:post, path_template, options)
183
+
184
+ promise = promise.then do |result|
185
+ http_response = result.response
186
+ status_code = http_response.status
187
+ response_content = http_response.body
188
+ unless status_code == 204
189
+ error_model = JSON.load(response_content)
190
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
191
+ end
192
+
193
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
194
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
195
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
196
+
197
+ result
198
+ end
199
+
200
+ promise.execute
201
+ end
202
+
203
+ end
204
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::CognitiveServices::Personalizer::V1_0
7
+ module Models
8
+ #
9
+ # Defines values for ErrorCode
10
+ #
11
+ module ErrorCode
12
+ BadRequest = "BadRequest"
13
+ ResourceNotFound = "ResourceNotFound"
14
+ InternalServerError = "InternalServerError"
15
+ end
16
+ end
17
+ end