Skip to content

Commit

Permalink
Add logout method
Browse files Browse the repository at this point in the history
  • Loading branch information
baurmatt committed Sep 21, 2017
1 parent 6af62d6 commit 40ea15e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ zbx = ZabbixApi.connect(
)
```

## Logout
```ruby
require "zabbixapi"

zbx = ZabbixApi.connect(
:url => 'http://localhost/zabbix/api_jsonrpc.php',
:user => 'Admin',
:password => 'zabbix'
)

# Do stuff

zbx.logout
```

## Create Host
```ruby
zbx.hosts.create(
Expand Down
6 changes: 6 additions & 0 deletions lib/zabbixapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def query(data)
@client.api_request(:method => data[:method], :params => data[:params])
end

# Invalidate current authentication token
# @return [Boolean]
def logout
@client.logout
end

# Initializes a new ZabbixApi object
#
# @param options [Hash]
Expand Down
10 changes: 10 additions & 0 deletions lib/zabbixapi/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ def auth
)
end

# Log out from the Zabbix Server
#
# @return [Boolean]
def logout
api_request(
:method => 'user.logout',
:params => []
)
end

# Initializes a new Client object
#
# @param options [Hash]
Expand Down

0 comments on commit 40ea15e

Please sign in to comment.