Search in sources :

Example 41 with StorageClient

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

the class AsyncCreateHmacKey method asyncCreateHmacKey.

public static void asyncCreateHmacKey() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        CreateHmacKeyRequest request = CreateHmacKeyRequest.newBuilder().setProject(ProjectName.of("[PROJECT]").toString()).setServiceAccountEmail("serviceAccountEmail1825953988").setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ApiFuture<CreateHmacKeyResponse> future = storageClient.createHmacKeyCallable().futureCall(request);
        // Do something.
        CreateHmacKeyResponse response = future.get();
    }
}
Also used : CreateHmacKeyResponse(com.google.storage.v2.CreateHmacKeyResponse) CreateHmacKeyRequest(com.google.storage.v2.CreateHmacKeyRequest) StorageClient(com.google.storage.v2.StorageClient)

Example 42 with StorageClient

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

the class AsyncLockBucketRetentionPolicy method asyncLockBucketRetentionPolicy.

public static void asyncLockBucketRetentionPolicy() 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();
        ApiFuture<Bucket> future = storageClient.lockBucketRetentionPolicyCallable().futureCall(request);
        // Do something.
        Bucket response = future.get();
    }
}
Also used : LockBucketRetentionPolicyRequest(com.google.storage.v2.LockBucketRetentionPolicyRequest) Bucket(com.google.storage.v2.Bucket) StorageClient(com.google.storage.v2.StorageClient)

Example 43 with StorageClient

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

the class AsyncListHmacKeysPaged method asyncListHmacKeysPaged.

public static void asyncListHmacKeysPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ListHmacKeysRequest request = ListHmacKeysRequest.newBuilder().setProject(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setServiceAccountEmail("serviceAccountEmail1825953988").setShowDeletedKeys(true).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        while (true) {
            ListHmacKeysResponse response = storageClient.listHmacKeysCallable().call(request);
            for (HmacKeyMetadata element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : HmacKeyMetadata(com.google.storage.v2.HmacKeyMetadata) ListHmacKeysRequest(com.google.storage.v2.ListHmacKeysRequest) ListHmacKeysResponse(com.google.storage.v2.ListHmacKeysResponse) StorageClient(com.google.storage.v2.StorageClient)

Example 44 with StorageClient

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

the class AsyncComposeObject method asyncComposeObject.

public static void asyncComposeObject() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ComposeObjectRequest request = ComposeObjectRequest.newBuilder().setDestination(Object.newBuilder().build()).addAllSourceObjects(new ArrayList<ComposeObjectRequest.SourceObject>()).setDestinationPredefinedAcl(PredefinedObjectAcl.forNumber(0)).setIfGenerationMatch(-1086241088).setIfMetagenerationMatch(1043427781).setKmsKey(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ApiFuture<Object> future = storageClient.composeObjectCallable().futureCall(request);
        // Do something.
        Object response = future.get();
    }
}
Also used : ComposeObjectRequest(com.google.storage.v2.ComposeObjectRequest) ArrayList(java.util.ArrayList) StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object)

Example 45 with StorageClient

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

the class SyncCreateSetCredentialsProvider method syncCreateSetCredentialsProvider.

public static void syncCreateSetCredentialsProvider() throws Exception {
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    StorageSettings storageSettings = StorageSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)).build();
    StorageClient storageClient = StorageClient.create(storageSettings);
}
Also used : StorageSettings(com.google.storage.v2.StorageSettings) 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