Class: Tripwire::Server::WebhooksResource

Inherits:
BaseResource show all
Defined in:
lib/tripwire/server/client.rb

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from Tripwire::Server::BaseResource

Instance Method Details

#create_endpoint(organization_id, name:, url:, event_types:) ⇒ Object



373
374
375
376
377
378
379
# File 'lib/tripwire/server/client.rb', line 373

def create_endpoint(organization_id, name:, url:, event_types:)
  @client.request_json("POST", "/v1/organizations/#{CGI.escape(organization_id)}/webhooks/endpoints", body: {
    name: name,
    url: url,
    event_types: event_types
  })[:data]
end

#disable_endpoint(organization_id, endpoint_id) ⇒ Object



385
386
387
# File 'lib/tripwire/server/client.rb', line 385

def disable_endpoint(organization_id, endpoint_id)
  @client.request_json("DELETE", "/v1/organizations/#{CGI.escape(organization_id)}/webhooks/endpoints/#{CGI.escape(endpoint_id)}")[:data]
end

#list_endpoints(organization_id) ⇒ Object



368
369
370
371
# File 'lib/tripwire/server/client.rb', line 368

def list_endpoints(organization_id)
  payload = @client.request_json("GET", "/v1/organizations/#{CGI.escape(organization_id)}/webhooks/endpoints")
  list_result(payload)
end

#list_events(organization_id, endpoint_id: nil, type: nil, limit: nil) ⇒ Object



397
398
399
400
401
402
403
404
# File 'lib/tripwire/server/client.rb', line 397

def list_events(organization_id, endpoint_id: nil, type: nil, limit: nil)
  payload = @client.request_json("GET", "/v1/organizations/#{CGI.escape(organization_id)}/events", query: {
    endpoint_id: endpoint_id,
    type: type,
    limit: limit
  })
  list_result(payload)
end

#retrieve_event(organization_id, event_id) ⇒ Object



406
407
408
# File 'lib/tripwire/server/client.rb', line 406

def retrieve_event(organization_id, event_id)
  @client.request_json("GET", "/v1/organizations/#{CGI.escape(organization_id)}/events/#{CGI.escape(event_id)}")[:data]
end

#rotate_secret(organization_id, endpoint_id) ⇒ Object



389
390
391
# File 'lib/tripwire/server/client.rb', line 389

def rotate_secret(organization_id, endpoint_id)
  @client.request_json("POST", "/v1/organizations/#{CGI.escape(organization_id)}/webhooks/endpoints/#{CGI.escape(endpoint_id)}/rotations")[:data]
end

#send_test(organization_id, endpoint_id) ⇒ Object



393
394
395
# File 'lib/tripwire/server/client.rb', line 393

def send_test(organization_id, endpoint_id)
  @client.request_json("POST", "/v1/organizations/#{CGI.escape(organization_id)}/webhooks/endpoints/#{CGI.escape(endpoint_id)}/test")[:data]
end

#update_endpoint(organization_id, endpoint_id, **updates) ⇒ Object



381
382
383
# File 'lib/tripwire/server/client.rb', line 381

def update_endpoint(organization_id, endpoint_id, **updates)
  @client.request_json("PATCH", "/v1/organizations/#{CGI.escape(organization_id)}/webhooks/endpoints/#{CGI.escape(endpoint_id)}", body: updates)[:data]
end