Class: Cerca::Resources::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/cerca/resources/webhooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Webhooks

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 Webhooks.

Parameters:



176
177
178
# File 'lib/cerca/resources/webhooks.rb', line 176

def initialize(client:)
  @client = client
end

Instance Method Details

#create(fleet_id, url:, events: nil, request_options: {}) ⇒ Cerca::Models::WebhookSubscriptionCreated

Create webhook

Parameters:

Returns:

See Also:



21
22
23
24
25
26
27
28
29
30
# File 'lib/cerca/resources/webhooks.rb', line 21

def create(fleet_id, params)
  parsed, options = Cerca::WebhookCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["fleets/%1$s/webhooks", fleet_id],
    body: parsed,
    model: Cerca::WebhookSubscriptionCreated,
    options: options
  )
end

#delete(fleet_id, webhook_id, request_options: {}) ⇒ nil

Delete webhook

Parameters:

  • fleet_id (String)
  • webhook_id (String)
  • request_options (Cerca::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



124
125
126
127
128
129
130
131
# File 'lib/cerca/resources/webhooks.rb', line 124

def delete(fleet_id, webhook_id, params = {})
  @client.request(
    method: :delete,
    path: ["fleets/%1$s/webhooks/%2$s", fleet_id, webhook_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(fleet_id, cursor: nil, limit: nil, request_options: {}) ⇒ Cerca::Internal::SubscriptionsCursorPage<Cerca::Models::WebhookSubscription>

Some parameter documentations has been truncated, see Models::WebhookListParams for more details.

List webhooks

Parameters:

  • fleet_id (String)
  • cursor (String)

    Opaque pagination cursor returned by a previous request.

  • limit (String)

    Maximum number of items to return. Defaults to 20 and preserves parseInt semanti

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

Returns:

See Also:



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/cerca/resources/webhooks.rb', line 100

def list(fleet_id, params = {})
  parsed, options = Cerca::WebhookListParams.dump_request(params)
  query = Cerca::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["fleets/%1$s/webhooks", fleet_id],
    query: query,
    page: Cerca::Internal::SubscriptionsCursorPage,
    model: Cerca::WebhookSubscription,
    options: options
  )
end

#retrieve(fleet_id, webhook_id, request_options: {}) ⇒ Cerca::Models::WebhookSubscription

Retrieve webhook

Parameters:

  • fleet_id (String)
  • webhook_id (String)
  • request_options (Cerca::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



43
44
45
46
47
48
49
50
# File 'lib/cerca/resources/webhooks.rb', line 43

def retrieve(fleet_id, webhook_id, params = {})
  @client.request(
    method: :get,
    path: ["fleets/%1$s/webhooks/%2$s", fleet_id, webhook_id],
    model: Cerca::WebhookSubscription,
    options: params[:request_options]
  )
end

#rotate(fleet_id, webhook_id, request_options: {}) ⇒ Cerca::Models::WebhookSubscriptionCreated

Rotate webhook secret

Parameters:

  • fleet_id (String)
  • webhook_id (String)
  • request_options (Cerca::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



144
145
146
147
148
149
150
151
# File 'lib/cerca/resources/webhooks.rb', line 144

def rotate(fleet_id, webhook_id, params = {})
  @client.request(
    method: :post,
    path: ["fleets/%1$s/webhooks/%2$s/rotate", fleet_id, webhook_id],
    model: Cerca::WebhookSubscriptionCreated,
    options: params[:request_options]
  )
end

#test_(fleet_id, webhook_id, request_options: {}) ⇒ Cerca::Models::WebhookTestResponse

Send test webhook

Parameters:

  • fleet_id (String)
  • webhook_id (String)
  • request_options (Cerca::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



164
165
166
167
168
169
170
171
# File 'lib/cerca/resources/webhooks.rb', line 164

def test_(fleet_id, webhook_id, params = {})
  @client.request(
    method: :post,
    path: ["fleets/%1$s/webhooks/%2$s/test", fleet_id, webhook_id],
    model: Cerca::Models::WebhookTestResponse,
    options: params[:request_options]
  )
end

#update(fleet_id, webhook_id, enabled: nil, events: nil, url: nil, request_options: {}) ⇒ Cerca::Models::WebhookSubscription

Update webhook

Parameters:

  • fleet_id (String)
  • webhook_id (String)
  • enabled (Boolean)

    Whether deliveries are enabled for this subscription.

  • events (Array<Symbol, Cerca::Models::WebhookSubscriptionEventType>)

    Event names to deliver. Omit to subscribe to all non-test events.

  • url (String)

    HTTPS endpoint that will receive webhook deliveries.

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

Returns:

See Also:



71
72
73
74
75
76
77
78
79
80
# File 'lib/cerca/resources/webhooks.rb', line 71

def update(fleet_id, webhook_id, params = {})
  parsed, options = Cerca::WebhookUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["fleets/%1$s/webhooks/%2$s", fleet_id, webhook_id],
    body: parsed,
    model: Cerca::WebhookSubscription,
    options: options
  )
end