private GetMetricStatisticsRequest buildRequest ( String bucketName , String metricName , String storageType ) { GetMetricStatisticsRequest request = new GetMetricStatisticsRequest ( ) ; request . setMetricName ( metricName ) ; request . setNamespace ( "AWS/S3" ) ; request . setPeriod ( 360 ) ; request . setStatistics ( Collections . singletonList ( "Maximum" ) ) ; Calendar cal = Calendar . getInstance ( TimeZone . getTimeZone ( "UTC" ) ) ; Date currentTime = cal . getTime ( ) ; cal . add ( Calendar . DATE , - 1 ) ; request . setStartTime ( cal . getTime ( ) ) ; request . setEndTime ( currentTime ) ; List < Dimension > dimensions = new ArrayList <> ( ) ; dimensions . add ( new Dimension ( ) . withName ( "BucketName" ) . withValue ( bucketName ) ) ; dimensions . add ( new Dimension ( ) . withName ( "StorageType" ) . withValue ( storageType ) ) ; request . setDimensions ( dimensions ) ; return request ; }
Create the request to ask for bucket metrics