fastly 8.0.1 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +198 -130
  3. data/Gemfile.lock +1 -1
  4. data/README.md +13 -7
  5. data/docs/{ErrorResponse.md → AutomationTokenErrorResponse.md} +1 -1
  6. data/docs/AutomationTokensApi.md +2 -2
  7. data/docs/Backend.md +1 -1
  8. data/docs/BackendApi.md +4 -4
  9. data/docs/BackendResponse.md +1 -1
  10. data/docs/BillingInvoicesApi.md +96 -0
  11. data/docs/Director.md +1 -1
  12. data/docs/DirectorApi.md +2 -2
  13. data/docs/DirectorResponse.md +1 -1
  14. data/docs/DomainInspectorHistoricalApi.md +4 -4
  15. data/docs/DomainInspectorRealtimeEntry.md +1 -1
  16. data/docs/Error.md +13 -0
  17. data/docs/ErrorResponseData.md +11 -0
  18. data/docs/Invoice.md +18 -0
  19. data/docs/InvoiceResponse.md +18 -0
  20. data/docs/Invoicelineitems.md +18 -0
  21. data/docs/KvStoreApi.md +1 -1
  22. data/docs/ListInvoicesResponse.md +11 -0
  23. data/docs/Listinvoices.md +11 -0
  24. data/docs/LoggingScalyrAdditional.md +1 -1
  25. data/docs/LoggingScalyrApi.md +4 -4
  26. data/docs/LoggingScalyrResponse.md +1 -1
  27. data/docs/Metadata.md +13 -0
  28. data/docs/OriginInspectorHistoricalApi.md +4 -4
  29. data/docs/OriginInspectorRealtimeEntry.md +1 -1
  30. data/docs/PoolAdditional.md +1 -1
  31. data/docs/PoolApi.md +4 -4
  32. data/docs/PoolResponse.md +1 -1
  33. data/docs/PoolResponsePost.md +1 -1
  34. data/docs/Pop.md +2 -2
  35. data/docs/PublishApi.md +1 -1
  36. data/docs/RealtimeEntry.md +1 -1
  37. data/docs/Results.md +2 -0
  38. data/docs/SecretStoreApi.md +4 -2
  39. data/docs/SecretStoreItemApi.md +2 -2
  40. data/docs/ServiceDetail.md +1 -1
  41. data/docs/ServiceListResponse.md +2 -2
  42. data/docs/ServiceListResponseAllOf.md +2 -2
  43. data/docs/ServiceResponse.md +1 -1
  44. data/docs/ServiceResponseAllOf.md +1 -1
  45. data/docs/TlsConfigurationResponseAttributes.md +1 -1
  46. data/docs/TlsConfigurationResponseAttributesAllOf.md +1 -1
  47. data/docs/TlsCsr.md +10 -0
  48. data/docs/TlsCsrData.md +12 -0
  49. data/docs/TlsCsrDataAttributes.md +20 -0
  50. data/docs/TlsCsrErrorResponse.md +10 -0
  51. data/docs/TlsCsrResponse.md +10 -0
  52. data/docs/TlsCsrResponseAttributes.md +10 -0
  53. data/docs/TlsCsrResponseData.md +13 -0
  54. data/docs/TlsCsrsApi.md +52 -0
  55. data/docs/TlsSubscriptionResponseAttributes.md +1 -0
  56. data/docs/TlsSubscriptionResponseAttributesAllOf.md +1 -0
  57. data/docs/TokensApi.md +1 -1
  58. data/docs/TypeTlsCsr.md +9 -0
  59. data/docs/VclApi.md +1 -1
  60. data/docs/WafActiveRulesApi.md +1 -1
  61. data/lib/fastly/api/automation_tokens_api.rb +3 -3
  62. data/lib/fastly/api/backend_api.rb +4 -4
  63. data/lib/fastly/api/billing_invoices_api.rb +151 -0
  64. data/lib/fastly/api/director_api.rb +2 -2
  65. data/lib/fastly/api/domain_inspector_historical_api.rb +4 -4
  66. data/lib/fastly/api/kv_store_api.rb +2 -2
  67. data/lib/fastly/api/logging_scalyr_api.rb +4 -4
  68. data/lib/fastly/api/origin_inspector_historical_api.rb +4 -4
  69. data/lib/fastly/api/pool_api.rb +4 -4
  70. data/lib/fastly/api/publish_api.rb +2 -2
  71. data/lib/fastly/api/secret_store_api.rb +5 -2
  72. data/lib/fastly/api/secret_store_item_api.rb +2 -2
  73. data/lib/fastly/api/tls_csrs_api.rb +83 -0
  74. data/lib/fastly/api/tokens_api.rb +2 -2
  75. data/lib/fastly/api/vcl_api.rb +2 -2
  76. data/lib/fastly/api/waf_active_rules_api.rb +2 -2
  77. data/lib/fastly/configuration.rb +18 -0
  78. data/lib/fastly/models/{error_response.rb → automation_token_error_response.rb} +3 -3
  79. data/lib/fastly/models/backend.rb +1 -1
  80. data/lib/fastly/models/backend_response.rb +1 -1
  81. data/lib/fastly/models/director.rb +1 -1
  82. data/lib/fastly/models/director_response.rb +1 -1
  83. data/lib/fastly/models/domain_inspector_realtime_entry.rb +1 -1
  84. data/lib/fastly/models/error.rb +243 -0
  85. data/lib/fastly/models/error_response_data.rb +225 -0
  86. data/lib/fastly/models/event_attributes.rb +2 -2
  87. data/lib/fastly/models/invoice.rb +298 -0
  88. data/lib/fastly/models/invoice_response.rb +305 -0
  89. data/lib/fastly/models/invoicelineitems.rb +297 -0
  90. data/lib/fastly/models/list_invoices_response.rb +234 -0
  91. data/lib/fastly/models/listinvoices.rb +227 -0
  92. data/lib/fastly/models/logging_scalyr_additional.rb +1 -1
  93. data/lib/fastly/models/logging_scalyr_response.rb +1 -1
  94. data/lib/fastly/models/metadata.rb +250 -0
  95. data/lib/fastly/models/origin_inspector_realtime_entry.rb +1 -1
  96. data/lib/fastly/models/pool_additional.rb +1 -1
  97. data/lib/fastly/models/pool_response.rb +1 -1
  98. data/lib/fastly/models/pool_response_post.rb +1 -1
  99. data/lib/fastly/models/pop.rb +2 -2
  100. data/lib/fastly/models/realtime_entry.rb +1 -1
  101. data/lib/fastly/models/relationship_tls_certificate.rb +1 -1
  102. data/lib/fastly/models/relationship_tls_configuration.rb +1 -1
  103. data/lib/fastly/models/results.rb +21 -1
  104. data/lib/fastly/models/service_detail.rb +1 -1
  105. data/lib/fastly/models/service_list_response.rb +2 -2
  106. data/lib/fastly/models/service_list_response_all_of.rb +2 -2
  107. data/lib/fastly/models/service_response.rb +1 -1
  108. data/lib/fastly/models/service_response_all_of.rb +1 -1
  109. data/lib/fastly/models/tls_configuration_response_attributes.rb +1 -1
  110. data/lib/fastly/models/tls_configuration_response_attributes_all_of.rb +1 -1
  111. data/lib/fastly/models/tls_csr.rb +216 -0
  112. data/lib/fastly/models/tls_csr_data.rb +236 -0
  113. data/lib/fastly/models/tls_csr_data_attributes.rb +358 -0
  114. data/lib/fastly/models/tls_csr_error_response.rb +218 -0
  115. data/lib/fastly/models/tls_csr_response.rb +216 -0
  116. data/lib/fastly/models/tls_csr_response_attributes.rb +217 -0
  117. data/lib/fastly/models/tls_csr_response_data.rb +245 -0
  118. data/lib/fastly/models/tls_subscription_data_attributes.rb +2 -2
  119. data/lib/fastly/models/tls_subscription_response_attributes.rb +14 -4
  120. data/lib/fastly/models/tls_subscription_response_attributes_all_of.rb +14 -4
  121. data/lib/fastly/models/type_tls_csr.rb +34 -0
  122. data/lib/fastly/version.rb +1 -1
  123. data/lib/fastly.rb +19 -1
  124. data/sig.json +1 -1
  125. metadata +40 -4
@@ -0,0 +1,358 @@
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 TlsCsrDataAttributes
16
+ # Subject Alternate Names - An array of one or more fully qualified domain names or public IP addresses to be secured by this certificate. Required.
17
+ attr_accessor :sans
18
+
19
+ # Common Name (CN) - The fully qualified domain name (FQDN) to be secured by this certificate. The common name should be one of the entries in the SANs parameter.
20
+ attr_accessor :common_name
21
+
22
+ # Country (C) - The two-letter ISO country code where the organization is located.
23
+ attr_accessor :country
24
+
25
+ # State (S) - The state, province, region, or county where the organization is located. This should not be abbreviated.
26
+ attr_accessor :state
27
+
28
+ # Locality (L) - The locality, city, town, or village where the organization is located.
29
+ attr_accessor :city
30
+
31
+ # Postal Code - The postal code where the organization is located.
32
+ attr_accessor :postal_code
33
+
34
+ # Street Address - The street address where the organization is located.
35
+ attr_accessor :street_address
36
+
37
+ # Organization (O) - The legal name of the organization, including any suffixes. This should not be abbreviated.
38
+ attr_accessor :organization
39
+
40
+ # Organizational Unit (OU) - The internal division of the organization managing the certificate.
41
+ attr_accessor :organizational_unit
42
+
43
+ # Email Address (EMAIL) - The organizational contact for this.
44
+ attr_accessor :email
45
+
46
+ # CSR Key Type.
47
+ attr_accessor :key_type
48
+
49
+ class EnumAttributeValidator
50
+ attr_reader :datatype
51
+ attr_reader :allowable_values
52
+
53
+ def initialize(datatype, allowable_values)
54
+ @allowable_values = allowable_values.map do |value|
55
+ case datatype.to_s
56
+ when /Integer/i
57
+ value.to_i
58
+ when /Float/i
59
+ value.to_f
60
+ else
61
+ value
62
+ end
63
+ end
64
+ end
65
+
66
+ def valid?(value)
67
+ !value || allowable_values.include?(value)
68
+ end
69
+ end
70
+
71
+ # Attribute mapping from ruby-style variable name to JSON key.
72
+ def self.attribute_map
73
+ {
74
+ :'sans' => :'sans',
75
+ :'common_name' => :'common_name',
76
+ :'country' => :'country',
77
+ :'state' => :'state',
78
+ :'city' => :'city',
79
+ :'postal_code' => :'postal_code',
80
+ :'street_address' => :'street_address',
81
+ :'organization' => :'organization',
82
+ :'organizational_unit' => :'organizational_unit',
83
+ :'email' => :'email',
84
+ :'key_type' => :'key_type'
85
+ }
86
+ end
87
+
88
+ # Returns all the JSON keys this model knows about
89
+ def self.acceptable_attributes
90
+ attribute_map.values
91
+ end
92
+
93
+ # Attribute type mapping.
94
+ def self.fastly_types
95
+ {
96
+ :'sans' => :'Array<String>',
97
+ :'common_name' => :'String',
98
+ :'country' => :'String',
99
+ :'state' => :'String',
100
+ :'city' => :'String',
101
+ :'postal_code' => :'String',
102
+ :'street_address' => :'String',
103
+ :'organization' => :'String',
104
+ :'organizational_unit' => :'String',
105
+ :'email' => :'String',
106
+ :'key_type' => :'String'
107
+ }
108
+ end
109
+
110
+ # List of attributes with nullable: true
111
+ def self.fastly_nullable
112
+ Set.new([
113
+ ])
114
+ end
115
+
116
+ # Initializes the object
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ def initialize(attributes = {})
119
+ if (!attributes.is_a?(Hash))
120
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::TlsCsrDataAttributes` initialize method"
121
+ end
122
+
123
+ # check to see if the attribute exists and convert string to symbol for hash key
124
+ attributes = attributes.each_with_object({}) { |(k, v), h|
125
+ if (!self.class.attribute_map.key?(k.to_sym))
126
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::TlsCsrDataAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
127
+ end
128
+ h[k.to_sym] = v
129
+ }
130
+
131
+ if attributes.key?(:'sans')
132
+ if (value = attributes[:'sans']).is_a?(Array)
133
+ self.sans = value
134
+ end
135
+ end
136
+
137
+ if attributes.key?(:'common_name')
138
+ self.common_name = attributes[:'common_name']
139
+ end
140
+
141
+ if attributes.key?(:'country')
142
+ self.country = attributes[:'country']
143
+ end
144
+
145
+ if attributes.key?(:'state')
146
+ self.state = attributes[:'state']
147
+ end
148
+
149
+ if attributes.key?(:'city')
150
+ self.city = attributes[:'city']
151
+ end
152
+
153
+ if attributes.key?(:'postal_code')
154
+ self.postal_code = attributes[:'postal_code']
155
+ end
156
+
157
+ if attributes.key?(:'street_address')
158
+ self.street_address = attributes[:'street_address']
159
+ end
160
+
161
+ if attributes.key?(:'organization')
162
+ self.organization = attributes[:'organization']
163
+ end
164
+
165
+ if attributes.key?(:'organizational_unit')
166
+ self.organizational_unit = attributes[:'organizational_unit']
167
+ end
168
+
169
+ if attributes.key?(:'email')
170
+ self.email = attributes[:'email']
171
+ end
172
+
173
+ if attributes.key?(:'key_type')
174
+ self.key_type = attributes[:'key_type']
175
+ end
176
+ end
177
+
178
+ # Show invalid properties with the reasons. Usually used together with valid?
179
+ # @return Array for valid properties with the reasons
180
+ def list_invalid_properties
181
+ invalid_properties = Array.new
182
+ if @sans.nil?
183
+ invalid_properties.push('invalid value for "sans", sans cannot be nil.')
184
+ end
185
+
186
+ invalid_properties
187
+ end
188
+
189
+ # Check to see if the all the properties in the model are valid
190
+ # @return true if the model is valid
191
+ def valid?
192
+ return false if @sans.nil?
193
+ key_type_validator = EnumAttributeValidator.new('String', ["RSA2048", "ECDSA256"])
194
+ return false unless key_type_validator.valid?(@key_type)
195
+ true
196
+ end
197
+
198
+ # Custom attribute writer method checking allowed values (enum).
199
+ # @param [Object] key_type Object to be assigned
200
+ def key_type=(key_type)
201
+ validator = EnumAttributeValidator.new('String', ["RSA2048", "ECDSA256"])
202
+ unless validator.valid?(key_type)
203
+ fail ArgumentError, "invalid value for \"key_type\", must be one of #{validator.allowable_values}."
204
+ end
205
+ @key_type = key_type
206
+ end
207
+
208
+ # Checks equality by comparing each attribute.
209
+ # @param [Object] Object to be compared
210
+ def ==(o)
211
+ return true if self.equal?(o)
212
+ self.class == o.class &&
213
+ sans == o.sans &&
214
+ common_name == o.common_name &&
215
+ country == o.country &&
216
+ state == o.state &&
217
+ city == o.city &&
218
+ postal_code == o.postal_code &&
219
+ street_address == o.street_address &&
220
+ organization == o.organization &&
221
+ organizational_unit == o.organizational_unit &&
222
+ email == o.email &&
223
+ key_type == o.key_type
224
+ end
225
+
226
+ # @see the `==` method
227
+ # @param [Object] Object to be compared
228
+ def eql?(o)
229
+ self == o
230
+ end
231
+
232
+ # Calculates hash code according to all attributes.
233
+ # @return [Integer] Hash code
234
+ def hash
235
+ [sans, common_name, country, state, city, postal_code, street_address, organization, organizational_unit, email, key_type].hash
236
+ end
237
+
238
+ # Builds the object from hash
239
+ # @param [Hash] attributes Model attributes in the form of hash
240
+ # @return [Object] Returns the model itself
241
+ def self.build_from_hash(attributes)
242
+ new.build_from_hash(attributes)
243
+ end
244
+
245
+ # Builds the object from hash
246
+ # @param [Hash] attributes Model attributes in the form of hash
247
+ # @return [Object] Returns the model itself
248
+ def build_from_hash(attributes)
249
+ return nil unless attributes.is_a?(Hash)
250
+ self.class.fastly_types.each_pair do |key, type|
251
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
252
+ self.send("#{key}=", nil)
253
+ elsif type =~ /\AArray<(.*)>/i
254
+ # check to ensure the input is an array given that the attribute
255
+ # is documented as an array but the input is not
256
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
257
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
258
+ end
259
+ elsif !attributes[self.class.attribute_map[key]].nil?
260
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
261
+ end
262
+ end
263
+
264
+ self
265
+ end
266
+
267
+ # Deserializes the data based on type
268
+ # @param string type Data type
269
+ # @param string value Value to be deserialized
270
+ # @return [Object] Deserialized data
271
+ def _deserialize(type, value)
272
+ case type.to_sym
273
+ when :Time
274
+ Time.parse(value)
275
+ when :Date
276
+ Date.parse(value)
277
+ when :String
278
+ value.to_s
279
+ when :Integer
280
+ value.to_i
281
+ when :Float
282
+ value.to_f
283
+ when :Boolean
284
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
285
+ true
286
+ else
287
+ false
288
+ end
289
+ when :Object
290
+ # generic object (usually a Hash), return directly
291
+ value
292
+ when /\AArray<(?<inner_type>.+)>\z/
293
+ inner_type = Regexp.last_match[:inner_type]
294
+ value.map { |v| _deserialize(inner_type, v) }
295
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
296
+ k_type = Regexp.last_match[:k_type]
297
+ v_type = Regexp.last_match[:v_type]
298
+ {}.tap do |hash|
299
+ value.each do |k, v|
300
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
301
+ end
302
+ end
303
+ else # model
304
+ # models (e.g. Pet) or oneOf
305
+ klass = Fastly.const_get(type)
306
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
307
+ end
308
+ end
309
+
310
+ # Returns the string representation of the object
311
+ # @return [String] String presentation of the object
312
+ def to_s
313
+ to_hash.to_s
314
+ end
315
+
316
+ # to_body is an alias to to_hash (backward compatibility)
317
+ # @return [Hash] Returns the object in the form of hash
318
+ def to_body
319
+ to_hash
320
+ end
321
+
322
+ # Returns the object in the form of hash
323
+ # @return [Hash] Returns the object in the form of hash
324
+ def to_hash
325
+ hash = {}
326
+ self.class.attribute_map.each_pair do |attr, param|
327
+ value = self.send(attr)
328
+ if value.nil?
329
+ is_nullable = self.class.fastly_nullable.include?(attr)
330
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
331
+ end
332
+
333
+ hash[param] = _to_hash(value)
334
+ end
335
+ hash
336
+ end
337
+
338
+ # Outputs non-array value in the form of hash
339
+ # For object, use to_hash. Otherwise, just return the value
340
+ # @param [Object] value Any valid value
341
+ # @return [Hash] Returns the value in the form of hash
342
+ def _to_hash(value)
343
+ if value.is_a?(Array)
344
+ value.compact.map { |v| _to_hash(v) }
345
+ elsif value.is_a?(Hash)
346
+ {}.tap do |hash|
347
+ value.each { |k, v| hash[k] = _to_hash(v) }
348
+ end
349
+ elsif value.respond_to? :to_hash
350
+ value.to_hash
351
+ else
352
+ value
353
+ end
354
+ end
355
+
356
+ end
357
+
358
+ end
@@ -0,0 +1,218 @@
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 TlsCsrErrorResponse
16
+ attr_accessor :errors
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :'errors' => :'errors'
22
+ }
23
+ end
24
+
25
+ # Returns all the JSON keys this model knows about
26
+ def self.acceptable_attributes
27
+ attribute_map.values
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.fastly_types
32
+ {
33
+ :'errors' => :'Array<ErrorResponseData>'
34
+ }
35
+ end
36
+
37
+ # List of attributes with nullable: true
38
+ def self.fastly_nullable
39
+ Set.new([
40
+ ])
41
+ end
42
+
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
45
+ def initialize(attributes = {})
46
+ if (!attributes.is_a?(Hash))
47
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::TlsCsrErrorResponse` initialize method"
48
+ end
49
+
50
+ # check to see if the attribute exists and convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) { |(k, v), h|
52
+ if (!self.class.attribute_map.key?(k.to_sym))
53
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::TlsCsrErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
54
+ end
55
+ h[k.to_sym] = v
56
+ }
57
+
58
+ if attributes.key?(:'errors')
59
+ if (value = attributes[:'errors']).is_a?(Array)
60
+ self.errors = value
61
+ end
62
+ end
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ errors == o.errors
84
+ end
85
+
86
+ # @see the `==` method
87
+ # @param [Object] Object to be compared
88
+ def eql?(o)
89
+ self == o
90
+ end
91
+
92
+ # Calculates hash code according to all attributes.
93
+ # @return [Integer] Hash code
94
+ def hash
95
+ [errors].hash
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def self.build_from_hash(attributes)
102
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ self.class.fastly_types.each_pair do |key, type|
111
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
112
+ self.send("#{key}=", nil)
113
+ elsif type =~ /\AArray<(.*)>/i
114
+ # check to ensure the input is an array given that the attribute
115
+ # is documented as an array but the input is not
116
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
117
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
118
+ end
119
+ elsif !attributes[self.class.attribute_map[key]].nil?
120
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
121
+ end
122
+ end
123
+
124
+ self
125
+ end
126
+
127
+ # Deserializes the data based on type
128
+ # @param string type Data type
129
+ # @param string value Value to be deserialized
130
+ # @return [Object] Deserialized data
131
+ def _deserialize(type, value)
132
+ case type.to_sym
133
+ when :Time
134
+ Time.parse(value)
135
+ when :Date
136
+ Date.parse(value)
137
+ when :String
138
+ value.to_s
139
+ when :Integer
140
+ value.to_i
141
+ when :Float
142
+ value.to_f
143
+ when :Boolean
144
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
145
+ true
146
+ else
147
+ false
148
+ end
149
+ when :Object
150
+ # generic object (usually a Hash), return directly
151
+ value
152
+ when /\AArray<(?<inner_type>.+)>\z/
153
+ inner_type = Regexp.last_match[:inner_type]
154
+ value.map { |v| _deserialize(inner_type, v) }
155
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
156
+ k_type = Regexp.last_match[:k_type]
157
+ v_type = Regexp.last_match[:v_type]
158
+ {}.tap do |hash|
159
+ value.each do |k, v|
160
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
161
+ end
162
+ end
163
+ else # model
164
+ # models (e.g. Pet) or oneOf
165
+ klass = Fastly.const_get(type)
166
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
167
+ end
168
+ end
169
+
170
+ # Returns the string representation of the object
171
+ # @return [String] String presentation of the object
172
+ def to_s
173
+ to_hash.to_s
174
+ end
175
+
176
+ # to_body is an alias to to_hash (backward compatibility)
177
+ # @return [Hash] Returns the object in the form of hash
178
+ def to_body
179
+ to_hash
180
+ end
181
+
182
+ # Returns the object in the form of hash
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_hash
185
+ hash = {}
186
+ self.class.attribute_map.each_pair do |attr, param|
187
+ value = self.send(attr)
188
+ if value.nil?
189
+ is_nullable = self.class.fastly_nullable.include?(attr)
190
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
191
+ end
192
+
193
+ hash[param] = _to_hash(value)
194
+ end
195
+ hash
196
+ end
197
+
198
+ # Outputs non-array value in the form of hash
199
+ # For object, use to_hash. Otherwise, just return the value
200
+ # @param [Object] value Any valid value
201
+ # @return [Hash] Returns the value in the form of hash
202
+ def _to_hash(value)
203
+ if value.is_a?(Array)
204
+ value.compact.map { |v| _to_hash(v) }
205
+ elsif value.is_a?(Hash)
206
+ {}.tap do |hash|
207
+ value.each { |k, v| hash[k] = _to_hash(v) }
208
+ end
209
+ elsif value.respond_to? :to_hash
210
+ value.to_hash
211
+ else
212
+ value
213
+ end
214
+ end
215
+
216
+ end
217
+
218
+ end