-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
96 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import logging | ||
import requests | ||
|
||
STATUS_CAKE_BASE_URL = "https://app.statuscake.com/API/" | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get(apikey, username, endpoint, params={}): | ||
|
||
request_url = "{base}{endpoint}".format( | ||
base=STATUS_CAKE_BASE_URL, endpoint=endpoint) | ||
|
||
logger.debug("Starting request: {request_url} {endpoint} {params}".format( | ||
request_url=request_url, | ||
endpoint=endpoint, | ||
params=params)) | ||
|
||
headers = { | ||
"API": apikey, | ||
"Username": username | ||
} | ||
|
||
response = requests.get(url=request_url, params=params, headers=headers) | ||
response.raise_for_status() | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import requests | ||
import logging | ||
from status_cake_client import STATUS_CAKE_BASE_URL | ||
|
||
from .base import get | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_tests(apikey, username, tags=""): | ||
endpoint = "Tests" | ||
request_url = "{base}{endpoint}".format( | ||
base=STATUS_CAKE_BASE_URL, endpoint=endpoint) | ||
params = { | ||
"tags": tags | ||
} | ||
|
||
logger.info("Sending request to {request_url}".format( | ||
request_url=request_url)) | ||
response = get(apikey, username, endpoint, params) | ||
|
||
headers = { | ||
"API": apikey, | ||
"Username": username | ||
} | ||
return response | ||
|
||
|
||
def get_test_details(apikey, username, test_id): | ||
endpoint = "Tests/Details/" | ||
params = { | ||
"tags": tags | ||
"TestID": test_id | ||
} | ||
|
||
response = requests.get(url=request_url, params=params, headers=headers) | ||
response.raise_for_status() | ||
response = get(apikey, username, endpoint, params) | ||
|
||
return response |