列出所有 Storage Lens 组
以下示例演示如何列出 Amazon Web Services 账户和主区域中的所有 Amazon S3 Storage Lens 存储统计管理工具组。这些示例显示了如何使用 Amazon S3 控制台、Amazon Command Line Interface (Amazon CLI) 和 Amazon SDK for Java 列出所有 Storage Lens 组。
列出账户和主区域中的所有 Storage Lens 组
登录到Amazon Web Services Management Console,然后通过以下网址打开 Amazon S3 控制台:https://console.aws.amazon.com/s3/
。 -
在左侧导航窗格中,选择 Storage Lens 组。
-
在 Storage Lens 组下,将显示您账户中的 Storage Lens 组列表。
以下 Amazon CLI 示例将列出您账户的所有 Storage Lens 组。要使用此示例命令,请将
替换为您自己的信息。user input
placeholders
aws s3control list-storage-lens-groups --account-id
111122223333
\ --regionus-east-1
以下 Amazon SDK for Java 示例将列出账户
的 Storage Lens 组。要使用此示例,请将 111122223333
替换为您自己的信息。user input placeholders
package aws.example.s3control; import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3control.S3ControlClient; import software.amazon.awssdk.services.s3control.model.ListStorageLensGroupsRequest; import software.amazon.awssdk.services.s3control.model.ListStorageLensGroupsResponse; public class ListStorageLensGroups { public static void main(String[] args) { String accountId = "
111122223333
"; try { ListStorageLensGroupsRequest listStorageLensGroupsRequest = ListStorageLensGroupsRequest.builder() .accountId(accountId
) .build(); S3ControlClient s3ControlClient = S3ControlClient.builder() .region(Region.US_WEST_2
) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); ListStorageLensGroupsResponse response = s3ControlClient.listStorageLensGroups(listStorageLensGroupsRequest); System.out.println(response); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 couldn't process // it and returned an error response. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3. e.printStackTrace(); } } }