Class: Smplkit::Audit::HttpConfiguration

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

Overview

Forwarder destination HTTP request shape.

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.



372
373
374
375
376
377
378
379
380
# File 'lib/smplkit/audit/models.rb', line 372

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 || [],
    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”.



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
# File 'lib/smplkit/audit/models.rb', line 368

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 || [],
      success_status: success_status, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || []).map do |hdr|
        name, value = if hdr.is_a?(Hash)
                        [hdr[:name] || hdr["name"],
                         hdr[:value] || hdr["value"]]
                      else
                        [hdr.name, hdr.value]
                      end
        SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value)
      end,
      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.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      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

#headersArray<HttpHeader>

Returns Headers attached to every outbound request. 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:

  • (Array<HttpHeader>)

    Headers attached to every outbound request. Values often carry credentials and are returned in plaintext on reads, so a get-mutate-put round-trip preserves them without re-entering secrets.



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
# File 'lib/smplkit/audit/models.rb', line 368

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 || [],
      success_status: success_status, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || []).map do |hdr|
        name, value = if hdr.is_a?(Hash)
                        [hdr[:name] || hdr["name"],
                         hdr[:value] || hdr["value"]]
                      else
                        [hdr.name, hdr.value]
                      end
        SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value)
      end,
      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.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      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:



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
# File 'lib/smplkit/audit/models.rb', line 368

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 || [],
      success_status: success_status, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || []).map do |hdr|
        name, value = if hdr.is_a?(Hash)
                        [hdr[:name] || hdr["name"],
                         hdr[:value] || hdr["value"]]
                      else
                        [hdr.name, hdr.value]
                      end
        SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value)
      end,
      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.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      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”.



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
# File 'lib/smplkit/audit/models.rb', line 368

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 || [],
      success_status: success_status, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || []).map do |hdr|
        name, value = if hdr.is_a?(Hash)
                        [hdr[:name] || hdr["name"],
                         hdr[:value] || hdr["value"]]
                      else
                        [hdr.name, hdr.value]
                      end
        SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value)
      end,
      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.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      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.



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
# File 'lib/smplkit/audit/models.rb', line 368

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 || [],
      success_status: success_status, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || []).map do |hdr|
        name, value = if hdr.is_a?(Hash)
                        [hdr[:name] || hdr["name"],
                         hdr[:value] || hdr["value"]]
                      else
                        [hdr.name, hdr.value]
                      end
        SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value)
      end,
      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.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      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.



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
# File 'lib/smplkit/audit/models.rb', line 368

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 || [],
      success_status: success_status, tls_verify: tls_verify, ca_cert: ca_cert
    )
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(h.method),
      url: h.url,
      headers: (h.headers || []).map do |hdr|
        name, value = if hdr.is_a?(Hash)
                        [hdr[:name] || hdr["name"],
                         hdr[:value] || hdr["value"]]
                      else
                        [hdr.name, hdr.value]
                      end
        SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value)
      end,
      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.
    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      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



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

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.
  new(
    method: src.method || HttpMethod::POST,
    url: src.url || "",
    headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
    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



382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/smplkit/audit/models.rb', line 382

def self.to_wire(src)
  h = src.is_a?(Hash) ? new(**src) : src
  SmplkitGeneratedClient::Audit::HttpConfiguration.new(
    method: HttpMethod.coerce(h.method),
    url: h.url,
    headers: (h.headers || []).map do |hdr|
      name, value = if hdr.is_a?(Hash)
                      [hdr[:name] || hdr["name"],
                       hdr[:value] || hdr["value"]]
                    else
                      [hdr.name, hdr.value]
                    end
      SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value)
    end,
    success_status: h.success_status,
    tls_verify: h.tls_verify,
    ca_cert: h.ca_cert
  )
end