Class: Smplkit::Jobs::JobEnvironment

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

Overview

Per-environment enablement, schedule, and configuration override for a job.

A job runs in a given environment only when that environment has an entry in Smplkit::Jobs::Job#environments with enabled: true (scheduled there for a recurring job, triggerable there for a manual one); an environment with no entry (or enabled: false) is disabled there.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) ⇒ JobEnvironment

Returns a new instance of JobEnvironment.



314
315
316
# File 'lib/smplkit/jobs/models.rb', line 314

def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil)
  super
end

Instance Attribute Details

#configurationHttpConfig?

Returns Optional per-environment request configuration that fully replaces the job’s base Smplkit::Jobs::Job#configuration for this environment. nil (the default) inherits the base configuration. As with the base configuration, header values are returned in plaintext on reads, so a get-mutate-put round-trip preserves them.

Returns:

  • (HttpConfig, nil)

    Optional per-environment request configuration that fully replaces the job’s base Smplkit::Jobs::Job#configuration for this environment. nil (the default) inherits the base configuration. As with the base configuration, header values are returned in plaintext on reads, so a get-mutate-put round-trip preserves them.



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/smplkit/jobs/models.rb', line 313

JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil)
    super
  end

  # @api private — Build a {JobEnvironment} from the generated wire model.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire
  #   model, or +nil+ for a disabled environment with no override.
  # @return [JobEnvironment]
  def self.from_wire(src)
    return new if src.nil?

    cfg = src.configuration
    new(
      enabled: src.enabled.nil? ? false : src.enabled,
      schedule: src.schedule,
      timezone: src.timezone,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

#enabledBoolean

Returns Whether the job is enabled in this environment. Defaults to false.

Returns:

  • (Boolean)

    Whether the job is enabled in this environment. Defaults to false.



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/smplkit/jobs/models.rb', line 313

JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil)
    super
  end

  # @api private — Build a {JobEnvironment} from the generated wire model.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire
  #   model, or +nil+ for a disabled environment with no override.
  # @return [JobEnvironment]
  def self.from_wire(src)
    return new if src.nil?

    cfg = src.configuration
    new(
      enabled: src.enabled.nil? ? false : src.enabled,
      schedule: src.schedule,
      timezone: src.timezone,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

#next_run_atString?

Returns Read-only. The next scheduled fire time in this environment. nil when the environment is not enabled, or once a one-off run has fired. Never written back on save.

Returns:

  • (String, nil)

    Read-only. The next scheduled fire time in this environment. nil when the environment is not enabled, or once a one-off run has fired. Never written back on save.



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/smplkit/jobs/models.rb', line 313

JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil)
    super
  end

  # @api private — Build a {JobEnvironment} from the generated wire model.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire
  #   model, or +nil+ for a disabled environment with no override.
  # @return [JobEnvironment]
  def self.from_wire(src)
    return new if src.nil?

    cfg = src.configuration
    new(
      enabled: src.enabled.nil? ? false : src.enabled,
      schedule: src.schedule,
      timezone: src.timezone,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

#scheduleString?

Returns Optional per-environment cron schedule override that varies the cadence in this environment. nil (the default) inherits the job’s base Smplkit::Jobs::Job#schedule. When present, it must be a 5-field UTC cron expression and is only meaningful on a recurring job —it cannot turn a one-off job recurring or vice-versa.

Returns:

  • (String, nil)

    Optional per-environment cron schedule override that varies the cadence in this environment. nil (the default) inherits the job’s base Smplkit::Jobs::Job#schedule. When present, it must be a 5-field UTC cron expression and is only meaningful on a recurring job —it cannot turn a one-off job recurring or vice-versa.



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/smplkit/jobs/models.rb', line 313

JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil)
    super
  end

  # @api private — Build a {JobEnvironment} from the generated wire model.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire
  #   model, or +nil+ for a disabled environment with no override.
  # @return [JobEnvironment]
  def self.from_wire(src)
    return new if src.nil?

    cfg = src.configuration
    new(
      enabled: src.enabled.nil? ? false : src.enabled,
      schedule: src.schedule,
      timezone: src.timezone,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

#timezoneString?

Returns Optional per-environment IANA timezone override for evaluating this environment’s cron #schedule (recurring jobs only). nil (the default) inherits the base Smplkit::Jobs::Job#timezone, else UTC. When present, it must be a valid IANA zone key (e.g. “America/New_York”); it may be set on an environment that inherits the base schedule (it need not also override #schedule). Sent on writes only when present.

Returns:

  • (String, nil)

    Optional per-environment IANA timezone override for evaluating this environment’s cron #schedule (recurring jobs only). nil (the default) inherits the base Smplkit::Jobs::Job#timezone, else UTC. When present, it must be a valid IANA zone key (e.g. “America/New_York”); it may be set on an environment that inherits the base schedule (it need not also override #schedule). Sent on writes only when present.



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/smplkit/jobs/models.rb', line 313

JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil)
    super
  end

  # @api private — Build a {JobEnvironment} from the generated wire model.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire
  #   model, or +nil+ for a disabled environment with no override.
  # @return [JobEnvironment]
  def self.from_wire(src)
    return new if src.nil?

    cfg = src.configuration
    new(
      enabled: src.enabled.nil? ? false : src.enabled,
      schedule: src.schedule,
      timezone: src.timezone,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

Class Method Details

.from_wire(src) ⇒ JobEnvironment

Parameters:

Returns:



323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/smplkit/jobs/models.rb', line 323

def self.from_wire(src)
  return new if src.nil?

  cfg = src.configuration
  new(
    enabled: src.enabled.nil? ? false : src.enabled,
    schedule: src.schedule,
    timezone: src.timezone,
    configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
    next_run_at: src.next_run_at
  )
end