Class: Smplkit::Audit::HttpConfiguration

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

Overview

Forwarder destination HTTP request shape — the base configuration.

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(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx", tls_verify: true, ca_cert: nil) ⇒ HttpConfiguration

Returns a new instance of HttpConfiguration.



365
366
367
368
369
370
371
372
373
# File 'lib/smplkit/audit/models.rb', line 365

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

Instance Attribute Details

#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”.



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/smplkit/audit/models.rb', line 361

HttpConfiguration = Struct.new(
  :method, :url, :headers, :success_status, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    method: HttpMethod::POST, url: "", headers: nil,
    success_status: "2xx", tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      success_status: success_status, 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

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

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

    # Absent ``tls_verify`` on the wire means a forwarder persisted
    # before the field landed — default to verifying so its prior
    # secure behaviour is preserved. 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),
      success_status: src.success_status || "2xx",
      # 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 outbound request, as a name→value object (e.g. { “DD-API-KEY” => “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 outbound request, as a name→value object (e.g. { “DD-API-KEY” => “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.



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/smplkit/audit/models.rb', line 361

HttpConfiguration = Struct.new(
  :method, :url, :headers, :success_status, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    method: HttpMethod::POST, url: "", headers: nil,
    success_status: "2xx", tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      success_status: success_status, 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

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

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

    # Absent ``tls_verify`` on the wire means a forwarder persisted
    # before the field landed — default to verifying so its prior
    # secure behaviour is preserved. 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),
      success_status: src.success_status || "2xx",
      # 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 for delivery. Defaults to Smplkit::Audit::HttpMethod::POST.

Returns:



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/smplkit/audit/models.rb', line 361

HttpConfiguration = Struct.new(
  :method, :url, :headers, :success_status, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    method: HttpMethod::POST, url: "", headers: nil,
    success_status: "2xx", tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      success_status: success_status, 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

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

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

    # Absent ``tls_verify`` on the wire means a forwarder persisted
    # before the field landed — default to verifying so its prior
    # secure behaviour is preserved. 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),
      success_status: src.success_status || "2xx",
      # 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 delivery 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 delivery to count as success — an exact code (+“200”+, “204”) or a class (+“2xx”+, “4xx”). Defaults to “2xx”.



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/smplkit/audit/models.rb', line 361

HttpConfiguration = Struct.new(
  :method, :url, :headers, :success_status, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    method: HttpMethod::POST, url: "", headers: nil,
    success_status: "2xx", tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      success_status: success_status, 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

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

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

    # Absent ``tls_verify`` on the wire means a forwarder persisted
    # before the field landed — default to verifying so its prior
    # secure behaviour is preserved. 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),
      success_status: src.success_status || "2xx",
      # 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 a destination that serves an untrusted certificate. Prefer pinning the issuing CA via ca_cert for long-lived self-signed setups.

Returns:

  • (Boolean)

    Whether to verify the destination’s TLS certificate chain. Defaults to true; flip to false only for short-lived testing against a destination that serves an untrusted certificate. Prefer pinning the issuing CA via ca_cert for long-lived self-signed setups.



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/smplkit/audit/models.rb', line 361

HttpConfiguration = Struct.new(
  :method, :url, :headers, :success_status, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    method: HttpMethod::POST, url: "", headers: nil,
    success_status: "2xx", tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      success_status: success_status, 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

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

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

    # Absent ``tls_verify`` on the wire means a forwarder persisted
    # before the field landed — default to verifying so its prior
    # secure behaviour is preserved. 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),
      success_status: src.success_status || "2xx",
      # 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 audit service sends each event to.

Returns:

  • (String)

    Destination URL the audit service sends each event to.



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/smplkit/audit/models.rb', line 361

HttpConfiguration = Struct.new(
  :method, :url, :headers, :success_status, :tls_verify, :ca_cert,
  keyword_init: true
) do
  def initialize(
    method: HttpMethod::POST, url: "", headers: nil,
    success_status: "2xx", tls_verify: true, ca_cert: nil
  )
    super(
      method: HttpMethod.coerce(method), url: url, headers: (headers || {}).transform_keys(&:to_s),
      success_status: success_status, 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

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

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

    # Absent ``tls_verify`` on the wire means a forwarder persisted
    # before the field landed — default to verifying so its prior
    # secure behaviour is preserved. 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),
      success_status: src.success_status || "2xx",
      # 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) ⇒ Object



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

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

  # Absent ``tls_verify`` on the wire means a forwarder persisted
  # before the field landed — default to verifying so its prior
  # secure behaviour is preserved. 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),
    success_status: src.success_status || "2xx",
    # 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) ⇒ Object



392
393
394
395
396
397
398
399
400
401
402
# File 'lib/smplkit/audit/models.rb', line 392

def self.to_wire(src)
  h = src.is_a?(Hash) ? new(**src) : src
  SmplkitGeneratedClient::Audit::ForwarderHttpConfiguration.new(
    method: HttpMethod.coerce(h.method),
    url: h.url,
    headers: (h.headers || {}).transform_keys(&:to_s),
    success_status: h.success_status,
    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)


388
389
390
# File 'lib/smplkit/audit/models.rb', line 388

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.



379
380
381
382
# File 'lib/smplkit/audit/models.rb', line 379

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