This file contains hidden or 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 requests | |
| import json | |
| def open_incidents_test(incident): | |
| url = "https:/xxxx/api/koi/servicenow_incident_api/update" | |
| payload = json.dumps({ | |
| "Incident_Update": { | |
| "number": incident, | |
| "state": "New", |
This file contains hidden or 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
| def close_incident(incident): | |
| url = SNOW_BASE_URL + "koi/servicenow_incident_api/update" | |
| payload = json.dumps({ | |
| "Incident_Update": { | |
| "number": incident['number']['value'], | |
| "state": "Closed", | |
| "work_notes": "xxxx", | |
| "additional_comments": "xxxx" |
This file contains hidden or 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
| def get_dp_info(session, access_token, incident): | |
| url = DP_BASE_URL + 'idb/sessions/filter/' | |
| # transform session name format | |
| zeros_to_prefix = 4 - len(incident['session_name'].split('-')[-1]) | |
| session_name = incident['session_name'].replace('-', ' ' + zeros_to_prefix * '0') | |
| payload = json.dumps({ | |
| "filter": { |
This file contains hidden or 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
| DP_BASE_URL = 'https://xxxx.com:xxxx/' | |
| def dp_login(): | |
| session = requests.session() | |
| url = DP_BASE_URL + 'auth/realms/DataProtector/protocol/openid-connect/token' | |
| payload = {'username':'xxxx|*|xxxx', 'password':'xxxx.', 'client_id':'dp-gui', 'grant_type':'password'} | |
| response = json.loads(session.post(url,data=payload,verify='xxxx_cacert.pem').text) | |
| access_token = response['access_token'] |
This file contains hidden or 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
| SNOW_BASE_URL = 'https://xxxx.service-now.com/api/' | |
| def snow_login(states): | |
| user = 'XXXX' | |
| pwd = 'XXXX' | |
| headers = {"Content-Type":"application/json","Accept":"application/json"} | |
| snow_data=[] | |
| for state in states: | |
| url = SNOW_BASE_URL + 'now/table/incident?sysparm_display_value=all&sysparm_fields=number%2Cassigned_to%2Csys_id%2Cstate%2Ccomments%2Cwork_notes%2Ccmdb_ci&cmdb_ci=xxxx&state='+state | |
This file contains hidden or 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 json | |
| import requests | |
| import time | |
| from pytz import timezone | |
| import datetime | |
| status_dict = {'0':'Running','1':'Running with Errors','12':'Running with Failures','15':'Queueing with Failures'} | |
| session_type_dict = {'0':'Backup'} | |
This file contains hidden or 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
| def json_to_csv(path, fileInput, fileOutput): | |
| inputFile = open(path + fileInput) | |
| data = json.load(inputFile) | |
| inputFile.close() | |
| with open(os.path.join(path,fileOutput), 'w') as fp: | |
| output = csv.writer(fp) | |
| output.writerow(data[0].keys()) | |
| for row in data: | |
| output.writerow(row.values()) |
This file contains hidden or 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
| def send_email(sender, recipient, aws_region, subject, file_name): | |
| # The email body for recipients with non-HTML email clients. | |
| BODY_TEXT = "Hello,\r\nPlease find the attached file." | |
| # The HTML body of the email. | |
| BODY_HTML = """\ | |
| <html> | |
| <head></head> | |
| <body> | |
| <h1>Hello!</h1> | |
| <p>Please find the attached file.</p> |
This file contains hidden or 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
| from botocore.exceptions import ClientError | |
| from botocore.vendored import requests | |
| def send_email(sender, recipient, aws_region, subject): | |
| # This address must be verified with Amazon SES. | |
| SENDER = sender | |
| # If your account is still in the sandbox, this address must be verified. | |
| RECIPIENT = recipient | |
| # Specify a configuration set. If you do not want to use a configuration |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.