Last active
August 9, 2017 23:51
-
-
Save hasasn/7062835b6e7f7227cae97eb48708db4c to your computer and use it in GitHub Desktop.
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
import sys, requests, os, json | |
# Initial setup | |
endpoint = 'https://dashboard.signalsciences.net/api/v0' | |
email = os.environ.get('SIGSCI_EMAIL') | |
password = os.environ.get('SIGSCI_PASSWORD') | |
# Set onelogin corpName for URL endpoint | |
corpName = 'REPLACEME' | |
# Set onelogin siteName for URL endpoint | |
siteName = 'REPLACEME' | |
# Authenticate | |
auth = requests.post( | |
endpoint + '/auth', | |
data = {"email": email, "password": password} | |
) | |
if auth.status_code == 401: | |
print 'Invalid login.' | |
sys.exit() | |
elif auth.status_code != 200: | |
print 'Unexpected status: %s response: %s' % (auth.status_code, auth.text) | |
sys.exit() | |
parsed_response = auth.json() | |
token = parsed_response['token'] | |
print token | |
# Fetch list of corps | |
headers = { | |
'Content-type': 'application/json', | |
'Authorization': 'Bearer %s' % token | |
} | |
# set agentStatus ['block', 'log', 'off'] | |
agentStatus = { | |
'agentLevel': 'off' | |
} | |
agentStatus = json.dumps(agentStatus) | |
corps = requests.patch(endpoint + '/corps/' + corpName + '/sites/' + siteName, headers=headers, data=agentStatus) | |
print corps.text | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment