fastly 10.0.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -1
  3. data/Gemfile.lock +1 -1
  4. data/README.md +2 -5
  5. data/docs/AutomationToken.md +1 -1
  6. data/docs/AutomationTokenCreateRequestAttributes.md +1 -1
  7. data/docs/AutomationTokenCreateResponse.md +4 -6
  8. data/docs/AutomationTokenCreateResponseAllOf.md +3 -3
  9. data/docs/AutomationTokenResponse.md +4 -6
  10. data/docs/AutomationTokenResponseAllOf.md +4 -4
  11. data/docs/BillingUsageMetricsApi.md +11 -9
  12. data/docs/ComputeAclListEntriesMeta.md +1 -1
  13. data/docs/Header.md +2 -0
  14. data/docs/HeaderApi.md +8 -8
  15. data/docs/KvStoreItemApi.md +4 -4
  16. data/docs/LoggingAzureblobAdditional.md +1 -1
  17. data/docs/LoggingAzureblobApi.md +4 -4
  18. data/docs/LoggingAzureblobResponse.md +1 -1
  19. data/docs/Results.md +7 -0
  20. data/docs/SnippetApi.md +2 -2
  21. data/docs/{SnippetResponseCommonAllOf.md → SnippetResponseAllOf.md} +1 -1
  22. data/docs/TlsBulkCertificatesApi.md +4 -0
  23. data/lib/fastly/api/automation_tokens_api.rb +6 -6
  24. data/lib/fastly/api/billing_usage_metrics_api.rb +11 -8
  25. data/lib/fastly/api/header_api.rb +8 -8
  26. data/lib/fastly/api/kv_store_item_api.rb +5 -5
  27. data/lib/fastly/api/logging_azureblob_api.rb +4 -4
  28. data/lib/fastly/api/snippet_api.rb +3 -3
  29. data/lib/fastly/api/tls_bulk_certificates_api.rb +6 -0
  30. data/lib/fastly/configuration.rb +0 -18
  31. data/lib/fastly/models/automation_token.rb +1 -1
  32. data/lib/fastly/models/automation_token_create_request_attributes.rb +1 -1
  33. data/lib/fastly/models/automation_token_create_response.rb +21 -43
  34. data/lib/fastly/models/automation_token_create_response_all_of.rb +13 -12
  35. data/lib/fastly/models/automation_token_response.rb +24 -46
  36. data/lib/fastly/models/automation_token_response_all_of.rb +11 -10
  37. data/lib/fastly/models/compute_acl_list_entries_meta.rb +1 -1
  38. data/lib/fastly/models/header.rb +26 -4
  39. data/lib/fastly/models/header_response.rb +0 -1
  40. data/lib/fastly/models/logging_azureblob_additional.rb +1 -1
  41. data/lib/fastly/models/logging_azureblob_response.rb +1 -1
  42. data/lib/fastly/models/results.rb +71 -1
  43. data/lib/fastly/models/schemas_snippet_response.rb +3 -2
  44. data/lib/fastly/models/snippet.rb +0 -8
  45. data/lib/fastly/models/snippet_response.rb +2 -1
  46. data/lib/fastly/models/{snippet_response_common_all_of.rb → snippet_response_all_of.rb} +3 -3
  47. data/lib/fastly/version.rb +1 -1
  48. data/lib/fastly.rb +1 -26
  49. data/sig.json +1 -1
  50. metadata +4 -54
  51. data/docs/Billing.md +0 -16
  52. data/docs/BillingApi.md +0 -139
  53. data/docs/BillingBandwidth.md +0 -11
  54. data/docs/BillingBandwidthTiers.md +0 -14
  55. data/docs/BillingEstimateInvoiceId.md +0 -10
  56. data/docs/BillingEstimateLines.md +0 -10
  57. data/docs/BillingEstimateLinesLineItems.md +0 -18
  58. data/docs/BillingEstimateResponse.md +0 -18
  59. data/docs/BillingInvoiceId.md +0 -10
  60. data/docs/BillingRegions.md +0 -13
  61. data/docs/BillingResponse.md +0 -18
  62. data/docs/BillingResponseItemItemsData.md +0 -10
  63. data/docs/BillingResponseLineItem.md +0 -29
  64. data/docs/BillingStatus.md +0 -11
  65. data/docs/BillingTotal.md +0 -25
  66. data/docs/BillingTotalExtras.md +0 -12
  67. data/docs/HeaderResponseAdditional.md +0 -11
  68. data/docs/LineItemData.md +0 -26
  69. data/docs/SchemasSnippetResponseCommon.md +0 -15
  70. data/docs/SnippetAllOf.md +0 -10
  71. data/docs/SnippetCommon.md +0 -13
  72. data/docs/SnippetResponseCommon.md +0 -15
  73. data/docs/SnippetResponsePost.md +0 -20
  74. data/docs/SnippetWithDynamicNumber.md +0 -14
  75. data/docs/SnippetWithDynamicNumberAllOf.md +0 -10
  76. data/lib/fastly/api/billing_api.rb +0 -229
  77. data/lib/fastly/models/billing.rb +0 -278
  78. data/lib/fastly/models/billing_bandwidth.rb +0 -227
  79. data/lib/fastly/models/billing_bandwidth_tiers.rb +0 -252
  80. data/lib/fastly/models/billing_estimate_invoice_id.rb +0 -216
  81. data/lib/fastly/models/billing_estimate_lines.rb +0 -218
  82. data/lib/fastly/models/billing_estimate_lines_line_items.rb +0 -288
  83. data/lib/fastly/models/billing_estimate_response.rb +0 -307
  84. data/lib/fastly/models/billing_invoice_id.rb +0 -216
  85. data/lib/fastly/models/billing_regions.rb +0 -243
  86. data/lib/fastly/models/billing_response.rb +0 -307
  87. data/lib/fastly/models/billing_response_item_items_data.rb +0 -218
  88. data/lib/fastly/models/billing_response_line_item.rb +0 -418
  89. data/lib/fastly/models/billing_status.rb +0 -262
  90. data/lib/fastly/models/billing_total.rb +0 -371
  91. data/lib/fastly/models/billing_total_extras.rb +0 -237
  92. data/lib/fastly/models/header_response_additional.rb +0 -229
  93. data/lib/fastly/models/line_item_data.rb +0 -377
  94. data/lib/fastly/models/schemas_snippet_response_common.rb +0 -276
  95. data/lib/fastly/models/snippet_all_of.rb +0 -251
  96. data/lib/fastly/models/snippet_common.rb +0 -284
  97. data/lib/fastly/models/snippet_response_common.rb +0 -276
  98. data/lib/fastly/models/snippet_response_post.rb +0 -375
  99. data/lib/fastly/models/snippet_with_dynamic_number.rb +0 -314
  100. data/lib/fastly/models/snippet_with_dynamic_number_all_of.rb +0 -251
@@ -1,218 +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://www.fastly.com/documentation/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 BillingResponseItemItemsData
16
- attr_accessor :line_items
17
-
18
- # Attribute mapping from ruby-style variable name to JSON key.
19
- def self.attribute_map
20
- {
21
- :'line_items' => :'line_items'
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
- :'line_items' => :'Array<BillingResponseLineItem>'
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::BillingResponseItemItemsData` 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::BillingResponseItemItemsData`. 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?(:'line_items')
59
- if (value = attributes[:'line_items']).is_a?(Array)
60
- self.line_items = 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
- line_items == o.line_items
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
- [line_items].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
@@ -1,418 +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://www.fastly.com/documentation/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 BillingResponseLineItem
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 :amount
26
-
27
- # An alphanumeric string identifying the invoice.
28
- attr_accessor :aria_invoice_id
29
-
30
- attr_accessor :client_service_id
31
-
32
- attr_accessor :credit_coupon_code
33
-
34
- attr_accessor :description
35
-
36
- attr_accessor :id
37
-
38
- attr_accessor :line_number
39
-
40
- attr_accessor :plan_name
41
-
42
- attr_accessor :plan_no
43
-
44
- attr_accessor :rate_per_unit
45
-
46
- attr_accessor :rate_schedule_no
47
-
48
- attr_accessor :rate_schedule_tier_no
49
-
50
- attr_accessor :service_name
51
-
52
- attr_accessor :service_no
53
-
54
- attr_accessor :units
55
-
56
- attr_accessor :usage_type_cd
57
-
58
- attr_accessor :usage_type_no
59
-
60
- # Attribute mapping from ruby-style variable name to JSON key.
61
- def self.attribute_map
62
- {
63
- :'created_at' => :'created_at',
64
- :'deleted_at' => :'deleted_at',
65
- :'updated_at' => :'updated_at',
66
- :'amount' => :'amount',
67
- :'aria_invoice_id' => :'aria_invoice_id',
68
- :'client_service_id' => :'client_service_id',
69
- :'credit_coupon_code' => :'credit_coupon_code',
70
- :'description' => :'description',
71
- :'id' => :'id',
72
- :'line_number' => :'line_number',
73
- :'plan_name' => :'plan_name',
74
- :'plan_no' => :'plan_no',
75
- :'rate_per_unit' => :'rate_per_unit',
76
- :'rate_schedule_no' => :'rate_schedule_no',
77
- :'rate_schedule_tier_no' => :'rate_schedule_tier_no',
78
- :'service_name' => :'service_name',
79
- :'service_no' => :'service_no',
80
- :'units' => :'units',
81
- :'usage_type_cd' => :'usage_type_cd',
82
- :'usage_type_no' => :'usage_type_no'
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
- :'created_at' => :'Time',
95
- :'deleted_at' => :'Time',
96
- :'updated_at' => :'Time',
97
- :'amount' => :'Float',
98
- :'aria_invoice_id' => :'String',
99
- :'client_service_id' => :'String',
100
- :'credit_coupon_code' => :'String',
101
- :'description' => :'String',
102
- :'id' => :'String',
103
- :'line_number' => :'Integer',
104
- :'plan_name' => :'String',
105
- :'plan_no' => :'Float',
106
- :'rate_per_unit' => :'Float',
107
- :'rate_schedule_no' => :'Float',
108
- :'rate_schedule_tier_no' => :'Float',
109
- :'service_name' => :'String',
110
- :'service_no' => :'Float',
111
- :'units' => :'Float',
112
- :'usage_type_cd' => :'String',
113
- :'usage_type_no' => :'Float'
114
- }
115
- end
116
-
117
- # List of attributes with nullable: true
118
- def self.fastly_nullable
119
- Set.new([
120
- :'created_at',
121
- :'deleted_at',
122
- :'updated_at',
123
- :'amount',
124
- :'aria_invoice_id',
125
- :'client_service_id',
126
- :'credit_coupon_code',
127
- :'description',
128
- :'line_number',
129
- :'plan_name',
130
- :'plan_no',
131
- :'rate_per_unit',
132
- :'rate_schedule_no',
133
- :'rate_schedule_tier_no',
134
- :'service_name',
135
- :'service_no',
136
- :'units',
137
- :'usage_type_cd',
138
- :'usage_type_no'
139
- ])
140
- end
141
-
142
- # List of class defined in allOf (OpenAPI v3)
143
- def self.fastly_all_of
144
- [
145
- :'LineItemData',
146
- :'Timestamps'
147
- ]
148
- end
149
-
150
- # Initializes the object
151
- # @param [Hash] attributes Model attributes in the form of hash
152
- def initialize(attributes = {})
153
- if (!attributes.is_a?(Hash))
154
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::BillingResponseLineItem` initialize method"
155
- end
156
-
157
- # check to see if the attribute exists and convert string to symbol for hash key
158
- attributes = attributes.each_with_object({}) { |(k, v), h|
159
- if (!self.class.attribute_map.key?(k.to_sym))
160
- fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::BillingResponseLineItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
161
- end
162
- h[k.to_sym] = v
163
- }
164
-
165
- if attributes.key?(:'created_at')
166
- self.created_at = attributes[:'created_at']
167
- end
168
-
169
- if attributes.key?(:'deleted_at')
170
- self.deleted_at = attributes[:'deleted_at']
171
- end
172
-
173
- if attributes.key?(:'updated_at')
174
- self.updated_at = attributes[:'updated_at']
175
- end
176
-
177
- if attributes.key?(:'amount')
178
- self.amount = attributes[:'amount']
179
- end
180
-
181
- if attributes.key?(:'aria_invoice_id')
182
- self.aria_invoice_id = attributes[:'aria_invoice_id']
183
- end
184
-
185
- if attributes.key?(:'client_service_id')
186
- self.client_service_id = attributes[:'client_service_id']
187
- end
188
-
189
- if attributes.key?(:'credit_coupon_code')
190
- self.credit_coupon_code = attributes[:'credit_coupon_code']
191
- end
192
-
193
- if attributes.key?(:'description')
194
- self.description = attributes[:'description']
195
- end
196
-
197
- if attributes.key?(:'id')
198
- self.id = attributes[:'id']
199
- end
200
-
201
- if attributes.key?(:'line_number')
202
- self.line_number = attributes[:'line_number']
203
- end
204
-
205
- if attributes.key?(:'plan_name')
206
- self.plan_name = attributes[:'plan_name']
207
- end
208
-
209
- if attributes.key?(:'plan_no')
210
- self.plan_no = attributes[:'plan_no']
211
- end
212
-
213
- if attributes.key?(:'rate_per_unit')
214
- self.rate_per_unit = attributes[:'rate_per_unit']
215
- end
216
-
217
- if attributes.key?(:'rate_schedule_no')
218
- self.rate_schedule_no = attributes[:'rate_schedule_no']
219
- end
220
-
221
- if attributes.key?(:'rate_schedule_tier_no')
222
- self.rate_schedule_tier_no = attributes[:'rate_schedule_tier_no']
223
- end
224
-
225
- if attributes.key?(:'service_name')
226
- self.service_name = attributes[:'service_name']
227
- end
228
-
229
- if attributes.key?(:'service_no')
230
- self.service_no = attributes[:'service_no']
231
- end
232
-
233
- if attributes.key?(:'units')
234
- self.units = attributes[:'units']
235
- end
236
-
237
- if attributes.key?(:'usage_type_cd')
238
- self.usage_type_cd = attributes[:'usage_type_cd']
239
- end
240
-
241
- if attributes.key?(:'usage_type_no')
242
- self.usage_type_no = attributes[:'usage_type_no']
243
- end
244
- end
245
-
246
- # Show invalid properties with the reasons. Usually used together with valid?
247
- # @return Array for valid properties with the reasons
248
- def list_invalid_properties
249
- invalid_properties = Array.new
250
- invalid_properties
251
- end
252
-
253
- # Check to see if the all the properties in the model are valid
254
- # @return true if the model is valid
255
- def valid?
256
- true
257
- end
258
-
259
- # Checks equality by comparing each attribute.
260
- # @param [Object] Object to be compared
261
- def ==(o)
262
- return true if self.equal?(o)
263
- self.class == o.class &&
264
- created_at == o.created_at &&
265
- deleted_at == o.deleted_at &&
266
- updated_at == o.updated_at &&
267
- amount == o.amount &&
268
- aria_invoice_id == o.aria_invoice_id &&
269
- client_service_id == o.client_service_id &&
270
- credit_coupon_code == o.credit_coupon_code &&
271
- description == o.description &&
272
- id == o.id &&
273
- line_number == o.line_number &&
274
- plan_name == o.plan_name &&
275
- plan_no == o.plan_no &&
276
- rate_per_unit == o.rate_per_unit &&
277
- rate_schedule_no == o.rate_schedule_no &&
278
- rate_schedule_tier_no == o.rate_schedule_tier_no &&
279
- service_name == o.service_name &&
280
- service_no == o.service_no &&
281
- units == o.units &&
282
- usage_type_cd == o.usage_type_cd &&
283
- usage_type_no == o.usage_type_no
284
- end
285
-
286
- # @see the `==` method
287
- # @param [Object] Object to be compared
288
- def eql?(o)
289
- self == o
290
- end
291
-
292
- # Calculates hash code according to all attributes.
293
- # @return [Integer] Hash code
294
- def hash
295
- [created_at, deleted_at, updated_at, amount, aria_invoice_id, client_service_id, credit_coupon_code, description, id, line_number, plan_name, plan_no, rate_per_unit, rate_schedule_no, rate_schedule_tier_no, service_name, service_no, units, usage_type_cd, usage_type_no].hash
296
- end
297
-
298
- # Builds the object from hash
299
- # @param [Hash] attributes Model attributes in the form of hash
300
- # @return [Object] Returns the model itself
301
- def self.build_from_hash(attributes)
302
- new.build_from_hash(attributes)
303
- end
304
-
305
- # Builds the object from hash
306
- # @param [Hash] attributes Model attributes in the form of hash
307
- # @return [Object] Returns the model itself
308
- def build_from_hash(attributes)
309
- return nil unless attributes.is_a?(Hash)
310
- self.class.fastly_types.each_pair do |key, type|
311
- if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
312
- self.send("#{key}=", nil)
313
- elsif type =~ /\AArray<(.*)>/i
314
- # check to ensure the input is an array given that the attribute
315
- # is documented as an array but the input is not
316
- if attributes[self.class.attribute_map[key]].is_a?(Array)
317
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
318
- end
319
- elsif !attributes[self.class.attribute_map[key]].nil?
320
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
321
- end
322
- end
323
-
324
- self
325
- end
326
-
327
- # Deserializes the data based on type
328
- # @param string type Data type
329
- # @param string value Value to be deserialized
330
- # @return [Object] Deserialized data
331
- def _deserialize(type, value)
332
- case type.to_sym
333
- when :Time
334
- Time.parse(value)
335
- when :Date
336
- Date.parse(value)
337
- when :String
338
- value.to_s
339
- when :Integer
340
- value.to_i
341
- when :Float
342
- value.to_f
343
- when :Boolean
344
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
345
- true
346
- else
347
- false
348
- end
349
- when :Object
350
- # generic object (usually a Hash), return directly
351
- value
352
- when /\AArray<(?<inner_type>.+)>\z/
353
- inner_type = Regexp.last_match[:inner_type]
354
- value.map { |v| _deserialize(inner_type, v) }
355
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
356
- k_type = Regexp.last_match[:k_type]
357
- v_type = Regexp.last_match[:v_type]
358
- {}.tap do |hash|
359
- value.each do |k, v|
360
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
361
- end
362
- end
363
- else # model
364
- # models (e.g. Pet) or oneOf
365
- klass = Fastly.const_get(type)
366
- klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
367
- end
368
- end
369
-
370
- # Returns the string representation of the object
371
- # @return [String] String presentation of the object
372
- def to_s
373
- to_hash.to_s
374
- end
375
-
376
- # to_body is an alias to to_hash (backward compatibility)
377
- # @return [Hash] Returns the object in the form of hash
378
- def to_body
379
- to_hash
380
- end
381
-
382
- # Returns the object in the form of hash
383
- # @return [Hash] Returns the object in the form of hash
384
- def to_hash
385
- hash = {}
386
- self.class.attribute_map.each_pair do |attr, param|
387
- value = self.send(attr)
388
- if value.nil?
389
- is_nullable = self.class.fastly_nullable.include?(attr)
390
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
391
- end
392
-
393
- hash[param] = _to_hash(value)
394
- end
395
- hash
396
- end
397
-
398
- # Outputs non-array value in the form of hash
399
- # For object, use to_hash. Otherwise, just return the value
400
- # @param [Object] value Any valid value
401
- # @return [Hash] Returns the value in the form of hash
402
- def _to_hash(value)
403
- if value.is_a?(Array)
404
- value.compact.map { |v| _to_hash(v) }
405
- elsif value.is_a?(Hash)
406
- {}.tap do |hash|
407
- value.each { |k, v| hash[k] = _to_hash(v) }
408
- end
409
- elsif value.respond_to? :to_hash
410
- value.to_hash
411
- else
412
- value
413
- end
414
- end
415
-
416
- end
417
-
418
- end