From 4884033f16834abc076c1359d9a806a2905d80c1 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Wed, 11 Sep 2024 15:28:03 +0000 Subject: [PATCH] chore(scripts): improve release script with git diff [skip-bc] (generated) https://github.com/algolia/api-clients-automation/pull/3686 Co-authored-by: Pierre Millot --- .github/ISSUE_TEMPLATE/Bug_report.yml | 1 - lib/algolia/api/usage_client.rb | 349 ------------------ lib/algolia/models/usage/error_base.rb | 212 ----------- lib/algolia/models/usage/error_item.rb | 240 ------------ lib/algolia/models/usage/forbidden_error.rb | 231 ------------ lib/algolia/models/usage/granularity.rb | 32 -- lib/algolia/models/usage/index_usage.rb | 213 ----------- .../models/usage/invalid_request_error.rb | 231 ------------ lib/algolia/models/usage/statistic.rb | 199 ---------- lib/algolia/models/usage/statistic_entry.rb | 221 ----------- lib/algolia/models/usage/statistic_value.rb | 108 ------ 11 files changed, 2037 deletions(-) delete mode 100644 lib/algolia/api/usage_client.rb delete mode 100644 lib/algolia/models/usage/error_base.rb delete mode 100644 lib/algolia/models/usage/error_item.rb delete mode 100644 lib/algolia/models/usage/forbidden_error.rb delete mode 100644 lib/algolia/models/usage/granularity.rb delete mode 100644 lib/algolia/models/usage/index_usage.rb delete mode 100644 lib/algolia/models/usage/invalid_request_error.rb delete mode 100644 lib/algolia/models/usage/statistic.rb delete mode 100644 lib/algolia/models/usage/statistic_entry.rb delete mode 100644 lib/algolia/models/usage/statistic_value.rb diff --git a/.github/ISSUE_TEMPLATE/Bug_report.yml b/.github/ISSUE_TEMPLATE/Bug_report.yml index e919fd95..ecf2dfdb 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.yml +++ b/.github/ISSUE_TEMPLATE/Bug_report.yml @@ -39,7 +39,6 @@ body: - Query-Suggestions - Recommend - Search - - Usage - Crawler validations: required: true diff --git a/lib/algolia/api/usage_client.rb b/lib/algolia/api/usage_client.rb deleted file mode 100644 index 45b0430f..00000000 --- a/lib/algolia/api/usage_client.rb +++ /dev/null @@ -1,349 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -module Algolia - class UsageClient - attr_accessor :api_client - - 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 - - def self.create(app_id, api_key, opts = {}) - hosts = [] - hosts << Transport::StatefulHost.new("usage.algolia.com", accept: CallType::READ | CallType::WRITE) - - config = Algolia::Configuration.new(app_id, api_key, hosts, "Usage", opts) - create_with_config(config) - end - - def self.create_with_config(config) - new(config) - end - - # Helper method to switch the API key used to authenticate the requests. - # - # @param api_key [String] the new API key to use. - # @return [void] - def set_client_api_key(api_key) - @api_client.set_client_api_key(api_key) - end - - # This method allow you to send requests to the Algolia REST API. - - # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) - # @param parameters [Hash] Query parameters to apply to the current query. - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Http::Response] the response - def custom_delete_with_http_info(path, parameters = nil, request_options = {}) - # 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(request_options[:query_params]) unless request_options[:query_params].nil? - header_params = {} - header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? - - post_body = request_options[:debug_body] - - new_options = request_options.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, new_options) - end - - # This method allow you to send requests to the Algolia REST API. - - # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) - # @param parameters [Hash] Query parameters to apply to the current query. - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Object] - def custom_delete(path, parameters = nil, request_options = {}) - response = custom_delete_with_http_info(path, parameters, request_options) - @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object") - end - - # This method allow you to send requests to the Algolia REST API. - - # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) - # @param parameters [Hash] Query parameters to apply to the current query. - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Http::Response] the response - def custom_get_with_http_info(path, parameters = nil, request_options = {}) - # 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(request_options[:query_params]) unless request_options[:query_params].nil? - header_params = {} - header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? - - post_body = request_options[:debug_body] - - new_options = request_options.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, new_options) - end - - # This method allow you to send requests to the Algolia REST API. - - # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) - # @param parameters [Hash] Query parameters to apply to the current query. - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Object] - def custom_get(path, parameters = nil, request_options = {}) - response = custom_get_with_http_info(path, parameters, request_options) - @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object") - end - - # This method allow you to send requests to the Algolia REST API. - - # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) - # @param parameters [Hash] Query parameters to apply to the current query. - # @param body [Object] Parameters to send with the custom request. - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Http::Response] the response - def custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) - # 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(request_options[:query_params]) unless request_options[:query_params].nil? - header_params = {} - header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? - - post_body = request_options[:debug_body] || @api_client.object_to_http_body(body) - - new_options = request_options.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, new_options) - end - - # This method allow you to send requests to the Algolia REST API. - - # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) - # @param parameters [Hash] Query parameters to apply to the current query. - # @param body [Object] Parameters to send with the custom request. - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Object] - def custom_post(path, parameters = nil, body = nil, request_options = {}) - response = custom_post_with_http_info(path, parameters, body, request_options) - @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object") - end - - # This method allow you to send requests to the Algolia REST API. - - # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) - # @param parameters [Hash] Query parameters to apply to the current query. - # @param body [Object] Parameters to send with the custom request. - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Http::Response] the response - def custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) - # 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(request_options[:query_params]) unless request_options[:query_params].nil? - header_params = {} - header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? - - post_body = request_options[:debug_body] || @api_client.object_to_http_body(body) - - new_options = request_options.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, new_options) - end - - # This method allow you to send requests to the Algolia REST API. - - # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) - # @param parameters [Hash] Query parameters to apply to the current query. - # @param body [Object] Parameters to send with the custom request. - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Object] - def custom_put(path, parameters = nil, body = nil, request_options = {}) - response = custom_put_with_http_info(path, parameters, body, request_options) - @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object") - end - - # Retrieves the selected usage statistics for one index. - - # @param statistic [Statistic] Usage statistics to retrieve. Use `*` to retrieve all usage metrics, otherwise add one or more of the following metrics, separated by a comma. **Search operations** - `search_operations`. All search operations. - `total_search_operations`: Sum of all search operations. - `total_search_requests`: Sum of all [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). The number of billed search requests is equal to this value minus `querysuggestions_total_search_requests`. - `queries_operations`. Number of [single index search](/specs/search#tag/Search/operation/searchSingleIndex) operations. - `multi_queries_operations`. Number of [multi-index search](/specs/search#tag/Search/operation/search) operations. **ACL operations** - `acl_operations`. All ACL operations. - `total_acl_operations`. Sum of all ACL operations. - `get_api_keys_operations`. Number of [list API keys](/specs/search#tag/Api-Keys/operation/listApiKeys) operations. - `get_api_key_operations`. Number of [get API key permission](/specs/search#tag/Api-Keys/operation/getApiKey) operations. - `add_api_key_operations`. Number of [create API key](/specs/search#tag/Api-Keys/operation/addApiKey) operations. - `update_api_key_operations`. Number of [update API key](/specs/search#tag/Api-Keys/operation/updateApiKey) operations. - `delete_api_key_operations`. Number of [delete API key](/specs/search#tag/Api-Keys/operation/deleteApiKey) operations. - `list_api_key_operations`. Number of list index API keys operations. **Indexing operations** - `indexing_operations`. All indexing operations. - `total_indexing_operations`. Sum of all indexing operations. - `browse_operations`. Number of [browse index](/specs/search#tag/Search/operation/browse) operations. - `clear_index_operations`. Number of [clear records](/specs/search#tag/Records/operation/clearObjects) operations. - `copy_move_operations`. Number of [copy or move index](/specs/search#tag/Indices/operation/operationIndex) operations. - `delete_index_operations`. Number of [delete index](/specs/search#tag/Indices/operation/deleteIndex) operations. - `get_log_operations`. Number of [get logs](/specs/search#tag/Advanced/operation/getLogs) operations. - `get_settings_operations`. Number of [get settings](/specs/search#operation/getIndexUsage) operations. - `set_settings_operations`. Number of [set settings](/specs/search#tag/Indices/operation/setSettings) operations. - `list_indices_operations`. Number of [list indices](/specs/search#tag/Indices/operation/listIndices) operations. - `wait_task_operations`. Number of [wait](/specs/search#tag/Indices/operation/getTask) operations. **Record operations** - `record_operations`. All record operations. - `total_records_operations`. Sum of all record operations. - `add_record_operations`. Number of [add or replace record](/specs/search#tag/Records/operation/saveObject) operations. - `batch_operations`. Number of [batch indexing](/specs/search#tag/Records/operation/multipleBatch) operations. - `delete_by_query_operations`. Number of [delete by query](/specs/search#tag/Records/operation/deleteBy) operations. - `delete_record_operations`. Number of [delete record](/specs/search#tag/Records/operation/deleteObject) operations. - `get_record_operations`. Number of [get record](/specs/search#tag/Records/operation/getObject) operations. - `partial_update_record_operations`. Number of [partially update records](/specs/search#tag/Records/operation/partialUpdateObject) operations. - `update_record_operations`. Number of [add or replace record by objectID](/specs/search#tag/Records/operation/addOrUpdateObject) operations. **Synonym operations** - `synonym_operations`. All synonym operations. - `total_synonym_operations`. Sum of all synonym operations. - `batch_synonym_operations`. Number of [save all synonyms](/specs/search#tag/Synonyms/operation/saveSynonyms) operations. - `clear_synonym_operations`. Number of [clear synonyms](/specs/search#tag/Synonyms/operation/clearSynonyms) operations. - `delete_synonym_operations`. Number of [delete synonym](/specs/search#tag/Synonyms/operation/deleteSynonym) operations. - `get_synonym_operations`. Number of [get synonym](/specs/search#tag/Synonyms/operation/getSynonym) operations. - `query_synonym_operations`. Number of [search synonyms](/specs/search#tag/Synonyms/operation/searchSynonyms) operations. - `update_synonym_operations`. Number of [save a synonym](/specs/search#tag/Synonyms/operation/saveSynonym) operations. **Rule operations** - `rule_operations`. All rule operations. - `total_rules_operations`. Sum of all rule operations. - `batch_rules_operations`. Number of [batch rules](/specs/search#tag/Rules/operation/saveRules) operations. - `clear_rules_operations`. Number of [delete rule](/specs/search#tag/Rules/operation/deleteRule) operations. - `delete_rules_operations`. Number of [clear rules](/specs/search#tag/Rules/operation/clearRules) operations. - `get_rules_operations`. Number of [get rule](/specs/search#tag/Rules/operation/getRule) operations. - `save_rules_operations`. Number of [save rule](/specs/search#operation/getIndexUsage) operations. - `search_rules_operations`. Number of [search rules](/specs/search#tag/Rules/operation/searchRules) operations. **Total operations** - `total_recommend_requests`. Number of [Recommend requests](https://www.algolia.com/doc/guides/algolia-ai/recommend/) - `total_write_operations`. Number of Write operations - `total_read_operations`. Number of read operations - `total_operations`. Sum of all operations **Total Query Suggestions operations** Query Suggestions operations are a subset of `total_search_operations`. - `querysuggestions_total_search_operations`. Number of Query Suggestions search operations. - `querysuggestions_total_search_requests`. Number of Query Suggestions [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - `querysuggestions_total_acl_operations`. Sum of all Query Suggestions [ACL operations](#acl-operations). - `querysuggestions_total_indexing_operations`. Number of Query Suggestions [indexing operations](#indexing-operations). - `querysuggestions_total_records_operations`. Number of Query Suggestions [record operations](#record-operations). - `querysuggestions_total_synonym_operations`. Number of Query Suggestions [synonym operations](#synonym-operations). - `querysuggestions_total_rules_operations`. Number of Query Suggestions [Rule operations](#rule-operations). - `querysuggestions_total_write_operations`. Number of Query Suggestions Write operations. - `querysuggestions_total_read_operations`. Number of Query Suggestions Read operations. - `querysuggestions_total_operations`. Sum of all Query Suggestions operations. **Processing time** - `avg_processing_time`. Average processing time (in milliseconds). - `90p_processing_time`. 90th percentile of processing time (in milliseconds). - `99p_processing_time`. 99th percentile of processing time (in milliseconds). - `queries_above_last_ms_processing_time`. Number of queries that take one or more seconds to process. **Indices** - `records`. Number of records. - `data_size`. The size of the records (in bytes). - `file_size`. The size of the records _and_ index metadata (in bytes). **Maximum queries per second** - `max_qps`. [Maximum queries per second](https://support.algolia.com/hc/en-us/articles/4406975224721) per server. - `region_max_qps`. Maximum queries per second per region. - `total_max_qps`. Maximum queries per second across all servers. **Used search capacity** The following capacities are reported in percent: - `used_search_capacity`. Maximum search capacity used per server. - `avg_used_search_capacity`. Average search capacity used per server. - `region_used_search_capacity`. Maximum search capacity used per region. - `region_avg_used_search_capacity`. Average search capacity used per region. - `total_used_search_capacity`. Maximum search capacity used for all servers. - `total_avg_used_search_capacity`. Average used search capacity for all servers. **Degraded queries** Check the impact of [degraded queries](https://support.algolia.com/hc/en-us/articles/4406981934481). - `degraded_queries_ssd_used_queries_impacted`. Percentage of degraded queries due to the Algolia search engine having to read from the server's SSD. - `degraded_queries_ssd_used_seconds_impacted`. Percentage of seconds affected by `ssd_used` degraded queries. - `degraded_queries_max_capacity_queries_impacted`. Percentage of degraded queries due to all search threads being used. - `degraded_queries_max_capacity_seconds_impacted`. Percentage of seconds affected by `max_capacity` degraded queries. (required) - # @param index_name [String] Name of the index on which to perform the operation. (required) - # @param start_date [String] Start date of the period to analyze, in RFC 3339 format. (required) - # @param end_date [String] End date of the period to analyze, in RFC 3339 format. (required) - # @param granularity [Granularity] Granularity of the aggregated metrics. - `hourly`: the maximum time range for hourly metrics is 7 days. - `daily`: the maximum time range for daily metrics is 365 days. (default to 'daily') - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Http::Response] the response - def get_index_usage_with_http_info( - statistic, - index_name, - start_date, - end_date, - granularity = nil, - request_options = {} - ) - # 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(request_options[:query_params]) unless request_options[:query_params].nil? - header_params = {} - header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? - - post_body = request_options[:debug_body] - - new_options = request_options.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, new_options) - end - - # Retrieves the selected usage statistics for one index. - - # @param statistic [Statistic] Usage statistics to retrieve. Use `*` to retrieve all usage metrics, otherwise add one or more of the following metrics, separated by a comma. **Search operations** - `search_operations`. All search operations. - `total_search_operations`: Sum of all search operations. - `total_search_requests`: Sum of all [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). The number of billed search requests is equal to this value minus `querysuggestions_total_search_requests`. - `queries_operations`. Number of [single index search](/specs/search#tag/Search/operation/searchSingleIndex) operations. - `multi_queries_operations`. Number of [multi-index search](/specs/search#tag/Search/operation/search) operations. **ACL operations** - `acl_operations`. All ACL operations. - `total_acl_operations`. Sum of all ACL operations. - `get_api_keys_operations`. Number of [list API keys](/specs/search#tag/Api-Keys/operation/listApiKeys) operations. - `get_api_key_operations`. Number of [get API key permission](/specs/search#tag/Api-Keys/operation/getApiKey) operations. - `add_api_key_operations`. Number of [create API key](/specs/search#tag/Api-Keys/operation/addApiKey) operations. - `update_api_key_operations`. Number of [update API key](/specs/search#tag/Api-Keys/operation/updateApiKey) operations. - `delete_api_key_operations`. Number of [delete API key](/specs/search#tag/Api-Keys/operation/deleteApiKey) operations. - `list_api_key_operations`. Number of list index API keys operations. **Indexing operations** - `indexing_operations`. All indexing operations. - `total_indexing_operations`. Sum of all indexing operations. - `browse_operations`. Number of [browse index](/specs/search#tag/Search/operation/browse) operations. - `clear_index_operations`. Number of [clear records](/specs/search#tag/Records/operation/clearObjects) operations. - `copy_move_operations`. Number of [copy or move index](/specs/search#tag/Indices/operation/operationIndex) operations. - `delete_index_operations`. Number of [delete index](/specs/search#tag/Indices/operation/deleteIndex) operations. - `get_log_operations`. Number of [get logs](/specs/search#tag/Advanced/operation/getLogs) operations. - `get_settings_operations`. Number of [get settings](/specs/search#operation/getIndexUsage) operations. - `set_settings_operations`. Number of [set settings](/specs/search#tag/Indices/operation/setSettings) operations. - `list_indices_operations`. Number of [list indices](/specs/search#tag/Indices/operation/listIndices) operations. - `wait_task_operations`. Number of [wait](/specs/search#tag/Indices/operation/getTask) operations. **Record operations** - `record_operations`. All record operations. - `total_records_operations`. Sum of all record operations. - `add_record_operations`. Number of [add or replace record](/specs/search#tag/Records/operation/saveObject) operations. - `batch_operations`. Number of [batch indexing](/specs/search#tag/Records/operation/multipleBatch) operations. - `delete_by_query_operations`. Number of [delete by query](/specs/search#tag/Records/operation/deleteBy) operations. - `delete_record_operations`. Number of [delete record](/specs/search#tag/Records/operation/deleteObject) operations. - `get_record_operations`. Number of [get record](/specs/search#tag/Records/operation/getObject) operations. - `partial_update_record_operations`. Number of [partially update records](/specs/search#tag/Records/operation/partialUpdateObject) operations. - `update_record_operations`. Number of [add or replace record by objectID](/specs/search#tag/Records/operation/addOrUpdateObject) operations. **Synonym operations** - `synonym_operations`. All synonym operations. - `total_synonym_operations`. Sum of all synonym operations. - `batch_synonym_operations`. Number of [save all synonyms](/specs/search#tag/Synonyms/operation/saveSynonyms) operations. - `clear_synonym_operations`. Number of [clear synonyms](/specs/search#tag/Synonyms/operation/clearSynonyms) operations. - `delete_synonym_operations`. Number of [delete synonym](/specs/search#tag/Synonyms/operation/deleteSynonym) operations. - `get_synonym_operations`. Number of [get synonym](/specs/search#tag/Synonyms/operation/getSynonym) operations. - `query_synonym_operations`. Number of [search synonyms](/specs/search#tag/Synonyms/operation/searchSynonyms) operations. - `update_synonym_operations`. Number of [save a synonym](/specs/search#tag/Synonyms/operation/saveSynonym) operations. **Rule operations** - `rule_operations`. All rule operations. - `total_rules_operations`. Sum of all rule operations. - `batch_rules_operations`. Number of [batch rules](/specs/search#tag/Rules/operation/saveRules) operations. - `clear_rules_operations`. Number of [delete rule](/specs/search#tag/Rules/operation/deleteRule) operations. - `delete_rules_operations`. Number of [clear rules](/specs/search#tag/Rules/operation/clearRules) operations. - `get_rules_operations`. Number of [get rule](/specs/search#tag/Rules/operation/getRule) operations. - `save_rules_operations`. Number of [save rule](/specs/search#operation/getIndexUsage) operations. - `search_rules_operations`. Number of [search rules](/specs/search#tag/Rules/operation/searchRules) operations. **Total operations** - `total_recommend_requests`. Number of [Recommend requests](https://www.algolia.com/doc/guides/algolia-ai/recommend/) - `total_write_operations`. Number of Write operations - `total_read_operations`. Number of read operations - `total_operations`. Sum of all operations **Total Query Suggestions operations** Query Suggestions operations are a subset of `total_search_operations`. - `querysuggestions_total_search_operations`. Number of Query Suggestions search operations. - `querysuggestions_total_search_requests`. Number of Query Suggestions [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - `querysuggestions_total_acl_operations`. Sum of all Query Suggestions [ACL operations](#acl-operations). - `querysuggestions_total_indexing_operations`. Number of Query Suggestions [indexing operations](#indexing-operations). - `querysuggestions_total_records_operations`. Number of Query Suggestions [record operations](#record-operations). - `querysuggestions_total_synonym_operations`. Number of Query Suggestions [synonym operations](#synonym-operations). - `querysuggestions_total_rules_operations`. Number of Query Suggestions [Rule operations](#rule-operations). - `querysuggestions_total_write_operations`. Number of Query Suggestions Write operations. - `querysuggestions_total_read_operations`. Number of Query Suggestions Read operations. - `querysuggestions_total_operations`. Sum of all Query Suggestions operations. **Processing time** - `avg_processing_time`. Average processing time (in milliseconds). - `90p_processing_time`. 90th percentile of processing time (in milliseconds). - `99p_processing_time`. 99th percentile of processing time (in milliseconds). - `queries_above_last_ms_processing_time`. Number of queries that take one or more seconds to process. **Indices** - `records`. Number of records. - `data_size`. The size of the records (in bytes). - `file_size`. The size of the records _and_ index metadata (in bytes). **Maximum queries per second** - `max_qps`. [Maximum queries per second](https://support.algolia.com/hc/en-us/articles/4406975224721) per server. - `region_max_qps`. Maximum queries per second per region. - `total_max_qps`. Maximum queries per second across all servers. **Used search capacity** The following capacities are reported in percent: - `used_search_capacity`. Maximum search capacity used per server. - `avg_used_search_capacity`. Average search capacity used per server. - `region_used_search_capacity`. Maximum search capacity used per region. - `region_avg_used_search_capacity`. Average search capacity used per region. - `total_used_search_capacity`. Maximum search capacity used for all servers. - `total_avg_used_search_capacity`. Average used search capacity for all servers. **Degraded queries** Check the impact of [degraded queries](https://support.algolia.com/hc/en-us/articles/4406981934481). - `degraded_queries_ssd_used_queries_impacted`. Percentage of degraded queries due to the Algolia search engine having to read from the server's SSD. - `degraded_queries_ssd_used_seconds_impacted`. Percentage of seconds affected by `ssd_used` degraded queries. - `degraded_queries_max_capacity_queries_impacted`. Percentage of degraded queries due to all search threads being used. - `degraded_queries_max_capacity_seconds_impacted`. Percentage of seconds affected by `max_capacity` degraded queries. (required) - # @param index_name [String] Name of the index on which to perform the operation. (required) - # @param start_date [String] Start date of the period to analyze, in RFC 3339 format. (required) - # @param end_date [String] End date of the period to analyze, in RFC 3339 format. (required) - # @param granularity [Granularity] Granularity of the aggregated metrics. - `hourly`: the maximum time range for hourly metrics is 7 days. - `daily`: the maximum time range for daily metrics is 365 days. (default to 'daily') - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [IndexUsage] - def get_index_usage(statistic, index_name, start_date, end_date, granularity = nil, request_options = {}) - response = get_index_usage_with_http_info( - statistic, - index_name, - start_date, - end_date, - granularity, - request_options - ) - @api_client.deserialize(response.body, request_options[:debug_return_type] || "Usage::IndexUsage") - end - - # Retrieves usage statistics evaluated over a specified period. - - # @param statistic [Statistic] Usage statistics to retrieve. Use `*` to retrieve all usage metrics, otherwise add one or more of the following metrics, separated by a comma. **Search operations** - `search_operations`. All search operations. - `total_search_operations`: Sum of all search operations. - `total_search_requests`: Sum of all [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). The number of billed search requests is equal to this value minus `querysuggestions_total_search_requests`. - `queries_operations`. Number of [single index search](/specs/search#tag/Search/operation/searchSingleIndex) operations. - `multi_queries_operations`. Number of [multi-index search](/specs/search#tag/Search/operation/search) operations. **ACL operations** - `acl_operations`. All ACL operations. - `total_acl_operations`. Sum of all ACL operations. - `get_api_keys_operations`. Number of [list API keys](/specs/search#tag/Api-Keys/operation/listApiKeys) operations. - `get_api_key_operations`. Number of [get API key permission](/specs/search#tag/Api-Keys/operation/getApiKey) operations. - `add_api_key_operations`. Number of [create API key](/specs/search#tag/Api-Keys/operation/addApiKey) operations. - `update_api_key_operations`. Number of [update API key](/specs/search#tag/Api-Keys/operation/updateApiKey) operations. - `delete_api_key_operations`. Number of [delete API key](/specs/search#tag/Api-Keys/operation/deleteApiKey) operations. - `list_api_key_operations`. Number of list index API keys operations. **Indexing operations** - `indexing_operations`. All indexing operations. - `total_indexing_operations`. Sum of all indexing operations. - `browse_operations`. Number of [browse index](/specs/search#tag/Search/operation/browse) operations. - `clear_index_operations`. Number of [clear records](/specs/search#tag/Records/operation/clearObjects) operations. - `copy_move_operations`. Number of [copy or move index](/specs/search#tag/Indices/operation/operationIndex) operations. - `delete_index_operations`. Number of [delete index](/specs/search#tag/Indices/operation/deleteIndex) operations. - `get_log_operations`. Number of [get logs](/specs/search#tag/Advanced/operation/getLogs) operations. - `get_settings_operations`. Number of [get settings](/specs/search#operation/getIndexUsage) operations. - `set_settings_operations`. Number of [set settings](/specs/search#tag/Indices/operation/setSettings) operations. - `list_indices_operations`. Number of [list indices](/specs/search#tag/Indices/operation/listIndices) operations. - `wait_task_operations`. Number of [wait](/specs/search#tag/Indices/operation/getTask) operations. **Record operations** - `record_operations`. All record operations. - `total_records_operations`. Sum of all record operations. - `add_record_operations`. Number of [add or replace record](/specs/search#tag/Records/operation/saveObject) operations. - `batch_operations`. Number of [batch indexing](/specs/search#tag/Records/operation/multipleBatch) operations. - `delete_by_query_operations`. Number of [delete by query](/specs/search#tag/Records/operation/deleteBy) operations. - `delete_record_operations`. Number of [delete record](/specs/search#tag/Records/operation/deleteObject) operations. - `get_record_operations`. Number of [get record](/specs/search#tag/Records/operation/getObject) operations. - `partial_update_record_operations`. Number of [partially update records](/specs/search#tag/Records/operation/partialUpdateObject) operations. - `update_record_operations`. Number of [add or replace record by objectID](/specs/search#tag/Records/operation/addOrUpdateObject) operations. **Synonym operations** - `synonym_operations`. All synonym operations. - `total_synonym_operations`. Sum of all synonym operations. - `batch_synonym_operations`. Number of [save all synonyms](/specs/search#tag/Synonyms/operation/saveSynonyms) operations. - `clear_synonym_operations`. Number of [clear synonyms](/specs/search#tag/Synonyms/operation/clearSynonyms) operations. - `delete_synonym_operations`. Number of [delete synonym](/specs/search#tag/Synonyms/operation/deleteSynonym) operations. - `get_synonym_operations`. Number of [get synonym](/specs/search#tag/Synonyms/operation/getSynonym) operations. - `query_synonym_operations`. Number of [search synonyms](/specs/search#tag/Synonyms/operation/searchSynonyms) operations. - `update_synonym_operations`. Number of [save a synonym](/specs/search#tag/Synonyms/operation/saveSynonym) operations. **Rule operations** - `rule_operations`. All rule operations. - `total_rules_operations`. Sum of all rule operations. - `batch_rules_operations`. Number of [batch rules](/specs/search#tag/Rules/operation/saveRules) operations. - `clear_rules_operations`. Number of [delete rule](/specs/search#tag/Rules/operation/deleteRule) operations. - `delete_rules_operations`. Number of [clear rules](/specs/search#tag/Rules/operation/clearRules) operations. - `get_rules_operations`. Number of [get rule](/specs/search#tag/Rules/operation/getRule) operations. - `save_rules_operations`. Number of [save rule](/specs/search#operation/getIndexUsage) operations. - `search_rules_operations`. Number of [search rules](/specs/search#tag/Rules/operation/searchRules) operations. **Total operations** - `total_recommend_requests`. Number of [Recommend requests](https://www.algolia.com/doc/guides/algolia-ai/recommend/) - `total_write_operations`. Number of Write operations - `total_read_operations`. Number of read operations - `total_operations`. Sum of all operations **Total Query Suggestions operations** Query Suggestions operations are a subset of `total_search_operations`. - `querysuggestions_total_search_operations`. Number of Query Suggestions search operations. - `querysuggestions_total_search_requests`. Number of Query Suggestions [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - `querysuggestions_total_acl_operations`. Sum of all Query Suggestions [ACL operations](#acl-operations). - `querysuggestions_total_indexing_operations`. Number of Query Suggestions [indexing operations](#indexing-operations). - `querysuggestions_total_records_operations`. Number of Query Suggestions [record operations](#record-operations). - `querysuggestions_total_synonym_operations`. Number of Query Suggestions [synonym operations](#synonym-operations). - `querysuggestions_total_rules_operations`. Number of Query Suggestions [Rule operations](#rule-operations). - `querysuggestions_total_write_operations`. Number of Query Suggestions Write operations. - `querysuggestions_total_read_operations`. Number of Query Suggestions Read operations. - `querysuggestions_total_operations`. Sum of all Query Suggestions operations. **Processing time** - `avg_processing_time`. Average processing time (in milliseconds). - `90p_processing_time`. 90th percentile of processing time (in milliseconds). - `99p_processing_time`. 99th percentile of processing time (in milliseconds). - `queries_above_last_ms_processing_time`. Number of queries that take one or more seconds to process. **Indices** - `records`. Number of records. - `data_size`. The size of the records (in bytes). - `file_size`. The size of the records _and_ index metadata (in bytes). **Maximum queries per second** - `max_qps`. [Maximum queries per second](https://support.algolia.com/hc/en-us/articles/4406975224721) per server. - `region_max_qps`. Maximum queries per second per region. - `total_max_qps`. Maximum queries per second across all servers. **Used search capacity** The following capacities are reported in percent: - `used_search_capacity`. Maximum search capacity used per server. - `avg_used_search_capacity`. Average search capacity used per server. - `region_used_search_capacity`. Maximum search capacity used per region. - `region_avg_used_search_capacity`. Average search capacity used per region. - `total_used_search_capacity`. Maximum search capacity used for all servers. - `total_avg_used_search_capacity`. Average used search capacity for all servers. **Degraded queries** Check the impact of [degraded queries](https://support.algolia.com/hc/en-us/articles/4406981934481). - `degraded_queries_ssd_used_queries_impacted`. Percentage of degraded queries due to the Algolia search engine having to read from the server's SSD. - `degraded_queries_ssd_used_seconds_impacted`. Percentage of seconds affected by `ssd_used` degraded queries. - `degraded_queries_max_capacity_queries_impacted`. Percentage of degraded queries due to all search threads being used. - `degraded_queries_max_capacity_seconds_impacted`. Percentage of seconds affected by `max_capacity` degraded queries. (required) - # @param start_date [String] Start date of the period to analyze, in RFC 3339 format. (required) - # @param end_date [String] End date of the period to analyze, in RFC 3339 format. (required) - # @param granularity [Granularity] Granularity of the aggregated metrics. - `hourly`: the maximum time range for hourly metrics is 7 days. - `daily`: the maximum time range for daily metrics is 365 days. (default to 'daily') - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [Http::Response] the response - def get_usage_with_http_info(statistic, start_date, end_date, granularity = nil, request_options = {}) - # 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(request_options[:query_params]) unless request_options[:query_params].nil? - header_params = {} - header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? - - post_body = request_options[:debug_body] - - new_options = request_options.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, new_options) - end - - # Retrieves usage statistics evaluated over a specified period. - - # @param statistic [Statistic] Usage statistics to retrieve. Use `*` to retrieve all usage metrics, otherwise add one or more of the following metrics, separated by a comma. **Search operations** - `search_operations`. All search operations. - `total_search_operations`: Sum of all search operations. - `total_search_requests`: Sum of all [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). The number of billed search requests is equal to this value minus `querysuggestions_total_search_requests`. - `queries_operations`. Number of [single index search](/specs/search#tag/Search/operation/searchSingleIndex) operations. - `multi_queries_operations`. Number of [multi-index search](/specs/search#tag/Search/operation/search) operations. **ACL operations** - `acl_operations`. All ACL operations. - `total_acl_operations`. Sum of all ACL operations. - `get_api_keys_operations`. Number of [list API keys](/specs/search#tag/Api-Keys/operation/listApiKeys) operations. - `get_api_key_operations`. Number of [get API key permission](/specs/search#tag/Api-Keys/operation/getApiKey) operations. - `add_api_key_operations`. Number of [create API key](/specs/search#tag/Api-Keys/operation/addApiKey) operations. - `update_api_key_operations`. Number of [update API key](/specs/search#tag/Api-Keys/operation/updateApiKey) operations. - `delete_api_key_operations`. Number of [delete API key](/specs/search#tag/Api-Keys/operation/deleteApiKey) operations. - `list_api_key_operations`. Number of list index API keys operations. **Indexing operations** - `indexing_operations`. All indexing operations. - `total_indexing_operations`. Sum of all indexing operations. - `browse_operations`. Number of [browse index](/specs/search#tag/Search/operation/browse) operations. - `clear_index_operations`. Number of [clear records](/specs/search#tag/Records/operation/clearObjects) operations. - `copy_move_operations`. Number of [copy or move index](/specs/search#tag/Indices/operation/operationIndex) operations. - `delete_index_operations`. Number of [delete index](/specs/search#tag/Indices/operation/deleteIndex) operations. - `get_log_operations`. Number of [get logs](/specs/search#tag/Advanced/operation/getLogs) operations. - `get_settings_operations`. Number of [get settings](/specs/search#operation/getIndexUsage) operations. - `set_settings_operations`. Number of [set settings](/specs/search#tag/Indices/operation/setSettings) operations. - `list_indices_operations`. Number of [list indices](/specs/search#tag/Indices/operation/listIndices) operations. - `wait_task_operations`. Number of [wait](/specs/search#tag/Indices/operation/getTask) operations. **Record operations** - `record_operations`. All record operations. - `total_records_operations`. Sum of all record operations. - `add_record_operations`. Number of [add or replace record](/specs/search#tag/Records/operation/saveObject) operations. - `batch_operations`. Number of [batch indexing](/specs/search#tag/Records/operation/multipleBatch) operations. - `delete_by_query_operations`. Number of [delete by query](/specs/search#tag/Records/operation/deleteBy) operations. - `delete_record_operations`. Number of [delete record](/specs/search#tag/Records/operation/deleteObject) operations. - `get_record_operations`. Number of [get record](/specs/search#tag/Records/operation/getObject) operations. - `partial_update_record_operations`. Number of [partially update records](/specs/search#tag/Records/operation/partialUpdateObject) operations. - `update_record_operations`. Number of [add or replace record by objectID](/specs/search#tag/Records/operation/addOrUpdateObject) operations. **Synonym operations** - `synonym_operations`. All synonym operations. - `total_synonym_operations`. Sum of all synonym operations. - `batch_synonym_operations`. Number of [save all synonyms](/specs/search#tag/Synonyms/operation/saveSynonyms) operations. - `clear_synonym_operations`. Number of [clear synonyms](/specs/search#tag/Synonyms/operation/clearSynonyms) operations. - `delete_synonym_operations`. Number of [delete synonym](/specs/search#tag/Synonyms/operation/deleteSynonym) operations. - `get_synonym_operations`. Number of [get synonym](/specs/search#tag/Synonyms/operation/getSynonym) operations. - `query_synonym_operations`. Number of [search synonyms](/specs/search#tag/Synonyms/operation/searchSynonyms) operations. - `update_synonym_operations`. Number of [save a synonym](/specs/search#tag/Synonyms/operation/saveSynonym) operations. **Rule operations** - `rule_operations`. All rule operations. - `total_rules_operations`. Sum of all rule operations. - `batch_rules_operations`. Number of [batch rules](/specs/search#tag/Rules/operation/saveRules) operations. - `clear_rules_operations`. Number of [delete rule](/specs/search#tag/Rules/operation/deleteRule) operations. - `delete_rules_operations`. Number of [clear rules](/specs/search#tag/Rules/operation/clearRules) operations. - `get_rules_operations`. Number of [get rule](/specs/search#tag/Rules/operation/getRule) operations. - `save_rules_operations`. Number of [save rule](/specs/search#operation/getIndexUsage) operations. - `search_rules_operations`. Number of [search rules](/specs/search#tag/Rules/operation/searchRules) operations. **Total operations** - `total_recommend_requests`. Number of [Recommend requests](https://www.algolia.com/doc/guides/algolia-ai/recommend/) - `total_write_operations`. Number of Write operations - `total_read_operations`. Number of read operations - `total_operations`. Sum of all operations **Total Query Suggestions operations** Query Suggestions operations are a subset of `total_search_operations`. - `querysuggestions_total_search_operations`. Number of Query Suggestions search operations. - `querysuggestions_total_search_requests`. Number of Query Suggestions [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - `querysuggestions_total_acl_operations`. Sum of all Query Suggestions [ACL operations](#acl-operations). - `querysuggestions_total_indexing_operations`. Number of Query Suggestions [indexing operations](#indexing-operations). - `querysuggestions_total_records_operations`. Number of Query Suggestions [record operations](#record-operations). - `querysuggestions_total_synonym_operations`. Number of Query Suggestions [synonym operations](#synonym-operations). - `querysuggestions_total_rules_operations`. Number of Query Suggestions [Rule operations](#rule-operations). - `querysuggestions_total_write_operations`. Number of Query Suggestions Write operations. - `querysuggestions_total_read_operations`. Number of Query Suggestions Read operations. - `querysuggestions_total_operations`. Sum of all Query Suggestions operations. **Processing time** - `avg_processing_time`. Average processing time (in milliseconds). - `90p_processing_time`. 90th percentile of processing time (in milliseconds). - `99p_processing_time`. 99th percentile of processing time (in milliseconds). - `queries_above_last_ms_processing_time`. Number of queries that take one or more seconds to process. **Indices** - `records`. Number of records. - `data_size`. The size of the records (in bytes). - `file_size`. The size of the records _and_ index metadata (in bytes). **Maximum queries per second** - `max_qps`. [Maximum queries per second](https://support.algolia.com/hc/en-us/articles/4406975224721) per server. - `region_max_qps`. Maximum queries per second per region. - `total_max_qps`. Maximum queries per second across all servers. **Used search capacity** The following capacities are reported in percent: - `used_search_capacity`. Maximum search capacity used per server. - `avg_used_search_capacity`. Average search capacity used per server. - `region_used_search_capacity`. Maximum search capacity used per region. - `region_avg_used_search_capacity`. Average search capacity used per region. - `total_used_search_capacity`. Maximum search capacity used for all servers. - `total_avg_used_search_capacity`. Average used search capacity for all servers. **Degraded queries** Check the impact of [degraded queries](https://support.algolia.com/hc/en-us/articles/4406981934481). - `degraded_queries_ssd_used_queries_impacted`. Percentage of degraded queries due to the Algolia search engine having to read from the server's SSD. - `degraded_queries_ssd_used_seconds_impacted`. Percentage of seconds affected by `ssd_used` degraded queries. - `degraded_queries_max_capacity_queries_impacted`. Percentage of degraded queries due to all search threads being used. - `degraded_queries_max_capacity_seconds_impacted`. Percentage of seconds affected by `max_capacity` degraded queries. (required) - # @param start_date [String] Start date of the period to analyze, in RFC 3339 format. (required) - # @param end_date [String] End date of the period to analyze, in RFC 3339 format. (required) - # @param granularity [Granularity] Granularity of the aggregated metrics. - `hourly`: the maximum time range for hourly metrics is 7 days. - `daily`: the maximum time range for daily metrics is 365 days. (default to 'daily') - # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) - # @return [IndexUsage] - def get_usage(statistic, start_date, end_date, granularity = nil, request_options = {}) - response = get_usage_with_http_info(statistic, start_date, end_date, granularity, request_options) - @api_client.deserialize(response.body, request_options[:debug_return_type] || "Usage::IndexUsage") - end - - end -end diff --git a/lib/algolia/models/usage/error_base.rb b/lib/algolia/models/usage/error_base.rb deleted file mode 100644 index 2fa2575b..00000000 --- a/lib/algolia/models/usage/error_base.rb +++ /dev/null @@ -1,212 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - # Error. - class ErrorBase - attr_accessor :message - - attr_accessor :additional_properties - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :message => :message - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.types_mapping - { - :message => :"String" - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new( - [] - ) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - raise( - ArgumentError, - "The input argument (attributes) must be a hash in `Algolia::ErrorBase` initialize method" - ) - end - - if attributes.key?(:message) - self.message = attributes[:message] - end - - # add extra attribute to additional_properties - self.additional_properties ||= {} - self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) }) - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(other) - return true if self.equal?(other) - self.class == other.class && - message == other.message - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(other) - self == other - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [message].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - types_mapping.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| - _deserialize(::Regexp.last_match(1), v) - } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]]) - end - end - - # add extra attribute to transformed_hash - transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) }) - new(transformed_hash) - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - # model - else - # models (e.g. Pet) or oneOf - klass = Algolia::Usage.const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass - .build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - def to_json(*_args) - to_hash.to_json - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - - # also add attributes from additional_properties to hash - self.additional_properties&.each_pair do |k, v| - hash[k.to_sym] = _to_hash(v) - end - - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to?(:to_hash) - value.to_hash - else - value - end - end - - end - - end -end diff --git a/lib/algolia/models/usage/error_item.rb b/lib/algolia/models/usage/error_item.rb deleted file mode 100644 index 9fa51e12..00000000 --- a/lib/algolia/models/usage/error_item.rb +++ /dev/null @@ -1,240 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - class ErrorItem - attr_accessor :code - - attr_accessor :message - - attr_accessor :line - - attr_accessor :position - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :code => :code, - :message => :message, - :line => :line, - :position => :position - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.types_mapping - { - :code => :"String", - :message => :"String", - :line => :"Integer", - :position => :"Integer" - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new( - [] - ) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - raise( - ArgumentError, - "The input argument (attributes) must be a hash in `Algolia::ErrorItem` initialize method" - ) - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - raise( - ArgumentError, - "`#{k}` is not a valid attribute in `Algolia::ErrorItem`. Please check the name to make sure it's valid. List of attributes: " + - self.class.attribute_map.keys.inspect - ) - end - - h[k.to_sym] = v - } - - if attributes.key?(:code) - self.code = attributes[:code] - end - - if attributes.key?(:message) - self.message = attributes[:message] - else - self.message = nil - end - - if attributes.key?(:line) - self.line = attributes[:line] - end - - if attributes.key?(:position) - self.position = attributes[:position] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(other) - return true if self.equal?(other) - self.class == other.class && - code == other.code && - message == other.message && - line == other.line && - position == other.position - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(other) - self == other - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [code, message, line, position].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - types_mapping.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| - _deserialize(::Regexp.last_match(1), v) - } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]]) - end - end - - new(transformed_hash) - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - # model - else - # models (e.g. Pet) or oneOf - klass = Algolia::Usage.const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass - .build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - def to_json(*_args) - to_hash.to_json - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to?(:to_hash) - value.to_hash - else - value - end - end - - end - - end -end diff --git a/lib/algolia/models/usage/forbidden_error.rb b/lib/algolia/models/usage/forbidden_error.rb deleted file mode 100644 index a8c49343..00000000 --- a/lib/algolia/models/usage/forbidden_error.rb +++ /dev/null @@ -1,231 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - class ForbiddenError - attr_accessor :code - - attr_accessor :message - - attr_accessor :errors - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :code => :code, - :message => :message, - :errors => :errors - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.types_mapping - { - :code => :"String", - :message => :"String", - :errors => :"Array" - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new( - [] - ) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - raise( - ArgumentError, - "The input argument (attributes) must be a hash in `Algolia::ForbiddenError` initialize method" - ) - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - raise( - ArgumentError, - "`#{k}` is not a valid attribute in `Algolia::ForbiddenError`. Please check the name to make sure it's valid. List of attributes: " + - self.class.attribute_map.keys.inspect - ) - end - - h[k.to_sym] = v - } - - if attributes.key?(:code) - self.code = attributes[:code] - end - - if attributes.key?(:message) - self.message = attributes[:message] - end - - if attributes.key?(:errors) - if (value = attributes[:errors]).is_a?(Array) - self.errors = value - end - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(other) - return true if self.equal?(other) - self.class == other.class && - code == other.code && - message == other.message && - errors == other.errors - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(other) - self == other - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [code, message, errors].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - types_mapping.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| - _deserialize(::Regexp.last_match(1), v) - } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]]) - end - end - - new(transformed_hash) - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - # model - else - # models (e.g. Pet) or oneOf - klass = Algolia::Usage.const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass - .build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - def to_json(*_args) - to_hash.to_json - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to?(:to_hash) - value.to_hash - else - value - end - end - - end - - end -end diff --git a/lib/algolia/models/usage/granularity.rb b/lib/algolia/models/usage/granularity.rb deleted file mode 100644 index b2e36d8e..00000000 --- a/lib/algolia/models/usage/granularity.rb +++ /dev/null @@ -1,32 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - class Granularity - HOURLY = "hourly".freeze - DAILY = "daily".freeze - - def self.all_vars - @all_vars ||= [HOURLY, DAILY].freeze - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if Granularity.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #Granularity" - end - end - end -end diff --git a/lib/algolia/models/usage/index_usage.rb b/lib/algolia/models/usage/index_usage.rb deleted file mode 100644 index 42a994e5..00000000 --- a/lib/algolia/models/usage/index_usage.rb +++ /dev/null @@ -1,213 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - class IndexUsage - attr_accessor :statistics - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :statistics => :statistics - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.types_mapping - { - :statistics => :"Array" - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new( - [] - ) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - raise( - ArgumentError, - "The input argument (attributes) must be a hash in `Algolia::IndexUsage` initialize method" - ) - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - raise( - ArgumentError, - "`#{k}` is not a valid attribute in `Algolia::IndexUsage`. Please check the name to make sure it's valid. List of attributes: " + - self.class.attribute_map.keys.inspect - ) - end - - h[k.to_sym] = v - } - - if attributes.key?(:statistics) - if (value = attributes[:statistics]).is_a?(Array) - self.statistics = value - end - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(other) - return true if self.equal?(other) - self.class == other.class && - statistics == other.statistics - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(other) - self == other - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [statistics].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - types_mapping.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| - _deserialize(::Regexp.last_match(1), v) - } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]]) - end - end - - new(transformed_hash) - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - # model - else - # models (e.g. Pet) or oneOf - klass = Algolia::Usage.const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass - .build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - def to_json(*_args) - to_hash.to_json - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to?(:to_hash) - value.to_hash - else - value - end - end - - end - - end -end diff --git a/lib/algolia/models/usage/invalid_request_error.rb b/lib/algolia/models/usage/invalid_request_error.rb deleted file mode 100644 index 67cfddf3..00000000 --- a/lib/algolia/models/usage/invalid_request_error.rb +++ /dev/null @@ -1,231 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - class InvalidRequestError - attr_accessor :code - - attr_accessor :message - - attr_accessor :errors - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :code => :code, - :message => :message, - :errors => :errors - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.types_mapping - { - :code => :"String", - :message => :"String", - :errors => :"Array" - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new( - [] - ) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - raise( - ArgumentError, - "The input argument (attributes) must be a hash in `Algolia::InvalidRequestError` initialize method" - ) - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - raise( - ArgumentError, - "`#{k}` is not a valid attribute in `Algolia::InvalidRequestError`. Please check the name to make sure it's valid. List of attributes: " + - self.class.attribute_map.keys.inspect - ) - end - - h[k.to_sym] = v - } - - if attributes.key?(:code) - self.code = attributes[:code] - end - - if attributes.key?(:message) - self.message = attributes[:message] - end - - if attributes.key?(:errors) - if (value = attributes[:errors]).is_a?(Array) - self.errors = value - end - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(other) - return true if self.equal?(other) - self.class == other.class && - code == other.code && - message == other.message && - errors == other.errors - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(other) - self == other - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [code, message, errors].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - types_mapping.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| - _deserialize(::Regexp.last_match(1), v) - } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]]) - end - end - - new(transformed_hash) - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - # model - else - # models (e.g. Pet) or oneOf - klass = Algolia::Usage.const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass - .build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - def to_json(*_args) - to_hash.to_json - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to?(:to_hash) - value.to_hash - else - value - end - end - - end - - end -end diff --git a/lib/algolia/models/usage/statistic.rb b/lib/algolia/models/usage/statistic.rb deleted file mode 100644 index 3d9cd1d7..00000000 --- a/lib/algolia/models/usage/statistic.rb +++ /dev/null @@ -1,199 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - class Statistic - ALL = "*".freeze - SEARCH_OPERATIONS = "search_operations".freeze - TOTAL_SEARCH_OPERATIONS = "total_search_operations".freeze - TOTAL_SEARCH_REQUESTS = "total_search_requests".freeze - QUERIES_OPERATIONS = "queries_operations".freeze - MULTI_QUERIES_OPERATIONS = "multi_queries_operations".freeze - ACL_OPERATIONS = "acl_operations".freeze - TOTAL_ACL_OPERATIONS = "total_acl_operations".freeze - GET_API_KEYS_OPERATIONS = "get_api_keys_operations".freeze - GET_API_KEY_OPERATIONS = "get_api_key_operations".freeze - ADD_API_KEY_OPERATIONS = "add_api_key_operations".freeze - UPDATE_API_KEY_OPERATIONS = "update_api_key_operations".freeze - DELETE_API_KEY_OPERATIONS = "delete_api_key_operations".freeze - LIST_API_KEY_OPERATIONS = "list_api_key_operations".freeze - INDEXING_OPERATIONS = "indexing_operations".freeze - TOTAL_INDEXING_OPERATIONS = "total_indexing_operations".freeze - BROWSE_OPERATIONS = "browse_operations".freeze - CLEAR_INDEX_OPERATIONS = "clear_index_operations".freeze - COPY_MOVE_OPERATIONS = "copy_move_operations".freeze - DELETE_INDEX_OPERATIONS = "delete_index_operations".freeze - GET_LOG_OPERATIONS = "get_log_operations".freeze - GET_SETTINGS_OPERATIONS = "get_settings_operations".freeze - SET_SETTINGS_OPERATIONS = "set_settings_operations".freeze - LIST_INDICES_OPERATIONS = "list_indices_operations".freeze - WAIT_TASK_OPERATIONS = "wait_task_operations".freeze - RECORD_OPERATIONS = "record_operations".freeze - TOTAL_RECORDS_OPERATIONS = "total_records_operations".freeze - ADD_RECORD_OPERATIONS = "add_record_operations".freeze - BATCH_OPERATIONS = "batch_operations".freeze - DELETE_BY_QUERY_OPERATIONS = "delete_by_query_operations".freeze - DELETE_RECORD_OPERATIONS = "delete_record_operations".freeze - GET_RECORD_OPERATIONS = "get_record_operations".freeze - PARTIAL_UPDATE_RECORD_OPERATIONS = "partial_update_record_operations".freeze - UPDATE_RECORD_OPERATIONS = "update_record_operations".freeze - SYNONYM_OPERATIONS = "synonym_operations".freeze - TOTAL_SYNONYM_OPERATIONS = "total_synonym_operations".freeze - BATCH_SYNONYM_OPERATIONS = "batch_synonym_operations".freeze - CLEAR_SYNONYM_OPERATIONS = "clear_synonym_operations".freeze - DELETE_SYNONYM_OPERATIONS = "delete_synonym_operations".freeze - GET_SYNONYM_OPERATIONS = "get_synonym_operations".freeze - QUERY_SYNONYM_OPERATIONS = "query_synonym_operations".freeze - UPDATE_SYNONYM_OPERATIONS = "update_synonym_operations".freeze - RULE_OPERATIONS = "rule_operations".freeze - TOTAL_RULES_OPERATIONS = "total_rules_operations".freeze - BATCH_RULES_OPERATIONS = "batch_rules_operations".freeze - CLEAR_RULES_OPERATIONS = "clear_rules_operations".freeze - DELETE_RULES_OPERATIONS = "delete_rules_operations".freeze - GET_RULES_OPERATIONS = "get_rules_operations".freeze - SAVE_RULES_OPERATIONS = "save_rules_operations".freeze - SEARCH_RULES_OPERATIONS = "search_rules_operations".freeze - TOTAL_RECOMMEND_REQUESTS = "total_recommend_requests".freeze - TOTAL_WRITE_OPERATIONS = "total_write_operations".freeze - TOTAL_READ_OPERATIONS = "total_read_operations".freeze - TOTAL_OPERATIONS = "total_operations".freeze - QUERYSUGGESTIONS_TOTAL_SEARCH_OPERATIONS = "querysuggestions_total_search_operations".freeze - QUERYSUGGESTIONS_TOTAL_SEARCH_REQUESTS = "querysuggestions_total_search_requests".freeze - QUERYSUGGESTIONS_TOTAL_ACL_OPERATIONS = "querysuggestions_total_acl_operations".freeze - QUERYSUGGESTIONS_TOTAL_INDEXING_OPERATIONS = "querysuggestions_total_indexing_operations".freeze - QUERYSUGGESTIONS_TOTAL_RECORDS_OPERATIONS = "querysuggestions_total_records_operations".freeze - QUERYSUGGESTIONS_TOTAL_SYNONYM_OPERATIONS = "querysuggestions_total_synonym_operations".freeze - QUERYSUGGESTIONS_TOTAL_RULES_OPERATIONS = "querysuggestions_total_rules_operations".freeze - QUERYSUGGESTIONS_TOTAL_WRITE_OPERATIONS = "querysuggestions_total_write_operations".freeze - QUERYSUGGESTIONS_TOTAL_READ_OPERATIONS = "querysuggestions_total_read_operations".freeze - QUERYSUGGESTIONS_TOTAL_OPERATIONS = "querysuggestions_total_operations".freeze - AVG_PROCESSING_TIME = "avg_processing_time".freeze - N90P_PROCESSING_TIME = "90p_processing_time".freeze - N99P_PROCESSING_TIME = "99p_processing_time".freeze - QUERIES_ABOVE_LAST_MS_PROCESSING_TIME = "queries_above_last_ms_processing_time".freeze - RECORDS = "records".freeze - DATA_SIZE = "data_size".freeze - FILE_SIZE = "file_size".freeze - MAX_QPS = "max_qps".freeze - REGION_MAX_QPS = "region_max_qps".freeze - TOTAL_MAX_QPS = "total_max_qps".freeze - USED_SEARCH_CAPACITY = "used_search_capacity".freeze - AVG_USED_SEARCH_CAPACITY = "avg_used_search_capacity".freeze - REGION_USED_SEARCH_CAPACITY = "region_used_search_capacity".freeze - REGION_AVG_USED_SEARCH_CAPACITY = "region_avg_used_search_capacity".freeze - TOTAL_USED_SEARCH_CAPACITY = "total_used_search_capacity".freeze - TOTAL_AVG_USED_SEARCH_CAPACITY = "total_avg_used_search_capacity".freeze - DEGRADED_QUERIES_SSD_USED_QUERIES_IMPACTED = "degraded_queries_ssd_used_queries_impacted".freeze - DEGRADED_QUERIES_SSD_USED_SECONDS_IMPACTED = "degraded_queries_ssd_used_seconds_impacted".freeze - DEGRADED_QUERIES_MAX_CAPACITY_QUERIES_IMPACTED = "degraded_queries_max_capacity_queries_impacted".freeze - DEGRADED_QUERIES_MAX_CAPACITY_SECONDS_IMPACTED = "degraded_queries_max_capacity_seconds_impacted".freeze - - def self.all_vars - @all_vars ||= [ - ALL, - SEARCH_OPERATIONS, - TOTAL_SEARCH_OPERATIONS, - TOTAL_SEARCH_REQUESTS, - QUERIES_OPERATIONS, - MULTI_QUERIES_OPERATIONS, - ACL_OPERATIONS, - TOTAL_ACL_OPERATIONS, - GET_API_KEYS_OPERATIONS, - GET_API_KEY_OPERATIONS, - ADD_API_KEY_OPERATIONS, - UPDATE_API_KEY_OPERATIONS, - DELETE_API_KEY_OPERATIONS, - LIST_API_KEY_OPERATIONS, - INDEXING_OPERATIONS, - TOTAL_INDEXING_OPERATIONS, - BROWSE_OPERATIONS, - CLEAR_INDEX_OPERATIONS, - COPY_MOVE_OPERATIONS, - DELETE_INDEX_OPERATIONS, - GET_LOG_OPERATIONS, - GET_SETTINGS_OPERATIONS, - SET_SETTINGS_OPERATIONS, - LIST_INDICES_OPERATIONS, - WAIT_TASK_OPERATIONS, - RECORD_OPERATIONS, - TOTAL_RECORDS_OPERATIONS, - ADD_RECORD_OPERATIONS, - BATCH_OPERATIONS, - DELETE_BY_QUERY_OPERATIONS, - DELETE_RECORD_OPERATIONS, - GET_RECORD_OPERATIONS, - PARTIAL_UPDATE_RECORD_OPERATIONS, - UPDATE_RECORD_OPERATIONS, - SYNONYM_OPERATIONS, - TOTAL_SYNONYM_OPERATIONS, - BATCH_SYNONYM_OPERATIONS, - CLEAR_SYNONYM_OPERATIONS, - DELETE_SYNONYM_OPERATIONS, - GET_SYNONYM_OPERATIONS, - QUERY_SYNONYM_OPERATIONS, - UPDATE_SYNONYM_OPERATIONS, - RULE_OPERATIONS, - TOTAL_RULES_OPERATIONS, - BATCH_RULES_OPERATIONS, - CLEAR_RULES_OPERATIONS, - DELETE_RULES_OPERATIONS, - GET_RULES_OPERATIONS, - SAVE_RULES_OPERATIONS, - SEARCH_RULES_OPERATIONS, - TOTAL_RECOMMEND_REQUESTS, - TOTAL_WRITE_OPERATIONS, - TOTAL_READ_OPERATIONS, - TOTAL_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_SEARCH_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_SEARCH_REQUESTS, - QUERYSUGGESTIONS_TOTAL_ACL_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_INDEXING_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_RECORDS_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_SYNONYM_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_RULES_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_WRITE_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_READ_OPERATIONS, - QUERYSUGGESTIONS_TOTAL_OPERATIONS, - AVG_PROCESSING_TIME, - N90P_PROCESSING_TIME, - N99P_PROCESSING_TIME, - QUERIES_ABOVE_LAST_MS_PROCESSING_TIME, - RECORDS, - DATA_SIZE, - FILE_SIZE, - MAX_QPS, - REGION_MAX_QPS, - TOTAL_MAX_QPS, - USED_SEARCH_CAPACITY, - AVG_USED_SEARCH_CAPACITY, - REGION_USED_SEARCH_CAPACITY, - REGION_AVG_USED_SEARCH_CAPACITY, - TOTAL_USED_SEARCH_CAPACITY, - TOTAL_AVG_USED_SEARCH_CAPACITY, - DEGRADED_QUERIES_SSD_USED_QUERIES_IMPACTED, - DEGRADED_QUERIES_SSD_USED_SECONDS_IMPACTED, - DEGRADED_QUERIES_MAX_CAPACITY_QUERIES_IMPACTED, - DEGRADED_QUERIES_MAX_CAPACITY_SECONDS_IMPACTED - ].freeze - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if Statistic.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #Statistic" - end - end - end -end diff --git a/lib/algolia/models/usage/statistic_entry.rb b/lib/algolia/models/usage/statistic_entry.rb deleted file mode 100644 index 7934028d..00000000 --- a/lib/algolia/models/usage/statistic_entry.rb +++ /dev/null @@ -1,221 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - class StatisticEntry - # Timestamp, measured in milliseconds since the Unix epoch. - attr_accessor :t - - attr_accessor :v - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :t => :t, - :v => :v - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.types_mapping - { - :t => :"Integer", - :v => :"StatisticValue" - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new( - [] - ) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - raise( - ArgumentError, - "The input argument (attributes) must be a hash in `Algolia::StatisticEntry` initialize method" - ) - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - raise( - ArgumentError, - "`#{k}` is not a valid attribute in `Algolia::StatisticEntry`. Please check the name to make sure it's valid. List of attributes: " + - self.class.attribute_map.keys.inspect - ) - end - - h[k.to_sym] = v - } - - if attributes.key?(:t) - self.t = attributes[:t] - end - - if attributes.key?(:v) - self.v = attributes[:v] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(other) - return true if self.equal?(other) - self.class == other.class && - t == other.t && - v == other.v - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(other) - self == other - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [t, v].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - types_mapping.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| - _deserialize(::Regexp.last_match(1), v) - } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]]) - end - end - - new(transformed_hash) - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - # model - else - # models (e.g. Pet) or oneOf - klass = Algolia::Usage.const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass - .build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - def to_json(*_args) - to_hash.to_json - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to?(:to_hash) - value.to_hash - else - value - end - end - - end - - end -end diff --git a/lib/algolia/models/usage/statistic_value.rb b/lib/algolia/models/usage/statistic_value.rb deleted file mode 100644 index df93cc42..00000000 --- a/lib/algolia/models/usage/statistic_value.rb +++ /dev/null @@ -1,108 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -require "date" -require "time" - -module Algolia - module Usage - module StatisticValue - class << self - # List of class defined in oneOf (OpenAPI v3) - def openapi_one_of - [ - :"Hash", - :"Integer" - ] - end - - # Builds the object - # @param [Mixed] Data to be matched against the list of oneOf items - # @return [Object] Returns the model or the data itself - def build(data) - # Go through the list of oneOf items and attempt to identify the appropriate one. - # Note: - # - We do not attempt to check whether exactly one item matches. - # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) - # due to the way the deserialization is made in the base_object template (it just casts without verifying). - # - TODO: scalar values are de facto behaving as if they were nullable. - # - TODO: logging when debugging is set. - openapi_one_of.each do |klass| - begin - # "nullable: true" - next if klass == :AnyType - typed_data = find_and_cast_into_type(klass, data) - return typed_data if typed_data - # rescue all errors so we keep iterating even if the current item lookup raises - rescue - end - end - - openapi_one_of.include?(:AnyType) ? data : nil - end - - private - - SchemaMismatchError = Class.new(StandardError) - - # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. - def find_and_cast_into_type(klass, data) - return if data.nil? - - case klass.to_s - when "Boolean" - return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) - when "Float" - return data if data.instance_of?(Float) - when "Integer" - return data if data.instance_of?(Integer) - when "Time" - return Time.parse(data) - when "Date" - return Date.parse(data) - when "String" - return data if data.instance_of?(String) - # "type: object" - when "Object" - return data if data.instance_of?(Hash) - # "type: array" - when /\AArray<(?.+)>\z/ - if data.instance_of?(Array) - sub_type = Regexp.last_match[:sub_type] - return data.map { |item| find_and_cast_into_type(sub_type, item) } - end - # "type: object" with "additionalProperties: { ... }" - when /\AHash.+)>\z/ - if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } - sub_type = Regexp.last_match[:sub_type] - return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } - end - # model - else - const = Algolia::Usage.const_get(klass) - if const - if const.respond_to?(:openapi_one_of) - # nested oneOf model - model = const.build(data) - elsif const.respond_to?(:acceptable_attributes) - # raise if data contains keys that are not known to the model - raise unless (data.keys - const.acceptable_attributes).empty? - model = const.build_from_hash(data) - else - # maybe it's an enum - model = const.build_from_hash(data) - end - - return model if model - end - end - - # if no match by now, raise - raise - rescue - raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" - end - end - end - - end -end