fastly 8.9.0 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -4
- data/docs/AccessKey.md +12 -0
- data/docs/AccessKeyResponse.md +15 -0
- data/docs/AclsInComputeApi.md +2 -2
- data/docs/Backend.md +2 -2
- data/docs/BackendApi.md +8 -8
- data/docs/BackendResponse.md +2 -2
- data/docs/BillingUsageMetricsApi.md +13 -19
- data/docs/ComputeAclUpdate.md +10 -0
- data/docs/DimensionAttributesCountryStats.md +12 -0
- data/docs/DimensionAttributesRate.md +10 -0
- data/docs/DimensionBrowser.md +10 -0
- data/docs/DimensionContentType.md +10 -0
- data/docs/DimensionCountry.md +10 -0
- data/docs/DimensionDevice.md +10 -0
- data/docs/DimensionOs.md +10 -0
- data/docs/DimensionResponse.md +10 -0
- data/docs/DimensionStatusCode.md +10 -0
- data/docs/DimensionUrl.md +10 -0
- data/docs/EnabledProductsApi.md +5 -5
- data/docs/FilterFieldItem.md +12 -0
- data/docs/GetLogInsightsResponse.md +11 -0
- data/docs/GetLogRecordsResponse.md +11 -0
- data/docs/GetLogRecordsResponseMeta.md +10 -0
- data/docs/GetLogRecordsResponseMetaFilters.md +16 -0
- data/docs/InsightsApi.md +69 -0
- data/docs/KvStoreItemApi.md +2 -0
- data/docs/LogExplorerApi.md +65 -0
- data/docs/LogInsights.md +12 -0
- data/docs/LogInsightsDimensionAttributes.md +49 -0
- data/docs/LogInsightsDimensions.md +61 -0
- data/docs/LogInsightsMeta.md +10 -0
- data/docs/LogInsightsMetaFilter.md +14 -0
- data/docs/LogInsightsValues.md +65 -0
- data/docs/LogPropertyServiceId.md +9 -0
- data/docs/LogRecord.md +37 -0
- data/docs/LoggingGrafanacloudlogsAdditional.md +14 -0
- data/docs/LoggingGrafanacloudlogsApi.md +259 -0
- data/docs/LoggingGrafanacloudlogsResponse.md +23 -0
- data/docs/ObjectStorageAccessKeysApi.md +163 -0
- data/docs/RealtimeEntryAggregated.md +3 -7
- data/docs/RealtimeMeasurements.md +3 -7
- data/docs/Results.md +3 -7
- data/docs/SetConfiguration.md +1 -0
- data/docs/Usagemetric.md +18 -0
- data/docs/Usagemetrics.md +10 -0
- data/docs/ValueField.md +59 -0
- data/docs/Values503Responses.md +12 -0
- data/docs/ValuesBandwidth.md +11 -0
- data/docs/ValuesBrowser.md +11 -0
- data/docs/ValuesCacheHitRatio.md +10 -0
- data/docs/ValuesCountryStats.md +12 -0
- data/docs/ValuesDuration.md +12 -0
- data/docs/ValuesMisses.md +10 -0
- data/docs/ValuesRate.md +10 -0
- data/docs/ValuesRequests.md +10 -0
- data/docs/ValuesStatusCodes.md +12 -0
- data/lib/fastly/api/acls_in_compute_api.rb +3 -3
- data/lib/fastly/api/backend_api.rb +8 -8
- data/lib/fastly/api/billing_usage_metrics_api.rb +30 -57
- data/lib/fastly/api/enabled_products_api.rb +10 -10
- data/lib/fastly/api/insights_api.rb +125 -0
- data/lib/fastly/api/kv_store_item_api.rb +3 -0
- data/lib/fastly/api/log_explorer_api.rb +109 -0
- data/lib/fastly/api/logging_grafanacloudlogs_api.rb +471 -0
- data/lib/fastly/api/object_storage_access_keys_api.rb +263 -0
- data/lib/fastly/configuration.rb +67 -1
- data/lib/fastly/models/access_key.rb +248 -0
- data/lib/fastly/models/access_key_response.rb +269 -0
- data/lib/fastly/models/backend.rb +2 -2
- data/lib/fastly/models/backend_response.rb +2 -2
- data/lib/fastly/models/compute_acl_list_entries.rb +1 -1
- data/lib/fastly/models/compute_acl_lookup.rb +1 -1
- data/lib/fastly/models/compute_acl_update.rb +219 -0
- data/lib/fastly/models/compute_acl_update_entry.rb +1 -1
- data/lib/fastly/models/dimension_attributes_country_stats.rb +237 -0
- data/lib/fastly/models/dimension_attributes_rate.rb +217 -0
- data/lib/fastly/models/dimension_browser.rb +217 -0
- data/lib/fastly/models/dimension_content_type.rb +217 -0
- data/lib/fastly/models/dimension_country.rb +217 -0
- data/lib/fastly/models/dimension_device.rb +217 -0
- data/lib/fastly/models/dimension_os.rb +217 -0
- data/lib/fastly/models/dimension_response.rb +217 -0
- data/lib/fastly/models/dimension_status_code.rb +217 -0
- data/lib/fastly/models/dimension_url.rb +217 -0
- data/lib/fastly/models/filter_field_item.rb +271 -0
- data/lib/fastly/models/get_log_insights_response.rb +227 -0
- data/lib/fastly/models/get_log_records_response.rb +227 -0
- data/lib/fastly/models/get_log_records_response_meta.rb +216 -0
- data/lib/fastly/models/get_log_records_response_meta_filters.rb +307 -0
- data/lib/fastly/models/log_insights.rb +234 -0
- data/lib/fastly/models/log_insights_dimension_attributes.rb +103 -0
- data/lib/fastly/models/log_insights_dimensions.rb +109 -0
- data/lib/fastly/models/log_insights_meta.rb +217 -0
- data/lib/fastly/models/log_insights_meta_filter.rb +284 -0
- data/lib/fastly/models/log_insights_values.rb +111 -0
- data/lib/fastly/models/log_property_service_id.rb +208 -0
- data/lib/fastly/models/log_record.rb +486 -0
- data/lib/fastly/models/logging_grafanacloudlogs_additional.rb +257 -0
- data/lib/fastly/models/logging_grafanacloudlogs_response.rb +408 -0
- data/lib/fastly/models/realtime_entry_aggregated.rb +34 -74
- data/lib/fastly/models/realtime_measurements.rb +34 -74
- data/lib/fastly/models/results.rb +31 -71
- data/lib/fastly/models/set_configuration.rb +14 -4
- data/lib/fastly/models/usagemetric.rb +297 -0
- data/lib/fastly/models/usagemetrics.rb +218 -0
- data/lib/fastly/models/value_field.rb +108 -0
- data/lib/fastly/models/values503_responses.rb +237 -0
- data/lib/fastly/models/values_bandwidth.rb +227 -0
- data/lib/fastly/models/values_browser.rb +227 -0
- data/lib/fastly/models/values_cache_hit_ratio.rb +217 -0
- data/lib/fastly/models/values_country_stats.rb +237 -0
- data/lib/fastly/models/values_duration.rb +237 -0
- data/lib/fastly/models/values_misses.rb +217 -0
- data/lib/fastly/models/values_rate.rb +217 -0
- data/lib/fastly/models/values_requests.rb +217 -0
- data/lib/fastly/models/values_status_codes.rb +237 -0
- data/lib/fastly/version.rb +1 -1
- data/lib/fastly.rb +45 -0
- data/sig.json +1 -1
- metadata +92 -2
@@ -19,11 +19,15 @@ module Fastly
|
|
19
19
|
# The new traffic ramp. Optional in the `PATCH` request body for `ngwaf`.
|
20
20
|
attr_accessor :traffic_ramp
|
21
21
|
|
22
|
+
# The new mode to run the product in. One of `block`, `log`, or `off`. Optional in the `PATCH` request body for `ddos_protection`.
|
23
|
+
attr_accessor :mode
|
24
|
+
|
22
25
|
# Attribute mapping from ruby-style variable name to JSON key.
|
23
26
|
def self.attribute_map
|
24
27
|
{
|
25
28
|
:'workspace_id' => :'workspace_id',
|
26
|
-
:'traffic_ramp' => :'traffic_ramp'
|
29
|
+
:'traffic_ramp' => :'traffic_ramp',
|
30
|
+
:'mode' => :'mode'
|
27
31
|
}
|
28
32
|
end
|
29
33
|
|
@@ -36,7 +40,8 @@ module Fastly
|
|
36
40
|
def self.fastly_types
|
37
41
|
{
|
38
42
|
:'workspace_id' => :'String',
|
39
|
-
:'traffic_ramp' => :'String'
|
43
|
+
:'traffic_ramp' => :'String',
|
44
|
+
:'mode' => :'String'
|
40
45
|
}
|
41
46
|
end
|
42
47
|
|
@@ -68,6 +73,10 @@ module Fastly
|
|
68
73
|
if attributes.key?(:'traffic_ramp')
|
69
74
|
self.traffic_ramp = attributes[:'traffic_ramp']
|
70
75
|
end
|
76
|
+
|
77
|
+
if attributes.key?(:'mode')
|
78
|
+
self.mode = attributes[:'mode']
|
79
|
+
end
|
71
80
|
end
|
72
81
|
|
73
82
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -89,7 +98,8 @@ module Fastly
|
|
89
98
|
return true if self.equal?(o)
|
90
99
|
self.class == o.class &&
|
91
100
|
workspace_id == o.workspace_id &&
|
92
|
-
traffic_ramp == o.traffic_ramp
|
101
|
+
traffic_ramp == o.traffic_ramp &&
|
102
|
+
mode == o.mode
|
93
103
|
end
|
94
104
|
|
95
105
|
# @see the `==` method
|
@@ -101,7 +111,7 @@ module Fastly
|
|
101
111
|
# Calculates hash code according to all attributes.
|
102
112
|
# @return [Integer] Hash code
|
103
113
|
def hash
|
104
|
-
[workspace_id, traffic_ramp].hash
|
114
|
+
[workspace_id, traffic_ramp, mode].hash
|
105
115
|
end
|
106
116
|
|
107
117
|
# Builds the object from hash
|
@@ -0,0 +1,297 @@
|
|
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 Usagemetric
|
16
|
+
# The year and month of the usage element.
|
17
|
+
attr_accessor :month
|
18
|
+
|
19
|
+
# The usage type identifier for the usage. This is a single, billable metric for the product.
|
20
|
+
attr_accessor :usage_type
|
21
|
+
|
22
|
+
# Full name of the product usage type as it might appear on a customer's invoice.
|
23
|
+
attr_accessor :name
|
24
|
+
|
25
|
+
# The geographical area applicable for regionally based products.
|
26
|
+
attr_accessor :region
|
27
|
+
|
28
|
+
# The unit for the usage as shown on an invoice. If there is no explicit unit, this field will be \"unit\" (e.g., a request with `product_id` of 'cdn_usage' and `usage_type` of 'North America Requests' has no unit, and will return \"unit\").
|
29
|
+
attr_accessor :unit
|
30
|
+
|
31
|
+
# The quantity of the usage for the product.
|
32
|
+
attr_accessor :quantity
|
33
|
+
|
34
|
+
# The raw units measured for the product.
|
35
|
+
attr_accessor :raw_quantity
|
36
|
+
|
37
|
+
# The product identifier associated with the usage type. This corresponds to a Fastly product offering.
|
38
|
+
attr_accessor :product_id
|
39
|
+
|
40
|
+
# The date when the usage metric was last updated.
|
41
|
+
attr_accessor :last_updated_at
|
42
|
+
|
43
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
44
|
+
def self.attribute_map
|
45
|
+
{
|
46
|
+
:'month' => :'month',
|
47
|
+
:'usage_type' => :'usage_type',
|
48
|
+
:'name' => :'name',
|
49
|
+
:'region' => :'region',
|
50
|
+
:'unit' => :'unit',
|
51
|
+
:'quantity' => :'quantity',
|
52
|
+
:'raw_quantity' => :'raw_quantity',
|
53
|
+
:'product_id' => :'product_id',
|
54
|
+
:'last_updated_at' => :'last_updated_at'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns all the JSON keys this model knows about
|
59
|
+
def self.acceptable_attributes
|
60
|
+
attribute_map.values
|
61
|
+
end
|
62
|
+
|
63
|
+
# Attribute type mapping.
|
64
|
+
def self.fastly_types
|
65
|
+
{
|
66
|
+
:'month' => :'String',
|
67
|
+
:'usage_type' => :'String',
|
68
|
+
:'name' => :'String',
|
69
|
+
:'region' => :'String',
|
70
|
+
:'unit' => :'String',
|
71
|
+
:'quantity' => :'Float',
|
72
|
+
:'raw_quantity' => :'Float',
|
73
|
+
:'product_id' => :'String',
|
74
|
+
:'last_updated_at' => :'String'
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
# List of attributes with nullable: true
|
79
|
+
def self.fastly_nullable
|
80
|
+
Set.new([
|
81
|
+
])
|
82
|
+
end
|
83
|
+
|
84
|
+
# Initializes the object
|
85
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
86
|
+
def initialize(attributes = {})
|
87
|
+
if (!attributes.is_a?(Hash))
|
88
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::Usagemetric` initialize method"
|
89
|
+
end
|
90
|
+
|
91
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
92
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
93
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
94
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::Usagemetric`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
95
|
+
end
|
96
|
+
h[k.to_sym] = v
|
97
|
+
}
|
98
|
+
|
99
|
+
if attributes.key?(:'month')
|
100
|
+
self.month = attributes[:'month']
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.key?(:'usage_type')
|
104
|
+
self.usage_type = attributes[:'usage_type']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.key?(:'name')
|
108
|
+
self.name = attributes[:'name']
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.key?(:'region')
|
112
|
+
self.region = attributes[:'region']
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes.key?(:'unit')
|
116
|
+
self.unit = attributes[:'unit']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'quantity')
|
120
|
+
self.quantity = attributes[:'quantity']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'raw_quantity')
|
124
|
+
self.raw_quantity = attributes[:'raw_quantity']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'product_id')
|
128
|
+
self.product_id = attributes[:'product_id']
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:'last_updated_at')
|
132
|
+
self.last_updated_at = attributes[:'last_updated_at']
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
137
|
+
# @return Array for valid properties with the reasons
|
138
|
+
def list_invalid_properties
|
139
|
+
invalid_properties = Array.new
|
140
|
+
invalid_properties
|
141
|
+
end
|
142
|
+
|
143
|
+
# Check to see if the all the properties in the model are valid
|
144
|
+
# @return true if the model is valid
|
145
|
+
def valid?
|
146
|
+
true
|
147
|
+
end
|
148
|
+
|
149
|
+
# Checks equality by comparing each attribute.
|
150
|
+
# @param [Object] Object to be compared
|
151
|
+
def ==(o)
|
152
|
+
return true if self.equal?(o)
|
153
|
+
self.class == o.class &&
|
154
|
+
month == o.month &&
|
155
|
+
usage_type == o.usage_type &&
|
156
|
+
name == o.name &&
|
157
|
+
region == o.region &&
|
158
|
+
unit == o.unit &&
|
159
|
+
quantity == o.quantity &&
|
160
|
+
raw_quantity == o.raw_quantity &&
|
161
|
+
product_id == o.product_id &&
|
162
|
+
last_updated_at == o.last_updated_at
|
163
|
+
end
|
164
|
+
|
165
|
+
# @see the `==` method
|
166
|
+
# @param [Object] Object to be compared
|
167
|
+
def eql?(o)
|
168
|
+
self == o
|
169
|
+
end
|
170
|
+
|
171
|
+
# Calculates hash code according to all attributes.
|
172
|
+
# @return [Integer] Hash code
|
173
|
+
def hash
|
174
|
+
[month, usage_type, name, region, unit, quantity, raw_quantity, product_id, last_updated_at].hash
|
175
|
+
end
|
176
|
+
|
177
|
+
# Builds the object from hash
|
178
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
179
|
+
# @return [Object] Returns the model itself
|
180
|
+
def self.build_from_hash(attributes)
|
181
|
+
new.build_from_hash(attributes)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Builds the object from hash
|
185
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
186
|
+
# @return [Object] Returns the model itself
|
187
|
+
def build_from_hash(attributes)
|
188
|
+
return nil unless attributes.is_a?(Hash)
|
189
|
+
self.class.fastly_types.each_pair do |key, type|
|
190
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
|
191
|
+
self.send("#{key}=", nil)
|
192
|
+
elsif type =~ /\AArray<(.*)>/i
|
193
|
+
# check to ensure the input is an array given that the attribute
|
194
|
+
# is documented as an array but the input is not
|
195
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
196
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
197
|
+
end
|
198
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
199
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
self
|
204
|
+
end
|
205
|
+
|
206
|
+
# Deserializes the data based on type
|
207
|
+
# @param string type Data type
|
208
|
+
# @param string value Value to be deserialized
|
209
|
+
# @return [Object] Deserialized data
|
210
|
+
def _deserialize(type, value)
|
211
|
+
case type.to_sym
|
212
|
+
when :Time
|
213
|
+
Time.parse(value)
|
214
|
+
when :Date
|
215
|
+
Date.parse(value)
|
216
|
+
when :String
|
217
|
+
value.to_s
|
218
|
+
when :Integer
|
219
|
+
value.to_i
|
220
|
+
when :Float
|
221
|
+
value.to_f
|
222
|
+
when :Boolean
|
223
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
224
|
+
true
|
225
|
+
else
|
226
|
+
false
|
227
|
+
end
|
228
|
+
when :Object
|
229
|
+
# generic object (usually a Hash), return directly
|
230
|
+
value
|
231
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
232
|
+
inner_type = Regexp.last_match[:inner_type]
|
233
|
+
value.map { |v| _deserialize(inner_type, v) }
|
234
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
235
|
+
k_type = Regexp.last_match[:k_type]
|
236
|
+
v_type = Regexp.last_match[:v_type]
|
237
|
+
{}.tap do |hash|
|
238
|
+
value.each do |k, v|
|
239
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
else # model
|
243
|
+
# models (e.g. Pet) or oneOf
|
244
|
+
klass = Fastly.const_get(type)
|
245
|
+
klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# Returns the string representation of the object
|
250
|
+
# @return [String] String presentation of the object
|
251
|
+
def to_s
|
252
|
+
to_hash.to_s
|
253
|
+
end
|
254
|
+
|
255
|
+
# to_body is an alias to to_hash (backward compatibility)
|
256
|
+
# @return [Hash] Returns the object in the form of hash
|
257
|
+
def to_body
|
258
|
+
to_hash
|
259
|
+
end
|
260
|
+
|
261
|
+
# Returns the object in the form of hash
|
262
|
+
# @return [Hash] Returns the object in the form of hash
|
263
|
+
def to_hash
|
264
|
+
hash = {}
|
265
|
+
self.class.attribute_map.each_pair do |attr, param|
|
266
|
+
value = self.send(attr)
|
267
|
+
if value.nil?
|
268
|
+
is_nullable = self.class.fastly_nullable.include?(attr)
|
269
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
270
|
+
end
|
271
|
+
|
272
|
+
hash[param] = _to_hash(value)
|
273
|
+
end
|
274
|
+
hash
|
275
|
+
end
|
276
|
+
|
277
|
+
# Outputs non-array value in the form of hash
|
278
|
+
# For object, use to_hash. Otherwise, just return the value
|
279
|
+
# @param [Object] value Any valid value
|
280
|
+
# @return [Hash] Returns the value in the form of hash
|
281
|
+
def _to_hash(value)
|
282
|
+
if value.is_a?(Array)
|
283
|
+
value.compact.map { |v| _to_hash(v) }
|
284
|
+
elsif value.is_a?(Hash)
|
285
|
+
{}.tap do |hash|
|
286
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
287
|
+
end
|
288
|
+
elsif value.respond_to? :to_hash
|
289
|
+
value.to_hash
|
290
|
+
else
|
291
|
+
value
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|
@@ -0,0 +1,218 @@
|
|
1
|
+
=begin
|
2
|
+
#Fastly API
|
3
|
+
|
4
|
+
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: oss@fastly.com
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
require 'time'
|
13
|
+
|
14
|
+
module Fastly
|
15
|
+
class Usagemetrics
|
16
|
+
attr_accessor :data
|
17
|
+
|
18
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
19
|
+
def self.attribute_map
|
20
|
+
{
|
21
|
+
:'data' => :'data'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns all the JSON keys this model knows about
|
26
|
+
def self.acceptable_attributes
|
27
|
+
attribute_map.values
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.fastly_types
|
32
|
+
{
|
33
|
+
:'data' => :'Array<Usagemetric>'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# List of attributes with nullable: true
|
38
|
+
def self.fastly_nullable
|
39
|
+
Set.new([
|
40
|
+
])
|
41
|
+
end
|
42
|
+
|
43
|
+
# Initializes the object
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
45
|
+
def initialize(attributes = {})
|
46
|
+
if (!attributes.is_a?(Hash))
|
47
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::Usagemetrics` initialize method"
|
48
|
+
end
|
49
|
+
|
50
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
51
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
52
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
53
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::Usagemetrics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
54
|
+
end
|
55
|
+
h[k.to_sym] = v
|
56
|
+
}
|
57
|
+
|
58
|
+
if attributes.key?(:'data')
|
59
|
+
if (value = attributes[:'data']).is_a?(Array)
|
60
|
+
self.data = value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
66
|
+
# @return Array for valid properties with the reasons
|
67
|
+
def list_invalid_properties
|
68
|
+
invalid_properties = Array.new
|
69
|
+
invalid_properties
|
70
|
+
end
|
71
|
+
|
72
|
+
# Check to see if the all the properties in the model are valid
|
73
|
+
# @return true if the model is valid
|
74
|
+
def valid?
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
78
|
+
# Checks equality by comparing each attribute.
|
79
|
+
# @param [Object] Object to be compared
|
80
|
+
def ==(o)
|
81
|
+
return true if self.equal?(o)
|
82
|
+
self.class == o.class &&
|
83
|
+
data == o.data
|
84
|
+
end
|
85
|
+
|
86
|
+
# @see the `==` method
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def eql?(o)
|
89
|
+
self == o
|
90
|
+
end
|
91
|
+
|
92
|
+
# Calculates hash code according to all attributes.
|
93
|
+
# @return [Integer] Hash code
|
94
|
+
def hash
|
95
|
+
[data].hash
|
96
|
+
end
|
97
|
+
|
98
|
+
# Builds the object from hash
|
99
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
100
|
+
# @return [Object] Returns the model itself
|
101
|
+
def self.build_from_hash(attributes)
|
102
|
+
new.build_from_hash(attributes)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Builds the object from hash
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
# @return [Object] Returns the model itself
|
108
|
+
def build_from_hash(attributes)
|
109
|
+
return nil unless attributes.is_a?(Hash)
|
110
|
+
self.class.fastly_types.each_pair do |key, type|
|
111
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
|
112
|
+
self.send("#{key}=", nil)
|
113
|
+
elsif type =~ /\AArray<(.*)>/i
|
114
|
+
# check to ensure the input is an array given that the attribute
|
115
|
+
# is documented as an array but the input is not
|
116
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
117
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
118
|
+
end
|
119
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
120
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
# Deserializes the data based on type
|
128
|
+
# @param string type Data type
|
129
|
+
# @param string value Value to be deserialized
|
130
|
+
# @return [Object] Deserialized data
|
131
|
+
def _deserialize(type, value)
|
132
|
+
case type.to_sym
|
133
|
+
when :Time
|
134
|
+
Time.parse(value)
|
135
|
+
when :Date
|
136
|
+
Date.parse(value)
|
137
|
+
when :String
|
138
|
+
value.to_s
|
139
|
+
when :Integer
|
140
|
+
value.to_i
|
141
|
+
when :Float
|
142
|
+
value.to_f
|
143
|
+
when :Boolean
|
144
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
145
|
+
true
|
146
|
+
else
|
147
|
+
false
|
148
|
+
end
|
149
|
+
when :Object
|
150
|
+
# generic object (usually a Hash), return directly
|
151
|
+
value
|
152
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
153
|
+
inner_type = Regexp.last_match[:inner_type]
|
154
|
+
value.map { |v| _deserialize(inner_type, v) }
|
155
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
156
|
+
k_type = Regexp.last_match[:k_type]
|
157
|
+
v_type = Regexp.last_match[:v_type]
|
158
|
+
{}.tap do |hash|
|
159
|
+
value.each do |k, v|
|
160
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
else # model
|
164
|
+
# models (e.g. Pet) or oneOf
|
165
|
+
klass = Fastly.const_get(type)
|
166
|
+
klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Returns the string representation of the object
|
171
|
+
# @return [String] String presentation of the object
|
172
|
+
def to_s
|
173
|
+
to_hash.to_s
|
174
|
+
end
|
175
|
+
|
176
|
+
# to_body is an alias to to_hash (backward compatibility)
|
177
|
+
# @return [Hash] Returns the object in the form of hash
|
178
|
+
def to_body
|
179
|
+
to_hash
|
180
|
+
end
|
181
|
+
|
182
|
+
# Returns the object in the form of hash
|
183
|
+
# @return [Hash] Returns the object in the form of hash
|
184
|
+
def to_hash
|
185
|
+
hash = {}
|
186
|
+
self.class.attribute_map.each_pair do |attr, param|
|
187
|
+
value = self.send(attr)
|
188
|
+
if value.nil?
|
189
|
+
is_nullable = self.class.fastly_nullable.include?(attr)
|
190
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
191
|
+
end
|
192
|
+
|
193
|
+
hash[param] = _to_hash(value)
|
194
|
+
end
|
195
|
+
hash
|
196
|
+
end
|
197
|
+
|
198
|
+
# Outputs non-array value in the form of hash
|
199
|
+
# For object, use to_hash. Otherwise, just return the value
|
200
|
+
# @param [Object] value Any valid value
|
201
|
+
# @return [Hash] Returns the value in the form of hash
|
202
|
+
def _to_hash(value)
|
203
|
+
if value.is_a?(Array)
|
204
|
+
value.compact.map { |v| _to_hash(v) }
|
205
|
+
elsif value.is_a?(Hash)
|
206
|
+
{}.tap do |hash|
|
207
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
208
|
+
end
|
209
|
+
elsif value.respond_to? :to_hash
|
210
|
+
value.to_hash
|
211
|
+
else
|
212
|
+
value
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
@@ -0,0 +1,108 @@
|
|
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
|
+
module ValueField
|
16
|
+
class << self
|
17
|
+
# List of class defined in oneOf (OpenAPI v3)
|
18
|
+
def fastly_one_of
|
19
|
+
[
|
20
|
+
:'Array<Float>',
|
21
|
+
:'Array<Integer>',
|
22
|
+
:'Array<String>',
|
23
|
+
:'Boolean',
|
24
|
+
:'Float',
|
25
|
+
:'Integer',
|
26
|
+
:'String'
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
# Builds the object
|
31
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
32
|
+
# @return [Object] Returns the model or the data itself
|
33
|
+
def build(data)
|
34
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
35
|
+
# Note:
|
36
|
+
# - We do not attempt to check whether exactly one item matches.
|
37
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
38
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
39
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
40
|
+
# - TODO: logging when debugging is set.
|
41
|
+
fastly_one_of.each do |klass|
|
42
|
+
begin
|
43
|
+
next if klass == :AnyType # "nullable: true"
|
44
|
+
typed_data = find_and_cast_into_type(klass, data)
|
45
|
+
return typed_data if typed_data
|
46
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
fastly_one_of.include?(:AnyType) ? data : nil
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
SchemaMismatchError = Class.new(StandardError)
|
56
|
+
|
57
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
58
|
+
def find_and_cast_into_type(klass, data)
|
59
|
+
return if data.nil?
|
60
|
+
|
61
|
+
case klass.to_s
|
62
|
+
when 'Boolean'
|
63
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
64
|
+
when 'Float'
|
65
|
+
return data if data.instance_of?(Float)
|
66
|
+
when 'Integer'
|
67
|
+
return data if data.instance_of?(Integer)
|
68
|
+
when 'Time'
|
69
|
+
return Time.parse(data)
|
70
|
+
when 'Date'
|
71
|
+
return Date.parse(data)
|
72
|
+
when 'String'
|
73
|
+
return data if data.instance_of?(String)
|
74
|
+
when 'Object' # "type: object"
|
75
|
+
return data if data.instance_of?(Hash)
|
76
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
77
|
+
if data.instance_of?(Array)
|
78
|
+
sub_type = Regexp.last_match[:sub_type]
|
79
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
80
|
+
end
|
81
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
82
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
83
|
+
sub_type = Regexp.last_match[:sub_type]
|
84
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
85
|
+
end
|
86
|
+
else # model
|
87
|
+
const = Fastly.const_get(klass)
|
88
|
+
if const
|
89
|
+
if const.respond_to?(:fastly_one_of) # nested oneOf model
|
90
|
+
model = const.build(data)
|
91
|
+
return model if model
|
92
|
+
else
|
93
|
+
# raise if data contains keys that are not known to the model
|
94
|
+
raise unless (data.keys - const.acceptable_attributes).empty?
|
95
|
+
model = const.build_from_hash(data)
|
96
|
+
return model if model && model.valid?
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
raise # if no match by now, raise
|
102
|
+
rescue
|
103
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|