Skip to content

Instantly share code, notes, and snippets.

@hasasn
Last active August 9, 2017 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasasn/7062835b6e7f7227cae97eb48708db4c to your computer and use it in GitHub Desktop.
Save hasasn/7062835b6e7f7227cae97eb48708db4c to your computer and use it in GitHub Desktop.
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