fastly 8.4.0 → 8.6.0

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