Class: Svix::StreamSinkIn
- Inherits:
-
Object
- Object
- Svix::StreamSinkIn
- Defined in:
- lib/svix/models/stream_sink_in.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
How many events will be batched in a request to the Sink.
-
#config ⇒ Object
Returns the value of attribute config.
-
#event_types ⇒ Object
A list of event types that filter which events are dispatched to the Sink.
-
#max_wait_secs ⇒ Object
How long to wait before a batch of events is sent, if the ‘batchSize` is not reached.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#status ⇒ Object
Whether the sink will receive events.
-
#uid ⇒ Object
An optional unique identifier for the sink.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ StreamSinkIn
constructor
A new instance of StreamSinkIn.
- #serialize ⇒ Object
-
#to_json ⇒ Object
Serializes the object to a json string.
Constructor Details
#initialize(attributes = {}) ⇒ StreamSinkIn
Returns a new instance of StreamSinkIn.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/svix/models/stream_sink_in.rb', line 82 def initialize(attributes = {}) unless attributes.is_a?(Hash) fail( ArgumentError, "The input argument (attributes) must be a hash in `Svix::StreamSinkIn` new method" ) end attributes.each do |k, v| unless ALL_FIELD.include?(k.to_s) fail(ArgumentError, "The field #{k} is not part of Svix::StreamSinkIn") end if k == "config" unless TYPE_TO_NAME.key?(v.class) fail(ArgumentError, "The field #{k} can't be a `#{v.class}` expected one of #{TYPE_TO_NAME.keys}") end instance_variable_set("@__enum_discriminator", TYPE_TO_NAME[v.class]) end instance_variable_set("@#{k}", v) instance_variable_set("@__#{k}_is_defined", true) end if @__enum_discriminator.nil? fail(ArgumentError, "Required config field was not set") end end |
Instance Attribute Details
#batch_size ⇒ Object
How many events will be batched in a request to the Sink.
48 49 50 |
# File 'lib/svix/models/stream_sink_in.rb', line 48 def batch_size @batch_size end |
#config ⇒ Object
Returns the value of attribute config.
66 67 68 |
# File 'lib/svix/models/stream_sink_in.rb', line 66 def config @config end |
#event_types ⇒ Object
A list of event types that filter which events are dispatched to the Sink. An empty list (or null) will not filter out any events.
50 51 52 |
# File 'lib/svix/models/stream_sink_in.rb', line 50 def event_types @event_types end |
#max_wait_secs ⇒ Object
How long to wait before a batch of events is sent, if the ‘batchSize` is not reached.
For example, with a ‘batchSize` of 100 and `maxWaitSecs` of 10, we will send a request after 10 seconds or 100 events, whichever comes first.
Note that we will never send an empty batch of events to the Sink.
56 57 58 |
# File 'lib/svix/models/stream_sink_in.rb', line 56 def max_wait_secs @max_wait_secs end |
#metadata ⇒ Object
Returns the value of attribute metadata.
57 58 59 |
# File 'lib/svix/models/stream_sink_in.rb', line 57 def @metadata end |
#status ⇒ Object
Whether the sink will receive events.
If the sink is ‘enabled`, any events posted to the stream will be dispatched to the Sink in the same order that events were posted to the stream.
If the sink is ‘disabled`, events will not be dispatched to the sink until the sink is reenabled.
63 64 65 |
# File 'lib/svix/models/stream_sink_in.rb', line 63 def status @status end |
#uid ⇒ Object
An optional unique identifier for the sink.
65 66 67 |
# File 'lib/svix/models/stream_sink_in.rb', line 65 def uid @uid end |
Class Method Details
.deserialize(attributes = {}) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/svix/models/stream_sink_in.rb', line 112 def self.deserialize(attributes = {}) attributes = attributes.transform_keys(&:to_s) attrs = Hash.new attrs["batch_size"] = attributes["batchSize"] attrs["event_types"] = attributes["eventTypes"] attrs["max_wait_secs"] = attributes["maxWaitSecs"] attrs["metadata"] = attributes["metadata"] attrs["status"] = Svix::SinkStatusIn.deserialize(attributes["status"]) if attributes["status"] attrs["uid"] = attributes["uid"] unless NAME_TO_TYPE.key?(attributes["type"]) fail(ArgumentError, "Invalid type `#{attributes["type"]}` expected on of #{NAME_TO_TYPE.keys}") end unless attributes.key?("config") fail(ArgumentError, "Missing required field config") end attrs["config"] = NAME_TO_TYPE[attributes["type"]].deserialize(attributes["config"]) new(attrs) end |
Instance Method Details
#serialize ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/svix/models/stream_sink_in.rb', line 133 def serialize out = Hash.new out["batchSize"] = Svix::serialize_primitive(@batch_size) if @batch_size out["eventTypes"] = Svix::serialize_primitive(@event_types) if @event_types out["maxWaitSecs"] = Svix::serialize_primitive(@max_wait_secs) if @max_wait_secs out["metadata"] = Svix::serialize_primitive(@metadata) if @metadata out["status"] = Svix::serialize_schema_ref(@status) if @status out["uid"] = Svix::serialize_primitive(@uid) if @uid out["type"] = @__enum_discriminator out["config"] = @config.serialize out end |
#to_json ⇒ Object
Serializes the object to a json string
148 149 150 |
# File 'lib/svix/models/stream_sink_in.rb', line 148 def to_json JSON.dump(serialize) end |