Search in sources :

Example 31 with StorageClient

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

the class SyncGetIamPolicy method syncGetIamPolicy.

public static void syncGetIamPolicy() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setOptions(GetPolicyOptions.newBuilder().build()).build();
        Policy response = storageClient.getIamPolicy(request);
    }
}
Also used : Policy(com.google.iam.v1.Policy) StorageClient(com.google.storage.v2.StorageClient) GetIamPolicyRequest(com.google.iam.v1.GetIamPolicyRequest)

Example 32 with StorageClient

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

the class SyncGetIamPolicyString method syncGetIamPolicyString.

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

Example 33 with StorageClient

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

the class SyncDeleteObjectStringStringLong method syncDeleteObjectStringStringLong.

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

Example 34 with StorageClient

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

the class SyncGetBucketString method syncGetBucketString.

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

Example 35 with StorageClient

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

the class AsyncGetHmacKey method asyncGetHmacKey.

public static void asyncGetHmacKey() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetHmacKeyRequest request = GetHmacKeyRequest.newBuilder().setAccessId("accessId-2146437729").setProject(ProjectName.of("[PROJECT]").toString()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ApiFuture<HmacKeyMetadata> future = storageClient.getHmacKeyCallable().futureCall(request);
        // Do something.
        HmacKeyMetadata response = future.get();
    }
}
Also used : HmacKeyMetadata(com.google.storage.v2.HmacKeyMetadata) GetHmacKeyRequest(com.google.storage.v2.GetHmacKeyRequest) StorageClient(com.google.storage.v2.StorageClient)

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