class PactBroker::Webhooks::TriggeredWebhook

Constants

STATUS_FAILURE
STATUS_NOT_RUN
STATUS_RETRYING
STATUS_SUCCESS
TRIGGER_TYPE_RESOURCE_CREATION
TRIGGER_TYPE_USER

Public Instance Methods

consumer_name() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 76
def consumer_name
  consumer && consumer.name
end
delete() click to toggle source
Calls superclass method
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 27
def delete
  require "pact_broker/webhooks/execution"
  PactBroker::Webhooks::Execution.where(triggered_webhook: self).delete
  super
end
execute(options) click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 69
def execute options
  # getting a random 'no method to_domain for null' error
  # not sure on which object, so splitting this out into two lines
  pact = pact_publication.with_version_branches_and_tags.to_domain
  webhook.to_domain.execute(pact, verification, event_context.symbolize_keys, options)
end
failed() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 41
def failed
  where(status: STATUS_FAILURE)
end
failure?() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 88
def failure?
  status == STATUS_FAILURE
end
finished?() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 104
def finished?
  success? || failure?
end
latest_triggered_webhooks() click to toggle source

Return the dataset for the latest triggered webhooks grouped by consumer, provider, webhook and event. Excludes the deleted webhooks

# File lib/pact_broker/webhooks/triggered_webhook.rb, line 52
def latest_triggered_webhooks
  exclude(webhook_id: nil).max_group_by(:id, [:consumer_id, :provider_id, :webhook_uuid, :event_name]).order(:id)
end
not_run() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 45
def not_run
  where(status: STATUS_NOT_RUN)
end
not_run?() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 96
def not_run?
  status == STATUS_NOT_RUN
end
number_of_attempts_made() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 100
def number_of_attempts_made
  webhook_executions.size
end
number_of_attempts_remaining() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 108
def number_of_attempts_remaining
  if finished?
    0
  else
    (PactBroker.configuration.webhook_retry_schedule.size + 1) - number_of_attempts_made
  end
end
provider_name() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 80
def provider_name
  provider && provider.name
end
request_description() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 64
def request_description
  # webhook could be deleted
  webhook&.to_domain&.request_description
end
retrying() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 33
def retrying
  where(status: STATUS_RETRYING)
end
retrying?() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 92
def retrying?
  status == STATUS_RETRYING
end
success?() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 84
def success?
  status == STATUS_SUCCESS
end
successful() click to toggle source
# File lib/pact_broker/webhooks/triggered_webhook.rb, line 37
def successful
  where(status: STATUS_SUCCESS)
end