fastly 15.0.0 → 16.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 (164) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -1
  3. data/Gemfile.lock +3 -3
  4. data/README.md +32 -3
  5. data/docs/ApisecurityOperationsApi.md +465 -0
  6. data/docs/AutomationTokensApi.md +2 -2
  7. data/docs/Backend.md +1 -0
  8. data/docs/BackendApi.md +4 -0
  9. data/docs/BackendResponse.md +1 -0
  10. data/docs/DdosProtectionApi.md +4 -4
  11. data/docs/DdosProtectionEvent.md +2 -0
  12. data/docs/DdosProtectionEventAllOf.md +2 -0
  13. data/docs/DdosProtectionRequestEnableMode.md +10 -0
  14. data/docs/DiscoveredOperationBase.md +12 -0
  15. data/docs/DiscoveredOperationGet.md +15 -0
  16. data/docs/DiscoveredOperationGetExtra.md +12 -0
  17. data/docs/DmDomainsApi.md +2 -2
  18. data/docs/DomainInspectorHistoricalApi.md +1 -1
  19. data/docs/DomainInspectorMeasurements.md +63 -0
  20. data/docs/DomainOwnershipsApi.md +2 -2
  21. data/docs/DomainResearchApi.md +103 -0
  22. data/docs/DomainResearchResponseBodyEnable.md +12 -0
  23. data/docs/DomainResearchResponseCustomer.md +10 -0
  24. data/docs/DomainResearchResponseLinks.md +10 -0
  25. data/docs/DomainResearchResponseLinksLinks.md +10 -0
  26. data/docs/DomainResearchResponseProduct.md +10 -0
  27. data/docs/DomainResearchResponseProductProduct.md +11 -0
  28. data/docs/HistoricalApi.md +8 -0
  29. data/docs/HistoricalMeta.md +1 -0
  30. data/docs/IamV1RoleResponse.md +1 -0
  31. data/docs/InlineResponse2001.md +2 -1
  32. data/docs/InlineResponse20010.md +2 -1
  33. data/docs/InlineResponse20011.md +11 -0
  34. data/docs/InlineResponse20012.md +11 -0
  35. data/docs/InlineResponse20013.md +11 -0
  36. data/docs/InlineResponse20014.md +10 -0
  37. data/docs/InlineResponse2002.md +2 -2
  38. data/docs/InlineResponse2003.md +2 -2
  39. data/docs/InlineResponse2004.md +1 -2
  40. data/docs/InlineResponse2005.md +2 -1
  41. data/docs/InlineResponse2006.md +2 -2
  42. data/docs/InlineResponse2007.md +2 -2
  43. data/docs/InlineResponse2008.md +1 -2
  44. data/docs/InlineResponse2009.md +1 -2
  45. data/docs/InsightsApi.md +3 -3
  46. data/docs/KvStoreApi.md +43 -4
  47. data/docs/KvStoreDetails.md +2 -0
  48. data/docs/KvStoreItemApi.md +2 -2
  49. data/docs/{KvStoreRequestCreate.md → KvStoreRequestCreateOrUpdate.md} +1 -1
  50. data/docs/LogInsights.md +1 -1
  51. data/docs/Meta.md +11 -0
  52. data/docs/MetricsPlatformApi.md +75 -0
  53. data/docs/NgwafRequestEnable.md +1 -0
  54. data/docs/Offer.md +12 -0
  55. data/docs/OfferAllOf.md +12 -0
  56. data/docs/OperationBase.md +14 -0
  57. data/docs/OperationCreate.md +14 -0
  58. data/docs/OperationGet.md +18 -0
  59. data/docs/OperationGetExtra.md +13 -0
  60. data/docs/OperationUpdate.md +14 -0
  61. data/docs/OriginInspectorHistoricalApi.md +1 -1
  62. data/docs/PackageMetadata.md +2 -2
  63. data/docs/PlatformMetadata.md +14 -0
  64. data/docs/PlatformMetricsResponse.md +11 -0
  65. data/docs/PlatformValues.md +25 -0
  66. data/docs/ProductDdosProtectionApi.md +3 -1
  67. data/docs/ProductDomainResearchApi.md +115 -0
  68. data/docs/RealtimeEntryAggregated.md +25 -0
  69. data/docs/RealtimeMeasurements.md +25 -0
  70. data/docs/Results.md +25 -0
  71. data/docs/SecretStoreApi.md +2 -2
  72. data/docs/SecretStoreItemApi.md +2 -2
  73. data/docs/ServiceAuthorizationsApi.md +2 -2
  74. data/docs/Status.md +15 -0
  75. data/docs/StatusAllOf.md +15 -0
  76. data/docs/Suggestion.md +13 -0
  77. data/docs/SuggestionAllOf.md +13 -0
  78. data/docs/TagBase.md +11 -0
  79. data/docs/TagCreate.md +11 -0
  80. data/docs/TagGet.md +15 -0
  81. data/docs/TagGetExtra.md +13 -0
  82. data/docs/Values.md +63 -0
  83. data/lib/fastly/api/apisecurity_operations_api.rb +829 -0
  84. data/lib/fastly/api/automation_tokens_api.rb +3 -3
  85. data/lib/fastly/api/backend_api.rb +6 -0
  86. data/lib/fastly/api/ddos_protection_api.rb +6 -6
  87. data/lib/fastly/api/dm_domains_api.rb +3 -3
  88. data/lib/fastly/api/domain_inspector_historical_api.rb +1 -1
  89. data/lib/fastly/api/domain_ownerships_api.rb +3 -3
  90. data/lib/fastly/api/domain_research_api.rb +163 -0
  91. data/lib/fastly/api/historical_api.rb +12 -0
  92. data/lib/fastly/api/kv_store_api.rb +74 -6
  93. data/lib/fastly/api/kv_store_item_api.rb +3 -3
  94. data/lib/fastly/api/metrics_platform_api.rb +134 -0
  95. data/lib/fastly/api/origin_inspector_historical_api.rb +1 -1
  96. data/lib/fastly/api/product_ddos_protection_api.rb +10 -3
  97. data/lib/fastly/api/product_domain_research_api.rb +186 -0
  98. data/lib/fastly/api/secret_store_api.rb +3 -3
  99. data/lib/fastly/api/secret_store_item_api.rb +3 -3
  100. data/lib/fastly/api/service_authorizations_api.rb +3 -3
  101. data/lib/fastly/configuration.rb +108 -0
  102. data/lib/fastly/models/backend.rb +11 -1
  103. data/lib/fastly/models/backend_response.rb +11 -1
  104. data/lib/fastly/models/ddos_protection_event.rb +21 -1
  105. data/lib/fastly/models/ddos_protection_event_all_of.rb +21 -1
  106. data/lib/fastly/models/ddos_protection_request_enable_mode.rb +251 -0
  107. data/lib/fastly/models/discovered_operation_base.rb +271 -0
  108. data/lib/fastly/models/discovered_operation_get.rb +336 -0
  109. data/lib/fastly/models/discovered_operation_get_extra.rb +271 -0
  110. data/lib/fastly/models/domain_inspector_measurements.rb +634 -4
  111. data/lib/fastly/models/domain_research_response_body_enable.rb +243 -0
  112. data/lib/fastly/models/domain_research_response_customer.rb +216 -0
  113. data/lib/fastly/models/domain_research_response_links.rb +216 -0
  114. data/lib/fastly/models/domain_research_response_links_links.rb +217 -0
  115. data/lib/fastly/models/domain_research_response_product.rb +216 -0
  116. data/lib/fastly/models/domain_research_response_product_product.rb +227 -0
  117. data/lib/fastly/models/historical_meta.rb +13 -4
  118. data/lib/fastly/models/iam_v1_role_response.rb +10 -1
  119. data/lib/fastly/models/inline_response2001.rb +12 -3
  120. data/lib/fastly/models/inline_response20010.rb +13 -4
  121. data/lib/fastly/models/inline_response20011.rb +227 -0
  122. data/lib/fastly/models/inline_response20012.rb +227 -0
  123. data/lib/fastly/models/inline_response20013.rb +227 -0
  124. data/lib/fastly/models/inline_response20014.rb +218 -0
  125. data/lib/fastly/models/inline_response2002.rb +14 -13
  126. data/lib/fastly/models/inline_response2003.rb +14 -23
  127. data/lib/fastly/models/inline_response2004.rb +5 -15
  128. data/lib/fastly/models/inline_response2005.rb +18 -8
  129. data/lib/fastly/models/inline_response2006.rb +11 -1
  130. data/lib/fastly/models/inline_response2007.rb +4 -2
  131. data/lib/fastly/models/inline_response2008.rb +8 -18
  132. data/lib/fastly/models/inline_response2009.rb +8 -17
  133. data/lib/fastly/models/kv_store_details.rb +24 -4
  134. data/lib/fastly/models/{kv_store_request_create.rb → kv_store_request_create_or_update.rb} +3 -3
  135. data/lib/fastly/models/log_insights.rb +4 -2
  136. data/lib/fastly/models/meta.rb +266 -0
  137. data/lib/fastly/models/ngwaf_request_enable.rb +14 -4
  138. data/lib/fastly/models/offer.rb +245 -0
  139. data/lib/fastly/models/offer_all_of.rb +237 -0
  140. data/lib/fastly/models/operation_base.rb +308 -0
  141. data/lib/fastly/models/operation_create.rb +315 -0
  142. data/lib/fastly/models/operation_get.rb +381 -0
  143. data/lib/fastly/models/operation_get_extra.rb +257 -0
  144. data/lib/fastly/models/operation_update.rb +308 -0
  145. data/lib/fastly/models/package_metadata.rb +2 -2
  146. data/lib/fastly/models/platform_metadata.rb +258 -0
  147. data/lib/fastly/models/platform_metrics_response.rb +228 -0
  148. data/lib/fastly/models/platform_values.rb +368 -0
  149. data/lib/fastly/models/realtime_entry_aggregated.rb +254 -4
  150. data/lib/fastly/models/realtime_measurements.rb +254 -4
  151. data/lib/fastly/models/results.rb +251 -1
  152. data/lib/fastly/models/status.rb +276 -0
  153. data/lib/fastly/models/status_all_of.rb +268 -0
  154. data/lib/fastly/models/suggestion.rb +255 -0
  155. data/lib/fastly/models/suggestion_all_of.rb +247 -0
  156. data/lib/fastly/models/tag_base.rb +275 -0
  157. data/lib/fastly/models/tag_create.rb +282 -0
  158. data/lib/fastly/models/tag_get.rb +352 -0
  159. data/lib/fastly/models/tag_get_extra.rb +267 -0
  160. data/lib/fastly/models/values.rb +634 -4
  161. data/lib/fastly/version.rb +1 -1
  162. data/lib/fastly.rb +38 -1
  163. data/sig.json +1 -1
  164. metadata +78 -4
@@ -0,0 +1,247 @@
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 SuggestionAllOf
16
+ # The suggested domain, consisting of a subdomain and zone.
17
+ attr_accessor :domain
18
+
19
+ # The subdomain of the suggested domain.
20
+ attr_accessor :subdomain
21
+
22
+ # The zone of the suggested domain.
23
+ attr_accessor :zone
24
+
25
+ # If present, the path is to be appended to the domain to complete the suggestion.
26
+ attr_accessor :path
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'domain' => :'domain',
32
+ :'subdomain' => :'subdomain',
33
+ :'zone' => :'zone',
34
+ :'path' => :'path'
35
+ }
36
+ end
37
+
38
+ # Returns all the JSON keys this model knows about
39
+ def self.acceptable_attributes
40
+ attribute_map.values
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.fastly_types
45
+ {
46
+ :'domain' => :'String',
47
+ :'subdomain' => :'String',
48
+ :'zone' => :'String',
49
+ :'path' => :'String'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.fastly_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::SuggestionAllOf` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::SuggestionAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'domain')
75
+ self.domain = attributes[:'domain']
76
+ end
77
+
78
+ if attributes.key?(:'subdomain')
79
+ self.subdomain = attributes[:'subdomain']
80
+ end
81
+
82
+ if attributes.key?(:'zone')
83
+ self.zone = attributes[:'zone']
84
+ end
85
+
86
+ if attributes.key?(:'path')
87
+ self.path = attributes[:'path']
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ invalid_properties = Array.new
95
+ invalid_properties
96
+ end
97
+
98
+ # Check to see if the all the properties in the model are valid
99
+ # @return true if the model is valid
100
+ def valid?
101
+ true
102
+ end
103
+
104
+ # Checks equality by comparing each attribute.
105
+ # @param [Object] Object to be compared
106
+ def ==(o)
107
+ return true if self.equal?(o)
108
+ self.class == o.class &&
109
+ domain == o.domain &&
110
+ subdomain == o.subdomain &&
111
+ zone == o.zone &&
112
+ path == o.path
113
+ end
114
+
115
+ # @see the `==` method
116
+ # @param [Object] Object to be compared
117
+ def eql?(o)
118
+ self == o
119
+ end
120
+
121
+ # Calculates hash code according to all attributes.
122
+ # @return [Integer] Hash code
123
+ def hash
124
+ [domain, subdomain, zone, path].hash
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def self.build_from_hash(attributes)
131
+ new.build_from_hash(attributes)
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def build_from_hash(attributes)
138
+ return nil unless attributes.is_a?(Hash)
139
+ self.class.fastly_types.each_pair do |key, type|
140
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
141
+ self.send("#{key}=", nil)
142
+ elsif type =~ /\AArray<(.*)>/i
143
+ # check to ensure the input is an array given that the attribute
144
+ # is documented as an array but the input is not
145
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
146
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
147
+ end
148
+ elsif !attributes[self.class.attribute_map[key]].nil?
149
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
150
+ end
151
+ end
152
+
153
+ self
154
+ end
155
+
156
+ # Deserializes the data based on type
157
+ # @param string type Data type
158
+ # @param string value Value to be deserialized
159
+ # @return [Object] Deserialized data
160
+ def _deserialize(type, value)
161
+ case type.to_sym
162
+ when :Time
163
+ Time.parse(value)
164
+ when :Date
165
+ Date.parse(value)
166
+ when :String
167
+ value.to_s
168
+ when :Integer
169
+ value.to_i
170
+ when :Float
171
+ value.to_f
172
+ when :Boolean
173
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
174
+ true
175
+ else
176
+ false
177
+ end
178
+ when :Object
179
+ # generic object (usually a Hash), return directly
180
+ value
181
+ when /\AArray<(?<inner_type>.+)>\z/
182
+ inner_type = Regexp.last_match[:inner_type]
183
+ value.map { |v| _deserialize(inner_type, v) }
184
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
185
+ k_type = Regexp.last_match[:k_type]
186
+ v_type = Regexp.last_match[:v_type]
187
+ {}.tap do |hash|
188
+ value.each do |k, v|
189
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
190
+ end
191
+ end
192
+ else # model
193
+ # models (e.g. Pet) or oneOf
194
+ klass = Fastly.const_get(type)
195
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
196
+ end
197
+ end
198
+
199
+ # Returns the string representation of the object
200
+ # @return [String] String presentation of the object
201
+ def to_s
202
+ to_hash.to_s
203
+ end
204
+
205
+ # to_body is an alias to to_hash (backward compatibility)
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_body
208
+ to_hash
209
+ end
210
+
211
+ # Returns the object in the form of hash
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_hash
214
+ hash = {}
215
+ self.class.attribute_map.each_pair do |attr, param|
216
+ value = self.send(attr)
217
+ if value.nil?
218
+ is_nullable = self.class.fastly_nullable.include?(attr)
219
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
220
+ end
221
+
222
+ hash[param] = _to_hash(value)
223
+ end
224
+ hash
225
+ end
226
+
227
+ # Outputs non-array value in the form of hash
228
+ # For object, use to_hash. Otherwise, just return the value
229
+ # @param [Object] value Any valid value
230
+ # @return [Hash] Returns the value in the form of hash
231
+ def _to_hash(value)
232
+ if value.is_a?(Array)
233
+ value.compact.map { |v| _to_hash(v) }
234
+ elsif value.is_a?(Hash)
235
+ {}.tap do |hash|
236
+ value.each { |k, v| hash[k] = _to_hash(v) }
237
+ end
238
+ elsif value.respond_to? :to_hash
239
+ value.to_hash
240
+ else
241
+ value
242
+ end
243
+ end
244
+
245
+ end
246
+
247
+ end
@@ -0,0 +1,275 @@
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 TagBase
16
+ # The name of the operation tag.
17
+ attr_accessor :name
18
+
19
+ # A description of the operation tag.
20
+ attr_accessor :description
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'name' => :'name',
26
+ :'description' => :'description'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.fastly_types
37
+ {
38
+ :'name' => :'String',
39
+ :'description' => :'String'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.fastly_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::TagBase` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::TagBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'name')
65
+ self.name = attributes[:'name']
66
+ end
67
+
68
+ if attributes.key?(:'description')
69
+ self.description = attributes[:'description']
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ invalid_properties = Array.new
77
+ if !@name.nil? && @name.to_s.length > 64
78
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 64.')
79
+ end
80
+
81
+ if !@name.nil? && @name.to_s.length < 1
82
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
83
+ end
84
+
85
+ if !@description.nil? && @description.to_s.length > 255
86
+ invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 255.')
87
+ end
88
+
89
+ if !@description.nil? && @description.to_s.length < 1
90
+ invalid_properties.push('invalid value for "description", the character length must be great than or equal to 1.')
91
+ end
92
+
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ return false if !@name.nil? && @name.to_s.length > 64
100
+ return false if !@name.nil? && @name.to_s.length < 1
101
+ return false if !@description.nil? && @description.to_s.length > 255
102
+ return false if !@description.nil? && @description.to_s.length < 1
103
+ true
104
+ end
105
+
106
+ # Custom attribute writer method with validation
107
+ # @param [Object] name Value to be assigned
108
+ def name=(name)
109
+ if !name.nil? && name.to_s.length > 64
110
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 64.'
111
+ end
112
+
113
+ if !name.nil? && name.to_s.length < 1
114
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
115
+ end
116
+
117
+ @name = name
118
+ end
119
+
120
+ # Custom attribute writer method with validation
121
+ # @param [Object] description Value to be assigned
122
+ def description=(description)
123
+ if !description.nil? && description.to_s.length > 255
124
+ fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 255.'
125
+ end
126
+
127
+ if !description.nil? && description.to_s.length < 1
128
+ fail ArgumentError, 'invalid value for "description", the character length must be great than or equal to 1.'
129
+ end
130
+
131
+ @description = description
132
+ end
133
+
134
+ # Checks equality by comparing each attribute.
135
+ # @param [Object] Object to be compared
136
+ def ==(o)
137
+ return true if self.equal?(o)
138
+ self.class == o.class &&
139
+ name == o.name &&
140
+ description == o.description
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Integer] Hash code
151
+ def hash
152
+ [name, description].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def self.build_from_hash(attributes)
159
+ new.build_from_hash(attributes)
160
+ end
161
+
162
+ # Builds the object from hash
163
+ # @param [Hash] attributes Model attributes in the form of hash
164
+ # @return [Object] Returns the model itself
165
+ def build_from_hash(attributes)
166
+ return nil unless attributes.is_a?(Hash)
167
+ self.class.fastly_types.each_pair do |key, type|
168
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
169
+ self.send("#{key}=", nil)
170
+ elsif type =~ /\AArray<(.*)>/i
171
+ # check to ensure the input is an array given that the attribute
172
+ # is documented as an array but the input is not
173
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
174
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
175
+ end
176
+ elsif !attributes[self.class.attribute_map[key]].nil?
177
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
178
+ end
179
+ end
180
+
181
+ self
182
+ end
183
+
184
+ # Deserializes the data based on type
185
+ # @param string type Data type
186
+ # @param string value Value to be deserialized
187
+ # @return [Object] Deserialized data
188
+ def _deserialize(type, value)
189
+ case type.to_sym
190
+ when :Time
191
+ Time.parse(value)
192
+ when :Date
193
+ Date.parse(value)
194
+ when :String
195
+ value.to_s
196
+ when :Integer
197
+ value.to_i
198
+ when :Float
199
+ value.to_f
200
+ when :Boolean
201
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
202
+ true
203
+ else
204
+ false
205
+ end
206
+ when :Object
207
+ # generic object (usually a Hash), return directly
208
+ value
209
+ when /\AArray<(?<inner_type>.+)>\z/
210
+ inner_type = Regexp.last_match[:inner_type]
211
+ value.map { |v| _deserialize(inner_type, v) }
212
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
213
+ k_type = Regexp.last_match[:k_type]
214
+ v_type = Regexp.last_match[:v_type]
215
+ {}.tap do |hash|
216
+ value.each do |k, v|
217
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
218
+ end
219
+ end
220
+ else # model
221
+ # models (e.g. Pet) or oneOf
222
+ klass = Fastly.const_get(type)
223
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = self.send(attr)
245
+ if value.nil?
246
+ is_nullable = self.class.fastly_nullable.include?(attr)
247
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
248
+ end
249
+
250
+ hash[param] = _to_hash(value)
251
+ end
252
+ hash
253
+ end
254
+
255
+ # Outputs non-array value in the form of hash
256
+ # For object, use to_hash. Otherwise, just return the value
257
+ # @param [Object] value Any valid value
258
+ # @return [Hash] Returns the value in the form of hash
259
+ def _to_hash(value)
260
+ if value.is_a?(Array)
261
+ value.compact.map { |v| _to_hash(v) }
262
+ elsif value.is_a?(Hash)
263
+ {}.tap do |hash|
264
+ value.each { |k, v| hash[k] = _to_hash(v) }
265
+ end
266
+ elsif value.respond_to? :to_hash
267
+ value.to_hash
268
+ else
269
+ value
270
+ end
271
+ end
272
+
273
+ end
274
+
275
+ end