Search in sources :

Example 76 with StorageClient

use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.

the class AsyncListObjectsPaged method asyncListObjectsPaged.

public static void asyncListObjectsPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ListObjectsRequest request = ListObjectsRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setDelimiter("delimiter-250518009").setIncludeTrailingDelimiter(true).setPrefix("prefix-980110702").setVersions(true).setReadMask(FieldMask.newBuilder().build()).setLexicographicStart("lexicographicStart-2093413008").setLexicographicEnd("lexicographicEnd1646968169").setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        while (true) {
            ListObjectsResponse response = storageClient.listObjectsCallable().call(request);
            for (Object element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : ListObjectsRequest(com.google.storage.v2.ListObjectsRequest) StorageClient(com.google.storage.v2.StorageClient) ListObjectsResponse(com.google.storage.v2.ListObjectsResponse) Object(com.google.storage.v2.Object)

Example 77 with StorageClient

use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.

the class SyncLockBucketRetentionPolicy method syncLockBucketRetentionPolicy.

public static void syncLockBucketRetentionPolicy() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        LockBucketRetentionPolicyRequest request = LockBucketRetentionPolicyRequest.newBuilder().setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString()).setIfMetagenerationMatch(1043427781).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        Bucket response = storageClient.lockBucketRetentionPolicy(request);
    }
}
Also used : LockBucketRetentionPolicyRequest(com.google.storage.v2.LockBucketRetentionPolicyRequest) Bucket(com.google.storage.v2.Bucket) StorageClient(com.google.storage.v2.StorageClient)

Example 78 with StorageClient

use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.

the class SyncGetIamPolicyResourcename method syncGetIamPolicyResourcename.

public static void syncGetIamPolicyResourcename() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ResourceName resource = CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
        Policy response = storageClient.getIamPolicy(resource);
    }
}
Also used : Policy(com.google.iam.v1.Policy) ResourceName(com.google.api.resourcenames.ResourceName) StorageClient(com.google.storage.v2.StorageClient)

Example 79 with StorageClient

use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.

the class AsyncGetNotification method asyncGetNotification.

public static void asyncGetNotification() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetNotificationRequest request = GetNotificationRequest.newBuilder().setName(BucketName.of("[PROJECT]", "[BUCKET]").toString()).build();
        ApiFuture<Notification> future = storageClient.getNotificationCallable().futureCall(request);
        // Do something.
        Notification response = future.get();
    }
}
Also used : StorageClient(com.google.storage.v2.StorageClient) GetNotificationRequest(com.google.storage.v2.GetNotificationRequest) Notification(com.google.storage.v2.Notification)

Example 80 with StorageClient

use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.

the class SyncGetNotification method syncGetNotification.

public static void syncGetNotification() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetNotificationRequest request = GetNotificationRequest.newBuilder().setName(BucketName.of("[PROJECT]", "[BUCKET]").toString()).build();
        Notification response = storageClient.getNotification(request);
    }
}
Also used : StorageClient(com.google.storage.v2.StorageClient) GetNotificationRequest(com.google.storage.v2.GetNotificationRequest) Notification(com.google.storage.v2.Notification)

Aggregations

StorageClient (com.google.storage.v2.StorageClient)93 Bucket (com.google.storage.v2.Bucket)17 Object (com.google.storage.v2.Object)11 Notification (com.google.storage.v2.Notification)10 HmacKeyMetadata (com.google.storage.v2.HmacKeyMetadata)9 Policy (com.google.iam.v1.Policy)8 ProjectName (com.google.storage.v2.ProjectName)6 ArrayList (java.util.ArrayList)6 TestIamPermissionsResponse (com.google.iam.v1.TestIamPermissionsResponse)4 Empty (com.google.protobuf.Empty)4 BucketName (com.google.storage.v2.BucketName)4 CreateHmacKeyResponse (com.google.storage.v2.CreateHmacKeyResponse)4 ServiceAccount (com.google.storage.v2.ServiceAccount)4 ResourceName (com.google.api.resourcenames.ResourceName)3 FieldMask (com.google.protobuf.FieldMask)3 QueryWriteStatusResponse (com.google.storage.v2.QueryWriteStatusResponse)3 GetIamPolicyRequest (com.google.iam.v1.GetIamPolicyRequest)2 SetIamPolicyRequest (com.google.iam.v1.SetIamPolicyRequest)2 TestIamPermissionsRequest (com.google.iam.v1.TestIamPermissionsRequest)2 ComposeObjectRequest (com.google.storage.v2.ComposeObjectRequest)2