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 ListIncidentsResponse
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,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 ListRealTimeDimensionsResponse
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,193 @@
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 ListRealTimeDimensionsResponseData
10
+ attr_accessor :name
11
+
12
+ attr_accessor :display_name
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :'name' => :'name',
18
+ :'display_name' => :'display_name'
19
+ }
20
+ end
21
+
22
+ # Attribute type mapping.
23
+ def self.openapi_types
24
+ {
25
+ :'name' => :'String',
26
+ :'display_name' => :'String'
27
+ }
28
+ end
29
+
30
+ # Initializes the object
31
+ # @param [Hash] attributes Model attributes in the form of hash
32
+ def initialize(attributes = {})
33
+ return unless attributes.is_a?(Hash)
34
+
35
+ # convert string to symbol for hash key
36
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
37
+
38
+ if attributes.has_key?(:'name')
39
+ self.name = attributes[:'name']
40
+ end
41
+
42
+ if attributes.has_key?(:'display_name')
43
+ self.display_name = attributes[:'display_name']
44
+ end
45
+ end
46
+
47
+ # Show invalid properties with the reasons. Usually used together with valid?
48
+ # @return Array for valid properties with the reasons
49
+ def list_invalid_properties
50
+ invalid_properties = Array.new
51
+ invalid_properties
52
+ end
53
+
54
+ # Check to see if the all the properties in the model are valid
55
+ # @return true if the model is valid
56
+ def valid?
57
+ true
58
+ end
59
+
60
+ # Checks equality by comparing each attribute.
61
+ # @param [Object] Object to be compared
62
+ def ==(o)
63
+ return true if self.equal?(o)
64
+ self.class == o.class &&
65
+ name == o.name &&
66
+ display_name == o.display_name
67
+ end
68
+
69
+ # @see the `==` method
70
+ # @param [Object] Object to be compared
71
+ def eql?(o)
72
+ self == o
73
+ end
74
+
75
+ # Calculates hash code according to all attributes.
76
+ # @return [Fixnum] Hash code
77
+ def hash
78
+ [name, display_name].hash
79
+ end
80
+
81
+ # Builds the object from hash
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ # @return [Object] Returns the model itself
84
+ def self.build_from_hash(attributes)
85
+ new.build_from_hash(attributes)
86
+ end
87
+
88
+ # Builds the object from hash
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ # @return [Object] Returns the model itself
91
+ def build_from_hash(attributes)
92
+ return nil unless attributes.is_a?(Hash)
93
+ self.class.openapi_types.each_pair do |key, type|
94
+ if type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
98
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
+ end
100
+ elsif !attributes[self.class.attribute_map[key]].nil?
101
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+
105
+ self
106
+ end
107
+
108
+ # Deserializes the data based on type
109
+ # @param string type Data type
110
+ # @param string value Value to be deserialized
111
+ # @return [Object] Deserialized data
112
+ def _deserialize(type, value)
113
+ case type.to_sym
114
+ when :DateTime
115
+ DateTime.parse(value)
116
+ when :Date
117
+ Date.parse(value)
118
+ when :String
119
+ value.to_s
120
+ when :Integer
121
+ value.to_i
122
+ when :Float
123
+ value.to_f
124
+ when :BOOLEAN
125
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
+ true
127
+ else
128
+ false
129
+ end
130
+ when :Object
131
+ # generic object (usually a Hash), return directly
132
+ value
133
+ when /\AArray<(?<inner_type>.+)>\z/
134
+ inner_type = Regexp.last_match[:inner_type]
135
+ value.map { |v| _deserialize(inner_type, v) }
136
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
+ k_type = Regexp.last_match[:k_type]
138
+ v_type = Regexp.last_match[:v_type]
139
+ {}.tap do |hash|
140
+ value.each do |k, v|
141
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
+ end
143
+ end
144
+ else # model
145
+ MuxRuby.const_get(type).build_from_hash(value)
146
+ end
147
+ end
148
+
149
+ # Returns the string representation of the object
150
+ # @return [String] String presentation of the object
151
+ def to_s
152
+ to_hash.to_s
153
+ end
154
+
155
+ # to_body is an alias to to_hash (backward compatibility)
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_body
158
+ to_hash
159
+ end
160
+
161
+ # Returns the object in the form of hash
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_hash
164
+ hash = {}
165
+ self.class.attribute_map.each_pair do |attr, param|
166
+ value = self.send(attr)
167
+ next if value.nil?
168
+ hash[param] = _to_hash(value)
169
+ end
170
+ hash
171
+ end
172
+
173
+ # Outputs non-array value in the form of hash
174
+ # For object, use to_hash. Otherwise, just return the value
175
+ # @param [Object] value Any valid value
176
+ # @return [Hash] Returns the value in the form of hash
177
+ def _to_hash(value)
178
+ if value.is_a?(Array)
179
+ value.compact.map { |v| _to_hash(v) }
180
+ elsif value.is_a?(Hash)
181
+ {}.tap do |hash|
182
+ value.each { |k, v| hash[k] = _to_hash(v) }
183
+ end
184
+ elsif value.respond_to? :to_hash
185
+ value.to_hash
186
+ else
187
+ value
188
+ end
189
+ end
190
+
191
+ end
192
+
193
+ end