Class: SmplkitGeneratedClient::Jobs::RetryPolicy

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb

Overview

A named, reusable automatic-retry policy. A policy decides whether and how a failed run is retried. Reference it from a job’s ‘retry_policy` (and optionally override it per environment). A job that references nothing uses the built-in `Default` policy, which never retries.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ RetryPolicy

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 126

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::Jobs::RetryPolicy` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::Jobs::RetryPolicy`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  else
    self.name = nil
  end

  if attributes.key?(:'max_retries')
    self.max_retries = attributes[:'max_retries']
  else
    self.max_retries = nil
  end

  if attributes.key?(:'backoff')
    self.backoff = attributes[:'backoff']
  else
    self.backoff = nil
  end

  if attributes.key?(:'delay_seconds')
    self.delay_seconds = attributes[:'delay_seconds']
  else
    self.delay_seconds = nil
  end

  if attributes.key?(:'max_delay_seconds')
    self.max_delay_seconds = attributes[:'max_delay_seconds']
  end

  if attributes.key?(:'retry_on')
    self.retry_on = attributes[:'retry_on']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'updated_at')
    self.updated_at = attributes[:'updated_at']
  end

  if attributes.key?(:'deleted_at')
    self.deleted_at = attributes[:'deleted_at']
  end

  if attributes.key?(:'version')
    self.version = attributes[:'version']
  end
end

Instance Attribute Details

#backoffObject

How the wait between retries grows. ‘fixed` waits `delay_seconds` before every retry. `exponential` doubles the wait each time — `delay_seconds`, then `2×`, `4×`, … — capped at `max_delay_seconds`.



26
27
28
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 26

def backoff
  @backoff
end

#created_atObject

When the policy was created.



38
39
40
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 38

def created_at
  @created_at
end

#delay_secondsObject

The wait before a retry, in seconds. For ‘fixed` backoff it is the constant wait before every retry; for `exponential` it is the base wait that doubles each retry.



29
30
31
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 29

def delay_seconds
  @delay_seconds
end

#deleted_atObject

When the policy was deleted. ‘null` for active policies.



44
45
46
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 44

def deleted_at
  @deleted_at
end

#max_delay_secondsObject

The ceiling on the wait between retries, in seconds, for ‘exponential` backoff — once the doubling reaches it, every subsequent retry waits this long. Only valid with `exponential` backoff; omit it for `fixed`.



32
33
34
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 32

def max_delay_seconds
  @max_delay_seconds
end

#max_retriesObject

How many times a failed run is retried, after the initial attempt — so ‘max_retries` of 3 means up to 4 attempts in total. `0` disables retries. Maximum 10.



23
24
25
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 23

def max_retries
  @max_retries
end

#nameObject

Human-readable name for the policy.



20
21
22
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 20

def name
  @name
end

#retry_onObject

Which failures are retried. A run is retried only when its failure matches this set; an empty set retries nothing. Some failures are never retried regardless of this value.



35
36
37
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 35

def retry_on
  @retry_on
end

#updated_atObject

When the policy was last modified.



41
42
43
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 41

def updated_at
  @updated_at
end

#versionObject

Monotonic counter incremented on every update, starting at 1.



47
48
49
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 47

def version
  @version
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



88
89
90
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 88

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



93
94
95
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 93

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 72

def self.attribute_map
  {
    :'name' => :'name',
    :'max_retries' => :'max_retries',
    :'backoff' => :'backoff',
    :'delay_seconds' => :'delay_seconds',
    :'max_delay_seconds' => :'max_delay_seconds',
    :'retry_on' => :'retry_on',
    :'created_at' => :'created_at',
    :'updated_at' => :'updated_at',
    :'deleted_at' => :'deleted_at',
    :'version' => :'version'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 358

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



114
115
116
117
118
119
120
121
122
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 114

def self.openapi_nullable
  Set.new([
    :'max_delay_seconds',
    :'created_at',
    :'updated_at',
    :'deleted_at',
    :'version'
  ])
end

.openapi_typesObject

Attribute type mapping.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 98

def self.openapi_types
  {
    :'name' => :'String',
    :'max_retries' => :'Integer',
    :'backoff' => :'String',
    :'delay_seconds' => :'Integer',
    :'max_delay_seconds' => :'Integer',
    :'retry_on' => :'RetryOn',
    :'created_at' => :'Time',
    :'updated_at' => :'Time',
    :'deleted_at' => :'Time',
    :'version' => :'Integer'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 328

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      name == o.name &&
      max_retries == o.max_retries &&
      backoff == o.backoff &&
      delay_seconds == o.delay_seconds &&
      max_delay_seconds == o.max_delay_seconds &&
      retry_on == o.retry_on &&
      created_at == o.created_at &&
      updated_at == o.updated_at &&
      deleted_at == o.deleted_at &&
      version == o.version
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


345
346
347
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 345

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



351
352
353
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 351

def hash
  [name, max_retries, backoff, delay_seconds, max_delay_seconds, retry_on, created_at, updated_at, deleted_at, version].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 191

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @name.nil?
    invalid_properties.push('invalid value for "name", name cannot be nil.')
  end

  if @name.to_s.length > 200
    invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 200.')
  end

  if @name.to_s.length < 1
    invalid_properties.push('invalid value for "name", the character length must be greater than or equal to 1.')
  end

  if @max_retries.nil?
    invalid_properties.push('invalid value for "max_retries", max_retries cannot be nil.')
  end

  if @max_retries > 10
    invalid_properties.push('invalid value for "max_retries", must be smaller than or equal to 10.')
  end

  if @max_retries < 0
    invalid_properties.push('invalid value for "max_retries", must be greater than or equal to 0.')
  end

  if @backoff.nil?
    invalid_properties.push('invalid value for "backoff", backoff cannot be nil.')
  end

  if @delay_seconds.nil?
    invalid_properties.push('invalid value for "delay_seconds", delay_seconds cannot be nil.')
  end

  if @delay_seconds < 1
    invalid_properties.push('invalid value for "delay_seconds", must be greater than or equal to 1.')
  end

  if !@max_delay_seconds.nil? && @max_delay_seconds < 1
    invalid_properties.push('invalid value for "max_delay_seconds", must be greater than or equal to 1.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 380

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/retry_policy.rb', line 239

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @name.nil?
  return false if @name.to_s.length > 200
  return false if @name.to_s.length < 1
  return false if @max_retries.nil?
  return false if @max_retries > 10
  return false if @max_retries < 0
  return false if @backoff.nil?
  backoff_validator = EnumAttributeValidator.new('String', ["fixed", "exponential"])
  return false unless backoff_validator.valid?(@backoff)
  return false if @delay_seconds.nil?
  return false if @delay_seconds < 1
  return false if !@max_delay_seconds.nil? && @max_delay_seconds < 1
  true
end