fastly 7.2.2 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +1 -1
  5. data/docs/CreateResponseObjectRequest.md +16 -0
  6. data/docs/HistoricalApi.md +12 -12
  7. data/docs/{HistoricalAggregateResponse.md → HistoricalStatsAggregatedResponse.md} +1 -1
  8. data/docs/{HistoricalAggregateResponseAllOf.md → HistoricalStatsAggregatedResponseAllOf.md} +1 -1
  9. data/docs/{HistoricalResponse.md → HistoricalStatsByServiceResponse.md} +1 -1
  10. data/docs/{HistoricalResponseDataField.md → HistoricalStatsByServiceResponseAllOf.md} +1 -1
  11. data/docs/{HistoricalFieldResponse.md → HistoricalUsageAggregatedResponse.md} +2 -2
  12. data/docs/{HistoricalFieldResponseDataField.md → HistoricalUsageAggregatedResponseAllOf.md} +2 -2
  13. data/docs/{HistoricalUsageResults.md → HistoricalUsageData.md} +1 -1
  14. data/docs/HistoricalUsageMonthResponseData.md +2 -2
  15. data/docs/{HistoricalService.md → HistoricalUsageService.md} +1 -1
  16. data/docs/HistoricalUsageServiceResponse.md +1 -1
  17. data/docs/HistoricalUsageServiceResponseAllOf.md +1 -1
  18. data/docs/ResponseObjectApi.md +4 -0
  19. data/docs/Results.md +2 -0
  20. data/docs/TlsConfigurationResponseAttributes.md +1 -1
  21. data/docs/TlsConfigurationResponseAttributesAllOf.md +1 -1
  22. data/lib/fastly/api/historical_api.rb +18 -18
  23. data/lib/fastly/api/response_object_api.rb +8 -4
  24. data/lib/fastly/models/{historical_field_aggregate_response.rb → create_response_object_request.rb} +59 -35
  25. data/lib/fastly/models/{historical_aggregate_response.rb → historical_stats_aggregated_response.rb} +4 -4
  26. data/lib/fastly/models/{historical_aggregate_response_all_of.rb → historical_stats_aggregated_response_all_of.rb} +3 -3
  27. data/lib/fastly/models/{historical_response.rb → historical_stats_by_service_response.rb} +4 -4
  28. data/lib/fastly/models/{historical_response_data_field.rb → historical_stats_by_service_response_all_of.rb} +3 -3
  29. data/lib/fastly/models/{historical_field_response.rb → historical_usage_aggregated_response.rb} +6 -5
  30. data/lib/fastly/models/{historical_field_response_data_field.rb → historical_usage_aggregated_response_all_of.rb} +5 -4
  31. data/lib/fastly/models/{historical_usage_results.rb → historical_usage_data.rb} +4 -3
  32. data/lib/fastly/models/historical_usage_month_response_data.rb +7 -3
  33. data/lib/fastly/models/{historical_service.rb → historical_usage_service.rb} +3 -3
  34. data/lib/fastly/models/historical_usage_service_response.rb +5 -2
  35. data/lib/fastly/models/historical_usage_service_response_all_of.rb +5 -2
  36. data/lib/fastly/models/relationship_mutual_authentication.rb +1 -1
  37. data/lib/fastly/models/relationship_tls_domain.rb +1 -1
  38. data/lib/fastly/models/results.rb +24 -5
  39. data/lib/fastly/models/tls_configuration_response_attributes.rb +1 -1
  40. data/lib/fastly/models/tls_configuration_response_attributes_all_of.rb +1 -1
  41. data/lib/fastly/version.rb +1 -1
  42. data/lib/fastly.rb +9 -14
  43. data/sig.json +1 -1
  44. metadata +20 -30
  45. data/docs/HistoricalFieldAggregateResponse.md +0 -13
  46. data/docs/HistoricalFieldAggregateResponseAllOf.md +0 -10
  47. data/docs/HistoricalFieldResultsAttributes.md +0 -236
  48. data/docs/HistoricalFieldResultsAttributesAdditional.md +0 -11
  49. data/docs/HistoricalUsageAggregateResponse.md +0 -13
  50. data/docs/ReadOnlyIdService.md +0 -9
  51. data/lib/fastly/models/historical_field_aggregate_response_all_of.rb +0 -218
  52. data/lib/fastly/models/historical_field_results_attributes.rb +0 -2484
  53. data/lib/fastly/models/historical_field_results_attributes_additional.rb +0 -225
  54. data/lib/fastly/models/historical_usage_aggregate_response.rb +0 -254
  55. data/lib/fastly/models/read_only_id_service.rb +0 -207
@@ -1,225 +0,0 @@
1
- =begin
2
- #Fastly API
3
-
4
- #Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://developer.fastly.com/reference/api/)
5
-
6
- The version of the OpenAPI document: 1.0.0
7
- Contact: oss@fastly.com
8
-
9
- =end
10
-
11
- require 'date'
12
- require 'time'
13
-
14
- module Fastly
15
- class HistoricalFieldResultsAttributesAdditional
16
- attr_accessor :service_id
17
-
18
- attr_accessor :start_time
19
-
20
- # Attribute mapping from ruby-style variable name to JSON key.
21
- def self.attribute_map
22
- {
23
- :'service_id' => :'service_id',
24
- :'start_time' => :'start_time'
25
- }
26
- end
27
-
28
- # Returns all the JSON keys this model knows about
29
- def self.acceptable_attributes
30
- attribute_map.values
31
- end
32
-
33
- # Attribute type mapping.
34
- def self.fastly_types
35
- {
36
- :'service_id' => :'ReadOnlyIdService',
37
- :'start_time' => :'Integer'
38
- }
39
- end
40
-
41
- # List of attributes with nullable: true
42
- def self.fastly_nullable
43
- Set.new([
44
- ])
45
- end
46
-
47
- # Initializes the object
48
- # @param [Hash] attributes Model attributes in the form of hash
49
- def initialize(attributes = {})
50
- if (!attributes.is_a?(Hash))
51
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::HistoricalFieldResultsAttributesAdditional` initialize method"
52
- end
53
-
54
- # check to see if the attribute exists and convert string to symbol for hash key
55
- attributes = attributes.each_with_object({}) { |(k, v), h|
56
- if (!self.class.attribute_map.key?(k.to_sym))
57
- fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::HistoricalFieldResultsAttributesAdditional`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
- end
59
- h[k.to_sym] = v
60
- }
61
-
62
- if attributes.key?(:'service_id')
63
- self.service_id = attributes[:'service_id']
64
- end
65
-
66
- if attributes.key?(:'start_time')
67
- self.start_time = attributes[:'start_time']
68
- end
69
- end
70
-
71
- # Show invalid properties with the reasons. Usually used together with valid?
72
- # @return Array for valid properties with the reasons
73
- def list_invalid_properties
74
- invalid_properties = Array.new
75
- invalid_properties
76
- end
77
-
78
- # Check to see if the all the properties in the model are valid
79
- # @return true if the model is valid
80
- def valid?
81
- true
82
- end
83
-
84
- # Checks equality by comparing each attribute.
85
- # @param [Object] Object to be compared
86
- def ==(o)
87
- return true if self.equal?(o)
88
- self.class == o.class &&
89
- service_id == o.service_id &&
90
- start_time == o.start_time
91
- end
92
-
93
- # @see the `==` method
94
- # @param [Object] Object to be compared
95
- def eql?(o)
96
- self == o
97
- end
98
-
99
- # Calculates hash code according to all attributes.
100
- # @return [Integer] Hash code
101
- def hash
102
- [service_id, start_time].hash
103
- end
104
-
105
- # Builds the object from hash
106
- # @param [Hash] attributes Model attributes in the form of hash
107
- # @return [Object] Returns the model itself
108
- def self.build_from_hash(attributes)
109
- new.build_from_hash(attributes)
110
- end
111
-
112
- # Builds the object from hash
113
- # @param [Hash] attributes Model attributes in the form of hash
114
- # @return [Object] Returns the model itself
115
- def build_from_hash(attributes)
116
- return nil unless attributes.is_a?(Hash)
117
- self.class.fastly_types.each_pair do |key, type|
118
- if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
119
- self.send("#{key}=", nil)
120
- elsif type =~ /\AArray<(.*)>/i
121
- # check to ensure the input is an array given that the attribute
122
- # is documented as an array but the input is not
123
- if attributes[self.class.attribute_map[key]].is_a?(Array)
124
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
125
- end
126
- elsif !attributes[self.class.attribute_map[key]].nil?
127
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128
- end
129
- end
130
-
131
- self
132
- end
133
-
134
- # Deserializes the data based on type
135
- # @param string type Data type
136
- # @param string value Value to be deserialized
137
- # @return [Object] Deserialized data
138
- def _deserialize(type, value)
139
- case type.to_sym
140
- when :Time
141
- Time.parse(value)
142
- when :Date
143
- Date.parse(value)
144
- when :String
145
- value.to_s
146
- when :Integer
147
- value.to_i
148
- when :Float
149
- value.to_f
150
- when :Boolean
151
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
- true
153
- else
154
- false
155
- end
156
- when :Object
157
- # generic object (usually a Hash), return directly
158
- value
159
- when /\AArray<(?<inner_type>.+)>\z/
160
- inner_type = Regexp.last_match[:inner_type]
161
- value.map { |v| _deserialize(inner_type, v) }
162
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
- k_type = Regexp.last_match[:k_type]
164
- v_type = Regexp.last_match[:v_type]
165
- {}.tap do |hash|
166
- value.each do |k, v|
167
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
- end
169
- end
170
- else # model
171
- # models (e.g. Pet) or oneOf
172
- klass = Fastly.const_get(type)
173
- klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
- end
175
- end
176
-
177
- # Returns the string representation of the object
178
- # @return [String] String presentation of the object
179
- def to_s
180
- to_hash.to_s
181
- end
182
-
183
- # to_body is an alias to to_hash (backward compatibility)
184
- # @return [Hash] Returns the object in the form of hash
185
- def to_body
186
- to_hash
187
- end
188
-
189
- # Returns the object in the form of hash
190
- # @return [Hash] Returns the object in the form of hash
191
- def to_hash
192
- hash = {}
193
- self.class.attribute_map.each_pair do |attr, param|
194
- value = self.send(attr)
195
- if value.nil?
196
- is_nullable = self.class.fastly_nullable.include?(attr)
197
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
- end
199
-
200
- hash[param] = _to_hash(value)
201
- end
202
- hash
203
- end
204
-
205
- # Outputs non-array value in the form of hash
206
- # For object, use to_hash. Otherwise, just return the value
207
- # @param [Object] value Any valid value
208
- # @return [Hash] Returns the value in the form of hash
209
- def _to_hash(value)
210
- if value.is_a?(Array)
211
- value.compact.map { |v| _to_hash(v) }
212
- elsif value.is_a?(Hash)
213
- {}.tap do |hash|
214
- value.each { |k, v| hash[k] = _to_hash(v) }
215
- end
216
- elsif value.respond_to? :to_hash
217
- value.to_hash
218
- else
219
- value
220
- end
221
- end
222
-
223
- end
224
-
225
- end
@@ -1,254 +0,0 @@
1
- =begin
2
- #Fastly API
3
-
4
- #Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://developer.fastly.com/reference/api/)
5
-
6
- The version of the OpenAPI document: 1.0.0
7
- Contact: oss@fastly.com
8
-
9
- =end
10
-
11
- require 'date'
12
- require 'time'
13
-
14
- module Fastly
15
- class HistoricalUsageAggregateResponse
16
- # Whether or not we were able to successfully execute the query.
17
- attr_accessor :status
18
-
19
- attr_accessor :meta
20
-
21
- # If the query was not successful, this will provide a string that explains why.
22
- attr_accessor :msg
23
-
24
- attr_accessor :data
25
-
26
- # Attribute mapping from ruby-style variable name to JSON key.
27
- def self.attribute_map
28
- {
29
- :'status' => :'status',
30
- :'meta' => :'meta',
31
- :'msg' => :'msg',
32
- :'data' => :'data'
33
- }
34
- end
35
-
36
- # Returns all the JSON keys this model knows about
37
- def self.acceptable_attributes
38
- attribute_map.values
39
- end
40
-
41
- # Attribute type mapping.
42
- def self.fastly_types
43
- {
44
- :'status' => :'String',
45
- :'meta' => :'HistoricalMeta',
46
- :'msg' => :'String',
47
- :'data' => :'HistoricalUsageResults'
48
- }
49
- end
50
-
51
- # List of attributes with nullable: true
52
- def self.fastly_nullable
53
- Set.new([
54
- :'msg',
55
- ])
56
- end
57
-
58
- # List of class defined in allOf (OpenAPI v3)
59
- def self.fastly_all_of
60
- [
61
- :'Historical',
62
- :'HistoricalUsageServiceResponseAllOf'
63
- ]
64
- end
65
-
66
- # Initializes the object
67
- # @param [Hash] attributes Model attributes in the form of hash
68
- def initialize(attributes = {})
69
- if (!attributes.is_a?(Hash))
70
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::HistoricalUsageAggregateResponse` initialize method"
71
- end
72
-
73
- # check to see if the attribute exists and convert string to symbol for hash key
74
- attributes = attributes.each_with_object({}) { |(k, v), h|
75
- if (!self.class.attribute_map.key?(k.to_sym))
76
- fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::HistoricalUsageAggregateResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
- end
78
- h[k.to_sym] = v
79
- }
80
-
81
- if attributes.key?(:'status')
82
- self.status = attributes[:'status']
83
- end
84
-
85
- if attributes.key?(:'meta')
86
- self.meta = attributes[:'meta']
87
- end
88
-
89
- if attributes.key?(:'msg')
90
- self.msg = attributes[:'msg']
91
- end
92
-
93
- if attributes.key?(:'data')
94
- self.data = attributes[:'data']
95
- end
96
- end
97
-
98
- # Show invalid properties with the reasons. Usually used together with valid?
99
- # @return Array for valid properties with the reasons
100
- def list_invalid_properties
101
- invalid_properties = Array.new
102
- invalid_properties
103
- end
104
-
105
- # Check to see if the all the properties in the model are valid
106
- # @return true if the model is valid
107
- def valid?
108
- true
109
- end
110
-
111
- # Checks equality by comparing each attribute.
112
- # @param [Object] Object to be compared
113
- def ==(o)
114
- return true if self.equal?(o)
115
- self.class == o.class &&
116
- status == o.status &&
117
- meta == o.meta &&
118
- msg == o.msg &&
119
- data == o.data
120
- end
121
-
122
- # @see the `==` method
123
- # @param [Object] Object to be compared
124
- def eql?(o)
125
- self == o
126
- end
127
-
128
- # Calculates hash code according to all attributes.
129
- # @return [Integer] Hash code
130
- def hash
131
- [status, meta, msg, data].hash
132
- end
133
-
134
- # Builds the object from hash
135
- # @param [Hash] attributes Model attributes in the form of hash
136
- # @return [Object] Returns the model itself
137
- def self.build_from_hash(attributes)
138
- new.build_from_hash(attributes)
139
- end
140
-
141
- # Builds the object from hash
142
- # @param [Hash] attributes Model attributes in the form of hash
143
- # @return [Object] Returns the model itself
144
- def build_from_hash(attributes)
145
- return nil unless attributes.is_a?(Hash)
146
- self.class.fastly_types.each_pair do |key, type|
147
- if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
148
- self.send("#{key}=", nil)
149
- elsif type =~ /\AArray<(.*)>/i
150
- # check to ensure the input is an array given that the attribute
151
- # is documented as an array but the input is not
152
- if attributes[self.class.attribute_map[key]].is_a?(Array)
153
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
154
- end
155
- elsif !attributes[self.class.attribute_map[key]].nil?
156
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
157
- end
158
- end
159
-
160
- self
161
- end
162
-
163
- # Deserializes the data based on type
164
- # @param string type Data type
165
- # @param string value Value to be deserialized
166
- # @return [Object] Deserialized data
167
- def _deserialize(type, value)
168
- case type.to_sym
169
- when :Time
170
- Time.parse(value)
171
- when :Date
172
- Date.parse(value)
173
- when :String
174
- value.to_s
175
- when :Integer
176
- value.to_i
177
- when :Float
178
- value.to_f
179
- when :Boolean
180
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
- true
182
- else
183
- false
184
- end
185
- when :Object
186
- # generic object (usually a Hash), return directly
187
- value
188
- when /\AArray<(?<inner_type>.+)>\z/
189
- inner_type = Regexp.last_match[:inner_type]
190
- value.map { |v| _deserialize(inner_type, v) }
191
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
192
- k_type = Regexp.last_match[:k_type]
193
- v_type = Regexp.last_match[:v_type]
194
- {}.tap do |hash|
195
- value.each do |k, v|
196
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
197
- end
198
- end
199
- else # model
200
- # models (e.g. Pet) or oneOf
201
- klass = Fastly.const_get(type)
202
- klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
203
- end
204
- end
205
-
206
- # Returns the string representation of the object
207
- # @return [String] String presentation of the object
208
- def to_s
209
- to_hash.to_s
210
- end
211
-
212
- # to_body is an alias to to_hash (backward compatibility)
213
- # @return [Hash] Returns the object in the form of hash
214
- def to_body
215
- to_hash
216
- end
217
-
218
- # Returns the object in the form of hash
219
- # @return [Hash] Returns the object in the form of hash
220
- def to_hash
221
- hash = {}
222
- self.class.attribute_map.each_pair do |attr, param|
223
- value = self.send(attr)
224
- if value.nil?
225
- is_nullable = self.class.fastly_nullable.include?(attr)
226
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
227
- end
228
-
229
- hash[param] = _to_hash(value)
230
- end
231
- hash
232
- end
233
-
234
- # Outputs non-array value in the form of hash
235
- # For object, use to_hash. Otherwise, just return the value
236
- # @param [Object] value Any valid value
237
- # @return [Hash] Returns the value in the form of hash
238
- def _to_hash(value)
239
- if value.is_a?(Array)
240
- value.compact.map { |v| _to_hash(v) }
241
- elsif value.is_a?(Hash)
242
- {}.tap do |hash|
243
- value.each { |k, v| hash[k] = _to_hash(v) }
244
- end
245
- elsif value.respond_to? :to_hash
246
- value.to_hash
247
- else
248
- value
249
- end
250
- end
251
-
252
- end
253
-
254
- end
@@ -1,207 +0,0 @@
1
- =begin
2
- #Fastly API
3
-
4
- #Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://developer.fastly.com/reference/api/)
5
-
6
- The version of the OpenAPI document: 1.0.0
7
- Contact: oss@fastly.com
8
-
9
- =end
10
-
11
- require 'date'
12
- require 'time'
13
-
14
- module Fastly
15
- class ReadOnlyIdService
16
- # Attribute mapping from ruby-style variable name to JSON key.
17
- def self.attribute_map
18
- {
19
- }
20
- end
21
-
22
- # Returns all the JSON keys this model knows about
23
- def self.acceptable_attributes
24
- attribute_map.values
25
- end
26
-
27
- # Attribute type mapping.
28
- def self.fastly_types
29
- {
30
- }
31
- end
32
-
33
- # List of attributes with nullable: true
34
- def self.fastly_nullable
35
- Set.new([
36
- ])
37
- end
38
-
39
- # Initializes the object
40
- # @param [Hash] attributes Model attributes in the form of hash
41
- def initialize(attributes = {})
42
- if (!attributes.is_a?(Hash))
43
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::ReadOnlyIdService` initialize method"
44
- end
45
-
46
- # check to see if the attribute exists and convert string to symbol for hash key
47
- attributes = attributes.each_with_object({}) { |(k, v), h|
48
- if (!self.class.attribute_map.key?(k.to_sym))
49
- fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::ReadOnlyIdService`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
50
- end
51
- h[k.to_sym] = v
52
- }
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
- end
74
-
75
- # @see the `==` method
76
- # @param [Object] Object to be compared
77
- def eql?(o)
78
- self == o
79
- end
80
-
81
- # Calculates hash code according to all attributes.
82
- # @return [Integer] Hash code
83
- def hash
84
- [].hash
85
- end
86
-
87
- # Builds the object from hash
88
- # @param [Hash] attributes Model attributes in the form of hash
89
- # @return [Object] Returns the model itself
90
- def self.build_from_hash(attributes)
91
- new.build_from_hash(attributes)
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 build_from_hash(attributes)
98
- return nil unless attributes.is_a?(Hash)
99
- self.class.fastly_types.each_pair do |key, type|
100
- if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
101
- self.send("#{key}=", nil)
102
- elsif type =~ /\AArray<(.*)>/i
103
- # check to ensure the input is an array given that the attribute
104
- # is documented as an array but the input is not
105
- if attributes[self.class.attribute_map[key]].is_a?(Array)
106
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
107
- end
108
- elsif !attributes[self.class.attribute_map[key]].nil?
109
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
110
- end
111
- end
112
-
113
- self
114
- end
115
-
116
- # Deserializes the data based on type
117
- # @param string type Data type
118
- # @param string value Value to be deserialized
119
- # @return [Object] Deserialized data
120
- def _deserialize(type, value)
121
- case type.to_sym
122
- when :Time
123
- Time.parse(value)
124
- when :Date
125
- Date.parse(value)
126
- when :String
127
- value.to_s
128
- when :Integer
129
- value.to_i
130
- when :Float
131
- value.to_f
132
- when :Boolean
133
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
134
- true
135
- else
136
- false
137
- end
138
- when :Object
139
- # generic object (usually a Hash), return directly
140
- value
141
- when /\AArray<(?<inner_type>.+)>\z/
142
- inner_type = Regexp.last_match[:inner_type]
143
- value.map { |v| _deserialize(inner_type, v) }
144
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
145
- k_type = Regexp.last_match[:k_type]
146
- v_type = Regexp.last_match[:v_type]
147
- {}.tap do |hash|
148
- value.each do |k, v|
149
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
150
- end
151
- end
152
- else # model
153
- # models (e.g. Pet) or oneOf
154
- klass = Fastly.const_get(type)
155
- klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
156
- end
157
- end
158
-
159
- # Returns the string representation of the object
160
- # @return [String] String presentation of the object
161
- def to_s
162
- to_hash.to_s
163
- end
164
-
165
- # to_body is an alias to to_hash (backward compatibility)
166
- # @return [Hash] Returns the object in the form of hash
167
- def to_body
168
- to_hash
169
- end
170
-
171
- # Returns the object in the form of hash
172
- # @return [Hash] Returns the object in the form of hash
173
- def to_hash
174
- hash = {}
175
- self.class.attribute_map.each_pair do |attr, param|
176
- value = self.send(attr)
177
- if value.nil?
178
- is_nullable = self.class.fastly_nullable.include?(attr)
179
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
180
- end
181
-
182
- hash[param] = _to_hash(value)
183
- end
184
- hash
185
- end
186
-
187
- # Outputs non-array value in the form of hash
188
- # For object, use to_hash. Otherwise, just return the value
189
- # @param [Object] value Any valid value
190
- # @return [Hash] Returns the value in the form of hash
191
- def _to_hash(value)
192
- if value.is_a?(Array)
193
- value.compact.map { |v| _to_hash(v) }
194
- elsif value.is_a?(Hash)
195
- {}.tap do |hash|
196
- value.each { |k, v| hash[k] = _to_hash(v) }
197
- end
198
- elsif value.respond_to? :to_hash
199
- value.to_hash
200
- else
201
- value
202
- end
203
- end
204
-
205
- end
206
-
207
- end