Class: Smplkit::Audit::HttpConfiguration
- Inherits:
-
Struct
- Object
- Struct
- Smplkit::Audit::HttpConfiguration
- 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
-
#ca_cert ⇒ String?
Optional PEM-encoded certificate (or bundle) trusted in addition to the system CA store.
-
#headers ⇒ Array<HttpHeader>
Headers attached to every outbound request.
-
#method ⇒ String
HTTP verb used for delivery.
-
#success_status ⇒ String
Status the destination must return for delivery to count as success — an exact code (+“200”+, “204”) or a class (+“2xx”+, “4xx”).
-
#tls_verify ⇒ Boolean
Whether to verify the destination’s TLS certificate chain.
-
#url ⇒ String
Destination URL the audit service sends each event to.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx", tls_verify: true, ca_cert: nil) ⇒ HttpConfiguration
constructor
A new instance of HttpConfiguration.
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.
350 351 352 353 354 355 356 357 358 |
# File 'lib/smplkit/audit/models.rb', line 350 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_cert ⇒ String?
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”.
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/smplkit/audit/models.rb', line 346 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 |
#headers ⇒ Array<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.
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/smplkit/audit/models.rb', line 346 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 |
#method ⇒ String
Returns HTTP verb used for delivery. Defaults to Smplkit::Audit::HttpMethod::POST.
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/smplkit/audit/models.rb', line 346 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_status ⇒ String
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”.
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/smplkit/audit/models.rb', line 346 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_verify ⇒ Boolean
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.
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/smplkit/audit/models.rb', line 346 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 |
#url ⇒ String
Returns Destination URL the audit service sends each event to.
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/smplkit/audit/models.rb', line 346 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
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/smplkit/audit/models.rb', line 380 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
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/smplkit/audit/models.rb', line 360 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 |