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.



283
284
285
286
287
288
289
290
291
# File 'lib/smplkit/audit/models.rb', line 283

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



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/smplkit/audit/models.rb', line 279

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.



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/smplkit/audit/models.rb', line 279

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:



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/smplkit/audit/models.rb', line 279

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



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/smplkit/audit/models.rb', line 279

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.



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/smplkit/audit/models.rb', line 279

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.



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/smplkit/audit/models.rb', line 279

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



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

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



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/smplkit/audit/models.rb', line 293

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