fastly 10.0.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -1
  3. data/Gemfile.lock +1 -1
  4. data/README.md +2 -5
  5. data/docs/AutomationToken.md +1 -1
  6. data/docs/AutomationTokenCreateRequestAttributes.md +1 -1
  7. data/docs/AutomationTokenCreateResponse.md +4 -6
  8. data/docs/AutomationTokenCreateResponseAllOf.md +3 -3
  9. data/docs/AutomationTokenResponse.md +4 -6
  10. data/docs/AutomationTokenResponseAllOf.md +4 -4
  11. data/docs/BillingUsageMetricsApi.md +11 -9
  12. data/docs/ComputeAclListEntriesMeta.md +1 -1
  13. data/docs/Header.md +2 -0
  14. data/docs/HeaderApi.md +8 -8
  15. data/docs/KvStoreItemApi.md +4 -4
  16. data/docs/LoggingAzureblobAdditional.md +1 -1
  17. data/docs/LoggingAzureblobApi.md +4 -4
  18. data/docs/LoggingAzureblobResponse.md +1 -1
  19. data/docs/Results.md +7 -0
  20. data/docs/SnippetApi.md +2 -2
  21. data/docs/{SnippetResponseCommonAllOf.md → SnippetResponseAllOf.md} +1 -1
  22. data/docs/TlsBulkCertificatesApi.md +4 -0
  23. data/lib/fastly/api/automation_tokens_api.rb +6 -6
  24. data/lib/fastly/api/billing_usage_metrics_api.rb +11 -8
  25. data/lib/fastly/api/header_api.rb +8 -8
  26. data/lib/fastly/api/kv_store_item_api.rb +5 -5
  27. data/lib/fastly/api/logging_azureblob_api.rb +4 -4
  28. data/lib/fastly/api/snippet_api.rb +3 -3
  29. data/lib/fastly/api/tls_bulk_certificates_api.rb +6 -0
  30. data/lib/fastly/configuration.rb +0 -18
  31. data/lib/fastly/models/automation_token.rb +1 -1
  32. data/lib/fastly/models/automation_token_create_request_attributes.rb +1 -1
  33. data/lib/fastly/models/automation_token_create_response.rb +21 -43
  34. data/lib/fastly/models/automation_token_create_response_all_of.rb +13 -12
  35. data/lib/fastly/models/automation_token_response.rb +24 -46
  36. data/lib/fastly/models/automation_token_response_all_of.rb +11 -10
  37. data/lib/fastly/models/compute_acl_list_entries_meta.rb +1 -1
  38. data/lib/fastly/models/header.rb +26 -4
  39. data/lib/fastly/models/header_response.rb +0 -1
  40. data/lib/fastly/models/logging_azureblob_additional.rb +1 -1
  41. data/lib/fastly/models/logging_azureblob_response.rb +1 -1
  42. data/lib/fastly/models/results.rb +71 -1
  43. data/lib/fastly/models/schemas_snippet_response.rb +3 -2
  44. data/lib/fastly/models/snippet.rb +0 -8
  45. data/lib/fastly/models/snippet_response.rb +2 -1
  46. data/lib/fastly/models/{snippet_response_common_all_of.rb → snippet_response_all_of.rb} +3 -3
  47. data/lib/fastly/version.rb +1 -1
  48. data/lib/fastly.rb +1 -26
  49. data/sig.json +1 -1
  50. metadata +4 -54
  51. data/docs/Billing.md +0 -16
  52. data/docs/BillingApi.md +0 -139
  53. data/docs/BillingBandwidth.md +0 -11
  54. data/docs/BillingBandwidthTiers.md +0 -14
  55. data/docs/BillingEstimateInvoiceId.md +0 -10
  56. data/docs/BillingEstimateLines.md +0 -10
  57. data/docs/BillingEstimateLinesLineItems.md +0 -18
  58. data/docs/BillingEstimateResponse.md +0 -18
  59. data/docs/BillingInvoiceId.md +0 -10
  60. data/docs/BillingRegions.md +0 -13
  61. data/docs/BillingResponse.md +0 -18
  62. data/docs/BillingResponseItemItemsData.md +0 -10
  63. data/docs/BillingResponseLineItem.md +0 -29
  64. data/docs/BillingStatus.md +0 -11
  65. data/docs/BillingTotal.md +0 -25
  66. data/docs/BillingTotalExtras.md +0 -12
  67. data/docs/HeaderResponseAdditional.md +0 -11
  68. data/docs/LineItemData.md +0 -26
  69. data/docs/SchemasSnippetResponseCommon.md +0 -15
  70. data/docs/SnippetAllOf.md +0 -10
  71. data/docs/SnippetCommon.md +0 -13
  72. data/docs/SnippetResponseCommon.md +0 -15
  73. data/docs/SnippetResponsePost.md +0 -20
  74. data/docs/SnippetWithDynamicNumber.md +0 -14
  75. data/docs/SnippetWithDynamicNumberAllOf.md +0 -10
  76. data/lib/fastly/api/billing_api.rb +0 -229
  77. data/lib/fastly/models/billing.rb +0 -278
  78. data/lib/fastly/models/billing_bandwidth.rb +0 -227
  79. data/lib/fastly/models/billing_bandwidth_tiers.rb +0 -252
  80. data/lib/fastly/models/billing_estimate_invoice_id.rb +0 -216
  81. data/lib/fastly/models/billing_estimate_lines.rb +0 -218
  82. data/lib/fastly/models/billing_estimate_lines_line_items.rb +0 -288
  83. data/lib/fastly/models/billing_estimate_response.rb +0 -307
  84. data/lib/fastly/models/billing_invoice_id.rb +0 -216
  85. data/lib/fastly/models/billing_regions.rb +0 -243
  86. data/lib/fastly/models/billing_response.rb +0 -307
  87. data/lib/fastly/models/billing_response_item_items_data.rb +0 -218
  88. data/lib/fastly/models/billing_response_line_item.rb +0 -418
  89. data/lib/fastly/models/billing_status.rb +0 -262
  90. data/lib/fastly/models/billing_total.rb +0 -371
  91. data/lib/fastly/models/billing_total_extras.rb +0 -237
  92. data/lib/fastly/models/header_response_additional.rb +0 -229
  93. data/lib/fastly/models/line_item_data.rb +0 -377
  94. data/lib/fastly/models/schemas_snippet_response_common.rb +0 -276
  95. data/lib/fastly/models/snippet_all_of.rb +0 -251
  96. data/lib/fastly/models/snippet_common.rb +0 -284
  97. data/lib/fastly/models/snippet_response_common.rb +0 -276
  98. data/lib/fastly/models/snippet_response_post.rb +0 -375
  99. data/lib/fastly/models/snippet_with_dynamic_number.rb +0 -314
  100. data/lib/fastly/models/snippet_with_dynamic_number_all_of.rb +0 -251
@@ -1,229 +0,0 @@
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 'cgi'
12
-
13
- module Fastly
14
- class BillingApi
15
- attr_accessor :api_client
16
-
17
- def initialize(api_client = ApiClient.default)
18
- @api_client = api_client
19
- end
20
- # Get an invoice
21
- # Get the invoice for a given year and month. Can be any month from when the Customer was created to the current month.
22
- # @option opts [String] :month 2-digit month. (required)
23
- # @option opts [String] :year 4-digit year. (required)
24
- # @return [BillingResponse]
25
- def get_invoice(opts = {})
26
- data, _status_code, _headers = get_invoice_with_http_info(opts)
27
- data
28
- end
29
-
30
- # Get an invoice
31
- # Get the invoice for a given year and month. Can be any month from when the Customer was created to the current month.
32
- # @option opts [String] :month 2-digit month. (required)
33
- # @option opts [String] :year 4-digit year. (required)
34
- # @return [Array<(BillingResponse, Integer, Hash)>] BillingResponse data, response status code and response headers
35
- def get_invoice_with_http_info(opts = {})
36
- if @api_client.config.debugging
37
- @api_client.config.logger.debug 'Calling API: BillingApi.get_invoice ...'
38
- end
39
- # unbox the parameters from the hash
40
- month = opts[:'month']
41
- year = opts[:'year']
42
- # verify the required parameter 'month' is set
43
- if @api_client.config.client_side_validation && month.nil?
44
- fail ArgumentError, "Missing the required parameter 'month' when calling BillingApi.get_invoice"
45
- end
46
- # verify the required parameter 'year' is set
47
- if @api_client.config.client_side_validation && year.nil?
48
- fail ArgumentError, "Missing the required parameter 'year' when calling BillingApi.get_invoice"
49
- end
50
- # resource path
51
- local_var_path = '/billing/v2/year/{year}/month/{month}'.sub('{' + 'month' + '}', CGI.escape(month.to_s)).sub('{' + 'year' + '}', CGI.escape(year.to_s))
52
-
53
- # query parameters
54
- query_params = opts[:query_params] || {}
55
-
56
- # header parameters
57
- header_params = opts[:header_params] || {}
58
- # HTTP header 'Accept' (if needed)
59
- header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/pdf'])
60
-
61
- # form parameters
62
- form_params = opts[:form_params] || {}
63
-
64
- # http body (model)
65
- post_body = opts[:debug_body]
66
-
67
- # return_type
68
- return_type = opts[:debug_return_type] || 'BillingResponse'
69
-
70
- # auth_names
71
- auth_names = opts[:debug_auth_names] || ['token']
72
-
73
- new_options = opts.merge(
74
- :operation => :"BillingApi.get_invoice",
75
- :header_params => header_params,
76
- :query_params => query_params,
77
- :form_params => form_params,
78
- :body => post_body,
79
- :auth_names => auth_names,
80
- :return_type => return_type
81
- )
82
-
83
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
84
- if @api_client.config.debugging
85
- @api_client.config.logger.debug "API called: BillingApi#get_invoice\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
- end
87
- return data, status_code, headers
88
- end
89
-
90
- # Get an invoice
91
- # Get the invoice for the given invoice_id.
92
- # @option opts [String] :customer_id Alphanumeric string identifying the customer. (required)
93
- # @option opts [Integer] :invoice_id (required)
94
- # @return [BillingResponse]
95
- def get_invoice_by_id(opts = {})
96
- data, _status_code, _headers = get_invoice_by_id_with_http_info(opts)
97
- data
98
- end
99
-
100
- # Get an invoice
101
- # Get the invoice for the given invoice_id.
102
- # @option opts [String] :customer_id Alphanumeric string identifying the customer. (required)
103
- # @option opts [Integer] :invoice_id (required)
104
- # @return [Array<(BillingResponse, Integer, Hash)>] BillingResponse data, response status code and response headers
105
- def get_invoice_by_id_with_http_info(opts = {})
106
- if @api_client.config.debugging
107
- @api_client.config.logger.debug 'Calling API: BillingApi.get_invoice_by_id ...'
108
- end
109
- # unbox the parameters from the hash
110
- customer_id = opts[:'customer_id']
111
- invoice_id = opts[:'invoice_id']
112
- # verify the required parameter 'customer_id' is set
113
- if @api_client.config.client_side_validation && customer_id.nil?
114
- fail ArgumentError, "Missing the required parameter 'customer_id' when calling BillingApi.get_invoice_by_id"
115
- end
116
- # verify the required parameter 'invoice_id' is set
117
- if @api_client.config.client_side_validation && invoice_id.nil?
118
- fail ArgumentError, "Missing the required parameter 'invoice_id' when calling BillingApi.get_invoice_by_id"
119
- end
120
- # resource path
121
- local_var_path = '/billing/v2/account_customers/{customer_id}/invoices/{invoice_id}'.sub('{' + 'customer_id' + '}', CGI.escape(customer_id.to_s)).sub('{' + 'invoice_id' + '}', CGI.escape(invoice_id.to_s))
122
-
123
- # query parameters
124
- query_params = opts[:query_params] || {}
125
-
126
- # header parameters
127
- header_params = opts[:header_params] || {}
128
- # HTTP header 'Accept' (if needed)
129
- header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/pdf'])
130
-
131
- # form parameters
132
- form_params = opts[:form_params] || {}
133
-
134
- # http body (model)
135
- post_body = opts[:debug_body]
136
-
137
- # return_type
138
- return_type = opts[:debug_return_type] || 'BillingResponse'
139
-
140
- # auth_names
141
- auth_names = opts[:debug_auth_names] || ['token']
142
-
143
- new_options = opts.merge(
144
- :operation => :"BillingApi.get_invoice_by_id",
145
- :header_params => header_params,
146
- :query_params => query_params,
147
- :form_params => form_params,
148
- :body => post_body,
149
- :auth_names => auth_names,
150
- :return_type => return_type
151
- )
152
-
153
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
154
- if @api_client.config.debugging
155
- @api_client.config.logger.debug "API called: BillingApi#get_invoice_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
156
- end
157
- return data, status_code, headers
158
- end
159
-
160
- # Get month-to-date billing estimate
161
- # Get the current month-to-date estimate. This endpoint has two different responses. Under normal circumstances, it generally takes less than 5 seconds to generate but in certain cases can take up to 60 seconds. Once generated the month-to-date estimate is cached for 4 hours, and is available the next request will return the JSON representation of the month-to-date estimate. While a report is being generated in the background, this endpoint will return a `202 Accepted` response. The full format of which can be found in detail in our [billing calculation guide](https://docs.fastly.com/en/guides/how-we-calculate-your-bill). There are certain accounts for which we are unable to generate a month-to-date estimate. For example, accounts who have parent-pay are unable to generate an MTD estimate. The parent accounts are able to generate a month-to-date estimate but that estimate will not include the child accounts amounts at this time.
162
- # @option opts [String] :customer_id Alphanumeric string identifying the customer. (required)
163
- # @option opts [String] :month 2-digit month.
164
- # @option opts [String] :year 4-digit year.
165
- # @return [BillingEstimateResponse]
166
- def get_invoice_mtd(opts = {})
167
- data, _status_code, _headers = get_invoice_mtd_with_http_info(opts)
168
- data
169
- end
170
-
171
- # Get month-to-date billing estimate
172
- # Get the current month-to-date estimate. This endpoint has two different responses. Under normal circumstances, it generally takes less than 5 seconds to generate but in certain cases can take up to 60 seconds. Once generated the month-to-date estimate is cached for 4 hours, and is available the next request will return the JSON representation of the month-to-date estimate. While a report is being generated in the background, this endpoint will return a &#x60;202 Accepted&#x60; response. The full format of which can be found in detail in our [billing calculation guide](https://docs.fastly.com/en/guides/how-we-calculate-your-bill). There are certain accounts for which we are unable to generate a month-to-date estimate. For example, accounts who have parent-pay are unable to generate an MTD estimate. The parent accounts are able to generate a month-to-date estimate but that estimate will not include the child accounts amounts at this time.
173
- # @option opts [String] :customer_id Alphanumeric string identifying the customer. (required)
174
- # @option opts [String] :month 2-digit month.
175
- # @option opts [String] :year 4-digit year.
176
- # @return [Array<(BillingEstimateResponse, Integer, Hash)>] BillingEstimateResponse data, response status code and response headers
177
- def get_invoice_mtd_with_http_info(opts = {})
178
- if @api_client.config.debugging
179
- @api_client.config.logger.debug 'Calling API: BillingApi.get_invoice_mtd ...'
180
- end
181
- # unbox the parameters from the hash
182
- customer_id = opts[:'customer_id']
183
- # verify the required parameter 'customer_id' is set
184
- if @api_client.config.client_side_validation && customer_id.nil?
185
- fail ArgumentError, "Missing the required parameter 'customer_id' when calling BillingApi.get_invoice_mtd"
186
- end
187
- # resource path
188
- local_var_path = '/billing/v2/account_customers/{customer_id}/mtd_invoice'.sub('{' + 'customer_id' + '}', CGI.escape(customer_id.to_s))
189
-
190
- # query parameters
191
- query_params = opts[:query_params] || {}
192
- query_params[:'month'] = opts[:'month'] if !opts[:'month'].nil?
193
- query_params[:'year'] = opts[:'year'] if !opts[:'year'].nil?
194
-
195
- # header parameters
196
- header_params = opts[:header_params] || {}
197
- # HTTP header 'Accept' (if needed)
198
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
199
-
200
- # form parameters
201
- form_params = opts[:form_params] || {}
202
-
203
- # http body (model)
204
- post_body = opts[:debug_body]
205
-
206
- # return_type
207
- return_type = opts[:debug_return_type] || 'BillingEstimateResponse'
208
-
209
- # auth_names
210
- auth_names = opts[:debug_auth_names] || ['token']
211
-
212
- new_options = opts.merge(
213
- :operation => :"BillingApi.get_invoice_mtd",
214
- :header_params => header_params,
215
- :query_params => query_params,
216
- :form_params => form_params,
217
- :body => post_body,
218
- :auth_names => auth_names,
219
- :return_type => return_type
220
- )
221
-
222
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
223
- if @api_client.config.debugging
224
- @api_client.config.logger.debug "API called: BillingApi#get_invoice_mtd\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
225
- end
226
- return data, status_code, headers
227
- end
228
- end
229
- end
@@ -1,278 +0,0 @@
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 Billing
16
- # Date and time in ISO 8601 format.
17
- attr_accessor :end_time
18
-
19
- # Date and time in ISO 8601 format.
20
- attr_accessor :start_time
21
-
22
- attr_accessor :customer_id
23
-
24
- # The current state of our third-party billing vendor. One of `up` or `down`.
25
- attr_accessor :vendor_state
26
-
27
- attr_accessor :status
28
-
29
- attr_accessor :total
30
-
31
- # Breakdown of regional data for products that are region based.
32
- attr_accessor :regions
33
-
34
- # Attribute mapping from ruby-style variable name to JSON key.
35
- def self.attribute_map
36
- {
37
- :'end_time' => :'end_time',
38
- :'start_time' => :'start_time',
39
- :'customer_id' => :'customer_id',
40
- :'vendor_state' => :'vendor_state',
41
- :'status' => :'status',
42
- :'total' => :'total',
43
- :'regions' => :'regions'
44
- }
45
- end
46
-
47
- # Returns all the JSON keys this model knows about
48
- def self.acceptable_attributes
49
- attribute_map.values
50
- end
51
-
52
- # Attribute type mapping.
53
- def self.fastly_types
54
- {
55
- :'end_time' => :'Time',
56
- :'start_time' => :'Time',
57
- :'customer_id' => :'String',
58
- :'vendor_state' => :'String',
59
- :'status' => :'BillingStatus',
60
- :'total' => :'BillingTotal',
61
- :'regions' => :'Hash<String, BillingRegions>'
62
- }
63
- end
64
-
65
- # List of attributes with nullable: true
66
- def self.fastly_nullable
67
- Set.new([
68
- :'end_time',
69
- :'start_time',
70
- ])
71
- end
72
-
73
- # Initializes the object
74
- # @param [Hash] attributes Model attributes in the form of hash
75
- def initialize(attributes = {})
76
- if (!attributes.is_a?(Hash))
77
- fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::Billing` initialize method"
78
- end
79
-
80
- # check to see if the attribute exists and convert string to symbol for hash key
81
- attributes = attributes.each_with_object({}) { |(k, v), h|
82
- if (!self.class.attribute_map.key?(k.to_sym))
83
- fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::Billing`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
- end
85
- h[k.to_sym] = v
86
- }
87
-
88
- if attributes.key?(:'end_time')
89
- self.end_time = attributes[:'end_time']
90
- end
91
-
92
- if attributes.key?(:'start_time')
93
- self.start_time = attributes[:'start_time']
94
- end
95
-
96
- if attributes.key?(:'customer_id')
97
- self.customer_id = attributes[:'customer_id']
98
- end
99
-
100
- if attributes.key?(:'vendor_state')
101
- self.vendor_state = attributes[:'vendor_state']
102
- end
103
-
104
- if attributes.key?(:'status')
105
- self.status = attributes[:'status']
106
- end
107
-
108
- if attributes.key?(:'total')
109
- self.total = attributes[:'total']
110
- end
111
-
112
- if attributes.key?(:'regions')
113
- if (value = attributes[:'regions']).is_a?(Hash)
114
- self.regions = value
115
- end
116
- end
117
- end
118
-
119
- # Show invalid properties with the reasons. Usually used together with valid?
120
- # @return Array for valid properties with the reasons
121
- def list_invalid_properties
122
- invalid_properties = Array.new
123
- invalid_properties
124
- end
125
-
126
- # Check to see if the all the properties in the model are valid
127
- # @return true if the model is valid
128
- def valid?
129
- true
130
- end
131
-
132
- # Checks equality by comparing each attribute.
133
- # @param [Object] Object to be compared
134
- def ==(o)
135
- return true if self.equal?(o)
136
- self.class == o.class &&
137
- end_time == o.end_time &&
138
- start_time == o.start_time &&
139
- customer_id == o.customer_id &&
140
- vendor_state == o.vendor_state &&
141
- status == o.status &&
142
- total == o.total &&
143
- regions == o.regions
144
- end
145
-
146
- # @see the `==` method
147
- # @param [Object] Object to be compared
148
- def eql?(o)
149
- self == o
150
- end
151
-
152
- # Calculates hash code according to all attributes.
153
- # @return [Integer] Hash code
154
- def hash
155
- [end_time, start_time, customer_id, vendor_state, status, total, regions].hash
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 self.build_from_hash(attributes)
162
- new.build_from_hash(attributes)
163
- end
164
-
165
- # Builds the object from hash
166
- # @param [Hash] attributes Model attributes in the form of hash
167
- # @return [Object] Returns the model itself
168
- def build_from_hash(attributes)
169
- return nil unless attributes.is_a?(Hash)
170
- self.class.fastly_types.each_pair do |key, type|
171
- if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
172
- self.send("#{key}=", nil)
173
- elsif type =~ /\AArray<(.*)>/i
174
- # check to ensure the input is an array given that the attribute
175
- # is documented as an array but the input is not
176
- if attributes[self.class.attribute_map[key]].is_a?(Array)
177
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
178
- end
179
- elsif !attributes[self.class.attribute_map[key]].nil?
180
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
181
- end
182
- end
183
-
184
- self
185
- end
186
-
187
- # Deserializes the data based on type
188
- # @param string type Data type
189
- # @param string value Value to be deserialized
190
- # @return [Object] Deserialized data
191
- def _deserialize(type, value)
192
- case type.to_sym
193
- when :Time
194
- Time.parse(value)
195
- when :Date
196
- Date.parse(value)
197
- when :String
198
- value.to_s
199
- when :Integer
200
- value.to_i
201
- when :Float
202
- value.to_f
203
- when :Boolean
204
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
205
- true
206
- else
207
- false
208
- end
209
- when :Object
210
- # generic object (usually a Hash), return directly
211
- value
212
- when /\AArray<(?<inner_type>.+)>\z/
213
- inner_type = Regexp.last_match[:inner_type]
214
- value.map { |v| _deserialize(inner_type, v) }
215
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
216
- k_type = Regexp.last_match[:k_type]
217
- v_type = Regexp.last_match[:v_type]
218
- {}.tap do |hash|
219
- value.each do |k, v|
220
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
221
- end
222
- end
223
- else # model
224
- # models (e.g. Pet) or oneOf
225
- klass = Fastly.const_get(type)
226
- klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
227
- end
228
- end
229
-
230
- # Returns the string representation of the object
231
- # @return [String] String presentation of the object
232
- def to_s
233
- to_hash.to_s
234
- end
235
-
236
- # to_body is an alias to to_hash (backward compatibility)
237
- # @return [Hash] Returns the object in the form of hash
238
- def to_body
239
- to_hash
240
- end
241
-
242
- # Returns the object in the form of hash
243
- # @return [Hash] Returns the object in the form of hash
244
- def to_hash
245
- hash = {}
246
- self.class.attribute_map.each_pair do |attr, param|
247
- value = self.send(attr)
248
- if value.nil?
249
- is_nullable = self.class.fastly_nullable.include?(attr)
250
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
251
- end
252
-
253
- hash[param] = _to_hash(value)
254
- end
255
- hash
256
- end
257
-
258
- # Outputs non-array value in the form of hash
259
- # For object, use to_hash. Otherwise, just return the value
260
- # @param [Object] value Any valid value
261
- # @return [Hash] Returns the value in the form of hash
262
- def _to_hash(value)
263
- if value.is_a?(Array)
264
- value.compact.map { |v| _to_hash(v) }
265
- elsif value.is_a?(Hash)
266
- {}.tap do |hash|
267
- value.each { |k, v| hash[k] = _to_hash(v) }
268
- end
269
- elsif value.respond_to? :to_hash
270
- value.to_hash
271
- else
272
- value
273
- end
274
- end
275
-
276
- end
277
-
278
- end