Class: SmplkitGeneratedClient::Jobs::Run

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

Overview

One occurrence of a job executing.

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 = {}) ⇒ Run

Initializes the object

Parameters:

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

    Model attributes in the form of hash



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 175

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::Jobs::Run` 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::Run`. 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?(:'job')
    self.job = attributes[:'job']
  else
    self.job = nil
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  if attributes.key?(:'request')
    if (value = attributes[:'request']).is_a?(Hash)
      self.request = value
    end
  end

  if attributes.key?(:'result')
    if (value = attributes[:'result']).is_a?(Hash)
      self.result = value
    end
  end

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

Instance Attribute Details

#_retryObject

Retry-chain position, present only when ‘trigger` is `RETRY`: the id of the original run the chain retries (`of`) and this run’s ‘attempt` number.



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

def _retry
  @_retry
end

#created_atObject

When the run was enqueued (became ‘PENDING`).



71
72
73
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 71

def created_at
  @created_at
end

#environmentObject

The environment this run executed in. A scheduled run inherits the firing job-environment; a manual run is created in the environment you name with the ‘X-Smplkit-Environment` header; a rerun copies its source run’s environment.



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

def environment
  @environment
end

#errorObject

Free-text failure detail, if any.



62
63
64
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 62

def error
  @error
end

#failure_reasonObject

Why a ‘FAILED` run failed; `null` otherwise.



59
60
61
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 59

def failure_reason
  @failure_reason
end

#finished_atObject

When execution finished.



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

def finished_at
  @finished_at
end

#jobObject

The id of the job this run belongs to.



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

def job
  @job
end

#job_versionObject

The job’s version at the time the run executed.



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

def job_version
  @job_version
end

#pending_duration_msObject

Milliseconds the run waited as ‘PENDING` before starting.



50
51
52
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 50

def pending_duration_ms
  @pending_duration_ms
end

#requestObject

Snapshot of the request that was sent (header values redacted). Forensics only.



65
66
67
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 65

def request
  @request
end

#rerun_ofObject

The source run’s id; set only when ‘trigger` is `RERUN`.



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

def rerun_of
  @rerun_of
end

#resultObject

Outcome of the call. For ‘http`: `status`, `headers`, `body` (capped at 64 KiB), `body_truncated`, and the original `body_bytes`.



68
69
70
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 68

def result
  @result
end

#run_duration_msObject

Milliseconds the run spent executing.



53
54
55
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 53

def run_duration_ms
  @run_duration_ms
end

#scheduled_forObject

The intended fire time for a scheduled run; ‘null` for manual / rerun runs.



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

def scheduled_for
  @scheduled_for
end

#started_atObject

When execution started.



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

def started_at
  @started_at
end

#statusObject

Lifecycle state of the run.



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

def status
  @status
end

#total_duration_msObject

Milliseconds from enqueue to finish.



56
57
58
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 56

def total_duration_ms
  @total_duration_ms
end

#triggerObject

Why the run exists: ‘SCHEDULE`, `MANUAL` (Run now), `RERUN`, or `RETRY` (an automatic retry of a failed run).



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

def trigger
  @trigger
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



120
121
122
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 120

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



125
126
127
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 125

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 96

def self.attribute_map
  {
    :'job' => :'job',
    :'job_version' => :'job_version',
    :'environment' => :'environment',
    :'trigger' => :'trigger',
    :'rerun_of' => :'rerun_of',
    :'_retry' => :'retry',
    :'scheduled_for' => :'scheduled_for',
    :'status' => :'status',
    :'started_at' => :'started_at',
    :'finished_at' => :'finished_at',
    :'pending_duration_ms' => :'pending_duration_ms',
    :'run_duration_ms' => :'run_duration_ms',
    :'total_duration_ms' => :'total_duration_ms',
    :'failure_reason' => :'failure_reason',
    :'error' => :'error',
    :'request' => :'request',
    :'result' => :'result',
    :'created_at' => :'created_at'
  }
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



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 405

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



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 154

def self.openapi_nullable
  Set.new([
    :'job_version',
    :'rerun_of',
    :'_retry',
    :'scheduled_for',
    :'started_at',
    :'finished_at',
    :'pending_duration_ms',
    :'run_duration_ms',
    :'total_duration_ms',
    :'failure_reason',
    :'error',
    :'request',
    :'result',
    :'created_at'
  ])
end

.openapi_typesObject

Attribute type mapping.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 130

def self.openapi_types
  {
    :'job' => :'String',
    :'job_version' => :'Integer',
    :'environment' => :'String',
    :'trigger' => :'String',
    :'rerun_of' => :'String',
    :'_retry' => :'RunRetry',
    :'scheduled_for' => :'Time',
    :'status' => :'String',
    :'started_at' => :'Time',
    :'finished_at' => :'Time',
    :'pending_duration_ms' => :'Integer',
    :'run_duration_ms' => :'Integer',
    :'total_duration_ms' => :'Integer',
    :'failure_reason' => :'String',
    :'error' => :'String',
    :'request' => :'Hash<String, Object>',
    :'result' => :'Hash<String, Object>',
    :'created_at' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 367

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      job == o.job &&
      job_version == o.job_version &&
      environment == o.environment &&
      trigger == o.trigger &&
      rerun_of == o.rerun_of &&
      _retry == o._retry &&
      scheduled_for == o.scheduled_for &&
      status == o.status &&
      started_at == o.started_at &&
      finished_at == o.finished_at &&
      pending_duration_ms == o.pending_duration_ms &&
      run_duration_ms == o.run_duration_ms &&
      total_duration_ms == o.total_duration_ms &&
      failure_reason == o.failure_reason &&
      error == o.error &&
      request == o.request &&
      result == o.result &&
      created_at == o.created_at
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


392
393
394
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 392

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



398
399
400
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 398

def hash
  [job, job_version, environment, trigger, rerun_of, _retry, scheduled_for, status, started_at, finished_at, pending_duration_ms, run_duration_ms, total_duration_ms, failure_reason, error, request, result, created_at].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 276

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

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

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

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 427

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



300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/models/run.rb', line 300

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @job.nil?
  return false if @environment.nil?
  return false if @trigger.nil?
  trigger_validator = EnumAttributeValidator.new('String', ["SCHEDULE", "MANUAL", "RERUN", "RETRY"])
  return false unless trigger_validator.valid?(@trigger)
  return false if @status.nil?
  status_validator = EnumAttributeValidator.new('String', ["PENDING", "RUNNING", "SUCCEEDED", "FAILED", "CANCELED"])
  return false unless status_validator.valid?(@status)
  failure_reason_validator = EnumAttributeValidator.new('String', ["TIMEOUT", "CONNECTION_ERROR", "NON_SUCCESS_STATUS", "SSRF_BLOCKED", "QUOTA_EXCEEDED", "WORKER_LOST"])
  return false unless failure_reason_validator.valid?(@failure_reason)
  true
end