Class: Smplkit::Jobs::Run

Inherits:
Struct
  • Object
show all
Defined in:
lib/smplkit/jobs/models.rb

Overview

A single execution of a job (read-only) with rerun / cancel actions.

Runs are created and mutated by the jobs service, not by clients; clients influence runs only through #rerun / #cancel (and the run action on client.jobs). A run returned from the SDK holds a backref to the runs client so #rerun / #cancel work without re-deriving the client.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atString?

Returns When the run was enqueued (became PENDING).

Returns:

  • (String, nil)

    When the run was enqueued (became PENDING).



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#environmentString

Returns The environment this run executed in. A scheduled run inherits the firing job-environment; a manual run uses the environment named on the run-now request; a rerun copies its source run’s environment.

Returns:

  • (String)

    The environment this run executed in. A scheduled run inherits the firing job-environment; a manual run uses the environment named on the run-now request; a rerun copies its source run’s environment.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#errorString?

Returns Free-text failure detail, if any.

Returns:

  • (String, nil)

    Free-text failure detail, if any.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#failure_reasonString?

Returns Why a FAILED run failed; nil otherwise.

Returns:

  • (String, nil)

    Why a FAILED run failed; nil otherwise.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#finished_atString?

Returns When execution finished.

Returns:

  • (String, nil)

    When execution finished.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#idString

Returns Server-assigned UUID for this run.

Returns:

  • (String)

    Server-assigned UUID for this run.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#jobString

Returns The id of the job this run belongs to.

Returns:

  • (String)

    The id of the job this run belongs to.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#job_versionInteger?

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

Returns:

  • (Integer, nil)

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



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#pending_duration_msInteger?

Returns Milliseconds the run waited as PENDING before starting.

Returns:

  • (Integer, nil)

    Milliseconds the run waited as PENDING before starting.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#requestHash?

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

Returns:

  • (Hash, nil)

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



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#rerun_ofString?

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

Returns:

  • (String, nil)

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



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#resultHash?

Returns Outcome of the call (status, headers, body, …).

Returns:

  • (Hash, nil)

    Outcome of the call (status, headers, body, …).



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#retryRunRetry?

Returns Retry-chain position, populated only when trigger is RETRY; nil otherwise.

Returns:

  • (RunRetry, nil)

    Retry-chain position, populated only when trigger is RETRY; nil otherwise.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#run_duration_msInteger?

Returns Milliseconds the run spent executing.

Returns:

  • (Integer, nil)

    Milliseconds the run spent executing.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#scheduled_forString?

Returns The intended fire time for a scheduled run; nil for manual / rerun runs.

Returns:

  • (String, nil)

    The intended fire time for a scheduled run; nil for manual / rerun runs.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#started_atString?

Returns When execution started.

Returns:

  • (String, nil)

    When execution started.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#statusString

Returns Lifecycle state of the run.

Returns:

  • (String)

    Lifecycle state of the run.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#total_duration_msInteger?

Returns Milliseconds from enqueue to finish.

Returns:

  • (Integer, nil)

    Milliseconds from enqueue to finish.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

#triggerString

Returns Why the run exists — a raw string equal to one of the Smplkit::Jobs::RunTrigger constants: SCHEDULE, MANUAL (run now), or RERUN.

Returns:

  • (String)

    Why the run exists — a raw string equal to one of the Smplkit::Jobs::RunTrigger constants: SCHEDULE, MANUAL (run now), or RERUN.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/smplkit/jobs/models.rb', line 858

Run = Struct.new(
  :id, :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,
  keyword_init: true
) do
  # @api private — Build a {Run} from a JSON:API resource returned by the
  #   jobs service, binding it to +runs+ so {#rerun} / {#cancel} work.
  #
  # @param resource [Object] The JSON:API resource (id + attributes).
  # @param runs [RunsClient, nil] Runs client to bind the run to.
  # @return [Run] The hydrated run.
  def self.from_resource(resource, runs: nil)
    a = resource.attributes
    # The retry-chain position is populated only on a +RETRY+ run; the
    # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
    retry_chain = a._retry
    retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                  RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
                end
    new(
      id: resource.id,
      job: a.job,
      job_version: a.job_version,
      environment: a.environment,
      trigger: a.trigger,
      rerun_of: a.rerun_of,
      retry: retry_pos,
      scheduled_for: a.scheduled_for,
      status: a.status,
      started_at: a.started_at,
      finished_at: a.finished_at,
      pending_duration_ms: a.pending_duration_ms,
      run_duration_ms: a.run_duration_ms,
      total_duration_ms: a.total_duration_ms,
      failure_reason: a.failure_reason,
      error: a.error,
      request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
      result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
      created_at: a.created_at
    ).tap { |run| run.instance_variable_set(:@runs, runs) }
  end

  # Start a new run that repeats this one (a +RERUN+), in the same
  # environment.
  #
  # @return [Smplkit::Jobs::Run] The new run, with +rerun_of+ set to this
  #   run's id.
  # @raise [RuntimeError] when this run has no bound runs client.
  def rerun
    raise "Run was constructed without a client; cannot rerun" if @runs.nil?

    @runs.rerun(id)
  end

  # Cancel this run if it has not finished yet.
  #
  # @return [Smplkit::Jobs::Run] The updated run reflecting the cancellation.
  # @raise [RuntimeError] when this run has no bound runs client.
  def cancel
    raise "Run was constructed without a client; cannot cancel" if @runs.nil?

    @runs.cancel(id)
  end
end

Class Method Details

.from_resource(resource, runs: nil) ⇒ Run

Returns The hydrated run.

Parameters:

  • resource (Object)

    The JSON:API resource (id + attributes).

  • runs (RunsClient, nil) (defaults to: nil)

    Runs client to bind the run to.

Returns:

  • (Run)

    The hydrated run.



870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
# File 'lib/smplkit/jobs/models.rb', line 870

def self.from_resource(resource, runs: nil)
  a = resource.attributes
  # The retry-chain position is populated only on a +RETRY+ run; the
  # generated model exposes it as +_retry+ (+retry+ is a Ruby keyword).
  retry_chain = a._retry
  retry_pos = if a.trigger == RunTrigger::RETRY && !retry_chain.nil?
                RunRetry.new(of: retry_chain.of, attempt: retry_chain.attempt)
              end
  new(
    id: resource.id,
    job: a.job,
    job_version: a.job_version,
    environment: a.environment,
    trigger: a.trigger,
    rerun_of: a.rerun_of,
    retry: retry_pos,
    scheduled_for: a.scheduled_for,
    status: a.status,
    started_at: a.started_at,
    finished_at: a.finished_at,
    pending_duration_ms: a.pending_duration_ms,
    run_duration_ms: a.run_duration_ms,
    total_duration_ms: a.total_duration_ms,
    failure_reason: a.failure_reason,
    error: a.error,
    request: a.request.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.request),
    result: a.result.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.result),
    created_at: a.created_at
  ).tap { |run| run.instance_variable_set(:@runs, runs) }
end

Instance Method Details

#cancelSmplkit::Jobs::Run

Cancel this run if it has not finished yet.

Returns:

Raises:

  • (RuntimeError)

    when this run has no bound runs client.



917
918
919
920
921
# File 'lib/smplkit/jobs/models.rb', line 917

def cancel
  raise "Run was constructed without a client; cannot cancel" if @runs.nil?

  @runs.cancel(id)
end

#rerunSmplkit::Jobs::Run

Start a new run that repeats this one (a RERUN), in the same environment.

Returns:

Raises:

  • (RuntimeError)

    when this run has no bound runs client.



907
908
909
910
911
# File 'lib/smplkit/jobs/models.rb', line 907

def rerun
  raise "Run was constructed without a client; cannot rerun" if @runs.nil?

  @runs.rerun(id)
end