fastly 7.0.0 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -70,6 +70,9 @@ module Fastly
70
70
  # Name of a Condition, which if satisfied, will select this backend during a request. If set, will override any `auto_loadbalance` setting. By default, the first backend added to a service is selected for all requests.
71
71
  attr_accessor :request_condition
72
72
 
73
+ # Value that when shared across backends will enable those backends to share the same health check.
74
+ attr_accessor :share_key
75
+
73
76
  # Identifier of the POP to use as a [shield](https://docs.fastly.com/en/guides/shielding).
74
77
  attr_accessor :shield
75
78
 
@@ -125,6 +128,7 @@ module Fastly
125
128
  :'override_host' => :'override_host',
126
129
  :'port' => :'port',
127
130
  :'request_condition' => :'request_condition',
131
+ :'share_key' => :'share_key',
128
132
  :'shield' => :'shield',
129
133
  :'ssl_ca_cert' => :'ssl_ca_cert',
130
134
  :'ssl_cert_hostname' => :'ssl_cert_hostname',
@@ -166,6 +170,7 @@ module Fastly
166
170
  :'override_host' => :'String',
167
171
  :'port' => :'Integer',
168
172
  :'request_condition' => :'String',
173
+ :'share_key' => :'String',
169
174
  :'shield' => :'String',
170
175
  :'ssl_ca_cert' => :'String',
171
176
  :'ssl_cert_hostname' => :'String',
@@ -193,6 +198,7 @@ module Fastly
193
198
  :'max_tls_version',
194
199
  :'min_tls_version',
195
200
  :'override_host',
201
+ :'share_key',
196
202
  :'shield',
197
203
  :'ssl_ca_cert',
198
204
  :'ssl_cert_hostname',
@@ -296,6 +302,10 @@ module Fastly
296
302
  self.request_condition = attributes[:'request_condition']
297
303
  end
298
304
 
305
+ if attributes.key?(:'share_key')
306
+ self.share_key = attributes[:'share_key']
307
+ end
308
+
299
309
  if attributes.key?(:'shield')
300
310
  self.shield = attributes[:'shield']
301
311
  end
@@ -347,15 +357,32 @@ module Fastly
347
357
  # @return Array for valid properties with the reasons
348
358
  def list_invalid_properties
349
359
  invalid_properties = Array.new
360
+ pattern = Regexp.new(/^[A-Za-z0-9]+$/)
361
+ if !@share_key.nil? && @share_key !~ pattern
362
+ invalid_properties.push("invalid value for \"share_key\", must conform to the pattern #{pattern}.")
363
+ end
364
+
350
365
  invalid_properties
351
366
  end
352
367
 
353
368
  # Check to see if the all the properties in the model are valid
354
369
  # @return true if the model is valid
355
370
  def valid?
371
+ return false if !@share_key.nil? && @share_key !~ Regexp.new(/^[A-Za-z0-9]+$/)
356
372
  true
357
373
  end
358
374
 
375
+ # Custom attribute writer method with validation
376
+ # @param [Object] share_key Value to be assigned
377
+ def share_key=(share_key)
378
+ pattern = Regexp.new(/^[A-Za-z0-9]+$/)
379
+ if !share_key.nil? && share_key !~ pattern
380
+ fail ArgumentError, "invalid value for \"share_key\", must conform to the pattern #{pattern}."
381
+ end
382
+
383
+ @share_key = share_key
384
+ end
385
+
359
386
  # Checks equality by comparing each attribute.
360
387
  # @param [Object] Object to be compared
361
388
  def ==(o)
@@ -380,6 +407,7 @@ module Fastly
380
407
  override_host == o.override_host &&
381
408
  port == o.port &&
382
409
  request_condition == o.request_condition &&
410
+ share_key == o.share_key &&
383
411
  shield == o.shield &&
384
412
  ssl_ca_cert == o.ssl_ca_cert &&
385
413
  ssl_cert_hostname == o.ssl_cert_hostname &&
@@ -402,7 +430,7 @@ module Fastly
402
430
  # Calculates hash code according to all attributes.
403
431
  # @return [Integer] Hash code
404
432
  def hash
405
- [address, auto_loadbalance, between_bytes_timeout, client_cert, comment, connect_timeout, first_byte_timeout, healthcheck, hostname, ipv4, ipv6, keepalive_time, max_conn, max_tls_version, min_tls_version, name, override_host, port, request_condition, shield, ssl_ca_cert, ssl_cert_hostname, ssl_check_cert, ssl_ciphers, ssl_client_cert, ssl_client_key, ssl_hostname, ssl_sni_hostname, use_ssl, weight].hash
433
+ [address, auto_loadbalance, between_bytes_timeout, client_cert, comment, connect_timeout, first_byte_timeout, healthcheck, hostname, ipv4, ipv6, keepalive_time, max_conn, max_tls_version, min_tls_version, name, override_host, port, request_condition, share_key, shield, ssl_ca_cert, ssl_cert_hostname, ssl_check_cert, ssl_ciphers, ssl_client_cert, ssl_client_key, ssl_hostname, ssl_sni_hostname, use_ssl, weight].hash
406
434
  end
407
435
 
408
436
  # Builds the object from hash
@@ -70,6 +70,9 @@ module Fastly
70
70
  # Name of a Condition, which if satisfied, will select this backend during a request. If set, will override any `auto_loadbalance` setting. By default, the first backend added to a service is selected for all requests.
71
71
  attr_accessor :request_condition
72
72
 
73
+ # Value that when shared across backends will enable those backends to share the same health check.
74
+ attr_accessor :share_key
75
+
73
76
  # Identifier of the POP to use as a [shield](https://docs.fastly.com/en/guides/shielding).
74
77
  attr_accessor :shield
75
78
 
@@ -141,6 +144,7 @@ module Fastly
141
144
  :'override_host' => :'override_host',
142
145
  :'port' => :'port',
143
146
  :'request_condition' => :'request_condition',
147
+ :'share_key' => :'share_key',
144
148
  :'shield' => :'shield',
145
149
  :'ssl_ca_cert' => :'ssl_ca_cert',
146
150
  :'ssl_cert_hostname' => :'ssl_cert_hostname',
@@ -188,6 +192,7 @@ module Fastly
188
192
  :'override_host' => :'String',
189
193
  :'port' => :'Integer',
190
194
  :'request_condition' => :'String',
195
+ :'share_key' => :'String',
191
196
  :'shield' => :'String',
192
197
  :'ssl_ca_cert' => :'String',
193
198
  :'ssl_cert_hostname' => :'String',
@@ -221,6 +226,7 @@ module Fastly
221
226
  :'max_tls_version',
222
227
  :'min_tls_version',
223
228
  :'override_host',
229
+ :'share_key',
224
230
  :'shield',
225
231
  :'ssl_ca_cert',
226
232
  :'ssl_cert_hostname',
@@ -337,6 +343,10 @@ module Fastly
337
343
  self.request_condition = attributes[:'request_condition']
338
344
  end
339
345
 
346
+ if attributes.key?(:'share_key')
347
+ self.share_key = attributes[:'share_key']
348
+ end
349
+
340
350
  if attributes.key?(:'shield')
341
351
  self.shield = attributes[:'shield']
342
352
  end
@@ -412,15 +422,32 @@ module Fastly
412
422
  # @return Array for valid properties with the reasons
413
423
  def list_invalid_properties
414
424
  invalid_properties = Array.new
425
+ pattern = Regexp.new(/^[A-Za-z0-9]+$/)
426
+ if !@share_key.nil? && @share_key !~ pattern
427
+ invalid_properties.push("invalid value for \"share_key\", must conform to the pattern #{pattern}.")
428
+ end
429
+
415
430
  invalid_properties
416
431
  end
417
432
 
418
433
  # Check to see if the all the properties in the model are valid
419
434
  # @return true if the model is valid
420
435
  def valid?
436
+ return false if !@share_key.nil? && @share_key !~ Regexp.new(/^[A-Za-z0-9]+$/)
421
437
  true
422
438
  end
423
439
 
440
+ # Custom attribute writer method with validation
441
+ # @param [Object] share_key Value to be assigned
442
+ def share_key=(share_key)
443
+ pattern = Regexp.new(/^[A-Za-z0-9]+$/)
444
+ if !share_key.nil? && share_key !~ pattern
445
+ fail ArgumentError, "invalid value for \"share_key\", must conform to the pattern #{pattern}."
446
+ end
447
+
448
+ @share_key = share_key
449
+ end
450
+
424
451
  # Checks equality by comparing each attribute.
425
452
  # @param [Object] Object to be compared
426
453
  def ==(o)
@@ -445,6 +472,7 @@ module Fastly
445
472
  override_host == o.override_host &&
446
473
  port == o.port &&
447
474
  request_condition == o.request_condition &&
475
+ share_key == o.share_key &&
448
476
  shield == o.shield &&
449
477
  ssl_ca_cert == o.ssl_ca_cert &&
450
478
  ssl_cert_hostname == o.ssl_cert_hostname &&
@@ -473,7 +501,7 @@ module Fastly
473
501
  # Calculates hash code according to all attributes.
474
502
  # @return [Integer] Hash code
475
503
  def hash
476
- [address, auto_loadbalance, between_bytes_timeout, client_cert, comment, connect_timeout, first_byte_timeout, healthcheck, hostname, ipv4, ipv6, keepalive_time, max_conn, max_tls_version, min_tls_version, name, override_host, port, request_condition, shield, ssl_ca_cert, ssl_cert_hostname, ssl_check_cert, ssl_ciphers, ssl_client_cert, ssl_client_key, ssl_hostname, ssl_sni_hostname, use_ssl, weight, created_at, deleted_at, updated_at, service_id, version, locked].hash
504
+ [address, auto_loadbalance, between_bytes_timeout, client_cert, comment, connect_timeout, first_byte_timeout, healthcheck, hostname, ipv4, ipv6, keepalive_time, max_conn, max_tls_version, min_tls_version, name, override_host, port, request_condition, share_key, shield, ssl_ca_cert, ssl_cert_hostname, ssl_check_cert, ssl_ciphers, ssl_client_cert, ssl_client_key, ssl_hostname, ssl_sni_hostname, use_ssl, weight, created_at, deleted_at, updated_at, service_id, version, locked].hash
477
505
  end
478
506
 
479
507
  # Builds the object from hash
@@ -0,0 +1,288 @@
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://developer.fastly.com/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 LoggingNewrelicotlpAdditional
16
+ # A Fastly [log format string](https://docs.fastly.com/en/guides/custom-log-formats).
17
+ attr_accessor :format
18
+
19
+ # The Insert API key from the Account page of your New Relic account. Required.
20
+ attr_accessor :token
21
+
22
+ # The region to which to stream logs.
23
+ attr_accessor :region
24
+
25
+ # (Optional) URL of the New Relic Trace Observer, if you are using New Relic Infinite Tracing.
26
+ attr_accessor :url
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'format' => :'format',
54
+ :'token' => :'token',
55
+ :'region' => :'region',
56
+ :'url' => :'url'
57
+ }
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.fastly_types
67
+ {
68
+ :'format' => :'String',
69
+ :'token' => :'String',
70
+ :'region' => :'String',
71
+ :'url' => :'String'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.fastly_nullable
77
+ Set.new([
78
+ :'url'
79
+ ])
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Fastly::LoggingNewrelicotlpAdditional` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Fastly::LoggingNewrelicotlpAdditional`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'format')
98
+ self.format = attributes[:'format']
99
+ else
100
+ self.format = '{\"timestamp\":\"%{begin:%Y-%m-%dT%H:%M:%S}t\",\"time_elapsed\":\"%{time.elapsed.usec}V\",\"is_tls\":\"%{if(req.is_ssl, \\\"true\\\", \\\"false\\\")}V\",\"client_ip\":\"%{req.http.Fastly-Client-IP}V\",\"geo_city\":\"%{client.geo.city}V\",\"geo_country_code\":\"%{client.geo.country_code}V\",\"request\":\"%{req.request}V\",\"host\":\"%{req.http.Fastly-Orig-Host}V\",\"url\":\"%{json.escape(req.url)}V\",\"request_referer\":\"%{json.escape(req.http.Referer)}V\",\"request_user_agent\":\"%{json.escape(req.http.User-Agent)}V\",\"request_accept_language\":\"%{json.escape(req.http.Accept-Language)}V\",\"request_accept_charset\":\"%{json.escape(req.http.Accept-Charset)}V\",\"cache_status\":\"%{regsub(fastly_info.state, \\\"^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*\\\", \\\"\\\\2\\\\3\\\") }V\"}'
101
+ end
102
+
103
+ if attributes.key?(:'token')
104
+ self.token = attributes[:'token']
105
+ end
106
+
107
+ if attributes.key?(:'region')
108
+ self.region = attributes[:'region']
109
+ else
110
+ self.region = 'US'
111
+ end
112
+
113
+ if attributes.key?(:'url')
114
+ self.url = attributes[:'url']
115
+ else
116
+ self.url = 'null'
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ invalid_properties = Array.new
124
+ invalid_properties
125
+ end
126
+
127
+ # Check to see if the all the properties in the model are valid
128
+ # @return true if the model is valid
129
+ def valid?
130
+ region_validator = EnumAttributeValidator.new('String', ["US", "EU"])
131
+ return false unless region_validator.valid?(@region)
132
+ true
133
+ end
134
+
135
+ # Custom attribute writer method checking allowed values (enum).
136
+ # @param [Object] region Object to be assigned
137
+ def region=(region)
138
+ validator = EnumAttributeValidator.new('String', ["US", "EU"])
139
+ unless validator.valid?(region)
140
+ fail ArgumentError, "invalid value for \"region\", must be one of #{validator.allowable_values}."
141
+ end
142
+ @region = region
143
+ end
144
+
145
+ # Checks equality by comparing each attribute.
146
+ # @param [Object] Object to be compared
147
+ def ==(o)
148
+ return true if self.equal?(o)
149
+ self.class == o.class &&
150
+ format == o.format &&
151
+ token == o.token &&
152
+ region == o.region &&
153
+ url == o.url
154
+ end
155
+
156
+ # @see the `==` method
157
+ # @param [Object] Object to be compared
158
+ def eql?(o)
159
+ self == o
160
+ end
161
+
162
+ # Calculates hash code according to all attributes.
163
+ # @return [Integer] Hash code
164
+ def hash
165
+ [format, token, region, url].hash
166
+ end
167
+
168
+ # Builds the object from hash
169
+ # @param [Hash] attributes Model attributes in the form of hash
170
+ # @return [Object] Returns the model itself
171
+ def self.build_from_hash(attributes)
172
+ new.build_from_hash(attributes)
173
+ end
174
+
175
+ # Builds the object from hash
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ # @return [Object] Returns the model itself
178
+ def build_from_hash(attributes)
179
+ return nil unless attributes.is_a?(Hash)
180
+ self.class.fastly_types.each_pair do |key, type|
181
+ if attributes[self.class.attribute_map[key]].nil? && self.class.fastly_nullable.include?(key)
182
+ self.send("#{key}=", nil)
183
+ elsif type =~ /\AArray<(.*)>/i
184
+ # check to ensure the input is an array given that the attribute
185
+ # is documented as an array but the input is not
186
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
187
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
188
+ end
189
+ elsif !attributes[self.class.attribute_map[key]].nil?
190
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
191
+ end
192
+ end
193
+
194
+ self
195
+ end
196
+
197
+ # Deserializes the data based on type
198
+ # @param string type Data type
199
+ # @param string value Value to be deserialized
200
+ # @return [Object] Deserialized data
201
+ def _deserialize(type, value)
202
+ case type.to_sym
203
+ when :Time
204
+ Time.parse(value)
205
+ when :Date
206
+ Date.parse(value)
207
+ when :String
208
+ value.to_s
209
+ when :Integer
210
+ value.to_i
211
+ when :Float
212
+ value.to_f
213
+ when :Boolean
214
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
215
+ true
216
+ else
217
+ false
218
+ end
219
+ when :Object
220
+ # generic object (usually a Hash), return directly
221
+ value
222
+ when /\AArray<(?<inner_type>.+)>\z/
223
+ inner_type = Regexp.last_match[:inner_type]
224
+ value.map { |v| _deserialize(inner_type, v) }
225
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
226
+ k_type = Regexp.last_match[:k_type]
227
+ v_type = Regexp.last_match[:v_type]
228
+ {}.tap do |hash|
229
+ value.each do |k, v|
230
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
231
+ end
232
+ end
233
+ else # model
234
+ # models (e.g. Pet) or oneOf
235
+ klass = Fastly.const_get(type)
236
+ klass.respond_to?(:fastly_one_of) ? klass.build(value) : klass.build_from_hash(value)
237
+ end
238
+ end
239
+
240
+ # Returns the string representation of the object
241
+ # @return [String] String presentation of the object
242
+ def to_s
243
+ to_hash.to_s
244
+ end
245
+
246
+ # to_body is an alias to to_hash (backward compatibility)
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_body
249
+ to_hash
250
+ end
251
+
252
+ # Returns the object in the form of hash
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_hash
255
+ hash = {}
256
+ self.class.attribute_map.each_pair do |attr, param|
257
+ value = self.send(attr)
258
+ if value.nil?
259
+ is_nullable = self.class.fastly_nullable.include?(attr)
260
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
261
+ end
262
+
263
+ hash[param] = _to_hash(value)
264
+ end
265
+ hash
266
+ end
267
+
268
+ # Outputs non-array value in the form of hash
269
+ # For object, use to_hash. Otherwise, just return the value
270
+ # @param [Object] value Any valid value
271
+ # @return [Hash] Returns the value in the form of hash
272
+ def _to_hash(value)
273
+ if value.is_a?(Array)
274
+ value.compact.map { |v| _to_hash(v) }
275
+ elsif value.is_a?(Hash)
276
+ {}.tap do |hash|
277
+ value.each { |k, v| hash[k] = _to_hash(v) }
278
+ end
279
+ elsif value.respond_to? :to_hash
280
+ value.to_hash
281
+ else
282
+ value
283
+ end
284
+ end
285
+
286
+ end
287
+
288
+ end