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
-
#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”).
-
#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") ⇒ HttpConfiguration
constructor
A new instance of HttpConfiguration.
Constructor Details
#initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx") ⇒ HttpConfiguration
Returns a new instance of HttpConfiguration.
244 245 246 |
# File 'lib/smplkit/audit/models.rb', line 244 def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx") super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status) end |
Instance Attribute Details
#headers ⇒ Array<HttpHeader>
Headers attached to every outbound request. Values carry credentials and are encrypted at rest server-side; reads return them redacted.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/smplkit/audit/models.rb', line 243 HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx") super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status) 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 ) end def self.from_wire(src) return new if src.nil? 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" ) end end |
#method ⇒ String
Returns HTTP verb used for delivery. Defaults to Smplkit::Audit::HttpMethod::POST.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/smplkit/audit/models.rb', line 243 HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx") super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status) 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 ) end def self.from_wire(src) return new if src.nil? 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" ) 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”.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/smplkit/audit/models.rb', line 243 HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx") super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status) 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 ) end def self.from_wire(src) return new if src.nil? 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" ) end end |
#url ⇒ String
Returns Destination URL the audit service sends each event to.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/smplkit/audit/models.rb', line 243 HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx") super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status) 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 ) end def self.from_wire(src) return new if src.nil? 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" ) end end |
Class Method Details
.from_wire(src) ⇒ Object
266 267 268 269 270 271 272 273 274 275 |
# File 'lib/smplkit/audit/models.rb', line 266 def self.from_wire(src) return new if src.nil? 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" ) end |
.to_wire(src) ⇒ Object
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/smplkit/audit/models.rb', line 248 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 ) end |