togai_client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +61 -0
- data/Rakefile +10 -0
- data/docs/Account.md +24 -0
- data/docs/AccountAliases.md +20 -0
- data/docs/AccountPaginatedResponse.md +22 -0
- data/docs/AccountsApi.md +595 -0
- data/docs/AddAccountAliasesRequest.md +18 -0
- data/docs/AssociatePricePlanRequest.md +24 -0
- data/docs/AssociatePricePlanResponse.md +22 -0
- data/docs/BaseSuccessResponse.md +18 -0
- data/docs/BundleStrategy.md +24 -0
- data/docs/BundleStrategyUsageMetersValue.md +18 -0
- data/docs/Computation.md +31 -0
- data/docs/CreateAccountRequest.md +22 -0
- data/docs/CreateCustomerRequest.md +26 -0
- data/docs/CreateCustomerResponse.md +26 -0
- data/docs/CreateEventSchemaRequest.md +24 -0
- data/docs/CreatePricePlanRequest.md +24 -0
- data/docs/CreateUsageMeterRequest.md +26 -0
- data/docs/Customer.md +30 -0
- data/docs/CustomerPaginatedResponse.md +22 -0
- data/docs/CustomersApi.md +363 -0
- data/docs/DimensionsSchema.md +18 -0
- data/docs/ErrorResponse.md +18 -0
- data/docs/Event.md +28 -0
- data/docs/EventAttribute.md +22 -0
- data/docs/EventAttributeSchema.md +20 -0
- data/docs/EventIngestionApi.md +146 -0
- data/docs/EventManagementApi.md +159 -0
- data/docs/EventPipelineInfo.md +26 -0
- data/docs/EventPipelineInfoAccount.md +20 -0
- data/docs/EventPipelineInfoCustomer.md +20 -0
- data/docs/EventPipelineInfoEventSchema.md +20 -0
- data/docs/EventPipelineInfoPricePlansInner.md +26 -0
- data/docs/EventPipelineInfoUsageMetersInner.md +24 -0
- data/docs/EventSchema.md +32 -0
- data/docs/EventSchemaListData.md +34 -0
- data/docs/EventSchemaListDataAllOf.md +18 -0
- data/docs/EventSchemaListPaginatedResponse.md +22 -0
- data/docs/EventSchemaVersionsResponse.md +18 -0
- data/docs/EventSchemasApi.md +581 -0
- data/docs/EventWithStatus.md +20 -0
- data/docs/EventWithStatusAndEventPipelineInfo.md +22 -0
- data/docs/EventWithStatusAndEventPipelineInfoAllOf.md +18 -0
- data/docs/GetEventResponse.md +18 -0
- data/docs/GetEventsResponse.md +20 -0
- data/docs/GetMetricsRequest.md +22 -0
- data/docs/GetMetricsResponse.md +18 -0
- data/docs/IngestBatchEventRequest.md +18 -0
- data/docs/IngestBatchEventResponse.md +18 -0
- data/docs/IngestError.md +20 -0
- data/docs/IngestEventRequest.md +18 -0
- data/docs/IngestEventResponse.md +18 -0
- data/docs/IngestionStatus.md +20 -0
- data/docs/MetricDataPoints.md +22 -0
- data/docs/MetricDataPointsGroupedBy.md +20 -0
- data/docs/MetricName.md +15 -0
- data/docs/MetricQuery.md +26 -0
- data/docs/MetricQueryFilterEntry.md +20 -0
- data/docs/MetricQueryResponse.md +22 -0
- data/docs/MetricsApi.md +79 -0
- data/docs/PaginationOptions.md +20 -0
- data/docs/PlanOverride.md +24 -0
- data/docs/PricePlan.md +26 -0
- data/docs/PricePlanListData.md +32 -0
- data/docs/PricePlanPaginatedResponse.md +22 -0
- data/docs/PricePlansApi.md +363 -0
- data/docs/PricingCycle.md +24 -0
- data/docs/PricingCycleStartOffset.md +20 -0
- data/docs/PricingSchedule.md +22 -0
- data/docs/RateCard.md +22 -0
- data/docs/RateCardBundle.md +22 -0
- data/docs/RateCardUsageValue.md +24 -0
- data/docs/RemoveAccountAliasesRequest.md +18 -0
- data/docs/SignupRequest.md +22 -0
- data/docs/SignupResponse.md +20 -0
- data/docs/StatusResponse.md +24 -0
- data/docs/StatusResponseHeaders.md +18 -0
- data/docs/UpdateAccountRequest.md +18 -0
- data/docs/UpdateCustomerRequest.md +22 -0
- data/docs/UpdateEventSchemaRequest.md +22 -0
- data/docs/UpdatePricePlanRequest.md +22 -0
- data/docs/UpdateUsageMeterRequest.md +24 -0
- data/docs/UsageMeter.md +34 -0
- data/docs/UsageMeterPaginatedResponse.md +22 -0
- data/docs/UsageMetersApi.md +521 -0
- data/docs/UsageStrategy.md +22 -0
- data/docs/UserDetails.md +26 -0
- data/git_push.sh +57 -0
- data/lib/togai_client/api/accounts_api.rb +679 -0
- data/lib/togai_client/api/customers_api.rb +365 -0
- data/lib/togai_client/api/event_ingestion_api.rb +158 -0
- data/lib/togai_client/api/event_management_api.rb +164 -0
- data/lib/togai_client/api/event_schemas_api.rb +579 -0
- data/lib/togai_client/api/metrics_api.rb +86 -0
- data/lib/togai_client/api/price_plans_api.rb +365 -0
- data/lib/togai_client/api/usage_meters_api.rb +572 -0
- data/lib/togai_client/api_client.rb +392 -0
- data/lib/togai_client/api_error.rb +57 -0
- data/lib/togai_client/configuration.rb +287 -0
- data/lib/togai_client/models/account.rb +373 -0
- data/lib/togai_client/models/account_aliases.rb +277 -0
- data/lib/togai_client/models/account_paginated_response.rb +239 -0
- data/lib/togai_client/models/add_account_aliases_request.rb +247 -0
- data/lib/togai_client/models/associate_price_plan_request.rb +274 -0
- data/lib/togai_client/models/associate_price_plan_response.rb +275 -0
- data/lib/togai_client/models/base_success_response.rb +224 -0
- data/lib/togai_client/models/bundle_strategy.rb +325 -0
- data/lib/togai_client/models/bundle_strategy_usage_meters_value.rb +224 -0
- data/lib/togai_client/models/computation.rb +294 -0
- data/lib/togai_client/models/create_account_request.rb +324 -0
- data/lib/togai_client/models/create_customer_request.rb +374 -0
- data/lib/togai_client/models/create_customer_response.rb +373 -0
- data/lib/togai_client/models/create_event_schema_request.rb +351 -0
- data/lib/togai_client/models/create_price_plan_request.rb +298 -0
- data/lib/togai_client/models/create_usage_meter_request.rb +368 -0
- data/lib/togai_client/models/customer.rb +442 -0
- data/lib/togai_client/models/customer_paginated_response.rb +239 -0
- data/lib/togai_client/models/dimensions_schema.rb +256 -0
- data/lib/togai_client/models/error_response.rb +244 -0
- data/lib/togai_client/models/event.rb +379 -0
- data/lib/togai_client/models/event_attribute.rb +304 -0
- data/lib/togai_client/models/event_attribute_schema.rb +281 -0
- data/lib/togai_client/models/event_pipeline_info.rb +260 -0
- data/lib/togai_client/models/event_pipeline_info_account.rb +238 -0
- data/lib/togai_client/models/event_pipeline_info_customer.rb +238 -0
- data/lib/togai_client/models/event_pipeline_info_event_schema.rb +238 -0
- data/lib/togai_client/models/event_pipeline_info_price_plans_inner.rb +283 -0
- data/lib/togai_client/models/event_pipeline_info_usage_meters_inner.rb +295 -0
- data/lib/togai_client/models/event_schema.rb +438 -0
- data/lib/togai_client/models/event_schema_list_data.rb +456 -0
- data/lib/togai_client/models/event_schema_list_data_all_of.rb +221 -0
- data/lib/togai_client/models/event_schema_list_paginated_response.rb +239 -0
- data/lib/togai_client/models/event_schema_versions_response.rb +227 -0
- data/lib/togai_client/models/event_with_status.rb +239 -0
- data/lib/togai_client/models/event_with_status_and_event_pipeline_info.rb +255 -0
- data/lib/togai_client/models/event_with_status_and_event_pipeline_info_all_of.rb +219 -0
- data/lib/togai_client/models/get_event_response.rb +222 -0
- data/lib/togai_client/models/get_events_response.rb +279 -0
- data/lib/togai_client/models/get_metrics_request.rb +265 -0
- data/lib/togai_client/models/get_metrics_response.rb +227 -0
- data/lib/togai_client/models/ingest_batch_event_request.rb +255 -0
- data/lib/togai_client/models/ingest_batch_event_response.rb +245 -0
- data/lib/togai_client/models/ingest_error.rb +229 -0
- data/lib/togai_client/models/ingest_event_request.rb +220 -0
- data/lib/togai_client/models/ingest_event_response.rb +244 -0
- data/lib/togai_client/models/ingestion_status.rb +284 -0
- data/lib/togai_client/models/metric_data_points.rb +289 -0
- data/lib/togai_client/models/metric_data_points_grouped_by.rb +238 -0
- data/lib/togai_client/models/metric_name.rb +38 -0
- data/lib/togai_client/models/metric_query.rb +331 -0
- data/lib/togai_client/models/metric_query_filter_entry.rb +241 -0
- data/lib/togai_client/models/metric_query_response.rb +255 -0
- data/lib/togai_client/models/pagination_options.rb +262 -0
- data/lib/togai_client/models/plan_override.rb +262 -0
- data/lib/togai_client/models/price_plan.rb +349 -0
- data/lib/togai_client/models/price_plan_list_data.rb +393 -0
- data/lib/togai_client/models/price_plan_paginated_response.rb +239 -0
- data/lib/togai_client/models/pricing_cycle.rb +313 -0
- data/lib/togai_client/models/pricing_cycle_start_offset.rb +241 -0
- data/lib/togai_client/models/pricing_schedule.rb +248 -0
- data/lib/togai_client/models/rate_card.rb +279 -0
- data/lib/togai_client/models/rate_card_bundle.rb +328 -0
- data/lib/togai_client/models/rate_card_usage_value.rb +343 -0
- data/lib/togai_client/models/remove_account_aliases_request.rb +247 -0
- data/lib/togai_client/models/signup_request.rb +293 -0
- data/lib/togai_client/models/signup_response.rb +260 -0
- data/lib/togai_client/models/status_response.rb +246 -0
- data/lib/togai_client/models/status_response_headers.rb +219 -0
- data/lib/togai_client/models/update_account_request.rb +245 -0
- data/lib/togai_client/models/update_customer_request.rb +304 -0
- data/lib/togai_client/models/update_event_schema_request.rb +306 -0
- data/lib/togai_client/models/update_price_plan_request.rb +254 -0
- data/lib/togai_client/models/update_usage_meter_request.rb +323 -0
- data/lib/togai_client/models/usage_meter.rb +440 -0
- data/lib/togai_client/models/usage_meter_paginated_response.rb +239 -0
- data/lib/togai_client/models/usage_strategy.rb +281 -0
- data/lib/togai_client/models/user_details.rb +380 -0
- data/lib/togai_client/version.rb +15 -0
- data/lib/togai_client.rb +125 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/spec_helper.rb +111 -0
- data/togai_client.gemspec +38 -0
- metadata +271 -0
@@ -0,0 +1,379 @@
|
|
1
|
+
=begin
|
2
|
+
#Togai Apis
|
3
|
+
|
4
|
+
#APIs for Togai App
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
Contact: engg@togai.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.1.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module TogaiClient
|
17
|
+
# Contents of the event
|
18
|
+
class Event
|
19
|
+
# Name of the event to be recorded.
|
20
|
+
attr_accessor :event_name
|
21
|
+
|
22
|
+
# A unique value to identify the event instance. This unique value should be generated by the client and it acts as the **idempotency key**. Togai server will use this key to recognize subsequent retries of the same request and avoid metering multiple times for that same request. This id can be created in any format but we recommend using UUIDv4 to reduce collision occurance. NOTE1: Expiry time for idempotency validation will be until the end of the billing cycle. Any request which comes after the billing cycle with the same id will be treated as new request and ingested for metering. NOTE2: If the billing cycle is not configured for the idempotency validation will be until **10 days** of the event ingestion.
|
23
|
+
attr_accessor :id
|
24
|
+
|
25
|
+
# Source time stamp of the event. This timestamp must be in ISO 8601 format.
|
26
|
+
attr_accessor :event_timestamp
|
27
|
+
|
28
|
+
attr_accessor :account_id
|
29
|
+
|
30
|
+
attr_accessor :event_attributes
|
31
|
+
|
32
|
+
# Dimensions are tags/labels associated with the events. This dimensions can be used to configure billing, for queries, analytics and reports.
|
33
|
+
attr_accessor :dimensions
|
34
|
+
|
35
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
36
|
+
def self.attribute_map
|
37
|
+
{
|
38
|
+
:'event_name' => :'eventName',
|
39
|
+
:'id' => :'id',
|
40
|
+
:'event_timestamp' => :'eventTimestamp',
|
41
|
+
:'account_id' => :'accountId',
|
42
|
+
:'event_attributes' => :'eventAttributes',
|
43
|
+
:'dimensions' => :'dimensions'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns all the JSON keys this model knows about
|
48
|
+
def self.acceptable_attributes
|
49
|
+
attribute_map.values
|
50
|
+
end
|
51
|
+
|
52
|
+
# Attribute type mapping.
|
53
|
+
def self.openapi_types
|
54
|
+
{
|
55
|
+
:'event_name' => :'String',
|
56
|
+
:'id' => :'String',
|
57
|
+
:'event_timestamp' => :'Time',
|
58
|
+
:'account_id' => :'String',
|
59
|
+
:'event_attributes' => :'Array<EventAttribute>',
|
60
|
+
:'dimensions' => :'Hash<String, String>'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# List of attributes with nullable: true
|
65
|
+
def self.openapi_nullable
|
66
|
+
Set.new([
|
67
|
+
])
|
68
|
+
end
|
69
|
+
|
70
|
+
# Initializes the object
|
71
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
72
|
+
def initialize(attributes = {})
|
73
|
+
if (!attributes.is_a?(Hash))
|
74
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::Event` initialize method"
|
75
|
+
end
|
76
|
+
|
77
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
78
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
79
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
80
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `TogaiClient::Event`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
81
|
+
end
|
82
|
+
h[k.to_sym] = v
|
83
|
+
}
|
84
|
+
|
85
|
+
if attributes.key?(:'event_name')
|
86
|
+
self.event_name = attributes[:'event_name']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'id')
|
90
|
+
self.id = attributes[:'id']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'event_timestamp')
|
94
|
+
self.event_timestamp = attributes[:'event_timestamp']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'account_id')
|
98
|
+
self.account_id = attributes[:'account_id']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'event_attributes')
|
102
|
+
if (value = attributes[:'event_attributes']).is_a?(Array)
|
103
|
+
self.event_attributes = value
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.key?(:'dimensions')
|
108
|
+
if (value = attributes[:'dimensions']).is_a?(Hash)
|
109
|
+
self.dimensions = value
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
115
|
+
# @return Array for valid properties with the reasons
|
116
|
+
def list_invalid_properties
|
117
|
+
invalid_properties = Array.new
|
118
|
+
if @event_name.nil?
|
119
|
+
invalid_properties.push('invalid value for "event_name", event_name cannot be nil.')
|
120
|
+
end
|
121
|
+
|
122
|
+
if @event_name.to_s.length > 255
|
123
|
+
invalid_properties.push('invalid value for "event_name", the character length must be smaller than or equal to 255.')
|
124
|
+
end
|
125
|
+
|
126
|
+
if @id.nil?
|
127
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
128
|
+
end
|
129
|
+
|
130
|
+
if @id.to_s.length > 255
|
131
|
+
invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 255.')
|
132
|
+
end
|
133
|
+
|
134
|
+
if @event_timestamp.nil?
|
135
|
+
invalid_properties.push('invalid value for "event_timestamp", event_timestamp cannot be nil.')
|
136
|
+
end
|
137
|
+
|
138
|
+
if @account_id.nil?
|
139
|
+
invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
|
140
|
+
end
|
141
|
+
|
142
|
+
if @account_id.to_s.length > 255
|
143
|
+
invalid_properties.push('invalid value for "account_id", the character length must be smaller than or equal to 255.')
|
144
|
+
end
|
145
|
+
|
146
|
+
if @event_attributes.nil?
|
147
|
+
invalid_properties.push('invalid value for "event_attributes", event_attributes cannot be nil.')
|
148
|
+
end
|
149
|
+
|
150
|
+
if @event_attributes.length > 50
|
151
|
+
invalid_properties.push('invalid value for "event_attributes", number of items must be less than or equal to 50.')
|
152
|
+
end
|
153
|
+
|
154
|
+
if @dimensions.nil?
|
155
|
+
invalid_properties.push('invalid value for "dimensions", dimensions cannot be nil.')
|
156
|
+
end
|
157
|
+
|
158
|
+
invalid_properties
|
159
|
+
end
|
160
|
+
|
161
|
+
# Check to see if the all the properties in the model are valid
|
162
|
+
# @return true if the model is valid
|
163
|
+
def valid?
|
164
|
+
return false if @event_name.nil?
|
165
|
+
return false if @event_name.to_s.length > 255
|
166
|
+
return false if @id.nil?
|
167
|
+
return false if @id.to_s.length > 255
|
168
|
+
return false if @event_timestamp.nil?
|
169
|
+
return false if @account_id.nil?
|
170
|
+
return false if @account_id.to_s.length > 255
|
171
|
+
return false if @event_attributes.nil?
|
172
|
+
return false if @event_attributes.length > 50
|
173
|
+
return false if @dimensions.nil?
|
174
|
+
true
|
175
|
+
end
|
176
|
+
|
177
|
+
# Custom attribute writer method with validation
|
178
|
+
# @param [Object] event_name Value to be assigned
|
179
|
+
def event_name=(event_name)
|
180
|
+
if event_name.nil?
|
181
|
+
fail ArgumentError, 'event_name cannot be nil'
|
182
|
+
end
|
183
|
+
|
184
|
+
if event_name.to_s.length > 255
|
185
|
+
fail ArgumentError, 'invalid value for "event_name", the character length must be smaller than or equal to 255.'
|
186
|
+
end
|
187
|
+
|
188
|
+
@event_name = event_name
|
189
|
+
end
|
190
|
+
|
191
|
+
# Custom attribute writer method with validation
|
192
|
+
# @param [Object] id Value to be assigned
|
193
|
+
def id=(id)
|
194
|
+
if id.nil?
|
195
|
+
fail ArgumentError, 'id cannot be nil'
|
196
|
+
end
|
197
|
+
|
198
|
+
if id.to_s.length > 255
|
199
|
+
fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 255.'
|
200
|
+
end
|
201
|
+
|
202
|
+
@id = id
|
203
|
+
end
|
204
|
+
|
205
|
+
# Custom attribute writer method with validation
|
206
|
+
# @param [Object] account_id Value to be assigned
|
207
|
+
def account_id=(account_id)
|
208
|
+
if account_id.nil?
|
209
|
+
fail ArgumentError, 'account_id cannot be nil'
|
210
|
+
end
|
211
|
+
|
212
|
+
if account_id.to_s.length > 255
|
213
|
+
fail ArgumentError, 'invalid value for "account_id", the character length must be smaller than or equal to 255.'
|
214
|
+
end
|
215
|
+
|
216
|
+
@account_id = account_id
|
217
|
+
end
|
218
|
+
|
219
|
+
# Custom attribute writer method with validation
|
220
|
+
# @param [Object] event_attributes Value to be assigned
|
221
|
+
def event_attributes=(event_attributes)
|
222
|
+
if event_attributes.nil?
|
223
|
+
fail ArgumentError, 'event_attributes cannot be nil'
|
224
|
+
end
|
225
|
+
|
226
|
+
if event_attributes.length > 50
|
227
|
+
fail ArgumentError, 'invalid value for "event_attributes", number of items must be less than or equal to 50.'
|
228
|
+
end
|
229
|
+
|
230
|
+
@event_attributes = event_attributes
|
231
|
+
end
|
232
|
+
|
233
|
+
# Checks equality by comparing each attribute.
|
234
|
+
# @param [Object] Object to be compared
|
235
|
+
def ==(o)
|
236
|
+
return true if self.equal?(o)
|
237
|
+
self.class == o.class &&
|
238
|
+
event_name == o.event_name &&
|
239
|
+
id == o.id &&
|
240
|
+
event_timestamp == o.event_timestamp &&
|
241
|
+
account_id == o.account_id &&
|
242
|
+
event_attributes == o.event_attributes &&
|
243
|
+
dimensions == o.dimensions
|
244
|
+
end
|
245
|
+
|
246
|
+
# @see the `==` method
|
247
|
+
# @param [Object] Object to be compared
|
248
|
+
def eql?(o)
|
249
|
+
self == o
|
250
|
+
end
|
251
|
+
|
252
|
+
# Calculates hash code according to all attributes.
|
253
|
+
# @return [Integer] Hash code
|
254
|
+
def hash
|
255
|
+
[event_name, id, event_timestamp, account_id, event_attributes, dimensions].hash
|
256
|
+
end
|
257
|
+
|
258
|
+
# Builds the object from hash
|
259
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
260
|
+
# @return [Object] Returns the model itself
|
261
|
+
def self.build_from_hash(attributes)
|
262
|
+
new.build_from_hash(attributes)
|
263
|
+
end
|
264
|
+
|
265
|
+
# Builds the object from hash
|
266
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
267
|
+
# @return [Object] Returns the model itself
|
268
|
+
def build_from_hash(attributes)
|
269
|
+
return nil unless attributes.is_a?(Hash)
|
270
|
+
attributes = attributes.transform_keys(&:to_sym)
|
271
|
+
self.class.openapi_types.each_pair do |key, type|
|
272
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
273
|
+
self.send("#{key}=", nil)
|
274
|
+
elsif type =~ /\AArray<(.*)>/i
|
275
|
+
# check to ensure the input is an array given that the attribute
|
276
|
+
# is documented as an array but the input is not
|
277
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
278
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
279
|
+
end
|
280
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
281
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
self
|
286
|
+
end
|
287
|
+
|
288
|
+
# Deserializes the data based on type
|
289
|
+
# @param string type Data type
|
290
|
+
# @param string value Value to be deserialized
|
291
|
+
# @return [Object] Deserialized data
|
292
|
+
def _deserialize(type, value)
|
293
|
+
case type.to_sym
|
294
|
+
when :Time
|
295
|
+
Time.parse(value)
|
296
|
+
when :Date
|
297
|
+
Date.parse(value)
|
298
|
+
when :String
|
299
|
+
value.to_s
|
300
|
+
when :Integer
|
301
|
+
value.to_i
|
302
|
+
when :Float
|
303
|
+
value.to_f
|
304
|
+
when :Boolean
|
305
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
306
|
+
true
|
307
|
+
else
|
308
|
+
false
|
309
|
+
end
|
310
|
+
when :Object
|
311
|
+
# generic object (usually a Hash), return directly
|
312
|
+
value
|
313
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
314
|
+
inner_type = Regexp.last_match[:inner_type]
|
315
|
+
value.map { |v| _deserialize(inner_type, v) }
|
316
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
317
|
+
k_type = Regexp.last_match[:k_type]
|
318
|
+
v_type = Regexp.last_match[:v_type]
|
319
|
+
{}.tap do |hash|
|
320
|
+
value.each do |k, v|
|
321
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
else # model
|
325
|
+
# models (e.g. Pet) or oneOf
|
326
|
+
klass = TogaiClient.const_get(type)
|
327
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
# Returns the string representation of the object
|
332
|
+
# @return [String] String presentation of the object
|
333
|
+
def to_s
|
334
|
+
to_hash.to_s
|
335
|
+
end
|
336
|
+
|
337
|
+
# to_body is an alias to to_hash (backward compatibility)
|
338
|
+
# @return [Hash] Returns the object in the form of hash
|
339
|
+
def to_body
|
340
|
+
to_hash
|
341
|
+
end
|
342
|
+
|
343
|
+
# Returns the object in the form of hash
|
344
|
+
# @return [Hash] Returns the object in the form of hash
|
345
|
+
def to_hash
|
346
|
+
hash = {}
|
347
|
+
self.class.attribute_map.each_pair do |attr, param|
|
348
|
+
value = self.send(attr)
|
349
|
+
if value.nil?
|
350
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
351
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
352
|
+
end
|
353
|
+
|
354
|
+
hash[param] = _to_hash(value)
|
355
|
+
end
|
356
|
+
hash
|
357
|
+
end
|
358
|
+
|
359
|
+
# Outputs non-array value in the form of hash
|
360
|
+
# For object, use to_hash. Otherwise, just return the value
|
361
|
+
# @param [Object] value Any valid value
|
362
|
+
# @return [Hash] Returns the value in the form of hash
|
363
|
+
def _to_hash(value)
|
364
|
+
if value.is_a?(Array)
|
365
|
+
value.compact.map { |v| _to_hash(v) }
|
366
|
+
elsif value.is_a?(Hash)
|
367
|
+
{}.tap do |hash|
|
368
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
369
|
+
end
|
370
|
+
elsif value.respond_to? :to_hash
|
371
|
+
value.to_hash
|
372
|
+
else
|
373
|
+
value
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
end
|
378
|
+
|
379
|
+
end
|
@@ -0,0 +1,304 @@
|
|
1
|
+
=begin
|
2
|
+
#Togai Apis
|
3
|
+
|
4
|
+
#APIs for Togai App
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
Contact: engg@togai.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.1.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module TogaiClient
|
17
|
+
# Metric to be recorded
|
18
|
+
class EventAttribute
|
19
|
+
# Name of the event attribute
|
20
|
+
attr_accessor :attribute_name
|
21
|
+
|
22
|
+
# Value of the event attribute
|
23
|
+
attr_accessor :attribute_value
|
24
|
+
|
25
|
+
# Unit with which the attribute value was measured. Natively supported units - \"Meters, Miles, Kilometers, Grams, Kilograms, ounces, Pounds, Minutes, Hours, Seconds, Milliseconds, Microseconds, None\". Clients are free to add any other custom units.
|
26
|
+
attr_accessor :attribute_value_unit
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'attribute_name' => :'attributeName',
|
32
|
+
:'attribute_value' => :'attributeValue',
|
33
|
+
:'attribute_value_unit' => :'attributeValueUnit'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns all the JSON keys this model knows about
|
38
|
+
def self.acceptable_attributes
|
39
|
+
attribute_map.values
|
40
|
+
end
|
41
|
+
|
42
|
+
# Attribute type mapping.
|
43
|
+
def self.openapi_types
|
44
|
+
{
|
45
|
+
:'attribute_name' => :'String',
|
46
|
+
:'attribute_value' => :'String',
|
47
|
+
:'attribute_value_unit' => :'String'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# List of attributes with nullable: true
|
52
|
+
def self.openapi_nullable
|
53
|
+
Set.new([
|
54
|
+
])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Initializes the object
|
58
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
59
|
+
def initialize(attributes = {})
|
60
|
+
if (!attributes.is_a?(Hash))
|
61
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::EventAttribute` initialize method"
|
62
|
+
end
|
63
|
+
|
64
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
66
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `TogaiClient::EventAttribute`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
68
|
+
end
|
69
|
+
h[k.to_sym] = v
|
70
|
+
}
|
71
|
+
|
72
|
+
if attributes.key?(:'attribute_name')
|
73
|
+
self.attribute_name = attributes[:'attribute_name']
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.key?(:'attribute_value')
|
77
|
+
self.attribute_value = attributes[:'attribute_value']
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.key?(:'attribute_value_unit')
|
81
|
+
self.attribute_value_unit = attributes[:'attribute_value_unit']
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
86
|
+
# @return Array for valid properties with the reasons
|
87
|
+
def list_invalid_properties
|
88
|
+
invalid_properties = Array.new
|
89
|
+
if @attribute_name.nil?
|
90
|
+
invalid_properties.push('invalid value for "attribute_name", attribute_name cannot be nil.')
|
91
|
+
end
|
92
|
+
|
93
|
+
if @attribute_name.to_s.length > 50
|
94
|
+
invalid_properties.push('invalid value for "attribute_name", the character length must be smaller than or equal to 50.')
|
95
|
+
end
|
96
|
+
|
97
|
+
if @attribute_value.nil?
|
98
|
+
invalid_properties.push('invalid value for "attribute_value", attribute_value cannot be nil.')
|
99
|
+
end
|
100
|
+
|
101
|
+
if @attribute_value.to_s.length > 50
|
102
|
+
invalid_properties.push('invalid value for "attribute_value", the character length must be smaller than or equal to 50.')
|
103
|
+
end
|
104
|
+
|
105
|
+
if !@attribute_value_unit.nil? && @attribute_value_unit.to_s.length > 50
|
106
|
+
invalid_properties.push('invalid value for "attribute_value_unit", the character length must be smaller than or equal to 50.')
|
107
|
+
end
|
108
|
+
|
109
|
+
invalid_properties
|
110
|
+
end
|
111
|
+
|
112
|
+
# Check to see if the all the properties in the model are valid
|
113
|
+
# @return true if the model is valid
|
114
|
+
def valid?
|
115
|
+
return false if @attribute_name.nil?
|
116
|
+
return false if @attribute_name.to_s.length > 50
|
117
|
+
return false if @attribute_value.nil?
|
118
|
+
return false if @attribute_value.to_s.length > 50
|
119
|
+
return false if !@attribute_value_unit.nil? && @attribute_value_unit.to_s.length > 50
|
120
|
+
true
|
121
|
+
end
|
122
|
+
|
123
|
+
# Custom attribute writer method with validation
|
124
|
+
# @param [Object] attribute_name Value to be assigned
|
125
|
+
def attribute_name=(attribute_name)
|
126
|
+
if attribute_name.nil?
|
127
|
+
fail ArgumentError, 'attribute_name cannot be nil'
|
128
|
+
end
|
129
|
+
|
130
|
+
if attribute_name.to_s.length > 50
|
131
|
+
fail ArgumentError, 'invalid value for "attribute_name", the character length must be smaller than or equal to 50.'
|
132
|
+
end
|
133
|
+
|
134
|
+
@attribute_name = attribute_name
|
135
|
+
end
|
136
|
+
|
137
|
+
# Custom attribute writer method with validation
|
138
|
+
# @param [Object] attribute_value Value to be assigned
|
139
|
+
def attribute_value=(attribute_value)
|
140
|
+
if attribute_value.nil?
|
141
|
+
fail ArgumentError, 'attribute_value cannot be nil'
|
142
|
+
end
|
143
|
+
|
144
|
+
if attribute_value.to_s.length > 50
|
145
|
+
fail ArgumentError, 'invalid value for "attribute_value", the character length must be smaller than or equal to 50.'
|
146
|
+
end
|
147
|
+
|
148
|
+
@attribute_value = attribute_value
|
149
|
+
end
|
150
|
+
|
151
|
+
# Custom attribute writer method with validation
|
152
|
+
# @param [Object] attribute_value_unit Value to be assigned
|
153
|
+
def attribute_value_unit=(attribute_value_unit)
|
154
|
+
if !attribute_value_unit.nil? && attribute_value_unit.to_s.length > 50
|
155
|
+
fail ArgumentError, 'invalid value for "attribute_value_unit", the character length must be smaller than or equal to 50.'
|
156
|
+
end
|
157
|
+
|
158
|
+
@attribute_value_unit = attribute_value_unit
|
159
|
+
end
|
160
|
+
|
161
|
+
# Checks equality by comparing each attribute.
|
162
|
+
# @param [Object] Object to be compared
|
163
|
+
def ==(o)
|
164
|
+
return true if self.equal?(o)
|
165
|
+
self.class == o.class &&
|
166
|
+
attribute_name == o.attribute_name &&
|
167
|
+
attribute_value == o.attribute_value &&
|
168
|
+
attribute_value_unit == o.attribute_value_unit
|
169
|
+
end
|
170
|
+
|
171
|
+
# @see the `==` method
|
172
|
+
# @param [Object] Object to be compared
|
173
|
+
def eql?(o)
|
174
|
+
self == o
|
175
|
+
end
|
176
|
+
|
177
|
+
# Calculates hash code according to all attributes.
|
178
|
+
# @return [Integer] Hash code
|
179
|
+
def hash
|
180
|
+
[attribute_name, attribute_value, attribute_value_unit].hash
|
181
|
+
end
|
182
|
+
|
183
|
+
# Builds the object from hash
|
184
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
185
|
+
# @return [Object] Returns the model itself
|
186
|
+
def self.build_from_hash(attributes)
|
187
|
+
new.build_from_hash(attributes)
|
188
|
+
end
|
189
|
+
|
190
|
+
# Builds the object from hash
|
191
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
192
|
+
# @return [Object] Returns the model itself
|
193
|
+
def build_from_hash(attributes)
|
194
|
+
return nil unless attributes.is_a?(Hash)
|
195
|
+
attributes = attributes.transform_keys(&:to_sym)
|
196
|
+
self.class.openapi_types.each_pair do |key, type|
|
197
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
198
|
+
self.send("#{key}=", nil)
|
199
|
+
elsif type =~ /\AArray<(.*)>/i
|
200
|
+
# check to ensure the input is an array given that the attribute
|
201
|
+
# is documented as an array but the input is not
|
202
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
203
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
204
|
+
end
|
205
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
206
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
self
|
211
|
+
end
|
212
|
+
|
213
|
+
# Deserializes the data based on type
|
214
|
+
# @param string type Data type
|
215
|
+
# @param string value Value to be deserialized
|
216
|
+
# @return [Object] Deserialized data
|
217
|
+
def _deserialize(type, value)
|
218
|
+
case type.to_sym
|
219
|
+
when :Time
|
220
|
+
Time.parse(value)
|
221
|
+
when :Date
|
222
|
+
Date.parse(value)
|
223
|
+
when :String
|
224
|
+
value.to_s
|
225
|
+
when :Integer
|
226
|
+
value.to_i
|
227
|
+
when :Float
|
228
|
+
value.to_f
|
229
|
+
when :Boolean
|
230
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
231
|
+
true
|
232
|
+
else
|
233
|
+
false
|
234
|
+
end
|
235
|
+
when :Object
|
236
|
+
# generic object (usually a Hash), return directly
|
237
|
+
value
|
238
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
239
|
+
inner_type = Regexp.last_match[:inner_type]
|
240
|
+
value.map { |v| _deserialize(inner_type, v) }
|
241
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
242
|
+
k_type = Regexp.last_match[:k_type]
|
243
|
+
v_type = Regexp.last_match[:v_type]
|
244
|
+
{}.tap do |hash|
|
245
|
+
value.each do |k, v|
|
246
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
else # model
|
250
|
+
# models (e.g. Pet) or oneOf
|
251
|
+
klass = TogaiClient.const_get(type)
|
252
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
# Returns the string representation of the object
|
257
|
+
# @return [String] String presentation of the object
|
258
|
+
def to_s
|
259
|
+
to_hash.to_s
|
260
|
+
end
|
261
|
+
|
262
|
+
# to_body is an alias to to_hash (backward compatibility)
|
263
|
+
# @return [Hash] Returns the object in the form of hash
|
264
|
+
def to_body
|
265
|
+
to_hash
|
266
|
+
end
|
267
|
+
|
268
|
+
# Returns the object in the form of hash
|
269
|
+
# @return [Hash] Returns the object in the form of hash
|
270
|
+
def to_hash
|
271
|
+
hash = {}
|
272
|
+
self.class.attribute_map.each_pair do |attr, param|
|
273
|
+
value = self.send(attr)
|
274
|
+
if value.nil?
|
275
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
276
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
277
|
+
end
|
278
|
+
|
279
|
+
hash[param] = _to_hash(value)
|
280
|
+
end
|
281
|
+
hash
|
282
|
+
end
|
283
|
+
|
284
|
+
# Outputs non-array value in the form of hash
|
285
|
+
# For object, use to_hash. Otherwise, just return the value
|
286
|
+
# @param [Object] value Any valid value
|
287
|
+
# @return [Hash] Returns the value in the form of hash
|
288
|
+
def _to_hash(value)
|
289
|
+
if value.is_a?(Array)
|
290
|
+
value.compact.map { |v| _to_hash(v) }
|
291
|
+
elsif value.is_a?(Hash)
|
292
|
+
{}.tap do |hash|
|
293
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
294
|
+
end
|
295
|
+
elsif value.respond_to? :to_hash
|
296
|
+
value.to_hash
|
297
|
+
else
|
298
|
+
value
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
end
|