class ServiceNow::Client
Attributes
connection[R]
Public Class Methods
authenticate(instance_id, client_id, client_secret, username, password)
click to toggle source
# File lib/servicenow/client.rb, line 8 def authenticate(instance_id, client_id, client_secret, username, password) connection_options = { url: "https://#{instance_id}.service-now.com/" } conn = Faraday.new(connection_options) do |faraday| faraday.request :url_encoded faraday.response :json faraday.response :raise_error faraday.adapter Faraday.default_adapter end params = { grant_type: "password", client_id: client_id, client_secret: client_secret, username: username, password: password } response = conn.post('oauth_token.do', params) connection = Connection.new(instance_id, response.body["access_token"]) Client.new(connection) end
new(connection)
click to toggle source
# File lib/servicenow/client.rb, line 34 def initialize(connection) @connection = connection end
Public Instance Methods
cmdb_instance(instance_class)
click to toggle source
# File lib/servicenow/client.rb, line 46 def cmdb_instance(instance_class) Client::CMDB.new(@connection, instance_class) end
incidents()
click to toggle source
# File lib/servicenow/client.rb, line 38 def incidents @incidents ||= Client::Tables.new(@connection, "incident") end
tables(table_name)
click to toggle source
# File lib/servicenow/client.rb, line 42 def tables(table_name) Client::Tables.new(@connection, table_name) end