-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add storage insights samples #8460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
storageinsights/pom.xml
Outdated
| @@ -0,0 +1,78 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!-- | |||
| ~ Copyright (c) 2015 Google Inc. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2023
| String sourceBucket = "your-source-bucket"; | ||
|
|
||
| // The name of your Google Cloud Storage destination bucket | ||
| String destinationBucket = "your-destination=bucket"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your-destination-bucket
| String bucketLocation = "us-west-1"; | ||
|
|
||
| listInventoryReportConfigs(projectId, bucketLocation); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
storageinsights/pom.xml
Outdated
|
|
||
| </dependencies> | ||
|
|
||
| </project> No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
|
|
||
| // [START storageinsights_create_inventory_report_config] | ||
|
|
||
| import com.google.cloud.storageinsights.v1.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll want to be explicit about which imports you're using?
| public static void getInventoryReportNames(String projectID, String location, String reportConfigUUID) throws IOException { | ||
| try (StorageInsightsClient storageInsightsClient = StorageInsightsClient.create()) { | ||
| ReportConfig config = storageInsightsClient.getReportConfig(ReportConfigName.of(projectID, location, reportConfigUUID)); | ||
| String extension = config.hasCsvOptions() ? "csv" : "parquet"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible have both csv and parquet options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope!
| String extension = config.hasCsvOptions() ? "csv" : "parquet"; | ||
| System.out.println("You can use the Google Cloud Storage Client to download the following objects from Google Cloud Storage:"); | ||
| for (ReportDetail reportDetail : storageInsightsClient.listReportDetails(config.getName()).iterateAll()) { | ||
| for(long index = reportDetail.getShardsCount() - 1; index >= 0; index--) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the report spread across shards and not known by the API? I'm wondering if it's necessary to create the report location or if the API itself has this value already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as i can tell it's necessary to construct it like this
| .setStartDate(Date.newBuilder().setDay(15).setMonth(8).setYear(3022).build()) | ||
| .setEndDate(Date.newBuilder().setDay(15).setMonth(9).setYear(3022).build()) | ||
| .build()) | ||
| .setCsvOptions(CSVOptions.newBuilder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a parquet option as well and you're only using Csv for this sample?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
.../main/java/com/google/cloud/storage/storageinsights/samples/DeleteInventoryReportConfig.java
Show resolved
Hide resolved
minherz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, follow up on means to elminiate 10 second sleep for each test run.
|
|
||
| grantBucketsInsightsPermissions(insightsServiceAccount, SOURCE_BUCKET); | ||
| grantBucketsInsightsPermissions(insightsServiceAccount, SINK_BUCKET); | ||
| Thread.sleep(10000); //gives time for service account permissions to propagate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i recommend to follow up on this. adding 10 seconds for each check "just in case" is not a good solution. did you consider using externally provisioned SA?
Adds samples for storage insights, intended for this page: https://cloud.google.com/storage/docs/insights/using-inventory-reports