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
@@ -12,7 +12,7 @@ require 'date'
12
12
  require 'time'
13
13
 
14
14
  module Fastly
15
- class SnippetResponseAllOf
15
+ class SnippetResponseCommonAllOf
16
16
  attr_accessor :service_id
17
17
 
18
18
  # String representing the number identifying a version of the service.
@@ -53,13 +53,13 @@ module Fastly
53
53
  # @param [Hash] attributes Model attributes in the form of hash
54
54
  def initialize(attributes = {})
55
55
  if (!attributes.is_a?(Hash))
56
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::SnippetResponseAllOf` initialize method"
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::SnippetResponseCommonAllOf` initialize method"
57
57
  end
58
58
 
59
59
  # check to see if the attribute exists and convert string to symbol for hash key
60
60
  attributes = attributes.each_with_object({}) { |(k, v), h|
61
61
  if (!self.class.attribute_map.key?(k.to_sym))
62
- fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::SnippetResponseAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::SnippetResponseCommonAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
63
  end
64
64
  h[k.to_sym] = v
65
65
  }
@@ -0,0 +1,374 @@
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 SnippetResponsePost
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
+ # Sets the snippet version.
29
+ attr_accessor :dynamic
30
+
31
+ # Date and time in ISO 8601 format.
32
+ attr_accessor :created_at
33
+
34
+ # Date and time in ISO 8601 format.
35
+ attr_accessor :deleted_at
36
+
37
+ # Date and time in ISO 8601 format.
38
+ attr_accessor :updated_at
39
+
40
+ attr_accessor :service_id
41
+
42
+ # String representing the number identifying a version of the service.
43
+ attr_accessor :version
44
+
45
+ attr_accessor :id
46
+
47
+ class EnumAttributeValidator
48
+ attr_reader :datatype
49
+ attr_reader :allowable_values
50
+
51
+ def initialize(datatype, allowable_values)
52
+ @allowable_values = allowable_values.map do |value|
53
+ case datatype.to_s
54
+ when /Integer/i
55
+ value.to_i
56
+ when /Float/i
57
+ value.to_f
58
+ else
59
+ value
60
+ end
61
+ end
62
+ end
63
+
64
+ def valid?(value)
65
+ !value || allowable_values.include?(value)
66
+ end
67
+ end
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'name' => :'name',
73
+ :'type' => :'type',
74
+ :'content' => :'content',
75
+ :'priority' => :'priority',
76
+ :'dynamic' => :'dynamic',
77
+ :'created_at' => :'created_at',
78
+ :'deleted_at' => :'deleted_at',
79
+ :'updated_at' => :'updated_at',
80
+ :'service_id' => :'service_id',
81
+ :'version' => :'version',
82
+ :'id' => :'id'
83
+ }
84
+ end
85
+
86
+ # Returns all the JSON keys this model knows about
87
+ def self.acceptable_attributes
88
+ attribute_map.values
89
+ end
90
+
91
+ # Attribute type mapping.
92
+ def self.fastly_types
93
+ {
94
+ :'name' => :'String',
95
+ :'type' => :'String',
96
+ :'content' => :'String',
97
+ :'priority' => :'String',
98
+ :'dynamic' => :'Float',
99
+ :'created_at' => :'Time',
100
+ :'deleted_at' => :'Time',
101
+ :'updated_at' => :'Time',
102
+ :'service_id' => :'String',
103
+ :'version' => :'String',
104
+ :'id' => :'String'
105
+ }
106
+ end
107
+
108
+ # List of attributes with nullable: true
109
+ def self.fastly_nullable
110
+ Set.new([
111
+ :'created_at',
112
+ :'deleted_at',
113
+ :'updated_at',
114
+ ])
115
+ end
116
+
117
+ # List of class defined in allOf (OpenAPI v3)
118
+ def self.fastly_all_of
119
+ [
120
+ :'SnippetResponseCommon',
121
+ :'SnippetWithDynamicNumber'
122
+ ]
123
+ end
124
+
125
+ # Initializes the object
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ def initialize(attributes = {})
128
+ if (!attributes.is_a?(Hash))
129
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::SnippetResponsePost` initialize method"
130
+ end
131
+
132
+ # check to see if the attribute exists and convert string to symbol for hash key
133
+ attributes = attributes.each_with_object({}) { |(k, v), h|
134
+ if (!self.class.attribute_map.key?(k.to_sym))
135
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::SnippetResponsePost`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
136
+ end
137
+ h[k.to_sym] = v
138
+ }
139
+
140
+ if attributes.key?(:'name')
141
+ self.name = attributes[:'name']
142
+ end
143
+
144
+ if attributes.key?(:'type')
145
+ self.type = attributes[:'type']
146
+ end
147
+
148
+ if attributes.key?(:'content')
149
+ self.content = attributes[:'content']
150
+ end
151
+
152
+ if attributes.key?(:'priority')
153
+ self.priority = attributes[:'priority']
154
+ else
155
+ self.priority = '100'
156
+ end
157
+
158
+ if attributes.key?(:'dynamic')
159
+ self.dynamic = attributes[:'dynamic']
160
+ end
161
+
162
+ if attributes.key?(:'created_at')
163
+ self.created_at = attributes[:'created_at']
164
+ end
165
+
166
+ if attributes.key?(:'deleted_at')
167
+ self.deleted_at = attributes[:'deleted_at']
168
+ end
169
+
170
+ if attributes.key?(:'updated_at')
171
+ self.updated_at = attributes[:'updated_at']
172
+ end
173
+
174
+ if attributes.key?(:'service_id')
175
+ self.service_id = attributes[:'service_id']
176
+ end
177
+
178
+ if attributes.key?(:'version')
179
+ self.version = attributes[:'version']
180
+ end
181
+
182
+ if attributes.key?(:'id')
183
+ self.id = attributes[:'id']
184
+ end
185
+ end
186
+
187
+ # Show invalid properties with the reasons. Usually used together with valid?
188
+ # @return Array for valid properties with the reasons
189
+ def list_invalid_properties
190
+ invalid_properties = Array.new
191
+ invalid_properties
192
+ end
193
+
194
+ # Check to see if the all the properties in the model are valid
195
+ # @return true if the model is valid
196
+ def valid?
197
+ type_validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
198
+ return false unless type_validator.valid?(@type)
199
+ dynamic_validator = EnumAttributeValidator.new('Float', [0, 1])
200
+ return false unless dynamic_validator.valid?(@dynamic)
201
+ true
202
+ end
203
+
204
+ # Custom attribute writer method checking allowed values (enum).
205
+ # @param [Object] type Object to be assigned
206
+ def type=(type)
207
+ validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
208
+ unless validator.valid?(type)
209
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
210
+ end
211
+ @type = type
212
+ end
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('Float', [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
+
224
+ # Checks equality by comparing each attribute.
225
+ # @param [Object] Object to be compared
226
+ def ==(o)
227
+ return true if self.equal?(o)
228
+ self.class == o.class &&
229
+ name == o.name &&
230
+ type == o.type &&
231
+ content == o.content &&
232
+ priority == o.priority &&
233
+ dynamic == o.dynamic &&
234
+ created_at == o.created_at &&
235
+ deleted_at == o.deleted_at &&
236
+ updated_at == o.updated_at &&
237
+ service_id == o.service_id &&
238
+ version == o.version &&
239
+ id == o.id
240
+ end
241
+
242
+ # @see the `==` method
243
+ # @param [Object] Object to be compared
244
+ def eql?(o)
245
+ self == o
246
+ end
247
+
248
+ # Calculates hash code according to all attributes.
249
+ # @return [Integer] Hash code
250
+ def hash
251
+ [name, type, content, priority, dynamic, created_at, deleted_at, updated_at, service_id, version, id].hash
252
+ end
253
+
254
+ # Builds the object from hash
255
+ # @param [Hash] attributes Model attributes in the form of hash
256
+ # @return [Object] Returns the model itself
257
+ def self.build_from_hash(attributes)
258
+ new.build_from_hash(attributes)
259
+ end
260
+
261
+ # Builds the object from hash
262
+ # @param [Hash] attributes Model attributes in the form of hash
263
+ # @return [Object] Returns the model itself
264
+ def build_from_hash(attributes)
265
+ return nil unless attributes.is_a?(Hash)
266
+ self.class.fastly_types.each_pair do |key, type|
267
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
268
+ self.send("#{key}=", nil)
269
+ elsif type =~ /\AArray<(.*)>/i
270
+ # check to ensure the input is an array given that the attribute
271
+ # is documented as an array but the input is not
272
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
273
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
274
+ end
275
+ elsif !attributes[self.class.attribute_map[key]].nil?
276
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
277
+ end
278
+ end
279
+
280
+ self
281
+ end
282
+
283
+ # Deserializes the data based on type
284
+ # @param string type Data type
285
+ # @param string value Value to be deserialized
286
+ # @return [Object] Deserialized data
287
+ def _deserialize(type, value)
288
+ case type.to_sym
289
+ when :Time
290
+ Time.parse(value)
291
+ when :Date
292
+ Date.parse(value)
293
+ when :String
294
+ value.to_s
295
+ when :Integer
296
+ value.to_i
297
+ when :Float
298
+ value.to_f
299
+ when :Boolean
300
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
301
+ true
302
+ else
303
+ false
304
+ end
305
+ when :Object
306
+ # generic object (usually a Hash), return directly
307
+ value
308
+ when /\AArray<(?<inner_type>.+)>\z/
309
+ inner_type = Regexp.last_match[:inner_type]
310
+ value.map { |v| _deserialize(inner_type, v) }
311
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
312
+ k_type = Regexp.last_match[:k_type]
313
+ v_type = Regexp.last_match[:v_type]
314
+ {}.tap do |hash|
315
+ value.each do |k, v|
316
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
317
+ end
318
+ end
319
+ else # model
320
+ # models (e.g. Pet) or oneOf
321
+ klass = Fastly.const_get(type)
322
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
323
+ end
324
+ end
325
+
326
+ # Returns the string representation of the object
327
+ # @return [String] String presentation of the object
328
+ def to_s
329
+ to_hash.to_s
330
+ end
331
+
332
+ # to_body is an alias to to_hash (backward compatibility)
333
+ # @return [Hash] Returns the object in the form of hash
334
+ def to_body
335
+ to_hash
336
+ end
337
+
338
+ # Returns the object in the form of hash
339
+ # @return [Hash] Returns the object in the form of hash
340
+ def to_hash
341
+ hash = {}
342
+ self.class.attribute_map.each_pair do |attr, param|
343
+ value = self.send(attr)
344
+ if value.nil?
345
+ is_nullable = self.class.fastly_nullable.include?(attr)
346
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
347
+ end
348
+
349
+ hash[param] = _to_hash(value)
350
+ end
351
+ hash
352
+ end
353
+
354
+ # Outputs non-array value in the form of hash
355
+ # For object, use to_hash. Otherwise, just return the value
356
+ # @param [Object] value Any valid value
357
+ # @return [Hash] Returns the value in the form of hash
358
+ def _to_hash(value)
359
+ if value.is_a?(Array)
360
+ value.compact.map { |v| _to_hash(v) }
361
+ elsif value.is_a?(Hash)
362
+ {}.tap do |hash|
363
+ value.each { |k, v| hash[k] = _to_hash(v) }
364
+ end
365
+ elsif value.respond_to? :to_hash
366
+ value.to_hash
367
+ else
368
+ value
369
+ end
370
+ end
371
+
372
+ end
373
+
374
+ end
@@ -0,0 +1,313 @@
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 SnippetWithDynamicNumber
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
+ # Sets the snippet version.
29
+ attr_accessor :dynamic
30
+
31
+ class EnumAttributeValidator
32
+ attr_reader :datatype
33
+ attr_reader :allowable_values
34
+
35
+ def initialize(datatype, allowable_values)
36
+ @allowable_values = allowable_values.map do |value|
37
+ case datatype.to_s
38
+ when /Integer/i
39
+ value.to_i
40
+ when /Float/i
41
+ value.to_f
42
+ else
43
+ value
44
+ end
45
+ end
46
+ end
47
+
48
+ def valid?(value)
49
+ !value || allowable_values.include?(value)
50
+ end
51
+ end
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'name' => :'name',
57
+ :'type' => :'type',
58
+ :'content' => :'content',
59
+ :'priority' => :'priority',
60
+ :'dynamic' => :'dynamic'
61
+ }
62
+ end
63
+
64
+ # Returns all the JSON keys this model knows about
65
+ def self.acceptable_attributes
66
+ attribute_map.values
67
+ end
68
+
69
+ # Attribute type mapping.
70
+ def self.fastly_types
71
+ {
72
+ :'name' => :'String',
73
+ :'type' => :'String',
74
+ :'content' => :'String',
75
+ :'priority' => :'String',
76
+ :'dynamic' => :'Float'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.fastly_nullable
82
+ Set.new([
83
+ ])
84
+ end
85
+
86
+ # List of class defined in allOf (OpenAPI v3)
87
+ def self.fastly_all_of
88
+ [
89
+ :'SnippetCommon',
90
+ :'SnippetWithDynamicNumberAllOf'
91
+ ]
92
+ end
93
+
94
+ # Initializes the object
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ def initialize(attributes = {})
97
+ if (!attributes.is_a?(Hash))
98
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::SnippetWithDynamicNumber` initialize method"
99
+ end
100
+
101
+ # check to see if the attribute exists and convert string to symbol for hash key
102
+ attributes = attributes.each_with_object({}) { |(k, v), h|
103
+ if (!self.class.attribute_map.key?(k.to_sym))
104
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::SnippetWithDynamicNumber`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
105
+ end
106
+ h[k.to_sym] = v
107
+ }
108
+
109
+ if attributes.key?(:'name')
110
+ self.name = attributes[:'name']
111
+ end
112
+
113
+ if attributes.key?(:'type')
114
+ self.type = attributes[:'type']
115
+ end
116
+
117
+ if attributes.key?(:'content')
118
+ self.content = attributes[:'content']
119
+ end
120
+
121
+ if attributes.key?(:'priority')
122
+ self.priority = attributes[:'priority']
123
+ else
124
+ self.priority = '100'
125
+ end
126
+
127
+ if attributes.key?(:'dynamic')
128
+ self.dynamic = attributes[:'dynamic']
129
+ end
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ invalid_properties = Array.new
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ type_validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
143
+ return false unless type_validator.valid?(@type)
144
+ dynamic_validator = EnumAttributeValidator.new('Float', [0, 1])
145
+ return false unless dynamic_validator.valid?(@dynamic)
146
+ true
147
+ end
148
+
149
+ # Custom attribute writer method checking allowed values (enum).
150
+ # @param [Object] type Object to be assigned
151
+ def type=(type)
152
+ validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
153
+ unless validator.valid?(type)
154
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
155
+ end
156
+ @type = type
157
+ end
158
+
159
+ # Custom attribute writer method checking allowed values (enum).
160
+ # @param [Object] dynamic Object to be assigned
161
+ def dynamic=(dynamic)
162
+ validator = EnumAttributeValidator.new('Float', [0, 1])
163
+ unless validator.valid?(dynamic)
164
+ fail ArgumentError, "invalid value for \"dynamic\", must be one of #{validator.allowable_values}."
165
+ end
166
+ @dynamic = dynamic
167
+ end
168
+
169
+ # Checks equality by comparing each attribute.
170
+ # @param [Object] Object to be compared
171
+ def ==(o)
172
+ return true if self.equal?(o)
173
+ self.class == o.class &&
174
+ name == o.name &&
175
+ type == o.type &&
176
+ content == o.content &&
177
+ priority == o.priority &&
178
+ dynamic == o.dynamic
179
+ end
180
+
181
+ # @see the `==` method
182
+ # @param [Object] Object to be compared
183
+ def eql?(o)
184
+ self == o
185
+ end
186
+
187
+ # Calculates hash code according to all attributes.
188
+ # @return [Integer] Hash code
189
+ def hash
190
+ [name, type, content, priority, dynamic].hash
191
+ end
192
+
193
+ # Builds the object from hash
194
+ # @param [Hash] attributes Model attributes in the form of hash
195
+ # @return [Object] Returns the model itself
196
+ def self.build_from_hash(attributes)
197
+ new.build_from_hash(attributes)
198
+ end
199
+
200
+ # Builds the object from hash
201
+ # @param [Hash] attributes Model attributes in the form of hash
202
+ # @return [Object] Returns the model itself
203
+ def build_from_hash(attributes)
204
+ return nil unless attributes.is_a?(Hash)
205
+ self.class.fastly_types.each_pair do |key, type|
206
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
207
+ self.send("#{key}=", nil)
208
+ elsif type =~ /\AArray<(.*)>/i
209
+ # check to ensure the input is an array given that the attribute
210
+ # is documented as an array but the input is not
211
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
212
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
213
+ end
214
+ elsif !attributes[self.class.attribute_map[key]].nil?
215
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
216
+ end
217
+ end
218
+
219
+ self
220
+ end
221
+
222
+ # Deserializes the data based on type
223
+ # @param string type Data type
224
+ # @param string value Value to be deserialized
225
+ # @return [Object] Deserialized data
226
+ def _deserialize(type, value)
227
+ case type.to_sym
228
+ when :Time
229
+ Time.parse(value)
230
+ when :Date
231
+ Date.parse(value)
232
+ when :String
233
+ value.to_s
234
+ when :Integer
235
+ value.to_i
236
+ when :Float
237
+ value.to_f
238
+ when :Boolean
239
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
240
+ true
241
+ else
242
+ false
243
+ end
244
+ when :Object
245
+ # generic object (usually a Hash), return directly
246
+ value
247
+ when /\AArray<(?<inner_type>.+)>\z/
248
+ inner_type = Regexp.last_match[:inner_type]
249
+ value.map { |v| _deserialize(inner_type, v) }
250
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
251
+ k_type = Regexp.last_match[:k_type]
252
+ v_type = Regexp.last_match[:v_type]
253
+ {}.tap do |hash|
254
+ value.each do |k, v|
255
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
256
+ end
257
+ end
258
+ else # model
259
+ # models (e.g. Pet) or oneOf
260
+ klass = Fastly.const_get(type)
261
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
262
+ end
263
+ end
264
+
265
+ # Returns the string representation of the object
266
+ # @return [String] String presentation of the object
267
+ def to_s
268
+ to_hash.to_s
269
+ end
270
+
271
+ # to_body is an alias to to_hash (backward compatibility)
272
+ # @return [Hash] Returns the object in the form of hash
273
+ def to_body
274
+ to_hash
275
+ end
276
+
277
+ # Returns the object in the form of hash
278
+ # @return [Hash] Returns the object in the form of hash
279
+ def to_hash
280
+ hash = {}
281
+ self.class.attribute_map.each_pair do |attr, param|
282
+ value = self.send(attr)
283
+ if value.nil?
284
+ is_nullable = self.class.fastly_nullable.include?(attr)
285
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
286
+ end
287
+
288
+ hash[param] = _to_hash(value)
289
+ end
290
+ hash
291
+ end
292
+
293
+ # Outputs non-array value in the form of hash
294
+ # For object, use to_hash. Otherwise, just return the value
295
+ # @param [Object] value Any valid value
296
+ # @return [Hash] Returns the value in the form of hash
297
+ def _to_hash(value)
298
+ if value.is_a?(Array)
299
+ value.compact.map { |v| _to_hash(v) }
300
+ elsif value.is_a?(Hash)
301
+ {}.tap do |hash|
302
+ value.each { |k, v| hash[k] = _to_hash(v) }
303
+ end
304
+ elsif value.respond_to? :to_hash
305
+ value.to_hash
306
+ else
307
+ value
308
+ end
309
+ end
310
+
311
+ end
312
+
313
+ end