oracle/oci-python-sdk

Focus report how we can get it.

Closed this issue · 1 comments

I am using the code to download the CSV file in Python below code also I am getting the focus report CSV file.

import oci
import os
reporting_namespace = 'bling'
                               
# Download all usage and cost files. You can comment out based on the specific need:
prefix_file_focus = "FOCUS Reports"  #  For FOCUS reports
                               
# Update these values
destintation_path = '/home/ubuntu/Desktop/downloaded_reports'
                               
# Make a directory to receive reports
if not os.path.exists(destintation_path):
    os.mkdir(destintation_path)
                               
# Get the list of reports
config = oci.config.from_file(oci.config.DEFAULT_LOCATION, oci.config.DEFAULT_PROFILE)
reporting_bucket = config['tenancy']
object_storage = oci.object_storage.ObjectStorageClient(config)
report_bucket_objects = oci.pagination.list_call_get_all_results(object_storage.list_objects, reporting_namespace, reporting_bucket, prefix=prefix_file_focus)                          
for o in report_bucket_objects.data.objects:
    print('Found file ' + o.name)
    object_details = object_storage.get_object(reporting_namespace, reporting_bucket, o.name)
    filename = o.name.rsplit('/', 1)[-1]
                               
    with open(destintation_path + '/' + filename, 'wb') as f:
        for chunk in object_details.data.raw.stream(1024 * 1024, decode_content=False):
            f.write(chunk)
                               
    print('----> File ' + o.name + ' Downloaded')

Is there any other way to get the focus report data with the help of the SDK API calls?
@adizohar can suggest any other way to get it.

Details reports only available using the CSVs, if you want summaries reports, you can use the usage-api APIs
Please check one of my tools - https://github.com/oracle/oci-python-sdk/tree/master/examples/showusage
If this answer your question, please close this ticket.
Thank you