Class: Zavudev::Resources::Functions::Triggers
- Inherits:
-
Object
- Object
- Zavudev::Resources::Functions::Triggers
- Defined in:
- lib/zavudev/resources/functions/triggers.rb,
sig/zavudev/resources/functions/triggers.rbs
Instance Method Summary collapse
-
#create(function_id, event_types:, sender_ids:, cron: nil, request_options: {}) ⇒ Zavudev::Models::Functions::TriggerCreateResponse
Some parameter documentations has been truncated, see Models::Functions::TriggerCreateParams for more details.
-
#delete(trigger_id, request_options: {}) ⇒ nil
Delete a trigger.
-
#initialize(client:) ⇒ Triggers
constructor
private
A new instance of Triggers.
-
#list(function_id, request_options: {}) ⇒ Zavudev::Models::Functions::TriggerListResponse
List function triggers.
-
#update(trigger_id, active:, request_options: {}) ⇒ Zavudev::Models::Functions::TriggerUpdateResponse
Enable or disable a trigger.
Constructor Details
#initialize(client:) ⇒ Triggers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Triggers.
110 111 112 |
# File 'lib/zavudev/resources/functions/triggers.rb', line 110 def initialize(client:) @client = client end |
Instance Method Details
#create(function_id, event_types:, sender_ids:, cron: nil, request_options: {}) ⇒ Zavudev::Models::Functions::TriggerCreateResponse
Some parameter documentations has been truncated, see Models::Functions::TriggerCreateParams for more details.
Subscribe a function to one or more event types, optionally scoped to specific senders. Provide eventTypes and senderIds (use null in senderIds for all senders); a trigger is created for each event type and sender combination.
The special event type cron runs the function on a schedule instead of a
messaging event: include a cron field with a 5-field UTC cron expression
(minimum granularity one minute). A cron trigger ignores the sender axis, and a
function may hold several cron triggers with different expressions. The function
receives an event with type: "cron" and data.cron.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/zavudev/resources/functions/triggers.rb', line 35 def create(function_id, params) parsed, = Zavudev::Functions::TriggerCreateParams.dump_request(params) @client.request( method: :post, path: ["v1/functions/%1$s/triggers", function_id], body: parsed, model: Zavudev::Models::Functions::TriggerCreateResponse, options: ) end |
#delete(trigger_id, request_options: {}) ⇒ nil
Delete a trigger
98 99 100 101 102 103 104 105 |
# File 'lib/zavudev/resources/functions/triggers.rb', line 98 def delete(trigger_id, params = {}) @client.request( method: :delete, path: ["v1/functions/triggers/%1$s", trigger_id], model: NilClass, options: params[:request_options] ) end |
#list(function_id, request_options: {}) ⇒ Zavudev::Models::Functions::TriggerListResponse
List function triggers
79 80 81 82 83 84 85 86 |
# File 'lib/zavudev/resources/functions/triggers.rb', line 79 def list(function_id, params = {}) @client.request( method: :get, path: ["v1/functions/%1$s/triggers", function_id], model: Zavudev::Models::Functions::TriggerListResponse, options: params[:request_options] ) end |
#update(trigger_id, active:, request_options: {}) ⇒ Zavudev::Models::Functions::TriggerUpdateResponse
Enable or disable a trigger
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/zavudev/resources/functions/triggers.rb', line 57 def update(trigger_id, params) parsed, = Zavudev::Functions::TriggerUpdateParams.dump_request(params) @client.request( method: :patch, path: ["v1/functions/triggers/%1$s", trigger_id], body: parsed, model: Zavudev::Models::Functions::TriggerUpdateResponse, options: ) end |