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.



336
337
338
339
340
341
342
343
344
# File 'lib/smplkit/audit/models.rb', line 336

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



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
# File 'lib/smplkit/audit/models.rb', line 332

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>

Headers attached to every outbound request. Values carry credentials and are encrypted at rest server-side; reads return them redacted.

Returns:

  • (Array<HttpHeader>)

    Headers attached to every outbound request. Values carry credentials and are encrypted at rest server-side; reads return them redacted.



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
# File 'lib/smplkit/audit/models.rb', line 332

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:



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
# File 'lib/smplkit/audit/models.rb', line 332

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



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
# File 'lib/smplkit/audit/models.rb', line 332

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.



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
# File 'lib/smplkit/audit/models.rb', line 332

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.



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
# File 'lib/smplkit/audit/models.rb', line 332

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



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/smplkit/audit/models.rb', line 366

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



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/smplkit/audit/models.rb', line 346

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