fastly 7.1.1 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +6 -5
  5. data/docs/HistoricalDdos.md +13 -0
  6. data/docs/HistoricalDdosMeta.md +13 -0
  7. data/docs/HistoricalFieldResultsAttributes.md +9 -0
  8. data/docs/KvStoreApi.md +15 -15
  9. data/docs/LoggingLogentriesAdditional.md +1 -1
  10. data/docs/LoggingLogentriesApi.md +4 -4
  11. data/docs/LoggingLogentriesResponse.md +1 -1
  12. data/docs/PlatformDdosDataItems.md +10 -0
  13. data/docs/PlatformDdosEntry.md +10 -0
  14. data/docs/PlatformDdosResponse.md +13 -0
  15. data/docs/PlatformDdosResponseAllOf.md +10 -0
  16. data/docs/RealtimeEntryAggregated.md +9 -0
  17. data/docs/RealtimeMeasurements.md +9 -0
  18. data/docs/Results.md +9 -0
  19. data/docs/SchemasSnippetResponse.md +1 -1
  20. data/docs/SchemasSnippetResponseCommon.md +15 -0
  21. data/docs/Snippet.md +1 -1
  22. data/docs/SnippetAllOf.md +10 -0
  23. data/docs/SnippetApi.md +6 -6
  24. data/docs/SnippetCommon.md +13 -0
  25. data/docs/SnippetResponse.md +1 -1
  26. data/docs/SnippetResponseCommon.md +15 -0
  27. data/docs/{SnippetResponseAllOf.md → SnippetResponseCommonAllOf.md} +1 -1
  28. data/docs/SnippetResponsePost.md +20 -0
  29. data/docs/SnippetWithDynamicNumber.md +14 -0
  30. data/docs/SnippetWithDynamicNumberAllOf.md +10 -0
  31. data/docs/ValuesDdos.md +15 -0
  32. data/docs/WholePlatformDdosHistoricalApi.md +56 -0
  33. data/lib/fastly/api/kv_store_api.rb +14 -14
  34. data/lib/fastly/api/logging_logentries_api.rb +4 -4
  35. data/lib/fastly/api/snippet_api.rb +17 -17
  36. data/lib/fastly/api/whole_platform_ddos_historical_api.rb +89 -0
  37. data/lib/fastly/configuration.rb +6 -0
  38. data/lib/fastly/models/historical_ddos.rb +249 -0
  39. data/lib/fastly/models/historical_ddos_meta.rb +248 -0
  40. data/lib/fastly/models/historical_field_results_attributes.rb +91 -1
  41. data/lib/fastly/models/logging_logentries_additional.rb +1 -1
  42. data/lib/fastly/models/logging_logentries_response.rb +1 -1
  43. data/lib/fastly/models/platform_ddos_data_items.rb +216 -0
  44. data/lib/fastly/models/platform_ddos_entry.rb +219 -0
  45. data/lib/fastly/models/platform_ddos_response.rb +257 -0
  46. data/lib/fastly/models/platform_ddos_response_all_of.rb +219 -0
  47. data/lib/fastly/models/realtime_entry_aggregated.rb +94 -4
  48. data/lib/fastly/models/realtime_measurements.rb +94 -4
  49. data/lib/fastly/models/results.rb +94 -4
  50. data/lib/fastly/models/schemas_snippet_response.rb +25 -26
  51. data/lib/fastly/models/schemas_snippet_response_common.rb +276 -0
  52. data/lib/fastly/models/snippet.rb +34 -26
  53. data/lib/fastly/models/snippet_all_of.rb +251 -0
  54. data/lib/fastly/models/snippet_common.rb +283 -0
  55. data/lib/fastly/models/snippet_response.rb +24 -25
  56. data/lib/fastly/models/snippet_response_common.rb +276 -0
  57. data/lib/fastly/models/{snippet_response_all_of.rb → snippet_response_common_all_of.rb} +3 -3
  58. data/lib/fastly/models/snippet_response_post.rb +374 -0
  59. data/lib/fastly/models/snippet_with_dynamic_number.rb +313 -0
  60. data/lib/fastly/models/snippet_with_dynamic_number_all_of.rb +251 -0
  61. data/lib/fastly/models/values_ddos.rb +268 -0
  62. data/lib/fastly/version.rb +1 -1
  63. data/lib/fastly.rb +16 -1
  64. data/sig.json +1 -1
  65. metadata +34 -4
@@ -0,0 +1,283 @@
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 SnippetCommon
16
+ # The name for the snippet.
17
+ attr_accessor :name
18
+
19
+ # The location in generated VCL where the snippet should be placed.
20
+ attr_accessor :type
21
+
22
+ # The VCL code that specifies exactly what the snippet does.
23
+ attr_accessor :content
24
+
25
+ # Priority determines execution order. Lower numbers execute first.
26
+ attr_accessor :priority
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'name' => :'name',
54
+ :'type' => :'type',
55
+ :'content' => :'content',
56
+ :'priority' => :'priority'
57
+ }
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.fastly_types
67
+ {
68
+ :'name' => :'String',
69
+ :'type' => :'String',
70
+ :'content' => :'String',
71
+ :'priority' => :'String'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.fastly_nullable
77
+ Set.new([
78
+ ])
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::SnippetCommon` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!self.class.attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::SnippetCommon`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'name')
97
+ self.name = attributes[:'name']
98
+ end
99
+
100
+ if attributes.key?(:'type')
101
+ self.type = attributes[:'type']
102
+ end
103
+
104
+ if attributes.key?(:'content')
105
+ self.content = attributes[:'content']
106
+ end
107
+
108
+ if attributes.key?(:'priority')
109
+ self.priority = attributes[:'priority']
110
+ else
111
+ self.priority = '100'
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ invalid_properties = Array.new
119
+ invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+ type_validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
126
+ return false unless type_validator.valid?(@type)
127
+ true
128
+ end
129
+
130
+ # Custom attribute writer method checking allowed values (enum).
131
+ # @param [Object] type Object to be assigned
132
+ def type=(type)
133
+ validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
134
+ unless validator.valid?(type)
135
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
136
+ end
137
+ @type = type
138
+ end
139
+
140
+ # Checks equality by comparing each attribute.
141
+ # @param [Object] Object to be compared
142
+ def ==(o)
143
+ return true if self.equal?(o)
144
+ self.class == o.class &&
145
+ name == o.name &&
146
+ type == o.type &&
147
+ content == o.content &&
148
+ priority == o.priority
149
+ end
150
+
151
+ # @see the `==` method
152
+ # @param [Object] Object to be compared
153
+ def eql?(o)
154
+ self == o
155
+ end
156
+
157
+ # Calculates hash code according to all attributes.
158
+ # @return [Integer] Hash code
159
+ def hash
160
+ [name, type, content, priority].hash
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def self.build_from_hash(attributes)
167
+ new.build_from_hash(attributes)
168
+ end
169
+
170
+ # Builds the object from hash
171
+ # @param [Hash] attributes Model attributes in the form of hash
172
+ # @return [Object] Returns the model itself
173
+ def build_from_hash(attributes)
174
+ return nil unless attributes.is_a?(Hash)
175
+ self.class.fastly_types.each_pair do |key, type|
176
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
177
+ self.send("#{key}=", nil)
178
+ elsif type =~ /\AArray<(.*)>/i
179
+ # check to ensure the input is an array given that the attribute
180
+ # is documented as an array but the input is not
181
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
182
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
183
+ end
184
+ elsif !attributes[self.class.attribute_map[key]].nil?
185
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
186
+ end
187
+ end
188
+
189
+ self
190
+ end
191
+
192
+ # Deserializes the data based on type
193
+ # @param string type Data type
194
+ # @param string value Value to be deserialized
195
+ # @return [Object] Deserialized data
196
+ def _deserialize(type, value)
197
+ case type.to_sym
198
+ when :Time
199
+ Time.parse(value)
200
+ when :Date
201
+ Date.parse(value)
202
+ when :String
203
+ value.to_s
204
+ when :Integer
205
+ value.to_i
206
+ when :Float
207
+ value.to_f
208
+ when :Boolean
209
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
210
+ true
211
+ else
212
+ false
213
+ end
214
+ when :Object
215
+ # generic object (usually a Hash), return directly
216
+ value
217
+ when /\AArray<(?<inner_type>.+)>\z/
218
+ inner_type = Regexp.last_match[:inner_type]
219
+ value.map { |v| _deserialize(inner_type, v) }
220
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
221
+ k_type = Regexp.last_match[:k_type]
222
+ v_type = Regexp.last_match[:v_type]
223
+ {}.tap do |hash|
224
+ value.each do |k, v|
225
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
226
+ end
227
+ end
228
+ else # model
229
+ # models (e.g. Pet) or oneOf
230
+ klass = Fastly.const_get(type)
231
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
232
+ end
233
+ end
234
+
235
+ # Returns the string representation of the object
236
+ # @return [String] String presentation of the object
237
+ def to_s
238
+ to_hash.to_s
239
+ end
240
+
241
+ # to_body is an alias to to_hash (backward compatibility)
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_body
244
+ to_hash
245
+ end
246
+
247
+ # Returns the object in the form of hash
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_hash
250
+ hash = {}
251
+ self.class.attribute_map.each_pair do |attr, param|
252
+ value = self.send(attr)
253
+ if value.nil?
254
+ is_nullable = self.class.fastly_nullable.include?(attr)
255
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
256
+ end
257
+
258
+ hash[param] = _to_hash(value)
259
+ end
260
+ hash
261
+ end
262
+
263
+ # Outputs non-array value in the form of hash
264
+ # For object, use to_hash. Otherwise, just return the value
265
+ # @param [Object] value Any valid value
266
+ # @return [Hash] Returns the value in the form of hash
267
+ def _to_hash(value)
268
+ if value.is_a?(Array)
269
+ value.compact.map { |v| _to_hash(v) }
270
+ elsif value.is_a?(Hash)
271
+ {}.tap do |hash|
272
+ value.each { |k, v| hash[k] = _to_hash(v) }
273
+ end
274
+ elsif value.respond_to? :to_hash
275
+ value.to_hash
276
+ else
277
+ value
278
+ end
279
+ end
280
+
281
+ end
282
+
283
+ end
@@ -16,9 +16,6 @@ module Fastly
16
16
  # The name for the snippet.
17
17
  attr_accessor :name
18
18
 
19
- # Sets the snippet version.
20
- attr_accessor :dynamic
21
-
22
19
  # The location in generated VCL where the snippet should be placed.
23
20
  attr_accessor :type
24
21
 
@@ -28,6 +25,9 @@ module Fastly
28
25
  # Priority determines execution order. Lower numbers execute first.
29
26
  attr_accessor :priority
30
27
 
28
+ # Sets the snippet version.
29
+ attr_accessor :dynamic
30
+
31
31
  # Date and time in ISO 8601 format.
32
32
  attr_accessor :created_at
33
33
 
@@ -70,10 +70,10 @@ module Fastly
70
70
  def self.attribute_map
71
71
  {
72
72
  :'name' => :'name',
73
- :'dynamic' => :'dynamic',
74
73
  :'type' => :'type',
75
74
  :'content' => :'content',
76
75
  :'priority' => :'priority',
76
+ :'dynamic' => :'dynamic',
77
77
  :'created_at' => :'created_at',
78
78
  :'deleted_at' => :'deleted_at',
79
79
  :'updated_at' => :'updated_at',
@@ -92,10 +92,10 @@ module Fastly
92
92
  def self.fastly_types
93
93
  {
94
94
  :'name' => :'String',
95
- :'dynamic' => :'String',
96
95
  :'type' => :'String',
97
96
  :'content' => :'String',
98
97
  :'priority' => :'String',
98
+ :'dynamic' => :'String',
99
99
  :'created_at' => :'Time',
100
100
  :'deleted_at' => :'Time',
101
101
  :'updated_at' => :'Time',
@@ -118,8 +118,7 @@ module Fastly
118
118
  def self.fastly_all_of
119
119
  [
120
120
  :'Snippet',
121
- :'SnippetResponseAllOf',
122
- :'Timestamps'
121
+ :'SnippetResponseCommon'
123
122
  ]
124
123
  end
125
124
 
@@ -142,10 +141,6 @@ module Fastly
142
141
  self.name = attributes[:'name']
143
142
  end
144
143
 
145
- if attributes.key?(:'dynamic')
146
- self.dynamic = attributes[:'dynamic']
147
- end
148
-
149
144
  if attributes.key?(:'type')
150
145
  self.type = attributes[:'type']
151
146
  end
@@ -160,6 +155,10 @@ module Fastly
160
155
  self.priority = '100'
161
156
  end
162
157
 
158
+ if attributes.key?(:'dynamic')
159
+ self.dynamic = attributes[:'dynamic']
160
+ end
161
+
163
162
  if attributes.key?(:'created_at')
164
163
  self.created_at = attributes[:'created_at']
165
164
  end
@@ -195,23 +194,13 @@ module Fastly
195
194
  # Check to see if the all the properties in the model are valid
196
195
  # @return true if the model is valid
197
196
  def valid?
198
- dynamic_validator = EnumAttributeValidator.new('String', ["0", "1"])
199
- return false unless dynamic_validator.valid?(@dynamic)
200
197
  type_validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
201
198
  return false unless type_validator.valid?(@type)
199
+ dynamic_validator = EnumAttributeValidator.new('String', ["0", "1"])
200
+ return false unless dynamic_validator.valid?(@dynamic)
202
201
  true
203
202
  end
204
203
 
205
- # Custom attribute writer method checking allowed values (enum).
206
- # @param [Object] dynamic Object to be assigned
207
- def dynamic=(dynamic)
208
- validator = EnumAttributeValidator.new('String', ["0", "1"])
209
- unless validator.valid?(dynamic)
210
- fail ArgumentError, "invalid value for \"dynamic\", must be one of #{validator.allowable_values}."
211
- end
212
- @dynamic = dynamic
213
- end
214
-
215
204
  # Custom attribute writer method checking allowed values (enum).
216
205
  # @param [Object] type Object to be assigned
217
206
  def type=(type)
@@ -222,16 +211,26 @@ module Fastly
222
211
  @type = type
223
212
  end
224
213
 
214
+ # Custom attribute writer method checking allowed values (enum).
215
+ # @param [Object] dynamic Object to be assigned
216
+ def dynamic=(dynamic)
217
+ validator = EnumAttributeValidator.new('String', ["0", "1"])
218
+ unless validator.valid?(dynamic)
219
+ fail ArgumentError, "invalid value for \"dynamic\", must be one of #{validator.allowable_values}."
220
+ end
221
+ @dynamic = dynamic
222
+ end
223
+
225
224
  # Checks equality by comparing each attribute.
226
225
  # @param [Object] Object to be compared
227
226
  def ==(o)
228
227
  return true if self.equal?(o)
229
228
  self.class == o.class &&
230
229
  name == o.name &&
231
- dynamic == o.dynamic &&
232
230
  type == o.type &&
233
231
  content == o.content &&
234
232
  priority == o.priority &&
233
+ dynamic == o.dynamic &&
235
234
  created_at == o.created_at &&
236
235
  deleted_at == o.deleted_at &&
237
236
  updated_at == o.updated_at &&
@@ -249,7 +248,7 @@ module Fastly
249
248
  # Calculates hash code according to all attributes.
250
249
  # @return [Integer] Hash code
251
250
  def hash
252
- [name, dynamic, type, content, priority, created_at, deleted_at, updated_at, service_id, version, id].hash
251
+ [name, type, content, priority, dynamic, created_at, deleted_at, updated_at, service_id, version, id].hash
253
252
  end
254
253
 
255
254
  # Builds the object from hash
@@ -0,0 +1,276 @@
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 SnippetResponseCommon
16
+ # Date and time in ISO 8601 format.
17
+ attr_accessor :created_at
18
+
19
+ # Date and time in ISO 8601 format.
20
+ attr_accessor :deleted_at
21
+
22
+ # Date and time in ISO 8601 format.
23
+ attr_accessor :updated_at
24
+
25
+ attr_accessor :service_id
26
+
27
+ # String representing the number identifying a version of the service.
28
+ attr_accessor :version
29
+
30
+ attr_accessor :id
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'created_at' => :'created_at',
36
+ :'deleted_at' => :'deleted_at',
37
+ :'updated_at' => :'updated_at',
38
+ :'service_id' => :'service_id',
39
+ :'version' => :'version',
40
+ :'id' => :'id'
41
+ }
42
+ end
43
+
44
+ # Returns all the JSON keys this model knows about
45
+ def self.acceptable_attributes
46
+ attribute_map.values
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.fastly_types
51
+ {
52
+ :'created_at' => :'Time',
53
+ :'deleted_at' => :'Time',
54
+ :'updated_at' => :'Time',
55
+ :'service_id' => :'String',
56
+ :'version' => :'String',
57
+ :'id' => :'String'
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.fastly_nullable
63
+ Set.new([
64
+ :'created_at',
65
+ :'deleted_at',
66
+ :'updated_at',
67
+ ])
68
+ end
69
+
70
+ # List of class defined in allOf (OpenAPI v3)
71
+ def self.fastly_all_of
72
+ [
73
+ :'SnippetResponseCommonAllOf',
74
+ :'Timestamps'
75
+ ]
76
+ end
77
+
78
+ # Initializes the object
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ def initialize(attributes = {})
81
+ if (!attributes.is_a?(Hash))
82
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::SnippetResponseCommon` initialize method"
83
+ end
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!self.class.attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::SnippetResponseCommon`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'created_at')
94
+ self.created_at = attributes[:'created_at']
95
+ end
96
+
97
+ if attributes.key?(:'deleted_at')
98
+ self.deleted_at = attributes[:'deleted_at']
99
+ end
100
+
101
+ if attributes.key?(:'updated_at')
102
+ self.updated_at = attributes[:'updated_at']
103
+ end
104
+
105
+ if attributes.key?(:'service_id')
106
+ self.service_id = attributes[:'service_id']
107
+ end
108
+
109
+ if attributes.key?(:'version')
110
+ self.version = attributes[:'version']
111
+ end
112
+
113
+ if attributes.key?(:'id')
114
+ self.id = attributes[:'id']
115
+ end
116
+ end
117
+
118
+ # Show invalid properties with the reasons. Usually used together with valid?
119
+ # @return Array for valid properties with the reasons
120
+ def list_invalid_properties
121
+ invalid_properties = Array.new
122
+ invalid_properties
123
+ end
124
+
125
+ # Check to see if the all the properties in the model are valid
126
+ # @return true if the model is valid
127
+ def valid?
128
+ true
129
+ end
130
+
131
+ # Checks equality by comparing each attribute.
132
+ # @param [Object] Object to be compared
133
+ def ==(o)
134
+ return true if self.equal?(o)
135
+ self.class == o.class &&
136
+ created_at == o.created_at &&
137
+ deleted_at == o.deleted_at &&
138
+ updated_at == o.updated_at &&
139
+ service_id == o.service_id &&
140
+ version == o.version &&
141
+ id == o.id
142
+ end
143
+
144
+ # @see the `==` method
145
+ # @param [Object] Object to be compared
146
+ def eql?(o)
147
+ self == o
148
+ end
149
+
150
+ # Calculates hash code according to all attributes.
151
+ # @return [Integer] Hash code
152
+ def hash
153
+ [created_at, deleted_at, updated_at, service_id, version, id].hash
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def self.build_from_hash(attributes)
160
+ new.build_from_hash(attributes)
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ self.class.fastly_types.each_pair do |key, type|
169
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
170
+ self.send("#{key}=", nil)
171
+ elsif type =~ /\AArray<(.*)>/i
172
+ # check to ensure the input is an array given that the attribute
173
+ # is documented as an array but the input is not
174
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
175
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
176
+ end
177
+ elsif !attributes[self.class.attribute_map[key]].nil?
178
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
179
+ end
180
+ end
181
+
182
+ self
183
+ end
184
+
185
+ # Deserializes the data based on type
186
+ # @param string type Data type
187
+ # @param string value Value to be deserialized
188
+ # @return [Object] Deserialized data
189
+ def _deserialize(type, value)
190
+ case type.to_sym
191
+ when :Time
192
+ Time.parse(value)
193
+ when :Date
194
+ Date.parse(value)
195
+ when :String
196
+ value.to_s
197
+ when :Integer
198
+ value.to_i
199
+ when :Float
200
+ value.to_f
201
+ when :Boolean
202
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
203
+ true
204
+ else
205
+ false
206
+ end
207
+ when :Object
208
+ # generic object (usually a Hash), return directly
209
+ value
210
+ when /\AArray<(?<inner_type>.+)>\z/
211
+ inner_type = Regexp.last_match[:inner_type]
212
+ value.map { |v| _deserialize(inner_type, v) }
213
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
214
+ k_type = Regexp.last_match[:k_type]
215
+ v_type = Regexp.last_match[:v_type]
216
+ {}.tap do |hash|
217
+ value.each do |k, v|
218
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
219
+ end
220
+ end
221
+ else # model
222
+ # models (e.g. Pet) or oneOf
223
+ klass = Fastly.const_get(type)
224
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
225
+ end
226
+ end
227
+
228
+ # Returns the string representation of the object
229
+ # @return [String] String presentation of the object
230
+ def to_s
231
+ to_hash.to_s
232
+ end
233
+
234
+ # to_body is an alias to to_hash (backward compatibility)
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_body
237
+ to_hash
238
+ end
239
+
240
+ # Returns the object in the form of hash
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_hash
243
+ hash = {}
244
+ self.class.attribute_map.each_pair do |attr, param|
245
+ value = self.send(attr)
246
+ if value.nil?
247
+ is_nullable = self.class.fastly_nullable.include?(attr)
248
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
249
+ end
250
+
251
+ hash[param] = _to_hash(value)
252
+ end
253
+ hash
254
+ end
255
+
256
+ # Outputs non-array value in the form of hash
257
+ # For object, use to_hash. Otherwise, just return the value
258
+ # @param [Object] value Any valid value
259
+ # @return [Hash] Returns the value in the form of hash
260
+ def _to_hash(value)
261
+ if value.is_a?(Array)
262
+ value.compact.map { |v| _to_hash(v) }
263
+ elsif value.is_a?(Hash)
264
+ {}.tap do |hash|
265
+ value.each { |k, v| hash[k] = _to_hash(v) }
266
+ end
267
+ elsif value.respond_to? :to_hash
268
+ value.to_hash
269
+ else
270
+ value
271
+ end
272
+ end
273
+
274
+ end
275
+
276
+ end