Class: Zavudev::Resources::Functions::Triggers

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/functions/triggers.rb,
sig/zavudev/resources/functions/triggers.rbs

Instance Method Summary collapse

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.

Parameters:



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.

Parameters:

  • function_id (String) —

    Zavu Function ID.

  • event_types (Array<String>) —

    Event types to subscribe to.

  • sender_ids (Array<String, nil>) —

    Senders to scope the triggers to. Use null for all senders.

  • cron (String) —

    Required when eventTypes includes cron: a 5-field cron expression (minute hour

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: options
  )
end

#delete(trigger_id, request_options: {}) ⇒ nil

Delete a trigger

Parameters:

Returns:

  • (nil)

See Also:



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

Parameters:

Returns:

See Also:



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

Parameters:

Returns:

See Also:



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, options = 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: options
  )
end