Class: Smplkit::Jobs::HttpConfig

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

Overview

The HTTP request a job performs when it fires (the http configuration).

Extends the shared forwarder shape with the two fields a scheduled job needs beyond a forwarder: a request body and a per-run timeout.

rubocop:disable Lint/StructNewOverride – “:method“ matches the API attribute and shadowing Struct#method is the expected ergonomics.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, method: HttpMethod::POST, headers: nil, body: nil, success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil) ⇒ HttpConfig

Returns a new instance of HttpConfig.



209
210
211
212
213
214
215
216
217
# File 'lib/smplkit/jobs/models.rb', line 209

def initialize(
  url:, method: HttpMethod::POST, headers: nil, body: nil,
  success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
)
  super(
    method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
    body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
  )
end

Instance Attribute Details

#bodyString?

Returns Request body sent on each run. nil (the default) sends an empty body, suitable for a connectivity ping. Sent verbatim —pair with a matching Content-Type header.

Returns:

  • (String, nil)

    Request body sent on each run. nil (the default) sends an empty body, suitable for a connectivity ping. Sent verbatim —pair with a matching Content-Type header.



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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/smplkit/jobs/models.rb', line 205

HttpConfig = Struct.new(
  :method, :url, :headers, :body, :success_status, :timeout, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    url:, method: HttpMethod::POST, headers: nil, body: nil,
    success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  # Set (or replace) a single request header by name.
  #
  # @param name [String] Header name.
  # @param value [String] Header value.
  def set_header(name, value)
    self.headers ||= {}
    headers[name.to_s] = value
  end

  # The value of header +name+, or +nil+ when it is not set.
  #
  # @param name [String] Header name.
  # @return [String, nil]
  def get_header(name)
    (headers || {})[name.to_s]
  end

  # @api private — Convert an {HttpConfig} (or a Hash with the same keys)
  #   into the generated wire model the jobs service expects. Headers travel
  #   as the generated name→value headers object.
  #
  # @param src [HttpConfig, Hash] The HTTP configuration to serialize.
  # @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || {}).transform_keys(&:to_s),
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

  # @api private — Build an {HttpConfig} from the generated wire model
  #   returned by the jobs service. Header values arrive in plaintext, so a
  #   round-trip back through {to_wire} preserves them.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
  #   wire model, or +nil+ for an empty configuration.
  # @return [HttpConfig] The wrapper-side configuration.
  def self.from_wire(src)
    return new(url: "") if src.nil?

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them. Header keys arrive as
    # symbols (the generated client symbolizes JSON) — stringify them so
    # {#get_header} and round-trips behave by name.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url,
      headers: (src.headers || {}).transform_keys(&:to_s),
      body: src.body,
      success_status: src.success_status,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#ca_certString?

Returns Optional PEM-encoded certificate (or bundle) trusted in addition to the system CA store. Ignored when tls_verify is false. nil (the default) means “use system CAs only”.

Returns:

  • (String, nil)

    Optional PEM-encoded certificate (or bundle) trusted in addition to the system CA store. Ignored when tls_verify is false. nil (the default) means “use system CAs only”.



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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/smplkit/jobs/models.rb', line 205

HttpConfig = Struct.new(
  :method, :url, :headers, :body, :success_status, :timeout, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    url:, method: HttpMethod::POST, headers: nil, body: nil,
    success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  # Set (or replace) a single request header by name.
  #
  # @param name [String] Header name.
  # @param value [String] Header value.
  def set_header(name, value)
    self.headers ||= {}
    headers[name.to_s] = value
  end

  # The value of header +name+, or +nil+ when it is not set.
  #
  # @param name [String] Header name.
  # @return [String, nil]
  def get_header(name)
    (headers || {})[name.to_s]
  end

  # @api private — Convert an {HttpConfig} (or a Hash with the same keys)
  #   into the generated wire model the jobs service expects. Headers travel
  #   as the generated name→value headers object.
  #
  # @param src [HttpConfig, Hash] The HTTP configuration to serialize.
  # @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || {}).transform_keys(&:to_s),
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

  # @api private — Build an {HttpConfig} from the generated wire model
  #   returned by the jobs service. Header values arrive in plaintext, so a
  #   round-trip back through {to_wire} preserves them.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
  #   wire model, or +nil+ for an empty configuration.
  # @return [HttpConfig] The wrapper-side configuration.
  def self.from_wire(src)
    return new(url: "") if src.nil?

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them. Header keys arrive as
    # symbols (the generated client symbolizes JSON) — stringify them so
    # {#get_header} and round-trips behave by name.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url,
      headers: (src.headers || {}).transform_keys(&:to_s),
      body: src.body,
      success_status: src.success_status,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#headersHash{String => String}

Returns Headers attached to every request, as a name→value object (e.g. { “Authorization” => “Bearer s3cr3t” }). Use #set_header / #get_header to read and write individual headers. Values often carry credentials and are returned in plaintext on reads, so a get-mutate-put round-trip preserves them without re-entering secrets.

Returns:

  • (Hash{String => String})

    Headers attached to every request, as a name→value object (e.g. { “Authorization” => “Bearer s3cr3t” }). Use #set_header / #get_header to read and write individual headers. Values often carry credentials and are returned in plaintext on reads, so a get-mutate-put round-trip preserves them without re-entering secrets.



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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/smplkit/jobs/models.rb', line 205

HttpConfig = Struct.new(
  :method, :url, :headers, :body, :success_status, :timeout, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    url:, method: HttpMethod::POST, headers: nil, body: nil,
    success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  # Set (or replace) a single request header by name.
  #
  # @param name [String] Header name.
  # @param value [String] Header value.
  def set_header(name, value)
    self.headers ||= {}
    headers[name.to_s] = value
  end

  # The value of header +name+, or +nil+ when it is not set.
  #
  # @param name [String] Header name.
  # @return [String, nil]
  def get_header(name)
    (headers || {})[name.to_s]
  end

  # @api private — Convert an {HttpConfig} (or a Hash with the same keys)
  #   into the generated wire model the jobs service expects. Headers travel
  #   as the generated name→value headers object.
  #
  # @param src [HttpConfig, Hash] The HTTP configuration to serialize.
  # @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || {}).transform_keys(&:to_s),
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

  # @api private — Build an {HttpConfig} from the generated wire model
  #   returned by the jobs service. Header values arrive in plaintext, so a
  #   round-trip back through {to_wire} preserves them.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
  #   wire model, or +nil+ for an empty configuration.
  # @return [HttpConfig] The wrapper-side configuration.
  def self.from_wire(src)
    return new(url: "") if src.nil?

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them. Header keys arrive as
    # symbols (the generated client symbolizes JSON) — stringify them so
    # {#get_header} and round-trips behave by name.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url,
      headers: (src.headers || {}).transform_keys(&:to_s),
      body: src.body,
      success_status: src.success_status,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#methodString

Returns HTTP verb used when the job fires. Defaults to Smplkit::Jobs::HttpMethod::POST.

Returns:



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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/smplkit/jobs/models.rb', line 205

HttpConfig = Struct.new(
  :method, :url, :headers, :body, :success_status, :timeout, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    url:, method: HttpMethod::POST, headers: nil, body: nil,
    success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  # Set (or replace) a single request header by name.
  #
  # @param name [String] Header name.
  # @param value [String] Header value.
  def set_header(name, value)
    self.headers ||= {}
    headers[name.to_s] = value
  end

  # The value of header +name+, or +nil+ when it is not set.
  #
  # @param name [String] Header name.
  # @return [String, nil]
  def get_header(name)
    (headers || {})[name.to_s]
  end

  # @api private — Convert an {HttpConfig} (or a Hash with the same keys)
  #   into the generated wire model the jobs service expects. Headers travel
  #   as the generated name→value headers object.
  #
  # @param src [HttpConfig, Hash] The HTTP configuration to serialize.
  # @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || {}).transform_keys(&:to_s),
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

  # @api private — Build an {HttpConfig} from the generated wire model
  #   returned by the jobs service. Header values arrive in plaintext, so a
  #   round-trip back through {to_wire} preserves them.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
  #   wire model, or +nil+ for an empty configuration.
  # @return [HttpConfig] The wrapper-side configuration.
  def self.from_wire(src)
    return new(url: "") if src.nil?

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them. Header keys arrive as
    # symbols (the generated client symbolizes JSON) — stringify them so
    # {#get_header} and round-trips behave by name.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url,
      headers: (src.headers || {}).transform_keys(&:to_s),
      body: src.body,
      success_status: src.success_status,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#success_statusString

Returns Status the destination must return for the run to count as success — an exact code (+“200”+, “204”) or a class (+“2xx”+, “4xx”). Defaults to “2xx”.

Returns:

  • (String)

    Status the destination must return for the run to count as success — an exact code (+“200”+, “204”) or a class (+“2xx”+, “4xx”). Defaults to “2xx”.



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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/smplkit/jobs/models.rb', line 205

HttpConfig = Struct.new(
  :method, :url, :headers, :body, :success_status, :timeout, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    url:, method: HttpMethod::POST, headers: nil, body: nil,
    success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  # Set (or replace) a single request header by name.
  #
  # @param name [String] Header name.
  # @param value [String] Header value.
  def set_header(name, value)
    self.headers ||= {}
    headers[name.to_s] = value
  end

  # The value of header +name+, or +nil+ when it is not set.
  #
  # @param name [String] Header name.
  # @return [String, nil]
  def get_header(name)
    (headers || {})[name.to_s]
  end

  # @api private — Convert an {HttpConfig} (or a Hash with the same keys)
  #   into the generated wire model the jobs service expects. Headers travel
  #   as the generated name→value headers object.
  #
  # @param src [HttpConfig, Hash] The HTTP configuration to serialize.
  # @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || {}).transform_keys(&:to_s),
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

  # @api private — Build an {HttpConfig} from the generated wire model
  #   returned by the jobs service. Header values arrive in plaintext, so a
  #   round-trip back through {to_wire} preserves them.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
  #   wire model, or +nil+ for an empty configuration.
  # @return [HttpConfig] The wrapper-side configuration.
  def self.from_wire(src)
    return new(url: "") if src.nil?

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them. Header keys arrive as
    # symbols (the generated client symbolizes JSON) — stringify them so
    # {#get_header} and round-trips behave by name.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url,
      headers: (src.headers || {}).transform_keys(&:to_s),
      body: src.body,
      success_status: src.success_status,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#timeoutInteger

Returns Per-run timeout in seconds. A run that does not complete within this many seconds fails with reason TIMEOUT. Defaults to 30; bounded by your plan’s maximum timeout.

Returns:

  • (Integer)

    Per-run timeout in seconds. A run that does not complete within this many seconds fails with reason TIMEOUT. Defaults to 30; bounded by your plan’s maximum timeout.



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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/smplkit/jobs/models.rb', line 205

HttpConfig = Struct.new(
  :method, :url, :headers, :body, :success_status, :timeout, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    url:, method: HttpMethod::POST, headers: nil, body: nil,
    success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  # Set (or replace) a single request header by name.
  #
  # @param name [String] Header name.
  # @param value [String] Header value.
  def set_header(name, value)
    self.headers ||= {}
    headers[name.to_s] = value
  end

  # The value of header +name+, or +nil+ when it is not set.
  #
  # @param name [String] Header name.
  # @return [String, nil]
  def get_header(name)
    (headers || {})[name.to_s]
  end

  # @api private — Convert an {HttpConfig} (or a Hash with the same keys)
  #   into the generated wire model the jobs service expects. Headers travel
  #   as the generated name→value headers object.
  #
  # @param src [HttpConfig, Hash] The HTTP configuration to serialize.
  # @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || {}).transform_keys(&:to_s),
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

  # @api private — Build an {HttpConfig} from the generated wire model
  #   returned by the jobs service. Header values arrive in plaintext, so a
  #   round-trip back through {to_wire} preserves them.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
  #   wire model, or +nil+ for an empty configuration.
  # @return [HttpConfig] The wrapper-side configuration.
  def self.from_wire(src)
    return new(url: "") if src.nil?

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them. Header keys arrive as
    # symbols (the generated client symbolizes JSON) — stringify them so
    # {#get_header} and round-trips behave by name.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url,
      headers: (src.headers || {}).transform_keys(&:to_s),
      body: src.body,
      success_status: src.success_status,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#tls_verifyBoolean

Returns Whether to verify the destination’s TLS certificate chain. Defaults to true; flip to false only for short-lived testing against an untrusted certificate. Prefer pinning the CA via ca_cert.

Returns:

  • (Boolean)

    Whether to verify the destination’s TLS certificate chain. Defaults to true; flip to false only for short-lived testing against an untrusted certificate. Prefer pinning the CA via ca_cert.



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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/smplkit/jobs/models.rb', line 205

HttpConfig = Struct.new(
  :method, :url, :headers, :body, :success_status, :timeout, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    url:, method: HttpMethod::POST, headers: nil, body: nil,
    success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  # Set (or replace) a single request header by name.
  #
  # @param name [String] Header name.
  # @param value [String] Header value.
  def set_header(name, value)
    self.headers ||= {}
    headers[name.to_s] = value
  end

  # The value of header +name+, or +nil+ when it is not set.
  #
  # @param name [String] Header name.
  # @return [String, nil]
  def get_header(name)
    (headers || {})[name.to_s]
  end

  # @api private — Convert an {HttpConfig} (or a Hash with the same keys)
  #   into the generated wire model the jobs service expects. Headers travel
  #   as the generated name→value headers object.
  #
  # @param src [HttpConfig, Hash] The HTTP configuration to serialize.
  # @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || {}).transform_keys(&:to_s),
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

  # @api private — Build an {HttpConfig} from the generated wire model
  #   returned by the jobs service. Header values arrive in plaintext, so a
  #   round-trip back through {to_wire} preserves them.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
  #   wire model, or +nil+ for an empty configuration.
  # @return [HttpConfig] The wrapper-side configuration.
  def self.from_wire(src)
    return new(url: "") if src.nil?

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them. Header keys arrive as
    # symbols (the generated client symbolizes JSON) — stringify them so
    # {#get_header} and round-trips behave by name.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url,
      headers: (src.headers || {}).transform_keys(&:to_s),
      body: src.body,
      success_status: src.success_status,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#urlString

Returns Destination URL the job requests on each run.

Returns:

  • (String)

    Destination URL the job requests on each run.



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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/smplkit/jobs/models.rb', line 205

HttpConfig = Struct.new(
  :method, :url, :headers, :body, :success_status, :timeout, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    url:, method: HttpMethod::POST, headers: nil, body: nil,
    success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      body: body, success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  # Set (or replace) a single request header by name.
  #
  # @param name [String] Header name.
  # @param value [String] Header value.
  def set_header(name, value)
    self.headers ||= {}
    headers[name.to_s] = value
  end

  # The value of header +name+, or +nil+ when it is not set.
  #
  # @param name [String] Header name.
  # @return [String, nil]
  def get_header(name)
    (headers || {})[name.to_s]
  end

  # @api private — Convert an {HttpConfig} (or a Hash with the same keys)
  #   into the generated wire model the jobs service expects. Headers travel
  #   as the generated name→value headers object.
  #
  # @param src [HttpConfig, Hash] The HTTP configuration to serialize.
  # @return [SmplkitGeneratedClient::Jobs::JobHttpConfiguration] The wire model.
  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || {}).transform_keys(&:to_s),
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

  # @api private — Build an {HttpConfig} from the generated wire model
  #   returned by the jobs service. Header values arrive in plaintext, so a
  #   round-trip back through {to_wire} preserves them.
  #
  # @param src [SmplkitGeneratedClient::Jobs::JobHttpConfiguration, nil] The
  #   wire model, or +nil+ for an empty configuration.
  # @return [HttpConfig] The wrapper-side configuration.
  def self.from_wire(src)
    return new(url: "") if src.nil?

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them. Header keys arrive as
    # symbols (the generated client symbolizes JSON) — stringify them so
    # {#get_header} and round-trips behave by name.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url,
      headers: (src.headers || {}).transform_keys(&:to_s),
      body: src.body,
      success_status: src.success_status,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

Class Method Details

.from_wire(src) ⇒ HttpConfig

Returns The wrapper-side configuration.

Parameters:

Returns:

  • (HttpConfig)

    The wrapper-side configuration.



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/smplkit/jobs/models.rb', line 263

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

  # +url+, +success_status+, and +timeout+ are required non-nil on the
  # generated jobs config, so they pass straight through. +method+,
  # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
  # wrapper-side defaults when the wire omits them. Header keys arrive as
  # symbols (the generated client symbolizes JSON) — stringify them so
  # {#get_header} and round-trips behave by name.
  new(
    method: src.method || HttpMethod::POST,
    url: src.url,
    headers: (src.headers || {}).transform_keys(&:to_s),
    body: src.body,
    success_status: src.success_status,
    timeout: src.timeout,
    # rubocop:disable Style/RedundantCondition -- nil and false are
    # distinct: nil means "field absent on the wire" (default to true);
    # explicit false means "verification disabled".
    tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
    # rubocop:enable Style/RedundantCondition
    ca_cert: src.ca_cert
  )
end

.to_wire(src) ⇒ SmplkitGeneratedClient::Jobs::JobHttpConfiguration

Returns The wire model.

Parameters:

  • src (HttpConfig, Hash)

    The HTTP configuration to serialize.

Returns:



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

def self.to_wire(src)
  h = src.is_a?(Hash) ? new(**src) : src
  SmplkitGeneratedClient::Jobs::JobHttpConfiguration.new(
    method: HttpMethod.coerce(h.method),
    url: h.url,
    headers: (h.headers || {}).transform_keys(&:to_s),
    body: h.body,
    success_status: h.success_status,
    timeout: h.timeout,
    tls_verify: h.tls_verify,
    ca_cert: h.ca_cert
  )
end

Instance Method Details

#get_header(name) ⇒ String?

The value of header name, or nil when it is not set.

Parameters:

  • name (String)

    Header name.

Returns:

  • (String, nil)


232
233
234
# File 'lib/smplkit/jobs/models.rb', line 232

def get_header(name)
  (headers || {})[name.to_s]
end

#set_header(name, value) ⇒ Object

Set (or replace) a single request header by name.

Parameters:

  • name (String)

    Header name.

  • value (String)

    Header value.



223
224
225
226
# File 'lib/smplkit/jobs/models.rb', line 223

def set_header(name, value)
  self.headers ||= {}
  headers[name.to_s] = value
end