Search in sources :

Example 71 with StorageClient

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

the class SyncDeleteObjectStringString method syncDeleteObjectStringString.

public static void syncDeleteObjectStringString() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        String bucket = "bucket-1378203158";
        String object = "object-1023368385";
        storageClient.deleteObject(bucket, object);
    }
}
Also used : StorageClient(com.google.storage.v2.StorageClient)

Example 72 with StorageClient

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

the class AsyncGetBucket method asyncGetBucket.

public static void asyncGetBucket() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetBucketRequest request = GetBucketRequest.newBuilder().setName(BucketName.of("[PROJECT]", "[BUCKET]").toString()).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonRequestParams(CommonRequestParams.newBuilder().build()).setReadMask(FieldMask.newBuilder().build()).build();
        ApiFuture<Bucket> future = storageClient.getBucketCallable().futureCall(request);
        // Do something.
        Bucket response = future.get();
    }
}
Also used : Bucket(com.google.storage.v2.Bucket) StorageClient(com.google.storage.v2.StorageClient) GetBucketRequest(com.google.storage.v2.GetBucketRequest)

Example 73 with StorageClient

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

the class SyncGetBucket method syncGetBucket.

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

Example 74 with StorageClient

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

the class SyncGetBucketBucketname method syncGetBucketBucketname.

public static void syncGetBucketBucketname() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        BucketName name = BucketName.of("[PROJECT]", "[BUCKET]");
        Bucket response = storageClient.getBucket(name);
    }
}
Also used : BucketName(com.google.storage.v2.BucketName) Bucket(com.google.storage.v2.Bucket) StorageClient(com.google.storage.v2.StorageClient)

Example 75 with StorageClient

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

the class AsyncListObjects method asyncListObjects.

public static void asyncListObjects() 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();
        ApiFuture<Object> future = storageClient.listObjectsPagedCallable().futureCall(request);
        // Do something.
        for (Object element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : ListObjectsRequest(com.google.storage.v2.ListObjectsRequest) StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object)

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