GoldenGate StreamAdmin account via Python
A few years ago, I wrote a blog post called “Where is my StreamAdmin account”? This post was related to how security worked within Oracle GoldenGate (Microservices). At the same time, I provided a quick cURL command on how to build a “StreamAdmin” account. Some time after that, I decided to write the same implemenation of the account in Python. The code that follows is from the python script that I wrote.
I’ve had this sitting on the shelf for last few years due to global issues, if you know what I mean. Hopefully, it can help a few people understand how to interact with Oracle GoldenGate (Microservices) via Python.
import requests
#global variables and lists
gg_servers_admin = ['localhost', '16001', 'localhost', '17001']
gg_payload = ['credential', 'Welcome1', 'info', 'Stream Admin', 'type', 'Basic', 'user', 'streamadmin']
gg_header = ['cache-control', 'no-cache']
vlist = []
vPayload = []
vHeader = []
vcURL = []
#Get server and port number from list
for i in range(0, len(gg_servers_admin),2):
vlist.append(gg_servers_admin[i] + ':' + gg_servers_admin[i+1])
#Get payload information
for p in range(0,len(gg_payload),2):
vPayload.append('"' + gg_payload[p] + '":"' + gg_payload[p+1] + '"')
#Get header information
for h in range(0, len(gg_header),2):
vHeader.append('"' + gg_header[h] + '":"' + gg_header[h+1] + '"')
#Build cURL components
for x in vlist:
vUrl = 'https://'
vEndPoint = '/services/v2/authorizations/'
vRole = 'Administrator'
vUser = 'streamadmin'
vurl = vUrl + x + vEndPoint + vRole + '/' + vUser
vcURL.append(vurl)
#Build Payload
vpayload = '{'
for y in vPayload:
vpayload = vpayload + y + ','
vpayload = vpayload.rstrip(',')
vpayload = vpayload + '}'
vcURL.append(vpayload)
vheader = '{'
#Build Header
for z in vHeader:
vheader = vheader + z + ','
vheader = vheader.rstrip(',')
vheader = vheader + '}'
vcURL.append(vheader)
for c in vcURL:
print c
response = requests.request("POST", vurl, data=vpayload, headers=vheader)
print (response.text)
For more examples of what can be done, check out a few Python scripts I wrote a few years ago – All scripts are in my public GitHub (here) and this will get filled in more as more projects are done.
Current Oracle Certs
Bobby Curtis
I’m Bobby Curtis and I’m just your normal average guy who has been working in the technology field for awhile (started when I was 18 with the US Army). The goal of this blog has changed a bit over the years. Initially, it was a general blog where I wrote thoughts down. Then it changed to focus on the Oracle Database, Oracle Enterprise Manager, and eventually Oracle GoldenGate.
If you want to follow me on a more timely manner, I can be followed on twitter at @dbasolved or on LinkedIn under “Bobby Curtis MBA”.