本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
列出所有 Storage Lens 群組
下列範例示範如何列出 AWS 帳戶 和主要區域中的所有 Amazon S3 Storage Lens 群組。這些範例示範如何使用 Amazon S3 主控台 AWS Command Line Interface (AWS CLI) 和 列出所有 Storage Lens 群組 AWS SDK for Java。
列出帳戶和主要區域中的所有 Storage Lens 群組
登入 AWS Management Console ,並在 https://console.aws.amazon.com/s3/
:// 開啟 Amazon S3 主控台。 -
在左側導覽窗格中,選擇 Storage Lens 群組。
-
在 Storage Lens 群組底下,會顯示您的帳戶中的 Storage Lens 群組清單。
下列 AWS CLI 範例列出您帳戶的所有 Storage Lens 群組。若要使用此範例命令,請以您自己的資訊取代
。user input
placeholders
aws s3control list-storage-lens-groups --account-id
111122223333
\ --regionus-east-1
下列 AWS 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(); } } }