ca_certs = '/opt/python/certs/cg_ca_certs.crt'
if not os.path.isfile(ca_certs):
print("Ca certificates are not found")
return None
secretName = os.getenv("sn_oauth_secrets")
http = urllib3.PoolManager(
cert_reqs='CERT_REQUIRED',
ca_certs=ca_certs
)
region = 'us-east-1'
# Fetch the access token
token = get_secret(secretName, region)
if token == 'Invalid Token':
return None
# Define the payload to update the Change Request
data = {
"state": new_state
}
headers = {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Authorization': f'Bearer {token}'
}
json_data = json.dumps(data)
try:
response = http.request('PUT', url, body=json_data, headers=headers)
print("Update ServiceNow CR Status:", response.status)
if response.status == 200:
return json.loads(response.data.decode('utf-8'))
else:
print(f"Error: Received status code {response.status}")
except MaxRetryError as e:
print("Max retries exceeded")
except HTTPError as e:
print(f"HTTP error occurred: {e}")
except Exception as err:
print("Update ServiceNow CR ERROR", err)
return None
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team