fastly 15.0.0 → 15.1.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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +10 -3
  5. data/docs/DdosProtectionEvent.md +2 -0
  6. data/docs/DdosProtectionEventAllOf.md +2 -0
  7. data/docs/DdosProtectionRequestEnableMode.md +10 -0
  8. data/docs/DomainInspectorHistoricalApi.md +1 -1
  9. data/docs/DomainResearchApi.md +103 -0
  10. data/docs/DomainResearchResponseBodyEnable.md +12 -0
  11. data/docs/DomainResearchResponseCustomer.md +10 -0
  12. data/docs/DomainResearchResponseLinks.md +10 -0
  13. data/docs/DomainResearchResponseLinksLinks.md +10 -0
  14. data/docs/DomainResearchResponseProduct.md +10 -0
  15. data/docs/DomainResearchResponseProductProduct.md +11 -0
  16. data/docs/IamV1RoleResponse.md +1 -0
  17. data/docs/InlineResponse20010.md +2 -1
  18. data/docs/InlineResponse20011.md +10 -0
  19. data/docs/InlineResponse2006.md +1 -2
  20. data/docs/InlineResponse2007.md +1 -1
  21. data/docs/InlineResponse2008.md +1 -1
  22. data/docs/InlineResponse2009.md +1 -1
  23. data/docs/KvStoreApi.md +43 -4
  24. data/docs/KvStoreDetails.md +2 -0
  25. data/docs/KvStoreItemApi.md +2 -2
  26. data/docs/{KvStoreRequestCreate.md → KvStoreRequestCreateOrUpdate.md} +1 -1
  27. data/docs/MetricsPlatformApi.md +75 -0
  28. data/docs/NgwafRequestEnable.md +1 -0
  29. data/docs/Offer.md +12 -0
  30. data/docs/OfferAllOf.md +12 -0
  31. data/docs/OriginInspectorHistoricalApi.md +1 -1
  32. data/docs/PlatformMetadata.md +14 -0
  33. data/docs/PlatformMetricsResponse.md +11 -0
  34. data/docs/PlatformValues.md +25 -0
  35. data/docs/ProductDdosProtectionApi.md +3 -1
  36. data/docs/ProductDomainResearchApi.md +115 -0
  37. data/docs/RealtimeEntryAggregated.md +4 -0
  38. data/docs/RealtimeMeasurements.md +4 -0
  39. data/docs/Results.md +4 -0
  40. data/docs/SecretStoreApi.md +2 -2
  41. data/docs/SecretStoreItemApi.md +2 -2
  42. data/docs/ServiceAuthorizationsApi.md +2 -2
  43. data/docs/Status.md +15 -0
  44. data/docs/StatusAllOf.md +15 -0
  45. data/docs/Suggestion.md +13 -0
  46. data/docs/SuggestionAllOf.md +13 -0
  47. data/lib/fastly/api/domain_inspector_historical_api.rb +1 -1
  48. data/lib/fastly/api/domain_research_api.rb +163 -0
  49. data/lib/fastly/api/kv_store_api.rb +74 -6
  50. data/lib/fastly/api/kv_store_item_api.rb +3 -3
  51. data/lib/fastly/api/metrics_platform_api.rb +134 -0
  52. data/lib/fastly/api/origin_inspector_historical_api.rb +1 -1
  53. data/lib/fastly/api/product_ddos_protection_api.rb +10 -3
  54. data/lib/fastly/api/product_domain_research_api.rb +186 -0
  55. data/lib/fastly/api/secret_store_api.rb +3 -3
  56. data/lib/fastly/api/secret_store_item_api.rb +3 -3
  57. data/lib/fastly/api/service_authorizations_api.rb +3 -3
  58. data/lib/fastly/configuration.rb +42 -0
  59. data/lib/fastly/models/ddos_protection_event.rb +21 -1
  60. data/lib/fastly/models/ddos_protection_event_all_of.rb +21 -1
  61. data/lib/fastly/models/ddos_protection_request_enable_mode.rb +251 -0
  62. data/lib/fastly/models/domain_research_response_body_enable.rb +243 -0
  63. data/lib/fastly/models/domain_research_response_customer.rb +216 -0
  64. data/lib/fastly/models/domain_research_response_links.rb +216 -0
  65. data/lib/fastly/models/domain_research_response_links_links.rb +217 -0
  66. data/lib/fastly/models/domain_research_response_product.rb +216 -0
  67. data/lib/fastly/models/domain_research_response_product_product.rb +227 -0
  68. data/lib/fastly/models/iam_v1_role_response.rb +10 -1
  69. data/lib/fastly/models/inline_response20010.rb +13 -4
  70. data/lib/fastly/models/inline_response20011.rb +218 -0
  71. data/lib/fastly/models/inline_response2006.rb +8 -17
  72. data/lib/fastly/models/inline_response2007.rb +1 -1
  73. data/lib/fastly/models/inline_response2008.rb +1 -1
  74. data/lib/fastly/models/inline_response2009.rb +1 -1
  75. data/lib/fastly/models/kv_store_details.rb +24 -4
  76. data/lib/fastly/models/{kv_store_request_create.rb → kv_store_request_create_or_update.rb} +3 -3
  77. data/lib/fastly/models/ngwaf_request_enable.rb +14 -4
  78. data/lib/fastly/models/offer.rb +245 -0
  79. data/lib/fastly/models/offer_all_of.rb +237 -0
  80. data/lib/fastly/models/platform_metadata.rb +258 -0
  81. data/lib/fastly/models/platform_metrics_response.rb +228 -0
  82. data/lib/fastly/models/platform_values.rb +368 -0
  83. data/lib/fastly/models/realtime_entry_aggregated.rb +44 -4
  84. data/lib/fastly/models/realtime_measurements.rb +44 -4
  85. data/lib/fastly/models/results.rb +41 -1
  86. data/lib/fastly/models/status.rb +276 -0
  87. data/lib/fastly/models/status_all_of.rb +268 -0
  88. data/lib/fastly/models/suggestion.rb +255 -0
  89. data/lib/fastly/models/suggestion_all_of.rb +247 -0
  90. data/lib/fastly/version.rb +1 -1
  91. data/lib/fastly.rb +21 -1
  92. data/sig.json +1 -1
  93. metadata +44 -4
@@ -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://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 InlineResponse20011
16
+ attr_accessor :data
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :'data' => :'data'
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
+ :'data' => :'Array<ServiceAuthorizationResponseData>'
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::InlineResponse20011` 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::InlineResponse20011`. 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?(:'data')
59
+ if (value = attributes[:'data']).is_a?(Array)
60
+ self.data = 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
+ data == o.data
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
+ [data].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
@@ -13,15 +13,12 @@ require 'time'
13
13
 
14
14
  module Fastly
15
15
  class InlineResponse2006
16
- attr_accessor :data
17
-
18
- attr_accessor :meta
16
+ attr_accessor :results
19
17
 
20
18
  # Attribute mapping from ruby-style variable name to JSON key.
21
19
  def self.attribute_map
22
20
  {
23
- :'data' => :'data',
24
- :'meta' => :'meta'
21
+ :'results' => :'results'
25
22
  }
26
23
  end
27
24
 
@@ -33,8 +30,7 @@ module Fastly
33
30
  # Attribute type mapping.
34
31
  def self.fastly_types
35
32
  {
36
- :'data' => :'Array<KvStoreDetails>',
37
- :'meta' => :'PaginationCursorMeta'
33
+ :'results' => :'Array<Suggestion>'
38
34
  }
39
35
  end
40
36
 
@@ -59,15 +55,11 @@ module Fastly
59
55
  h[k.to_sym] = v
60
56
  }
61
57
 
62
- if attributes.key?(:'data')
63
- if (value = attributes[:'data']).is_a?(Array)
64
- self.data = value
58
+ if attributes.key?(:'results')
59
+ if (value = attributes[:'results']).is_a?(Array)
60
+ self.results = value
65
61
  end
66
62
  end
67
-
68
- if attributes.key?(:'meta')
69
- self.meta = attributes[:'meta']
70
- end
71
63
  end
72
64
 
73
65
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -88,8 +80,7 @@ module Fastly
88
80
  def ==(o)
89
81
  return true if self.equal?(o)
90
82
  self.class == o.class &&
91
- data == o.data &&
92
- meta == o.meta
83
+ results == o.results
93
84
  end
94
85
 
95
86
  # @see the `==` method
@@ -101,7 +92,7 @@ module Fastly
101
92
  # Calculates hash code according to all attributes.
102
93
  # @return [Integer] Hash code
103
94
  def hash
104
- [data, meta].hash
95
+ [results].hash
105
96
  end
106
97
 
107
98
  # Builds the object from hash
@@ -33,7 +33,7 @@ module Fastly
33
33
  # Attribute type mapping.
34
34
  def self.fastly_types
35
35
  {
36
- :'data' => :'Array<String>',
36
+ :'data' => :'Array<KvStoreDetails>',
37
37
  :'meta' => :'PaginationCursorMeta'
38
38
  }
39
39
  end
@@ -33,7 +33,7 @@ module Fastly
33
33
  # Attribute type mapping.
34
34
  def self.fastly_types
35
35
  {
36
- :'data' => :'Array<SecretStoreResponse>',
36
+ :'data' => :'Array<String>',
37
37
  :'meta' => :'PaginationCursorMeta'
38
38
  }
39
39
  end
@@ -33,7 +33,7 @@ module Fastly
33
33
  # Attribute type mapping.
34
34
  def self.fastly_types
35
35
  {
36
- :'data' => :'Array<SecretResponse>',
36
+ :'data' => :'Array<SecretStoreResponse>',
37
37
  :'meta' => :'PaginationCursorMeta'
38
38
  }
39
39
  end
@@ -19,11 +19,19 @@ module Fastly
19
19
  # Name of the store.
20
20
  attr_accessor :name
21
21
 
22
+ # Timestamp at which the store was created.
23
+ attr_accessor :created_at
24
+
25
+ # Timestamp at which the store was last updated.
26
+ attr_accessor :updated_at
27
+
22
28
  # Attribute mapping from ruby-style variable name to JSON key.
23
29
  def self.attribute_map
24
30
  {
25
31
  :'id' => :'id',
26
- :'name' => :'name'
32
+ :'name' => :'name',
33
+ :'created_at' => :'created_at',
34
+ :'updated_at' => :'updated_at'
27
35
  }
28
36
  end
29
37
 
@@ -36,7 +44,9 @@ module Fastly
36
44
  def self.fastly_types
37
45
  {
38
46
  :'id' => :'String',
39
- :'name' => :'String'
47
+ :'name' => :'String',
48
+ :'created_at' => :'String',
49
+ :'updated_at' => :'String'
40
50
  }
41
51
  end
42
52
 
@@ -68,6 +78,14 @@ module Fastly
68
78
  if attributes.key?(:'name')
69
79
  self.name = attributes[:'name']
70
80
  end
81
+
82
+ if attributes.key?(:'created_at')
83
+ self.created_at = attributes[:'created_at']
84
+ end
85
+
86
+ if attributes.key?(:'updated_at')
87
+ self.updated_at = attributes[:'updated_at']
88
+ end
71
89
  end
72
90
 
73
91
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -89,7 +107,9 @@ module Fastly
89
107
  return true if self.equal?(o)
90
108
  self.class == o.class &&
91
109
  id == o.id &&
92
- name == o.name
110
+ name == o.name &&
111
+ created_at == o.created_at &&
112
+ updated_at == o.updated_at
93
113
  end
94
114
 
95
115
  # @see the `==` method
@@ -101,7 +121,7 @@ module Fastly
101
121
  # Calculates hash code according to all attributes.
102
122
  # @return [Integer] Hash code
103
123
  def hash
104
- [id, name].hash
124
+ [id, name, created_at, updated_at].hash
105
125
  end
106
126
 
107
127
  # Builds the object from hash
@@ -12,7 +12,7 @@ require 'date'
12
12
  require 'time'
13
13
 
14
14
  module Fastly
15
- class KvStoreRequestCreate
15
+ class KvStoreRequestCreateOrUpdate
16
16
  # A human-readable name for the store. Refer to https://docs.fastly.com/products/compute-resource-limits#kv-store for limitations on the KV store name.
17
17
  attr_accessor :name
18
18
 
@@ -45,13 +45,13 @@ module Fastly
45
45
  # @param [Hash] attributes Model attributes in the form of hash
46
46
  def initialize(attributes = {})
47
47
  if (!attributes.is_a?(Hash))
48
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::KvStoreRequestCreate` initialize method"
48
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::KvStoreRequestCreateOrUpdate` initialize method"
49
49
  end
50
50
 
51
51
  # check to see if the attribute exists and convert string to symbol for hash key
52
52
  attributes = attributes.each_with_object({}) { |(k, v), h|
53
53
  if (!self.class.attribute_map.key?(k.to_sym))
54
- fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::KvStoreRequestCreate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
54
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::KvStoreRequestCreateOrUpdate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
55
  end
56
56
  h[k.to_sym] = v
57
57
  }
@@ -16,10 +16,14 @@ module Fastly
16
16
  # The workspace to link.
17
17
  attr_accessor :workspace_id
18
18
 
19
+ # The percentage of traffic to inspect.
20
+ attr_accessor :traffic_ramp
21
+
19
22
  # Attribute mapping from ruby-style variable name to JSON key.
20
23
  def self.attribute_map
21
24
  {
22
- :'workspace_id' => :'workspace_id'
25
+ :'workspace_id' => :'workspace_id',
26
+ :'traffic_ramp' => :'traffic_ramp'
23
27
  }
24
28
  end
25
29
 
@@ -31,7 +35,8 @@ module Fastly
31
35
  # Attribute type mapping.
32
36
  def self.fastly_types
33
37
  {
34
- :'workspace_id' => :'String'
38
+ :'workspace_id' => :'String',
39
+ :'traffic_ramp' => :'String'
35
40
  }
36
41
  end
37
42
 
@@ -59,6 +64,10 @@ module Fastly
59
64
  if attributes.key?(:'workspace_id')
60
65
  self.workspace_id = attributes[:'workspace_id']
61
66
  end
67
+
68
+ if attributes.key?(:'traffic_ramp')
69
+ self.traffic_ramp = attributes[:'traffic_ramp']
70
+ end
62
71
  end
63
72
 
64
73
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -84,7 +93,8 @@ module Fastly
84
93
  def ==(o)
85
94
  return true if self.equal?(o)
86
95
  self.class == o.class &&
87
- workspace_id == o.workspace_id
96
+ workspace_id == o.workspace_id &&
97
+ traffic_ramp == o.traffic_ramp
88
98
  end
89
99
 
90
100
  # @see the `==` method
@@ -96,7 +106,7 @@ module Fastly
96
106
  # Calculates hash code according to all attributes.
97
107
  # @return [Integer] Hash code
98
108
  def hash
99
- [workspace_id].hash
109
+ [workspace_id, traffic_ramp].hash
100
110
  end
101
111
 
102
112
  # Builds the object from hash
@@ -0,0 +1,245 @@
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
+ # An offer from a domain aftermarket vendor.
16
+ class Offer
17
+ # The aftermarket vendor.
18
+ attr_accessor :vendor
19
+
20
+ # The price for the domain from the aftermarket vendor.
21
+ attr_accessor :price
22
+
23
+ # The currency for the aftermarket offer.
24
+ attr_accessor :currency
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'vendor' => :'vendor',
30
+ :'price' => :'price',
31
+ :'currency' => :'currency'
32
+ }
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.fastly_types
42
+ {
43
+ :'vendor' => :'String',
44
+ :'price' => :'String',
45
+ :'currency' => :'String'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.fastly_nullable
51
+ Set.new([
52
+ ])
53
+ end
54
+
55
+ # List of class defined in allOf (OpenAPI v3)
56
+ def self.fastly_all_of
57
+ [
58
+ :'OfferAllOf'
59
+ ]
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::Offer` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::Offer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'vendor')
78
+ self.vendor = attributes[:'vendor']
79
+ end
80
+
81
+ if attributes.key?(:'price')
82
+ self.price = attributes[:'price']
83
+ end
84
+
85
+ if attributes.key?(:'currency')
86
+ self.currency = attributes[:'currency']
87
+ end
88
+ end
89
+
90
+ # Show invalid properties with the reasons. Usually used together with valid?
91
+ # @return Array for valid properties with the reasons
92
+ def list_invalid_properties
93
+ invalid_properties = Array.new
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ true
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ vendor == o.vendor &&
109
+ price == o.price &&
110
+ currency == o.currency
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [vendor, price, currency].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ self.class.fastly_types.each_pair do |key, type|
138
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
139
+ self.send("#{key}=", nil)
140
+ elsif type =~ /\AArray<(.*)>/i
141
+ # check to ensure the input is an array given that the attribute
142
+ # is documented as an array but the input is not
143
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
144
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
145
+ end
146
+ elsif !attributes[self.class.attribute_map[key]].nil?
147
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
148
+ end
149
+ end
150
+
151
+ self
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def _deserialize(type, value)
159
+ case type.to_sym
160
+ when :Time
161
+ Time.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :Boolean
171
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ # models (e.g. Pet) or oneOf
192
+ klass = Fastly.const_get(type)
193
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ self.class.attribute_map.each_pair do |attr, param|
214
+ value = self.send(attr)
215
+ if value.nil?
216
+ is_nullable = self.class.fastly_nullable.include?(attr)
217
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
218
+ end
219
+
220
+ hash[param] = _to_hash(value)
221
+ end
222
+ hash
223
+ end
224
+
225
+ # Outputs non-array value in the form of hash
226
+ # For object, use to_hash. Otherwise, just return the value
227
+ # @param [Object] value Any valid value
228
+ # @return [Hash] Returns the value in the form of hash
229
+ def _to_hash(value)
230
+ if value.is_a?(Array)
231
+ value.compact.map { |v| _to_hash(v) }
232
+ elsif value.is_a?(Hash)
233
+ {}.tap do |hash|
234
+ value.each { |k, v| hash[k] = _to_hash(v) }
235
+ end
236
+ elsif value.respond_to? :to_hash
237
+ value.to_hash
238
+ else
239
+ value
240
+ end
241
+ end
242
+
243
+ end
244
+
245
+ end