Class: Algolia::UsageClient
- Inherits:
-
Object
- Object
- Algolia::UsageClient
- Defined in:
- lib/algolia/api/usage_client.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Class Method Summary collapse
Instance Method Summary collapse
- #custom_delete(path, parameters = nil, request_options = {}) ⇒ Object
-
#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
The response.
- #custom_get(path, parameters = nil, request_options = {}) ⇒ Object
-
#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
The response.
- #custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
-
#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
The response.
- #custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
-
#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
The response.
- #get_index_usage(statistic, index_name, start_date, end_date, granularity = nil, request_options = {}) ⇒ IndexUsage
-
#get_index_usage_with_http_info(statistic, index_name, start_date, end_date, granularity = nil, request_options = {}) ⇒ Http::Response
The response.
- #get_usage(statistic, start_date, end_date, granularity = nil, request_options = {}) ⇒ IndexUsage
-
#get_usage_with_http_info(statistic, start_date, end_date, granularity = nil, request_options = {}) ⇒ Http::Response
The response.
-
#initialize(config = nil) ⇒ UsageClient
constructor
A new instance of UsageClient.
Constructor Details
#initialize(config = nil) ⇒ UsageClient
Returns a new instance of UsageClient.
7 8 9 10 11 12 13 |
# File 'lib/algolia/api/usage_client.rb', line 7 def initialize(config = nil) raise "`config` is missing." if config.nil? raise "`app_id` is missing." if config.app_id.nil? || config.app_id == "" raise "`api_key` is missing." if config.api_key.nil? || config.api_key == "" @api_client = Algolia::ApiClient.new(config) end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
5 6 7 |
# File 'lib/algolia/api/usage_client.rb', line 5 def api_client @api_client end |
Class Method Details
.create(app_id, api_key, opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/algolia/api/usage_client.rb', line 15 def self.create(app_id, api_key, opts = {}) hosts = [] hosts << Transport::StatefulHost.new("usage.algolia.com", accept: CallType::READ | CallType::WRITE) hosts << Transport::StatefulHost.new("usage-dev.algolia.com", accept: CallType::READ | CallType::WRITE) config = Algolia::Configuration.new(app_id, api_key, hosts, "Usage", opts) create_with_config(config) end |
.create_with_config(config) ⇒ Object
24 25 26 |
# File 'lib/algolia/api/usage_client.rb', line 24 def self.create_with_config(config) new(config) end |
Instance Method Details
#custom_delete(path, parameters = nil, request_options = {}) ⇒ Object
66 67 68 69 |
# File 'lib/algolia/api/usage_client.rb', line 66 def custom_delete(path, parameters = nil, = {}) response = custom_delete_with_http_info(path, parameters, ) @api_client.deserialize(response.body, [:debug_return_type] || "Object") end |
#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
Returns the response.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/algolia/api/usage_client.rb', line 34 def custom_delete_with_http_info(path, parameters = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_delete`." end path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"UsageClient.custom_delete", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:DELETE, path, ) end |
#custom_get(path, parameters = nil, request_options = {}) ⇒ Object
109 110 111 112 |
# File 'lib/algolia/api/usage_client.rb', line 109 def custom_get(path, parameters = nil, = {}) response = custom_get_with_http_info(path, parameters, ) @api_client.deserialize(response.body, [:debug_return_type] || "Object") end |
#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
Returns the response.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/algolia/api/usage_client.rb', line 77 def custom_get_with_http_info(path, parameters = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_get`." end path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"UsageClient.custom_get", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:GET, path, ) end |
#custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
154 155 156 157 |
# File 'lib/algolia/api/usage_client.rb', line 154 def custom_post(path, parameters = nil, body = nil, = {}) response = custom_post_with_http_info(path, parameters, body, ) @api_client.deserialize(response.body, [:debug_return_type] || "Object") end |
#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
Returns the response.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/algolia/api/usage_client.rb', line 121 def custom_post_with_http_info(path, parameters = nil, body = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_post`." end path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] || @api_client.object_to_http_body(body) = .merge( :operation => :"UsageClient.custom_post", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:POST, path, ) end |
#custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
199 200 201 202 |
# File 'lib/algolia/api/usage_client.rb', line 199 def custom_put(path, parameters = nil, body = nil, = {}) response = custom_put_with_http_info(path, parameters, body, ) @api_client.deserialize(response.body, [:debug_return_type] || "Object") end |
#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
Returns the response.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/algolia/api/usage_client.rb', line 166 def custom_put_with_http_info(path, parameters = nil, body = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_put`." end path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] || @api_client.object_to_http_body(body) = .merge( :operation => :"UsageClient.custom_put", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:PUT, path, ) end |
#get_index_usage(statistic, index_name, start_date, end_date, granularity = nil, request_options = {}) ⇒ IndexUsage
272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/algolia/api/usage_client.rb', line 272 def get_index_usage(statistic, index_name, start_date, end_date, granularity = nil, = {}) response = get_index_usage_with_http_info( statistic, index_name, start_date, end_date, granularity, ) @api_client.deserialize(response.body, [:debug_return_type] || "Usage::IndexUsage") end |
#get_index_usage_with_http_info(statistic, index_name, start_date, end_date, granularity = nil, request_options = {}) ⇒ Http::Response
Returns the response.
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/algolia/api/usage_client.rb', line 213 def get_index_usage_with_http_info( statistic, index_name, start_date, end_date, granularity = nil, = {} ) # verify the required parameter 'statistic' is set if @api_client.config.client_side_validation && statistic.nil? raise ArgumentError, "Parameter `statistic` is required when calling `get_index_usage`." end # verify the required parameter 'index_name' is set if @api_client.config.client_side_validation && index_name.nil? raise ArgumentError, "Parameter `index_name` is required when calling `get_index_usage`." end # verify the required parameter 'start_date' is set if @api_client.config.client_side_validation && start_date.nil? raise ArgumentError, "Parameter `start_date` is required when calling `get_index_usage`." end # verify the required parameter 'end_date' is set if @api_client.config.client_side_validation && end_date.nil? raise ArgumentError, "Parameter `end_date` is required when calling `get_index_usage`." end path = "/1/usage/{statistic}/{indexName}".sub("{" + "statistic" + "}", Transport.encode_uri(statistic.to_s)).sub( "{" + "indexName" + "}", Transport.encode_uri(index_name.to_s) ) query_params = {} query_params[:startDate] = start_date query_params[:endDate] = end_date query_params[:granularity] = granularity unless granularity.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"UsageClient.get_index_usage", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:GET, path, ) end |
#get_usage(statistic, start_date, end_date, granularity = nil, request_options = {}) ⇒ IndexUsage
336 337 338 339 |
# File 'lib/algolia/api/usage_client.rb', line 336 def get_usage(statistic, start_date, end_date, granularity = nil, = {}) response = get_usage_with_http_info(statistic, start_date, end_date, granularity, ) @api_client.deserialize(response.body, [:debug_return_type] || "Usage::IndexUsage") end |
#get_usage_with_http_info(statistic, start_date, end_date, granularity = nil, request_options = {}) ⇒ Http::Response
Returns the response.
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/algolia/api/usage_client.rb', line 292 def get_usage_with_http_info(statistic, start_date, end_date, granularity = nil, = {}) # verify the required parameter 'statistic' is set if @api_client.config.client_side_validation && statistic.nil? raise ArgumentError, "Parameter `statistic` is required when calling `get_usage`." end # verify the required parameter 'start_date' is set if @api_client.config.client_side_validation && start_date.nil? raise ArgumentError, "Parameter `start_date` is required when calling `get_usage`." end # verify the required parameter 'end_date' is set if @api_client.config.client_side_validation && end_date.nil? raise ArgumentError, "Parameter `end_date` is required when calling `get_usage`." end path = "/1/usage/{statistic}".sub("{" + "statistic" + "}", Transport.encode_uri(statistic.to_s)) query_params = {} query_params[:startDate] = start_date query_params[:endDate] = end_date query_params[:granularity] = granularity unless granularity.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"UsageClient.get_usage", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:GET, path, ) end |