-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInitialSetup.py
More file actions
192 lines (164 loc) · 7.09 KB
/
Copy pathInitialSetup.py
File metadata and controls
192 lines (164 loc) · 7.09 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#DISCLAIMER: Use of this code is at your own risk. The author of this code and any contributors to this repository make no warranties,
#express or implied, regarding the accuracy, reliability, or suitability of this code for any purpose.
#This code is provided "as is" and without any warranty.
#The author and contributors are not responsible for any direct or indirect damages or losses resulting from the use of this code.
#It is your responsibility to ensure that the code is used in compliance with any applicable licenses, regulations, or laws.
#By using this code, you acknowledge and accept these terms and conditions. If you do not agree with these terms,
#do not use the code or any part of it.
import requests
import json
from base64 import b64encode
from requests.auth import HTTPBasicAuth
#declare array for extracts
aExtracts = []
aReplicats = []
aDistributionPath =[]
aListAlerts =[]
replicat=""
distpath=""
version ="v2"
username = '<gg usernamne>'
password = '<password>
sourceUrl = "https://<goldengate hostname>"
listExtractsNames={}
encoded_credentials = b64encode(bytes(f'{username}:{password}',
encoding='ascii')).decode('ascii')
auth_header = f'Basic {encoded_credentials}'
payload=""
header = f'{auth_header}'
headers = {
'Authorization': header,
'Cookie': ''
}
extractAPI = f'/services/{version}/extracts'
replicatAPI = f'/services/{version}/replicats'
distributionPathAPI=f'/services/{version}/sources'
GetExtractCheckPoint = "/services/{version}/extracts/{extract}/info/checkpoints"
GetReplicatCheckPoint = "/services/{version}/replicats/{replicat}/info/checkpoints"
retrieveReplicat =f'/services/{version}/replicats/'
retrieveExtract =f'/services/{version}/extracts/'
#Example for GoldenGate Initial Load.
bodyInitialLoad = {
'config': ["Extract IL2","ExtFile a5 Megabytes 2000 Purge","UseridAlias ADW DOMAIN OracleGoldenGate","Table ODI_DEMO.TRG_COUNTRY;"],
'source': 'tables'
}
#Example for GoldenGate Integrated Extract.
bodyExtract = {
'config': ["Extract ext4","ExtTrail a1","UseridAlias ADW DOMAIN OracleGoldenGate","Table ODI_DEMO.TRG_COUNTRY;"],
'source': 'tranlogs',
'credentials': {"alias":"ADW","domain":"OracleGoldenGate"},
'begin': 'now',
'targets': [
{
'name': 'a1',
'sizeMB': 500
}
]
}
#Example for GoldenGate Integrated Parallel replicat.
bodyReplicatIntegratedParallel = {
'config': ["Replicat Rep4","UseridAlias SQLServerConnection DOMAIN OracleGoldenGate","Map ODI_DEMO.TRG_COUNTRY,","Target dbo.COUNTRY;"],
'source': {
'name': 'a1'
},
'credentials': {"alias":"SQLServerConnection","domain":"OracleGoldenGate"},
'checkpoint':{
'table': 'dbo.checkpoint_table'
},
'mode': {
'type': 'integrated',
'parallel': True
}
}
#Example for GoldenGate Integrated replicat.
bodyReplicatIntegrated = {
'config': ["Replicat Rep5","UseridAlias SQLServerConnection DOMAIN OracleGoldenGate","Map ODI_DEMO.TRG_COUNTRY,","Target dbo.COUNTRY;"],
'source': {
'name': 'a1'
},
'credentials': {"alias":"SQLServerConnection","domain":"OracleGoldenGate"},
'checkpoint':{
'table': 'dbo.checkpoint_table'
},
'mode': {
'type': 'integrated',
'parallel': False
}
}
#Example for GoldenGate Non Integrated replicat.
bodyReplicatNonIntegrated = {
'config': ["Replicat Rep6","USERIDALIAS ADW DOMAIN OracleGoldenGate","Map ODI_DEMO.TRG_COUNTRY,","Target ODI_DEMO.TRG_COUNTRY;"],
'source': {
'name': 'a1'
},
'credentials': {"alias":"ADW","domain":"OracleGoldenGate"},
'checkpoint':{
'table': 'ODI_DEMO.ADW_CHECKTABLE'
},
'mode': {
'type': 'nonintegrated',
'parallel': False
}
}
#Example for GoldenGate Non Integrated Parallel replicat.
bodyReplicatNonIntegratedParallel = {
'config': ["Replicat Rep7","USERIDALIAS ADW DOMAIN OracleGoldenGate","Map ODI_DEMO.TRG_COUNTRY,","Target ODI_DEMO.TRG_COUNTRY;"],
'source': {
'name': 'a1'
},
'credentials': {"alias":"ADW","domain":"OracleGoldenGate"},
'checkpoint':{
'table': 'ODI_DEMO.ADW_CHECKTABLE'
},
'mode': {
'type': 'nonintegrated',
'parallel': True
}
}
#Example for GoldenGate Coordinated replicat.
bodyReplicatCoordinated = {
'config': ["Replicat Rep8","USERIDALIAS ADW DOMAIN OracleGoldenGate","Map ODI_DEMO.TRG_COUNTRY,","Target ODI_DEMO.TRG_COUNTRY;"],
'source': {
'name': 'a1'
},
'credentials': {"alias":"ADW","domain":"OracleGoldenGate"},
'checkpoint':{
'table': 'ODI_DEMO.ADW_CHECKTABLE'
},
'mode': {
'type': 'coordinated',
'maxThreads': 10
}
}
def createExtract(inputExtract, inputHearders, inputBody,url):
responsePost = requests.post(url+extractAPI+'/'+inputExtract, headers=inputHearders, json=inputBody)
print (responsePost.json())
def createReplicat(inputReplicat, inputHearders, inputBody, url):
responsePost = requests.post(url+replicatAPI+'/'+inputReplicat, headers=inputHearders, json=inputBody)
print (responsePost.json())
def startExtract(inputExtract,inputHearders, url):
inputBody = {"status":"running"}
responsePost = requests.patch(url+extractAPI+'/'+inputExtract, headers=inputHearders, json=inputBody)
print (responsePost.json())
def stopExtract(inputExtract,url):
inputBody = {"status":"stopped"}
responsePost = requests.patch(url+extractAPI+'/'+inputExtract, headers=headers, json=inputBody)
print (responsePost.json())
def deleteExtract(inputExtract,url):
responsePost = requests.delete(url+extractAPI+'/'+inputExtract, headers=headers, json=payload)
print (responsePost.json())
def startReplicat(inputReplicat,inputHearders,url):
inputBody = {"status":"running"}
responsePost = requests.patch(url+replicatAPI+'/'+inputReplicat, headers=inputHearders, json=inputBody)
print (responsePost.json())
def stopReplicat(inputReplicat,inputHearders,url):
inputBody = {"status":"stopped"}
responsePost = requests.patch(url+replicatAPI+'/'+inputReplicat, headers=inputHearders, json=inputBody)
print (responsePost.json())
def deleteReplicat(inputReplicat,url):
responsePost = requests.patch(url+replicatAPI+'/'+inputReplicat, headers=headers, json=payload)
print (responsePost.json())
#createExtract('EXT4', headers,bodyExtract,sourceUrl)
#createReplicat('REP8',headers,bodyReplicatCoordinated,sourceUrl)
#for initial load
#createExtract('IL2', headers, bodyInitialLoad,sourceUrl)