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,276 +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 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
@@ -1,375 +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 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
- :'content',
112
- :'created_at',
113
- :'deleted_at',
114
- :'updated_at',
115
- ])
116
- end
117
-
118
- # List of class defined in allOf (OpenAPI v3)
119
- def self.fastly_all_of
120
- [
121
- :'SnippetResponseCommon',
122
- :'SnippetWithDynamicNumber'
123
- ]
124
- end
125
-
126
- # Initializes the object
127
- # @param [Hash] attributes Model attributes in the form of hash
128
- def initialize(attributes = {})
129
- if (!attributes.is_a?(Hash))
130
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::SnippetResponsePost` initialize method"
131
- end
132
-
133
- # check to see if the attribute exists and convert string to symbol for hash key
134
- attributes = attributes.each_with_object({}) { |(k, v), h|
135
- if (!self.class.attribute_map.key?(k.to_sym))
136
- 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
137
- end
138
- h[k.to_sym] = v
139
- }
140
-
141
- if attributes.key?(:'name')
142
- self.name = attributes[:'name']
143
- end
144
-
145
- if attributes.key?(:'type')
146
- self.type = attributes[:'type']
147
- end
148
-
149
- if attributes.key?(:'content')
150
- self.content = attributes[:'content']
151
- end
152
-
153
- if attributes.key?(:'priority')
154
- self.priority = attributes[:'priority']
155
- else
156
- self.priority = '100'
157
- end
158
-
159
- if attributes.key?(:'dynamic')
160
- self.dynamic = attributes[:'dynamic']
161
- end
162
-
163
- if attributes.key?(:'created_at')
164
- self.created_at = attributes[:'created_at']
165
- end
166
-
167
- if attributes.key?(:'deleted_at')
168
- self.deleted_at = attributes[:'deleted_at']
169
- end
170
-
171
- if attributes.key?(:'updated_at')
172
- self.updated_at = attributes[:'updated_at']
173
- end
174
-
175
- if attributes.key?(:'service_id')
176
- self.service_id = attributes[:'service_id']
177
- end
178
-
179
- if attributes.key?(:'version')
180
- self.version = attributes[:'version']
181
- end
182
-
183
- if attributes.key?(:'id')
184
- self.id = attributes[:'id']
185
- end
186
- end
187
-
188
- # Show invalid properties with the reasons. Usually used together with valid?
189
- # @return Array for valid properties with the reasons
190
- def list_invalid_properties
191
- invalid_properties = Array.new
192
- invalid_properties
193
- end
194
-
195
- # Check to see if the all the properties in the model are valid
196
- # @return true if the model is valid
197
- def valid?
198
- type_validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
199
- return false unless type_validator.valid?(@type)
200
- dynamic_validator = EnumAttributeValidator.new('Float', [0, 1])
201
- return false unless dynamic_validator.valid?(@dynamic)
202
- true
203
- end
204
-
205
- # Custom attribute writer method checking allowed values (enum).
206
- # @param [Object] type Object to be assigned
207
- def type=(type)
208
- validator = EnumAttributeValidator.new('String', ["init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"])
209
- unless validator.valid?(type)
210
- fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
211
- end
212
- @type = type
213
- end
214
-
215
- # Custom attribute writer method checking allowed values (enum).
216
- # @param [Object] dynamic Object to be assigned
217
- def dynamic=(dynamic)
218
- validator = EnumAttributeValidator.new('Float', [0, 1])
219
- unless validator.valid?(dynamic)
220
- fail ArgumentError, "invalid value for \"dynamic\", must be one of #{validator.allowable_values}."
221
- end
222
- @dynamic = dynamic
223
- end
224
-
225
- # Checks equality by comparing each attribute.
226
- # @param [Object] Object to be compared
227
- def ==(o)
228
- return true if self.equal?(o)
229
- self.class == o.class &&
230
- name == o.name &&
231
- type == o.type &&
232
- content == o.content &&
233
- priority == o.priority &&
234
- dynamic == o.dynamic &&
235
- created_at == o.created_at &&
236
- deleted_at == o.deleted_at &&
237
- updated_at == o.updated_at &&
238
- service_id == o.service_id &&
239
- version == o.version &&
240
- id == o.id
241
- end
242
-
243
- # @see the `==` method
244
- # @param [Object] Object to be compared
245
- def eql?(o)
246
- self == o
247
- end
248
-
249
- # Calculates hash code according to all attributes.
250
- # @return [Integer] Hash code
251
- def hash
252
- [name, type, content, priority, dynamic, created_at, deleted_at, updated_at, service_id, version, id].hash
253
- end
254
-
255
- # Builds the object from hash
256
- # @param [Hash] attributes Model attributes in the form of hash
257
- # @return [Object] Returns the model itself
258
- def self.build_from_hash(attributes)
259
- new.build_from_hash(attributes)
260
- end
261
-
262
- # Builds the object from hash
263
- # @param [Hash] attributes Model attributes in the form of hash
264
- # @return [Object] Returns the model itself
265
- def build_from_hash(attributes)
266
- return nil unless attributes.is_a?(Hash)
267
- self.class.fastly_types.each_pair do |key, type|
268
- if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
269
- self.send("#{key}=", nil)
270
- elsif type =~ /\AArray<(.*)>/i
271
- # check to ensure the input is an array given that the attribute
272
- # is documented as an array but the input is not
273
- if attributes[self.class.attribute_map[key]].is_a?(Array)
274
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
275
- end
276
- elsif !attributes[self.class.attribute_map[key]].nil?
277
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
278
- end
279
- end
280
-
281
- self
282
- end
283
-
284
- # Deserializes the data based on type
285
- # @param string type Data type
286
- # @param string value Value to be deserialized
287
- # @return [Object] Deserialized data
288
- def _deserialize(type, value)
289
- case type.to_sym
290
- when :Time
291
- Time.parse(value)
292
- when :Date
293
- Date.parse(value)
294
- when :String
295
- value.to_s
296
- when :Integer
297
- value.to_i
298
- when :Float
299
- value.to_f
300
- when :Boolean
301
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
302
- true
303
- else
304
- false
305
- end
306
- when :Object
307
- # generic object (usually a Hash), return directly
308
- value
309
- when /\AArray<(?<inner_type>.+)>\z/
310
- inner_type = Regexp.last_match[:inner_type]
311
- value.map { |v| _deserialize(inner_type, v) }
312
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
313
- k_type = Regexp.last_match[:k_type]
314
- v_type = Regexp.last_match[:v_type]
315
- {}.tap do |hash|
316
- value.each do |k, v|
317
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
318
- end
319
- end
320
- else # model
321
- # models (e.g. Pet) or oneOf
322
- klass = Fastly.const_get(type)
323
- klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
324
- end
325
- end
326
-
327
- # Returns the string representation of the object
328
- # @return [String] String presentation of the object
329
- def to_s
330
- to_hash.to_s
331
- end
332
-
333
- # to_body is an alias to to_hash (backward compatibility)
334
- # @return [Hash] Returns the object in the form of hash
335
- def to_body
336
- to_hash
337
- end
338
-
339
- # Returns the object in the form of hash
340
- # @return [Hash] Returns the object in the form of hash
341
- def to_hash
342
- hash = {}
343
- self.class.attribute_map.each_pair do |attr, param|
344
- value = self.send(attr)
345
- if value.nil?
346
- is_nullable = self.class.fastly_nullable.include?(attr)
347
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
348
- end
349
-
350
- hash[param] = _to_hash(value)
351
- end
352
- hash
353
- end
354
-
355
- # Outputs non-array value in the form of hash
356
- # For object, use to_hash. Otherwise, just return the value
357
- # @param [Object] value Any valid value
358
- # @return [Hash] Returns the value in the form of hash
359
- def _to_hash(value)
360
- if value.is_a?(Array)
361
- value.compact.map { |v| _to_hash(v) }
362
- elsif value.is_a?(Hash)
363
- {}.tap do |hash|
364
- value.each { |k, v| hash[k] = _to_hash(v) }
365
- end
366
- elsif value.respond_to? :to_hash
367
- value.to_hash
368
- else
369
- value
370
- end
371
- end
372
-
373
- end
374
-
375
- end