azure_cognitiveservices_personalizer 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,66 @@
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
+ # A ranked action with its resulting probability.
10
+ #
11
+ class RankedAction
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [String] Id of the action
16
+ attr_accessor :id
17
+
18
+ # @return [Float] Probability of the action
19
+ attr_accessor :probability
20
+
21
+
22
+ #
23
+ # Mapper for RankedAction class as Ruby Hash.
24
+ # This will be used for serialization/deserialization.
25
+ #
26
+ def self.mapper()
27
+ {
28
+ client_side_validation: true,
29
+ required: false,
30
+ serialized_name: 'RankedAction',
31
+ type: {
32
+ name: 'Composite',
33
+ class_name: 'RankedAction',
34
+ model_properties: {
35
+ id: {
36
+ client_side_validation: true,
37
+ required: false,
38
+ read_only: true,
39
+ serialized_name: 'id',
40
+ constraints: {
41
+ MaxLength: 256
42
+ },
43
+ type: {
44
+ name: 'String'
45
+ }
46
+ },
47
+ probability: {
48
+ client_side_validation: true,
49
+ required: false,
50
+ read_only: true,
51
+ serialized_name: 'probability',
52
+ constraints: {
53
+ InclusiveMaximum: 1,
54
+ InclusiveMinimum: 0
55
+ },
56
+ type: {
57
+ name: 'Double'
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,47 @@
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
+ # Reward given to a rank response.
10
+ #
11
+ class RewardRequest
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [Float] Reward to be assigned to an action. Value should be
16
+ # between -1 and 1 inclusive.
17
+ attr_accessor :value
18
+
19
+
20
+ #
21
+ # Mapper for RewardRequest class as Ruby Hash.
22
+ # This will be used for serialization/deserialization.
23
+ #
24
+ def self.mapper()
25
+ {
26
+ client_side_validation: true,
27
+ required: false,
28
+ serialized_name: 'RewardRequest',
29
+ type: {
30
+ name: 'Composite',
31
+ class_name: 'RewardRequest',
32
+ model_properties: {
33
+ value: {
34
+ client_side_validation: true,
35
+ required: true,
36
+ serialized_name: 'value',
37
+ type: {
38
+ name: 'Double'
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,9 @@
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 end
7
+ module Azure::CognitiveServices end
8
+ module Azure::CognitiveServices::Personalizer end
9
+ module Azure::CognitiveServices::Personalizer::V1_0 end
@@ -0,0 +1,226 @@
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
+ # A service client - single point of access to the REST API.
9
+ #
10
+ class PersonalizerClient < MsRestAzure::AzureServiceClient
11
+ include MsRestAzure
12
+ include MsRestAzure::Serialization
13
+
14
+ # @return [String] the base URI of the service.
15
+ attr_reader :base_url
16
+
17
+ # @return Credentials needed for the client to connect to Azure.
18
+ attr_reader :credentials1
19
+
20
+ # @return [String] Supported Cognitive Services endpoint.
21
+ attr_accessor :endpoint
22
+
23
+ # @return Subscription credentials which uniquely identify client
24
+ # subscription.
25
+ attr_accessor :credentials
26
+
27
+ # @return [String] The preferred language for the response.
28
+ attr_accessor :accept_language
29
+
30
+ # @return [Integer] The retry timeout in seconds for Long Running
31
+ # Operations. Default value is 30.
32
+ attr_accessor :long_running_operation_retry_timeout
33
+
34
+ # @return [Boolean] Whether a unique x-ms-client-request-id should be
35
+ # generated. When set to true a unique x-ms-client-request-id value is
36
+ # generated and included in each request. Default is true.
37
+ attr_accessor :generate_client_request_id
38
+
39
+ # @return [Events] events
40
+ attr_reader :events
41
+
42
+ #
43
+ # Creates initializes a new instance of the PersonalizerClient class.
44
+ # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
45
+ # @param options [Array] filters to be applied to the HTTP requests.
46
+ #
47
+ def initialize(credentials = nil, options = nil)
48
+ super(credentials, options)
49
+ @base_url = '{Endpoint}/personalizer/v1.0'
50
+
51
+ fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
52
+ @credentials = credentials
53
+
54
+ @events = Events.new(self)
55
+ @accept_language = 'en-US'
56
+ @long_running_operation_retry_timeout = 30
57
+ @generate_client_request_id = true
58
+ add_telemetry
59
+ end
60
+
61
+ #
62
+ # Makes a request and returns the body of the response.
63
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
64
+ # @param path [String] the path, relative to {base_url}.
65
+ # @param options [Hash{String=>String}] specifying any request options like :body.
66
+ # @return [Hash{String=>String}] containing the body of the response.
67
+ # Example:
68
+ #
69
+ # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
70
+ # path = "/path"
71
+ # options = {
72
+ # body: request_content,
73
+ # query_params: {'api-version' => '2016-02-01'}
74
+ # }
75
+ # result = @client.make_request(:put, path, options)
76
+ #
77
+ def make_request(method, path, options = {})
78
+ result = make_request_with_http_info(method, path, options)
79
+ result.body unless result.nil?
80
+ end
81
+
82
+ #
83
+ # Makes a request and returns the operation response.
84
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
85
+ # @param path [String] the path, relative to {base_url}.
86
+ # @param options [Hash{String=>String}] specifying any request options like :body.
87
+ # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
88
+ #
89
+ def make_request_with_http_info(method, path, options = {})
90
+ result = make_request_async(method, path, options).value!
91
+ result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
92
+ result
93
+ end
94
+
95
+ #
96
+ # Makes a request asynchronously.
97
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
98
+ # @param path [String] the path, relative to {base_url}.
99
+ # @param options [Hash{String=>String}] specifying any request options like :body.
100
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
101
+ #
102
+ def make_request_async(method, path, options = {})
103
+ fail ArgumentError, 'method is nil' if method.nil?
104
+ fail ArgumentError, 'path is nil' if path.nil?
105
+
106
+ request_url = options[:base_url] || @base_url
107
+ if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
108
+ @request_headers['Content-Type'] = options[:headers]['Content-Type']
109
+ end
110
+
111
+ request_headers = @request_headers
112
+ request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
113
+ options.merge!({headers: request_headers.merge(options[:headers] || {})})
114
+ options.merge!({credentials: @credentials}) unless @credentials.nil?
115
+
116
+ super(request_url, method, path, options)
117
+ end
118
+
119
+ #
120
+ # A Personalizer rank request.
121
+ #
122
+ # @param rank_request [RankRequest] A Personalizer request.
123
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
124
+ # will be added to the HTTP request.
125
+ #
126
+ # @return [RankResponse] operation results.
127
+ #
128
+ def rank(rank_request, custom_headers:nil)
129
+ response = rank_async(rank_request, custom_headers:custom_headers).value!
130
+ response.body unless response.nil?
131
+ end
132
+
133
+ #
134
+ # A Personalizer rank request.
135
+ #
136
+ # @param rank_request [RankRequest] A Personalizer request.
137
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
138
+ # will be added to the HTTP request.
139
+ #
140
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
141
+ #
142
+ def rank_with_http_info(rank_request, custom_headers:nil)
143
+ rank_async(rank_request, custom_headers:custom_headers).value!
144
+ end
145
+
146
+ #
147
+ # A Personalizer rank request.
148
+ #
149
+ # @param rank_request [RankRequest] A Personalizer request.
150
+ # @param [Hash{String => String}] A hash of custom headers that will be added
151
+ # to the HTTP request.
152
+ #
153
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
154
+ #
155
+ def rank_async(rank_request, custom_headers:nil)
156
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
157
+ fail ArgumentError, "'endpoint' should satisfy the constraint - 'MaxLength': '1024'" if !endpoint.nil? && endpoint.length > 1024
158
+ fail ArgumentError, 'rank_request is nil' if rank_request.nil?
159
+
160
+
161
+ request_headers = {}
162
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
163
+
164
+ # Set Headers
165
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
166
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
167
+
168
+ # Serialize Request
169
+ request_mapper = Azure::CognitiveServices::Personalizer::V1_0::Models::RankRequest.mapper()
170
+ request_content = self.serialize(request_mapper, rank_request)
171
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
172
+
173
+ path_template = 'rank'
174
+
175
+ request_url = @base_url || self.base_url
176
+ request_url = request_url.gsub('{Endpoint}', endpoint)
177
+
178
+ options = {
179
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
180
+ body: request_content,
181
+ headers: request_headers.merge(custom_headers || {}),
182
+ base_url: request_url
183
+ }
184
+ promise = self.make_request_async(:post, path_template, options)
185
+
186
+ promise = promise.then do |result|
187
+ http_response = result.response
188
+ status_code = http_response.status
189
+ response_content = http_response.body
190
+ unless status_code == 201
191
+ error_model = JSON.load(response_content)
192
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
193
+ end
194
+
195
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
196
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
197
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
198
+ # Deserialize Response
199
+ if status_code == 201
200
+ begin
201
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
202
+ result_mapper = Azure::CognitiveServices::Personalizer::V1_0::Models::RankResponse.mapper()
203
+ result.body = self.deserialize(result_mapper, parsed_response)
204
+ rescue Exception => e
205
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
206
+ end
207
+ end
208
+
209
+ result
210
+ end
211
+
212
+ promise.execute
213
+ end
214
+
215
+
216
+ private
217
+ #
218
+ # Adds telemetry information.
219
+ #
220
+ def add_telemetry
221
+ sdk_information = 'azure_cognitiveservices_personalizer'
222
+ sdk_information = "#{sdk_information}/0.17.0"
223
+ add_user_agent_information(sdk_information)
224
+ end
225
+ end
226
+ end
@@ -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::CognitiveServices::Personalizer
6
+ VERSION = '0.17.0'
7
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: azure_cognitiveservices_personalizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.17.0
5
+ platform: ruby
6
+ authors:
7
+ - Microsoft Corporation
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dotenv
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ms_rest_azure
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.11.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.11.1
83
+ description:
84
+ email: azrubyteam@microsoft.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - LICENSE.txt
90
+ - lib/azure_cognitiveservices_personalizer.rb
91
+ - lib/module_definition.rb
92
+ - lib/profiles/latest/modules/personalizer_profile_module.rb
93
+ - lib/profiles/latest/personalizer_latest_profile_client.rb
94
+ - lib/profiles/latest/personalizer_module_definition.rb
95
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer.rb
96
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/events.rb
97
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/error_code.rb
98
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/error_response.rb
99
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/internal_error.rb
100
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/personalizer_error.rb
101
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/rank_request.rb
102
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/rank_response.rb
103
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/rankable_action.rb
104
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/ranked_action.rb
105
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/models/reward_request.rb
106
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/module_definition.rb
107
+ - lib/v1.0/generated/azure_cognitiveservices_personalizer/personalizer_client.rb
108
+ - lib/version.rb
109
+ homepage: https://aka.ms/azure-sdk-for-ruby
110
+ licenses:
111
+ - MIT
112
+ metadata:
113
+ bug_tracker_uri: https://github.com/Azure/azure-sdk-for-ruby/issues
114
+ changelog_uri: https://github.com/Azure/azure-sdk-for-ruby/blob/master/ChangeLog.md
115
+ documentation_uri: https://azure.microsoft.com/en-us/develop/ruby/
116
+ homepage_uri: https://aka.ms/azure-sdk-for-ruby
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: 2.0.0
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.5.1
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Official Ruby client library to consume Cognitiveservices Personalizer
137
+ test_files: []