Module: Pagerduty

Defined in:
lib/pagerduty.rb,
lib/pagerduty/version.rb,
lib/pagerduty/events_api_v1.rb,
lib/pagerduty/events_api_v2.rb,
lib/pagerduty/http_transport.rb

Defined Under Namespace

Classes: EventsApiV1, EventsApiV2, HttpTransport

Constant Summary collapse

VERSION =
"4.0.0"

Class Method Summary collapse

Class Method Details

.build(config) ⇒ Pagerduty::EventsApiV1

Build an instance that will send API calls to the specified Pagerduty Events API version.

Examples:

Build an instance for the Events API version 1

pagerduty = Pagerduty.build(
  integration_key: "<integration-key>",
  api_version:     1,
)

Build an instance using an HTTP proxy for API requests

pagerduty = Pagerduty.build(
  integration_key: "<integration-key>",
  api_version:     1,
  http_proxy:      {
    host:     "my.http.proxy.local",
    port:     3128,
    username: "<my-proxy-username>",
    password: "<my-proxy-password>",
  }
)

Parameters:

  • config (Hash)

    a customizable set of options

Options Hash (config):

  • integration_key (String)

    Authentication key for connecting to PagerDuty. A UUID expressed as a 32-digit hexadecimal number. Integration keys are generated by creating a new service, or creating a new integration for an existing service in PagerDuty, and can be found on a service’s Integrations tab. This option is required.

  • api_version (String)

    The version of the Pagerduty events API. The gem currently supports version 1 (‘1`). This option is required.

  • http_proxy.host (String)

    The DNS name or IP address of the proxy host. If nil or unprovided an HTTP proxy will not be used.

  • http_proxy.port (String)

    The TCP port to use to access the proxy.

  • http_proxy.username (String)

    username if authorization is required to use the proxy.

  • http_proxy.password (String)

    password if authorization is required to use the proxy.

Returns:

Raises:

  • (ArgumentError)

    If integration_key or api_version options are not provided. Or if the provided api_version is unsupported.



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/pagerduty.rb', line 66

def self.build(config)
  unless config.key?(:integration_key)
    raise ArgumentError, "integration_key not provided"
  end
  raise ArgumentError, "incident_key provided" if config.key?(:incident_key)

  version = config.fetch(:api_version) do
    raise ArgumentError, "api_version not provided"
  end
  events_api_class(version).new(config)
end