Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import requests
- import mariadb
- from requests.auth import HTTPBasicAuth
- # Connect to database
- connection = mariadb.connect(
- user= "", #use your username
- password="", # user your password
- host="dr-mr-kaardb-r01.mykaarma.com",
- port=3306,
- database="KaarDBProd"
- )
- # Create a cursor object
- mycursor = connection.cursor()
- # Define the SQL query to fetch the UUIDs
- uuid_list = [
- 'c01970c3e2d71b286448b5ff903aab59ae6f9a912747b03c7efb4218993573f2',
- '30f192e0d6fd87094762648d4b0862295daf5bf461f2ecbed9ff63fbbf44238d',
- 'b7491719a270d02dcc3307f0dbc4cf64dd6d6d1db491cde2feee1d1ac7409f32',
- 'eef22d545592fe6bf922ace06573dc1946e10b24db922e2241cbecdc586637ac',
- 'acaf6b97884abc93ac8781243aa709b135706d6ecd1f2c1edf68d29fa55cae82',
- '998ae04405dc39a8e441b33e3eb534d121abf17786224fe6a2c9909856f99a8c',
- 'accbd110aa8f9f3d97df3e8b4b70024774bfeb49b9ce0cd9b4ef3cc087de9c7c',
- '0494af3a4a9093579ae6d154e004effd4c66215eb60ae2d9ead25b44576f52b2',
- '667264d47cf5dadeba1496d7ed6f984e331ef2236795419c6065e187675d14ee',
- '40903dd4265fad5b29b1c413cadd77d1dbf5a0386e1aed9ad815b0f271cbf7d6',
- 'c507514438e83bb6055a8c5dd80b0182090e3bdb6924d08f5039c9dac0d20d8b',
- 'ce8c9b6417dfce9336ef242bd875b8388566ca0512aa10794d5daaa564f3f6e2',
- '43f0b6645d2dfba8af832610716f456d46f90d588791e0c603ccc7325b66be6c',
- '83522999954d3b6f591417d6a3bbdb8cfd9ca9934c2dee58e97267cd9d8a719c',
- '88472afa879d8163964ecbb68a10fc365e7f1dc547c46b681c910ea60e37e8c8',
- '63264da32049447bab38a02b31e7ac81af2ed83762d526144590a5bee63dd5ef',
- 'd88d2b8b28c73a8bb27b585aff8df3ea6bea07a46fe60abedb8b8b524fc827f1',
- '4c680b06c6e9ececbe6c66a21b40268f61d1bb7bce6ac114d540c4f5ddf9f6a1',
- '10ecfd71b3b5d32d4b91e1294145634cb5af6c683d7f4cbdf4fdb6a33043c581',
- '298a42a0ab1be41870af02a6813586c371ddacb987668ebf459112c35c291b8d',
- '457cbcbb55f129a5253a5ead8049b3cb26b6bde0794044f785bd8d02d93861f1',
- '2a2d6bbf177831a1811951a5a83197a5fa483a4514358bf5889e36ee29a5a214',
- '68742b4c90ccdd5859eda29b9b84f2568f5d6e310a643eaba5590bafb62852a0',
- '1ab062b650b0972b0878be7d4a3910d7eeb2317857a12cdd987c7aa3ec4c8905',
- '51da5b55ea4cce0c44d6e0b940323b99dacca0f1f73b1f51f12306c66935ade9',
- 'e080def589e6514a92b24c2cc33064cac0615ad3d2352695f3df6f6c02ade1f3',
- 'b526567241f4d785044b8dc47472f0e63bd78ae13bd496263fc23b3a90e53f56',
- 'a3a6e2029e5b50484e40e4b6d0d8624f53b815aa2405b261981336b5fea70c28',
- 'd732ae3dd8da2f1164ac37788a01021e722773135d04eff3c16f611fae4c833c',
- '9e866ef11910897abafd6e62b519221626237db1d5fe7832a1e5c1d269ca4d0a'
- ]
- sql = """select Dealer.UUID from Dealer where UUID in ({})""".format(
- ",".join(['"' + uuid + '"' for uuid in uuid_list])
- )
- # Execute the query
- mycursor.execute(sql)
- # Fetch all the results
- results = mycursor.fetchall()
- print(results)
- # Close the cursor and the connection
- mycursor.close()
- connection.close()
- # Create an empty dictionary to store the JSON data
- data = {}
- print("Dealers selected:")
- # Loop through the results and add them to the dictionary
- for i, result in enumerate(results):
- # Get the UUID from the result tuple
- uuid = result[0]
- print(uuid)
- # Create a sub-dictionary for each UUID
- data[uuid] = {
- "updateDSORequestDTOList": [
- {
- "optionKey": "appointments.populate.appointmentview.mongo.rollout",
- "optionValue": "true",
- "validate": True
- },
- # {
- # "optionKey": "rollout.stage",
- # "optionValue": "canary",
- # "validate": True
- # }
- # {
- # "optionKey": "appointments.ledger.view.backend.redesigned.rollout",
- # "optionValue": "false",
- # "validate": True
- # },
- # {
- # "optionKey": "mci.generic.eventbus.publish.rollout",
- # "optionValue": "false",
- # "validate": True
- # }
- ]
- }
- data = {"dealerUuidAndUpdateDealerSetupOptionCollectionMap": data}
- # Add the validate key to the main dictionary
- data["validate"] = True
- # Convert the dictionary to a JSON string
- json_data = json.dumps(data, indent=4)
- print("Request Body: ")
- # Print the JSON string
- print(json_data)
- url = 'https://api.mykaarma.com/manage/v2/dealers/dsos/bulk'
- auth = HTTPBasicAuth('mk-admin-tool','W4vqUxuzYSg_clNvEt_nn0oHZFTJGjGRxwQ8CxV7y7c')
- response = requests.put(url, auth = auth, json = data)
- print('Response Status Code:', response.status_code)
- print('Response Content:', response.text)
Advertisement
Add Comment
Please, Sign In to add comment