-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprivacy.py
49 lines (38 loc) · 1.58 KB
/
privacy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json
import requests
time = input_data['miliseconds']
# Array contain list of screens to disable. Use the get {{url}}/teams/{{teamID}}/screens to return screen list
array = ["screen1", "screen2", "screen3", "screenn"]
url = "https://signage-api.screen.cloud/api/v1/teams/<team ID>/screens/"
for x in array:
payload = "{\n \"content_id\": \"<conent id>\",\n \"mime_type\": \"image/jpeg\",\n \"duration\": %s\n}" % time
headers = {
'Content-Type': "application/json",
'Authorization': "Basic <key>",
'cache-control': "no-cache",
}
response = requests.request("PUT", (url+x+"/takeover"), data=payload, headers=headers)
print(response.text)
print(payload)
# Set the webhook_url to the one provided by Slack when you create the webhook at https://my.slack.com/services/new/incoming-webhook/
webhook_url = 'https://hooks.slack.com/services/<webhook URL back to slack>'
slack_data = {
"attachments": [
{
"fallback": "Required plain-text summary of the attachment.",
"color": "#EC1075",
"title": "Privacy Enabled",
"text": ":red-flag: Sensitive screens around the office have been made :dark_sunglasses: for {} minutes".format(input_data['minutes']),
}
]
}
print(slack_data)
response = requests.post(
webhook_url, data=json.dumps(slack_data),
headers={'Content-Type': 'application/json'}
)
if response.status_code != 200:
raise ValueError(
'Request to slack returned an error %s, the response is:\n%s'
% (response.status_code, response.text)
)