-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathStatusPageComponents.py
31 lines (24 loc) · 1.19 KB
/
StatusPageComponents.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
import requests
def main():
# Define the service for which we are checking the status
# Example services using this API are GitHub, Dropbox, Discord, Vimeo
service = "GitHub Status"
# Set the base URL of the status page API for the service
# Example API URLs for these services are:
# https://www.githubstatus.com, https://status.dropbox.com, https://www.vimeostatus.com/
urlapi = "https://www.githubstatus.com"
# Define header parameters for the request to the local API
header_params = {
"identifier": service,
"type": "Status Page",
}
# Create a session object to manage and persist settings across requests
session = requests.Session()
# Send a GET request to the status API to get the current status of the components in JSON format
components = session.get(urlapi + "/api/v2/components.json")
# Send a PUT request to the local Data API with the status data
# Include the header parameters for additional context
session.put("http://localhost:34567/api/data/parameters", json=components.json(), headers=header_params)
# Execute the main function when the script is run
if __name__ == "__main__":
main()