fastly 8.5.0 → 8.7.0

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