0

We are trying to download the wallet credentials.zip file for Autonomous Datawarehouse via Python SDK.

We have an option called --file when we do the same operation using oci cli.

oci db autonomous-data-warehouse generate-wallet --autonomous-data-warehouse-id <ocid> --password <my_admin_password> --file <filename.zip>

We are trying the same thing using the python sdk, but we do not get an option to download the zip file. We are executing the below code: wallet=database_client.generate_autonomous_data_warehouse_wallet("oicd",Password).

We get a response of 200. But how do we download the zip file? We tried wallet.data and wallet.headers. Not sure which sub-options to use.

Would be great if someone could help us on this!

char
  • 2,063
  • 3
  • 15
  • 26

2 Answers2

0

According to the Python SDK API reference for this operation, this operation returns a "Response object with data of type stream."

So all you need to do is save the response body (wallet.data in your example) to a file with the proper file extension.

Joe
  • 2,500
  • 1
  • 14
  • 12
0

Try something like this:

wallet = database_client.generate_autonomous_data_warehouse_wallet(<OCID>, <password>)
with open('<wallet_file>.zip', 'wb') as f:
    for chunk in wallet.data.raw.stream(1024 * 1024, decode_content=False):
        f.write(chunk)

The response object (your wallet) has a data field that needs to be streamed into a zip-file.

char
  • 2,063
  • 3
  • 15
  • 26