Class: Readiness::Pagerduty::Services

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/pagerduty/services.rb

Overview

TODO:

Create a service

TODO:

Delete a service

TODO:

Update a service

TODO:

List audit records for a service

TODO:

Creat a new integration

TODO:

Update an existing integration

TODO:

View an integration

Defines the class Services within the module Readiness::Pagerduty.

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Constructor Details

#initialize(object = {}) ⇒ Services

Creates a new Readiness::Pagerduty::Services instance

Examples:

require 'support_readiness'
Readiness::Pagerduty::Services.new

Parameters:

Author:

  • Jason Colyer

Since:

  • 1.0.0



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/support_readiness/pagerduty/services.rb', line 31

def initialize(object = {})
  @acknowledgement_timeout = object['acknowledgement_timeout']
  @alert_creation = object['alert_creation']
  @auto_pause_notifications_parameters = object['auto_pause_notifications_parameters']
  @auto_resolve_timeout = object['auto_resolve_timeout']
  @created_at = object['created_at']
  @escalation_policy = object['escalation_policy']
  @html_url = object['html_url']
  @id = object['id']
  @incident_urgency_rule = object['incident_urgency_rule']
  @integrations = object['integrations']
  @name = object['name']
  @scheduled_actions = object['scheduled_actions']
  @self = object['self']
  @status = object['status']
  @summary = object['summary']
  @support_hours = object['support_hours']
  @teams = object['teams']
  @type = object['type']
end

Instance Attribute Details

#acknowledgement_timeoutObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def acknowledgement_timeout
  @acknowledgement_timeout
end

#alert_creationObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def alert_creation
  @alert_creation
end

#auto_pause_notifications_parametersObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def auto_pause_notifications_parameters
  @auto_pause_notifications_parameters
end

#auto_resolve_timeoutObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def auto_resolve_timeout
  @auto_resolve_timeout
end

#created_atObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def created_at
  @created_at
end

#escalation_policyObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def escalation_policy
  @escalation_policy
end

#html_urlObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def html_url
  @html_url
end

#idObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def id
  @id
end

#incident_urgency_ruleObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def incident_urgency_rule
  @incident_urgency_rule
end

#integrationsObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def integrations
  @integrations
end

#nameObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def name
  @name
end

#scheduled_actionsObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def scheduled_actions
  @scheduled_actions
end

#selfObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def self
  @self
end

#statusObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def status
  @status
end

#summaryObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def summary
  @summary
end

#support_hoursObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def support_hours
  @support_hours
end

#teamsObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def teams
  @teams
end

#typeObject

Since:

  • 1.0.0



20
21
22
# File 'lib/support_readiness/pagerduty/services.rb', line 20

def type
  @type
end

Class Method Details

.find(client, sid) ⇒ Hash

Locates a service within Pagerduty. This will not exit on error (except Authentication errors)

Examples:

require 'support_readiness'
config = Readiness::Pagerduty::Configuration.new
config.token = 'test123abc'
client = Readiness::Pagerduty::Client.new(config)
service = Readiness::Pagerduty::Services.find(client, "PIJ90N7")
pp service.name
# => "My Application Service"

Parameters:

  • client (Object)

    An instance of Client

  • sid (String)

    The service ID to find

Returns:

  • (Hash)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



100
101
102
103
104
105
106
# File 'lib/support_readiness/pagerduty/services.rb', line 100

def self.find(client, sid)
  response = client.connection.get("services/#{sid}")
  handle_request_error(0, 'Pagerduty', response.status,  { action: 'get', id: sid }) unless response.status == 200
  return Services.new(Oj.load(response.body)['service']) if response.status == 200

  Oj.load(response.body)
end

.find!(client, sid) ⇒ Object

Locates a service within Pagerduty. This will exit on error

Examples:

require 'support_readiness'
config = Readiness::Pagerduty::Configuration.new
config.token = 'test123abc'
client = Readiness::Pagerduty::Client.new(config)
service = Readiness::Pagerduty::Services.find!(client, "PIJ90N7")
pp service.name
# => "My Application Service"

Parameters:

  • client (Object)

    An instance of Client

  • sid (String)

    The service ID to find

Returns:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



125
126
127
128
129
# File 'lib/support_readiness/pagerduty/services.rb', line 125

def self.find!(client, sid)
  response = client.connection.get("services/#{sid}")
  handle_request_error(1, 'Pagerduty', response.status, { action: 'Find service', id: sid }) unless response.status == 200
  Services.new(Oj.load(response.body)['service'])
end

.list(client) ⇒ Array

Lists services

Examples:

require 'support_readiness'
config = Readiness::Pagerduty::Configuration.new
config.token = 'test123abc'
client = Readiness::Pagerduty::Client.new(config)
services = Readiness::Pagerduty::Services.list(client)
pp services.first.name
# => "My Application Service"

Parameters:

  • client (Object)

    An instance of Client

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/support_readiness/pagerduty/services.rb', line 68

def self.list(client)
  array = []
  offset = 0
  loop do
    response = client.connection.get "services?limit=100&offset=#{offset}"
    handle_request_error(0, 'Pagerduty', response.status) unless response.status == 200
    body = Oj.load(response.body)
    array += body['services'].map { |e| Services.new(e) }
    break unless body['more']

    offset += 100
  end
  array
end