fastly 8.5.0 → 8.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +15 -2
  5. data/docs/{RelationshipTlsDnsRecord.md → AsyncResponse.md} +3 -2
  6. data/docs/BillingInvoicesApi.md +37 -4
  7. data/docs/BillingUsageMetricsApi.md +111 -0
  8. data/docs/CreateDashboardRequest.md +12 -0
  9. data/docs/Dashboard.md +17 -0
  10. data/docs/DashboardItem.md +15 -0
  11. data/docs/DashboardItemPropertyDataSource.md +11 -0
  12. data/docs/DashboardItemPropertyDataSourcePropertyConfig.md +10 -0
  13. data/docs/DashboardItemPropertyVisualization.md +11 -0
  14. data/docs/DashboardItemPropertyVisualizationPropertyConfig.md +12 -0
  15. data/docs/{RelationshipTlsDnsRecords.md → DashboardPropertyCreatedBy.md} +1 -2
  16. data/docs/{RelationshipTlsDnsRecordDnsRecord.md → DashboardPropertyUpdatedBy.md} +1 -2
  17. data/docs/DomainInspectorMeasurements.md +1 -1
  18. data/docs/{InvoiceResponse.md → EomInvoiceResponse.md} +1 -1
  19. data/docs/GetServiceLevelUsageResponse.md +10 -0
  20. data/docs/GetServiceLevelUsageTypesResponse.md +10 -0
  21. data/docs/IncludedWithTlsConfiguration.md +10 -0
  22. data/docs/IncludedWithTlsConfigurationItem.md +12 -0
  23. data/docs/ListDashboardsResponse.md +11 -0
  24. data/docs/{ListInvoicesResponse.md → ListEomInvoicesResponse.md} +1 -1
  25. data/docs/MtdInvoiceResponse.md +15 -0
  26. data/docs/Mtdinvoice.md +15 -0
  27. data/docs/Mtdlineitems.md +18 -0
  28. data/docs/ObservabilityCustomDashboardsApi.md +203 -0
  29. data/docs/RealtimeEntryAggregated.md +1 -0
  30. data/docs/RealtimeMeasurements.md +1 -0
  31. data/docs/RelationshipDefaultEcdsaTlsCertificate.md +10 -0
  32. data/docs/RelationshipDefaultEcdsaTlsCertificateDefaultEcdsaCertificate.md +10 -0
  33. data/docs/RelationshipDefaultEcdsaTlsCertificateDefaultEcdsaCertificateData.md +11 -0
  34. data/docs/RelationshipDefaultTlsCertificate.md +10 -0
  35. data/docs/RelationshipDefaultTlsCertificateDefaultCertificate.md +10 -0
  36. data/docs/RelationshipDefaultTlsCertificateDefaultCertificateData.md +11 -0
  37. data/docs/RelationshipTlsDnsRecordsRequest.md +10 -0
  38. data/docs/RelationshipTlsDnsRecordsRequestDnsRecords.md +10 -0
  39. data/docs/RelationshipTlsDnsRecordsRequestDnsRecordsData.md +11 -0
  40. data/docs/RelationshipTlsDnsRecordsResponse.md +10 -0
  41. data/docs/RelationshipTlsDnsRecordsResponseDnsRecords.md +10 -0
  42. data/docs/{RelationshipMemberTlsDnsRecord.md → RelationshipTlsDnsRecordsResponseDnsRecordsData.md} +1 -1
  43. data/docs/Results.md +1 -0
  44. data/docs/Serviceusagemetric.md +13 -0
  45. data/docs/Serviceusagemetrics.md +10 -0
  46. data/docs/ServiceusagemetricsData.md +16 -0
  47. data/docs/Serviceusagetype.md +11 -0
  48. data/docs/Serviceusagetypes.md +10 -0
  49. data/docs/TlsCertificateBlobResponse.md +10 -0
  50. data/docs/TlsCertificatesApi.md +38 -0
  51. data/docs/TlsDnsRecord.md +1 -2
  52. data/docs/UpdateDashboardRequest.md +12 -0
  53. data/docs/Values.md +1 -1
  54. data/lib/fastly/api/billing_invoices_api.rb +62 -6
  55. data/lib/fastly/api/billing_usage_metrics_api.rb +213 -0
  56. data/lib/fastly/api/observability_custom_dashboards_api.rb +333 -0
  57. data/lib/fastly/api/tls_certificates_api.rb +63 -0
  58. data/lib/fastly/configuration.rb +54 -0
  59. data/lib/fastly/models/async_response.rb +225 -0
  60. data/lib/fastly/models/create_dashboard_request.rb +245 -0
  61. data/lib/fastly/models/dashboard.rb +290 -0
  62. data/lib/fastly/models/dashboard_item.rb +368 -0
  63. data/lib/fastly/models/dashboard_item_property_data_source.rb +271 -0
  64. data/lib/fastly/models/dashboard_item_property_data_source_property_config.rb +244 -0
  65. data/lib/fastly/models/dashboard_item_property_visualization.rb +271 -0
  66. data/lib/fastly/models/dashboard_item_property_visualization_property_config.rb +303 -0
  67. data/lib/fastly/models/dashboard_property_created_by.rb +208 -0
  68. data/lib/fastly/models/dashboard_property_updated_by.rb +208 -0
  69. data/lib/fastly/models/domain_inspector_measurements.rb +1 -1
  70. data/lib/fastly/models/{invoice_response.rb → eom_invoice_response.rb} +3 -3
  71. data/lib/fastly/models/get_service_level_usage_response.rb +223 -0
  72. data/lib/fastly/models/get_service_level_usage_types_response.rb +225 -0
  73. data/lib/fastly/models/included_with_tls_configuration.rb +218 -0
  74. data/lib/fastly/models/included_with_tls_configuration_item.rb +237 -0
  75. data/lib/fastly/models/invoicelineitems.rb +5 -5
  76. data/lib/fastly/models/list_dashboards_response.rb +229 -0
  77. data/lib/fastly/models/{list_invoices_response.rb → list_eom_invoices_response.rb} +3 -3
  78. data/lib/fastly/models/mtd_invoice_response.rb +275 -0
  79. data/lib/fastly/models/mtdinvoice.rb +268 -0
  80. data/lib/fastly/models/mtdlineitems.rb +297 -0
  81. data/lib/fastly/models/realtime_entry_aggregated.rb +14 -4
  82. data/lib/fastly/models/realtime_measurements.rb +14 -4
  83. data/lib/fastly/models/relationship_default_ecdsa_tls_certificate.rb +216 -0
  84. data/lib/fastly/models/relationship_default_ecdsa_tls_certificate_default_ecdsa_certificate.rb +216 -0
  85. data/lib/fastly/models/relationship_default_ecdsa_tls_certificate_default_ecdsa_certificate_data.rb +228 -0
  86. data/lib/fastly/models/relationship_default_tls_certificate.rb +216 -0
  87. data/lib/fastly/models/relationship_default_tls_certificate_default_certificate.rb +216 -0
  88. data/lib/fastly/models/relationship_default_tls_certificate_default_certificate_data.rb +228 -0
  89. data/lib/fastly/models/{relationship_tls_dns_records.rb → relationship_tls_dns_records_request.rb} +4 -4
  90. data/lib/fastly/models/relationship_tls_dns_records_request_dns_records.rb +218 -0
  91. data/lib/fastly/models/{relationship_member_tls_dns_record.rb → relationship_tls_dns_records_request_dns_records_data.rb} +3 -3
  92. data/lib/fastly/models/relationship_tls_dns_records_response.rb +216 -0
  93. data/lib/fastly/models/relationship_tls_dns_records_response_dns_records.rb +218 -0
  94. data/lib/fastly/models/relationship_tls_dns_records_response_dns_records_data.rb +227 -0
  95. data/lib/fastly/models/relationships_for_tls_configuration.rb +1 -1
  96. data/lib/fastly/models/results.rb +11 -1
  97. data/lib/fastly/models/serviceusagemetric.rb +246 -0
  98. data/lib/fastly/models/{relationship_tls_dns_record.rb → serviceusagemetrics.rb} +10 -10
  99. data/lib/fastly/models/serviceusagemetrics_data.rb +276 -0
  100. data/lib/fastly/models/serviceusagetype.rb +227 -0
  101. data/lib/fastly/models/{relationship_tls_dns_record_dns_record.rb → serviceusagetypes.rb} +4 -4
  102. data/lib/fastly/models/tls_certificate_blob_response.rb +217 -0
  103. data/lib/fastly/models/tls_dns_record.rb +48 -12
  104. data/lib/fastly/models/update_dashboard_request.rb +240 -0
  105. data/lib/fastly/models/values.rb +1 -1
  106. data/lib/fastly/version.rb +1 -1
  107. data/lib/fastly.rb +41 -6
  108. data/sig.json +1 -1
  109. metadata +84 -14
@@ -0,0 +1,229 @@
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 ListDashboardsResponse
16
+ attr_accessor :data
17
+
18
+ # Meta for the pagination.
19
+ attr_accessor :meta
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'data' => :'data',
25
+ :'meta' => :'meta'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.fastly_types
36
+ {
37
+ :'data' => :'Array<Dashboard>',
38
+ :'meta' => :'Object'
39
+ }
40
+ end
41
+
42
+ # List of attributes with nullable: true
43
+ def self.fastly_nullable
44
+ Set.new([
45
+ :'meta'
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::ListDashboardsResponse` 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::ListDashboardsResponse`. 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?(:'data')
65
+ if (value = attributes[:'data']).is_a?(Array)
66
+ self.data = value
67
+ end
68
+ end
69
+
70
+ if attributes.key?(:'meta')
71
+ self.meta = attributes[:'meta']
72
+ end
73
+ end
74
+
75
+ # Show invalid properties with the reasons. Usually used together with valid?
76
+ # @return Array for valid properties with the reasons
77
+ def list_invalid_properties
78
+ invalid_properties = Array.new
79
+ invalid_properties
80
+ end
81
+
82
+ # Check to see if the all the properties in the model are valid
83
+ # @return true if the model is valid
84
+ def valid?
85
+ true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ data == o.data &&
94
+ meta == o.meta
95
+ end
96
+
97
+ # @see the `==` method
98
+ # @param [Object] Object to be compared
99
+ def eql?(o)
100
+ self == o
101
+ end
102
+
103
+ # Calculates hash code according to all attributes.
104
+ # @return [Integer] Hash code
105
+ def hash
106
+ [data, meta].hash
107
+ end
108
+
109
+ # Builds the object from hash
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ # @return [Object] Returns the model itself
112
+ def self.build_from_hash(attributes)
113
+ new.build_from_hash(attributes)
114
+ end
115
+
116
+ # Builds the object from hash
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ # @return [Object] Returns the model itself
119
+ def build_from_hash(attributes)
120
+ return nil unless attributes.is_a?(Hash)
121
+ self.class.fastly_types.each_pair do |key, type|
122
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
123
+ self.send("#{key}=", nil)
124
+ elsif type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :Time
145
+ Time.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :Boolean
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ # models (e.g. Pet) or oneOf
176
+ klass = Fastly.const_get(type)
177
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ if value.nil?
200
+ is_nullable = self.class.fastly_nullable.include?(attr)
201
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
+ end
203
+
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+
227
+ end
228
+
229
+ end
@@ -12,7 +12,7 @@ require 'date'
12
12
  require 'time'
13
13
 
14
14
  module Fastly
15
- class ListInvoicesResponse
15
+ class ListEomInvoicesResponse
16
16
  attr_accessor :data
17
17
 
18
18
  attr_accessor :meta
@@ -55,13 +55,13 @@ module Fastly
55
55
  # @param [Hash] attributes Model attributes in the form of hash
56
56
  def initialize(attributes = {})
57
57
  if (!attributes.is_a?(Hash))
58
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::ListInvoicesResponse` initialize method"
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::ListEomInvoicesResponse` initialize method"
59
59
  end
60
60
 
61
61
  # check to see if the attribute exists and convert string to symbol for hash key
62
62
  attributes = attributes.each_with_object({}) { |(k, v), h|
63
63
  if (!self.class.attribute_map.key?(k.to_sym))
64
- fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::ListInvoicesResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::ListEomInvoicesResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
65
  end
66
66
  h[k.to_sym] = v
67
67
  }
@@ -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 MtdInvoiceResponse
16
+ # The Customer ID associated with the invoice.
17
+ attr_accessor :customer_id
18
+
19
+ # An alphanumeric string identifying the invoice.
20
+ attr_accessor :invoice_id
21
+
22
+ # The date and time (in ISO 8601 format) for the initiation point of a billing cycle, signifying the start of charges for a service or subscription.
23
+ attr_accessor :billing_start_date
24
+
25
+ # The date and time (in ISO 8601 format) for the termination point of a billing cycle, signifying the end of charges for a service or subscription.
26
+ attr_accessor :billing_end_date
27
+
28
+ # The total billable amount for invoiced services charged within a single month.
29
+ attr_accessor :monthly_transaction_amount
30
+
31
+ attr_accessor :transaction_line_items
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'customer_id' => :'customer_id',
37
+ :'invoice_id' => :'invoice_id',
38
+ :'billing_start_date' => :'billing_start_date',
39
+ :'billing_end_date' => :'billing_end_date',
40
+ :'monthly_transaction_amount' => :'monthly_transaction_amount',
41
+ :'transaction_line_items' => :'transaction_line_items'
42
+ }
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.fastly_types
52
+ {
53
+ :'customer_id' => :'String',
54
+ :'invoice_id' => :'String',
55
+ :'billing_start_date' => :'Time',
56
+ :'billing_end_date' => :'Time',
57
+ :'monthly_transaction_amount' => :'String',
58
+ :'transaction_line_items' => :'Array<Mtdlineitems>'
59
+ }
60
+ end
61
+
62
+ # List of attributes with nullable: true
63
+ def self.fastly_nullable
64
+ Set.new([
65
+ ])
66
+ end
67
+
68
+ # List of class defined in allOf (OpenAPI v3)
69
+ def self.fastly_all_of
70
+ [
71
+ :'Mtdinvoice'
72
+ ]
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ if (!attributes.is_a?(Hash))
79
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::MtdInvoiceResponse` initialize method"
80
+ end
81
+
82
+ # check to see if the attribute exists and convert string to symbol for hash key
83
+ attributes = attributes.each_with_object({}) { |(k, v), h|
84
+ if (!self.class.attribute_map.key?(k.to_sym))
85
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::MtdInvoiceResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
86
+ end
87
+ h[k.to_sym] = v
88
+ }
89
+
90
+ if attributes.key?(:'customer_id')
91
+ self.customer_id = attributes[:'customer_id']
92
+ end
93
+
94
+ if attributes.key?(:'invoice_id')
95
+ self.invoice_id = attributes[:'invoice_id']
96
+ end
97
+
98
+ if attributes.key?(:'billing_start_date')
99
+ self.billing_start_date = attributes[:'billing_start_date']
100
+ end
101
+
102
+ if attributes.key?(:'billing_end_date')
103
+ self.billing_end_date = attributes[:'billing_end_date']
104
+ end
105
+
106
+ if attributes.key?(:'monthly_transaction_amount')
107
+ self.monthly_transaction_amount = attributes[:'monthly_transaction_amount']
108
+ end
109
+
110
+ if attributes.key?(:'transaction_line_items')
111
+ if (value = attributes[:'transaction_line_items']).is_a?(Array)
112
+ self.transaction_line_items = value
113
+ end
114
+ end
115
+ end
116
+
117
+ # Show invalid properties with the reasons. Usually used together with valid?
118
+ # @return Array for valid properties with the reasons
119
+ def list_invalid_properties
120
+ invalid_properties = Array.new
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ true
128
+ end
129
+
130
+ # Checks equality by comparing each attribute.
131
+ # @param [Object] Object to be compared
132
+ def ==(o)
133
+ return true if self.equal?(o)
134
+ self.class == o.class &&
135
+ customer_id == o.customer_id &&
136
+ invoice_id == o.invoice_id &&
137
+ billing_start_date == o.billing_start_date &&
138
+ billing_end_date == o.billing_end_date &&
139
+ monthly_transaction_amount == o.monthly_transaction_amount &&
140
+ transaction_line_items == o.transaction_line_items
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
+ [customer_id, invoice_id, billing_start_date, billing_end_date, monthly_transaction_amount, transaction_line_items].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