Class: ServiceNow::Client
- Inherits:
-
Object
- Object
- ServiceNow::Client
- Defined in:
- lib/servicenow/client.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Class Method Summary collapse
Instance Method Summary collapse
- #cmdb_instance(instance_class) ⇒ Object
- #incidents ⇒ Object
-
#initialize(connection) ⇒ Client
constructor
A new instance of Client.
- #tables(table_name) ⇒ Object
Constructor Details
#initialize(connection) ⇒ Client
Returns a new instance of Client.
34 35 36 |
# File 'lib/servicenow/client.rb', line 34 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/servicenow/client.rb', line 5 def connection @connection end |
Class Method Details
.authenticate(instance_id, client_id, client_secret, username, password) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/servicenow/client.rb', line 8 def authenticate(instance_id, client_id, client_secret, username, password) = { url: "https://#{instance_id}.service-now.com/" } conn = Faraday.new() 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 |
Instance Method Details
#cmdb_instance(instance_class) ⇒ Object
46 47 48 |
# File 'lib/servicenow/client.rb', line 46 def cmdb_instance(instance_class) Client::CMDB.new(@connection, instance_class) end |