Skip to content

Commit

Permalink
Added support to manually call API endpoint. GET only
Browse files Browse the repository at this point in the history
  • Loading branch information
zemerick1 committed Feb 24, 2019
1 parent 240f659 commit 86a1249
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ print(CPPM.get_endpoints(10))
print('Endpoint: {}'.format(CPPM.get_endpoint(4814)))
Endpoint {'id': 4814, 'mac_address': '0000e349473f', 'status': 'Unknown', 'attributes': {}, '_links': {'self': {'href': 'https://clearpass.server.com/api/endpoint/4814'}}}

# Calls API endpoint. Only supports GET method
print('API Call: {}'.format(CPPM.api('/auth-method')))

```
7 changes: 7 additions & 0 deletions clearpasspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ def __init__(self, data):
'Content-Type': 'application/json',
'Authorization': "{} {}".format('Bearer', self.access_token)
}
def api(self, service):
''' Calls specified API service endpoint. Only supports GET methods '''
url = 'https://' + self.server + '/api' + service
r = requests.get(url, headers=self.headers)
json_r = json.loads(r.text)
return json_r['_embedded']

def online_status(self, macaddress):
''' Returns true/false if endpoint is online '''
is_online = False
Expand Down

0 comments on commit 86a1249

Please sign in to comment.