mux_ruby 1.7.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/docs/DimensionValue.md +9 -0
  4. data/docs/DimensionsApi.md +118 -0
  5. data/docs/FiltersApi.md +2 -2
  6. data/docs/GetRealTimeBreakdownResponse.md +10 -0
  7. data/docs/GetRealTimeHistogramTimeseriesResponse.md +11 -0
  8. data/docs/GetRealTimeHistogramTimeseriesResponseMeta.md +8 -0
  9. data/docs/GetRealTimeTimeseriesResponse.md +10 -0
  10. data/docs/Incident.md +28 -0
  11. data/docs/IncidentBreakdown.md +10 -0
  12. data/docs/IncidentNotification.md +10 -0
  13. data/docs/IncidentNotificationRule.md +12 -0
  14. data/docs/IncidentResponse.md +9 -0
  15. data/docs/IncidentsApi.md +186 -0
  16. data/docs/ListDimensionValuesResponse.md +10 -0
  17. data/docs/ListDimensionsResponse.md +10 -0
  18. data/docs/ListIncidentsResponse.md +10 -0
  19. data/docs/ListRealTimeDimensionsResponse.md +10 -0
  20. data/docs/ListRealTimeDimensionsResponseData.md +9 -0
  21. data/docs/ListRealTimeMetricsResponse.md +10 -0
  22. data/docs/ListRelatedIncidentsResponse.md +10 -0
  23. data/docs/NotificationRule.md +10 -0
  24. data/docs/RealTimeApi.md +280 -0
  25. data/docs/RealTimeBreakdownValue.md +12 -0
  26. data/docs/RealTimeHistogramTimeseriesBucket.md +9 -0
  27. data/docs/RealTimeHistogramTimeseriesBucketValues.md +9 -0
  28. data/docs/RealTimeHistogramTimeseriesDatapoint.md +14 -0
  29. data/docs/RealTimeTimeseriesDatapoint.md +10 -0
  30. data/examples/data/exercise-dimensions.rb +29 -0
  31. data/examples/data/exercise-incidents.rb +29 -0
  32. data/examples/data/exercise-realtime.rb +60 -0
  33. data/lib/mux_ruby.rb +26 -0
  34. data/lib/mux_ruby/api/dimensions_api.rb +128 -0
  35. data/lib/mux_ruby/api/filters_api.rb +4 -4
  36. data/lib/mux_ruby/api/incidents_api.rb +217 -0
  37. data/lib/mux_ruby/api/real_time_api.rb +311 -0
  38. data/lib/mux_ruby/models/asset.rb +12 -0
  39. data/lib/mux_ruby/models/dimension_value.rb +193 -0
  40. data/lib/mux_ruby/models/get_real_time_breakdown_response.rb +206 -0
  41. data/lib/mux_ruby/models/get_real_time_histogram_timeseries_response.rb +215 -0
  42. data/lib/mux_ruby/models/get_real_time_histogram_timeseries_response_meta.rb +186 -0
  43. data/lib/mux_ruby/models/get_real_time_timeseries_response.rb +206 -0
  44. data/lib/mux_ruby/models/incident.rb +370 -0
  45. data/lib/mux_ruby/models/incident_breakdown.rb +202 -0
  46. data/lib/mux_ruby/models/incident_notification.rb +202 -0
  47. data/lib/mux_ruby/models/incident_notification_rule.rb +222 -0
  48. data/lib/mux_ruby/models/incident_response.rb +195 -0
  49. data/lib/mux_ruby/models/list_dimension_values_response.rb +206 -0
  50. data/lib/mux_ruby/models/list_dimensions_response.rb +204 -0
  51. data/lib/mux_ruby/models/list_incidents_response.rb +206 -0
  52. data/lib/mux_ruby/models/list_real_time_dimensions_response.rb +206 -0
  53. data/lib/mux_ruby/models/list_real_time_dimensions_response_data.rb +193 -0
  54. data/lib/mux_ruby/models/list_real_time_metrics_response.rb +206 -0
  55. data/lib/mux_ruby/models/list_related_incidents_response.rb +206 -0
  56. data/lib/mux_ruby/models/notification_rule.rb +202 -0
  57. data/lib/mux_ruby/models/real_time_breakdown_value.rb +220 -0
  58. data/lib/mux_ruby/models/real_time_histogram_timeseries_bucket.rb +193 -0
  59. data/lib/mux_ruby/models/real_time_histogram_timeseries_bucket_values.rb +193 -0
  60. data/lib/mux_ruby/models/real_time_histogram_timeseries_datapoint.rb +240 -0
  61. data/lib/mux_ruby/models/real_time_timeseries_datapoint.rb +202 -0
  62. data/lib/mux_ruby/version.rb +1 -1
  63. data/spec/api/dimensions_api_spec.rb +55 -0
  64. data/spec/api/filters_api_spec.rb +2 -2
  65. data/spec/api/incidents_api_spec.rb +73 -0
  66. data/spec/api/real_time_api_spec.rb +93 -0
  67. data/spec/models/asset_spec.rb +4 -0
  68. data/spec/models/dimension_value_spec.rb +40 -0
  69. data/spec/models/get_real_time_breakdown_response_spec.rb +46 -0
  70. data/spec/models/get_real_time_histogram_timeseries_response_meta_spec.rb +34 -0
  71. data/spec/models/get_real_time_histogram_timeseries_response_spec.rb +52 -0
  72. data/spec/models/get_real_time_timeseries_response_spec.rb +46 -0
  73. data/spec/models/incident_breakdown_spec.rb +46 -0
  74. data/spec/models/incident_notification_rule_spec.rb +58 -0
  75. data/spec/models/incident_notification_spec.rb +46 -0
  76. data/spec/models/incident_response_spec.rb +40 -0
  77. data/spec/models/incident_spec.rb +154 -0
  78. data/spec/models/list_dimension_values_response_spec.rb +46 -0
  79. data/spec/models/list_dimensions_response_spec.rb +46 -0
  80. data/spec/models/list_incidents_response_spec.rb +46 -0
  81. data/spec/models/list_real_time_dimensions_response_data_spec.rb +40 -0
  82. data/spec/models/list_real_time_dimensions_response_spec.rb +46 -0
  83. data/spec/models/list_real_time_metrics_response_spec.rb +46 -0
  84. data/spec/models/list_related_incidents_response_spec.rb +46 -0
  85. data/spec/models/notification_rule_spec.rb +46 -0
  86. data/spec/models/real_time_breakdown_value_spec.rb +58 -0
  87. data/spec/models/real_time_histogram_timeseries_bucket_spec.rb +40 -0
  88. data/spec/models/real_time_histogram_timeseries_bucket_values_spec.rb +40 -0
  89. data/spec/models/real_time_histogram_timeseries_datapoint_spec.rb +70 -0
  90. data/spec/models/real_time_timeseries_datapoint_spec.rb +46 -0
  91. metadata +171 -64
@@ -0,0 +1,206 @@
1
+ =begin
2
+ # Mux Ruby - Copyright 2019 Mux Inc.
3
+ # NOTE: This file is auto generated. Do not edit this file manually.
4
+ =end
5
+
6
+ require 'date'
7
+
8
+ module MuxRuby
9
+ class ListRealTimeMetricsResponse
10
+ attr_accessor :data
11
+
12
+ attr_accessor :total_row_count
13
+
14
+ attr_accessor :timeframe
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :'data' => :'data',
20
+ :'total_row_count' => :'total_row_count',
21
+ :'timeframe' => :'timeframe'
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.openapi_types
27
+ {
28
+ :'data' => :'Array<ListRealTimeDimensionsResponseData>',
29
+ :'total_row_count' => :'Integer',
30
+ :'timeframe' => :'Array<Integer>'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
41
+
42
+ if attributes.has_key?(:'data')
43
+ if (value = attributes[:'data']).is_a?(Array)
44
+ self.data = value
45
+ end
46
+ end
47
+
48
+ if attributes.has_key?(:'total_row_count')
49
+ self.total_row_count = attributes[:'total_row_count']
50
+ end
51
+
52
+ if attributes.has_key?(:'timeframe')
53
+ if (value = attributes[:'timeframe']).is_a?(Array)
54
+ self.timeframe = value
55
+ end
56
+ end
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ invalid_properties
64
+ end
65
+
66
+ # Check to see if the all the properties in the model are valid
67
+ # @return true if the model is valid
68
+ def valid?
69
+ true
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(o)
75
+ return true if self.equal?(o)
76
+ self.class == o.class &&
77
+ data == o.data &&
78
+ total_row_count == o.total_row_count &&
79
+ timeframe == o.timeframe
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [data, total_row_count, timeframe].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def self.build_from_hash(attributes)
98
+ new.build_from_hash(attributes)
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ self.class.openapi_types.each_pair do |key, type|
107
+ if type =~ /\AArray<(.*)>/i
108
+ # check to ensure the input is an array given that the attribute
109
+ # is documented as an array but the input is not
110
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
111
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
112
+ end
113
+ elsif !attributes[self.class.attribute_map[key]].nil?
114
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
115
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
116
+ end
117
+
118
+ self
119
+ end
120
+
121
+ # Deserializes the data based on type
122
+ # @param string type Data type
123
+ # @param string value Value to be deserialized
124
+ # @return [Object] Deserialized data
125
+ def _deserialize(type, value)
126
+ case type.to_sym
127
+ when :DateTime
128
+ DateTime.parse(value)
129
+ when :Date
130
+ Date.parse(value)
131
+ when :String
132
+ value.to_s
133
+ when :Integer
134
+ value.to_i
135
+ when :Float
136
+ value.to_f
137
+ when :BOOLEAN
138
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
139
+ true
140
+ else
141
+ false
142
+ end
143
+ when :Object
144
+ # generic object (usually a Hash), return directly
145
+ value
146
+ when /\AArray<(?<inner_type>.+)>\z/
147
+ inner_type = Regexp.last_match[:inner_type]
148
+ value.map { |v| _deserialize(inner_type, v) }
149
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
150
+ k_type = Regexp.last_match[:k_type]
151
+ v_type = Regexp.last_match[:v_type]
152
+ {}.tap do |hash|
153
+ value.each do |k, v|
154
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
155
+ end
156
+ end
157
+ else # model
158
+ MuxRuby.const_get(type).build_from_hash(value)
159
+ end
160
+ end
161
+
162
+ # Returns the string representation of the object
163
+ # @return [String] String presentation of the object
164
+ def to_s
165
+ to_hash.to_s
166
+ end
167
+
168
+ # to_body is an alias to to_hash (backward compatibility)
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = self.send(attr)
180
+ next if value.nil?
181
+ hash[param] = _to_hash(value)
182
+ end
183
+ hash
184
+ end
185
+
186
+ # Outputs non-array value in the form of hash
187
+ # For object, use to_hash. Otherwise, just return the value
188
+ # @param [Object] value Any valid value
189
+ # @return [Hash] Returns the value in the form of hash
190
+ def _to_hash(value)
191
+ if value.is_a?(Array)
192
+ value.compact.map { |v| _to_hash(v) }
193
+ elsif value.is_a?(Hash)
194
+ {}.tap do |hash|
195
+ value.each { |k, v| hash[k] = _to_hash(v) }
196
+ end
197
+ elsif value.respond_to? :to_hash
198
+ value.to_hash
199
+ else
200
+ value
201
+ end
202
+ end
203
+
204
+ end
205
+
206
+ end
@@ -0,0 +1,206 @@
1
+ =begin
2
+ # Mux Ruby - Copyright 2019 Mux Inc.
3
+ # NOTE: This file is auto generated. Do not edit this file manually.
4
+ =end
5
+
6
+ require 'date'
7
+
8
+ module MuxRuby
9
+ class ListRelatedIncidentsResponse
10
+ attr_accessor :data
11
+
12
+ attr_accessor :total_row_count
13
+
14
+ attr_accessor :timeframe
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :'data' => :'data',
20
+ :'total_row_count' => :'total_row_count',
21
+ :'timeframe' => :'timeframe'
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.openapi_types
27
+ {
28
+ :'data' => :'Array<Incident>',
29
+ :'total_row_count' => :'Integer',
30
+ :'timeframe' => :'Array<Integer>'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
41
+
42
+ if attributes.has_key?(:'data')
43
+ if (value = attributes[:'data']).is_a?(Array)
44
+ self.data = value
45
+ end
46
+ end
47
+
48
+ if attributes.has_key?(:'total_row_count')
49
+ self.total_row_count = attributes[:'total_row_count']
50
+ end
51
+
52
+ if attributes.has_key?(:'timeframe')
53
+ if (value = attributes[:'timeframe']).is_a?(Array)
54
+ self.timeframe = value
55
+ end
56
+ end
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ invalid_properties
64
+ end
65
+
66
+ # Check to see if the all the properties in the model are valid
67
+ # @return true if the model is valid
68
+ def valid?
69
+ true
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(o)
75
+ return true if self.equal?(o)
76
+ self.class == o.class &&
77
+ data == o.data &&
78
+ total_row_count == o.total_row_count &&
79
+ timeframe == o.timeframe
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [data, total_row_count, timeframe].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def self.build_from_hash(attributes)
98
+ new.build_from_hash(attributes)
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ self.class.openapi_types.each_pair do |key, type|
107
+ if type =~ /\AArray<(.*)>/i
108
+ # check to ensure the input is an array given that the attribute
109
+ # is documented as an array but the input is not
110
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
111
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
112
+ end
113
+ elsif !attributes[self.class.attribute_map[key]].nil?
114
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
115
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
116
+ end
117
+
118
+ self
119
+ end
120
+
121
+ # Deserializes the data based on type
122
+ # @param string type Data type
123
+ # @param string value Value to be deserialized
124
+ # @return [Object] Deserialized data
125
+ def _deserialize(type, value)
126
+ case type.to_sym
127
+ when :DateTime
128
+ DateTime.parse(value)
129
+ when :Date
130
+ Date.parse(value)
131
+ when :String
132
+ value.to_s
133
+ when :Integer
134
+ value.to_i
135
+ when :Float
136
+ value.to_f
137
+ when :BOOLEAN
138
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
139
+ true
140
+ else
141
+ false
142
+ end
143
+ when :Object
144
+ # generic object (usually a Hash), return directly
145
+ value
146
+ when /\AArray<(?<inner_type>.+)>\z/
147
+ inner_type = Regexp.last_match[:inner_type]
148
+ value.map { |v| _deserialize(inner_type, v) }
149
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
150
+ k_type = Regexp.last_match[:k_type]
151
+ v_type = Regexp.last_match[:v_type]
152
+ {}.tap do |hash|
153
+ value.each do |k, v|
154
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
155
+ end
156
+ end
157
+ else # model
158
+ MuxRuby.const_get(type).build_from_hash(value)
159
+ end
160
+ end
161
+
162
+ # Returns the string representation of the object
163
+ # @return [String] String presentation of the object
164
+ def to_s
165
+ to_hash.to_s
166
+ end
167
+
168
+ # to_body is an alias to to_hash (backward compatibility)
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = self.send(attr)
180
+ next if value.nil?
181
+ hash[param] = _to_hash(value)
182
+ end
183
+ hash
184
+ end
185
+
186
+ # Outputs non-array value in the form of hash
187
+ # For object, use to_hash. Otherwise, just return the value
188
+ # @param [Object] value Any valid value
189
+ # @return [Hash] Returns the value in the form of hash
190
+ def _to_hash(value)
191
+ if value.is_a?(Array)
192
+ value.compact.map { |v| _to_hash(v) }
193
+ elsif value.is_a?(Hash)
194
+ {}.tap do |hash|
195
+ value.each { |k, v| hash[k] = _to_hash(v) }
196
+ end
197
+ elsif value.respond_to? :to_hash
198
+ value.to_hash
199
+ else
200
+ value
201
+ end
202
+ end
203
+
204
+ end
205
+
206
+ end
@@ -0,0 +1,202 @@
1
+ =begin
2
+ # Mux Ruby - Copyright 2019 Mux Inc.
3
+ # NOTE: This file is auto generated. Do not edit this file manually.
4
+ =end
5
+
6
+ require 'date'
7
+
8
+ module MuxRuby
9
+ class NotificationRule
10
+ attr_accessor :value
11
+
12
+ attr_accessor :name
13
+
14
+ attr_accessor :id
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :'value' => :'value',
20
+ :'name' => :'name',
21
+ :'id' => :'id'
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.openapi_types
27
+ {
28
+ :'value' => :'String',
29
+ :'name' => :'String',
30
+ :'id' => :'String'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
41
+
42
+ if attributes.has_key?(:'value')
43
+ self.value = attributes[:'value']
44
+ end
45
+
46
+ if attributes.has_key?(:'name')
47
+ self.name = attributes[:'name']
48
+ end
49
+
50
+ if attributes.has_key?(:'id')
51
+ self.id = attributes[:'id']
52
+ end
53
+ end
54
+
55
+ # Show invalid properties with the reasons. Usually used together with valid?
56
+ # @return Array for valid properties with the reasons
57
+ def list_invalid_properties
58
+ invalid_properties = Array.new
59
+ invalid_properties
60
+ end
61
+
62
+ # Check to see if the all the properties in the model are valid
63
+ # @return true if the model is valid
64
+ def valid?
65
+ true
66
+ end
67
+
68
+ # Checks equality by comparing each attribute.
69
+ # @param [Object] Object to be compared
70
+ def ==(o)
71
+ return true if self.equal?(o)
72
+ self.class == o.class &&
73
+ value == o.value &&
74
+ name == o.name &&
75
+ id == o.id
76
+ end
77
+
78
+ # @see the `==` method
79
+ # @param [Object] Object to be compared
80
+ def eql?(o)
81
+ self == o
82
+ end
83
+
84
+ # Calculates hash code according to all attributes.
85
+ # @return [Fixnum] Hash code
86
+ def hash
87
+ [value, name, id].hash
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def self.build_from_hash(attributes)
94
+ new.build_from_hash(attributes)
95
+ end
96
+
97
+ # Builds the object from hash
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ # @return [Object] Returns the model itself
100
+ def build_from_hash(attributes)
101
+ return nil unless attributes.is_a?(Hash)
102
+ self.class.openapi_types.each_pair do |key, type|
103
+ if type =~ /\AArray<(.*)>/i
104
+ # check to ensure the input is an array given that the attribute
105
+ # is documented as an array but the input is not
106
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
107
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
108
+ end
109
+ elsif !attributes[self.class.attribute_map[key]].nil?
110
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
111
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
112
+ end
113
+
114
+ self
115
+ end
116
+
117
+ # Deserializes the data based on type
118
+ # @param string type Data type
119
+ # @param string value Value to be deserialized
120
+ # @return [Object] Deserialized data
121
+ def _deserialize(type, value)
122
+ case type.to_sym
123
+ when :DateTime
124
+ DateTime.parse(value)
125
+ when :Date
126
+ Date.parse(value)
127
+ when :String
128
+ value.to_s
129
+ when :Integer
130
+ value.to_i
131
+ when :Float
132
+ value.to_f
133
+ when :BOOLEAN
134
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
135
+ true
136
+ else
137
+ false
138
+ end
139
+ when :Object
140
+ # generic object (usually a Hash), return directly
141
+ value
142
+ when /\AArray<(?<inner_type>.+)>\z/
143
+ inner_type = Regexp.last_match[:inner_type]
144
+ value.map { |v| _deserialize(inner_type, v) }
145
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
146
+ k_type = Regexp.last_match[:k_type]
147
+ v_type = Regexp.last_match[:v_type]
148
+ {}.tap do |hash|
149
+ value.each do |k, v|
150
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
151
+ end
152
+ end
153
+ else # model
154
+ MuxRuby.const_get(type).build_from_hash(value)
155
+ end
156
+ end
157
+
158
+ # Returns the string representation of the object
159
+ # @return [String] String presentation of the object
160
+ def to_s
161
+ to_hash.to_s
162
+ end
163
+
164
+ # to_body is an alias to to_hash (backward compatibility)
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_body
167
+ to_hash
168
+ end
169
+
170
+ # Returns the object in the form of hash
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_hash
173
+ hash = {}
174
+ self.class.attribute_map.each_pair do |attr, param|
175
+ value = self.send(attr)
176
+ next if value.nil?
177
+ hash[param] = _to_hash(value)
178
+ end
179
+ hash
180
+ end
181
+
182
+ # Outputs non-array value in the form of hash
183
+ # For object, use to_hash. Otherwise, just return the value
184
+ # @param [Object] value Any valid value
185
+ # @return [Hash] Returns the value in the form of hash
186
+ def _to_hash(value)
187
+ if value.is_a?(Array)
188
+ value.compact.map { |v| _to_hash(v) }
189
+ elsif value.is_a?(Hash)
190
+ {}.tap do |hash|
191
+ value.each { |k, v| hash[k] = _to_hash(v) }
192
+ end
193
+ elsif value.respond_to? :to_hash
194
+ value.to_hash
195
+ else
196
+ value
197
+ end
198
+ end
199
+
200
+ end
201
+
202
+ end