Search in sources :

Example 1 with GetAppProfileRequest

use of com.google.bigtable.admin.v2.GetAppProfileRequest in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method getAppProfileTest.

@Test
public void getAppProfileTest() throws Exception {
    AppProfile expectedResponse = AppProfile.newBuilder().setName(AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]").toString()).setEtag("etag3123477").setDescription("description-1724546052").build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
    AppProfile actualResponse = client.getAppProfile(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetAppProfileRequest actualRequest = ((GetAppProfileRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : GetAppProfileRequest(com.google.bigtable.admin.v2.GetAppProfileRequest) AbstractMessage(com.google.protobuf.AbstractMessage) AppProfile(com.google.bigtable.admin.v2.AppProfile) AppProfileName(com.google.bigtable.admin.v2.AppProfileName) Test(org.junit.Test)

Example 2 with GetAppProfileRequest

use of com.google.bigtable.admin.v2.GetAppProfileRequest in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method getAppProfileTest2.

@Test
public void getAppProfileTest2() throws Exception {
    AppProfile expectedResponse = AppProfile.newBuilder().setName(AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]").toString()).setEtag("etag3123477").setDescription("description-1724546052").build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    AppProfile actualResponse = client.getAppProfile(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetAppProfileRequest actualRequest = ((GetAppProfileRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : GetAppProfileRequest(com.google.bigtable.admin.v2.GetAppProfileRequest) AbstractMessage(com.google.protobuf.AbstractMessage) AppProfile(com.google.bigtable.admin.v2.AppProfile) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with GetAppProfileRequest

use of com.google.bigtable.admin.v2.GetAppProfileRequest in project java-bigtable by googleapis.

the class BigtableInstanceAdminClient method getAppProfileAsync.

/**
 * Asynchronously gets the app profile by ID.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * ApiFuture<AppProfile> appProfileFuture = client.getAppProfileAsync("my-instance", "my-app-profile");
 *
 * AppProfile appProfile = appProfileFuture.get();
 * }</pre>
 *
 * @see AppProfile
 */
@SuppressWarnings("WeakerAccess")
public ApiFuture<AppProfile> getAppProfileAsync(String instanceId, String appProfileId) {
    String name = NameUtil.formatAppProfileName(projectId, instanceId, appProfileId);
    GetAppProfileRequest request = GetAppProfileRequest.newBuilder().setName(name).build();
    return ApiFutures.transform(stub.getAppProfileCallable().futureCall(request), new ApiFunction<com.google.bigtable.admin.v2.AppProfile, AppProfile>() {

        @Override
        public AppProfile apply(com.google.bigtable.admin.v2.AppProfile proto) {
            return AppProfile.fromProto(proto);
        }
    }, MoreExecutors.directExecutor());
}
Also used : GetAppProfileRequest(com.google.bigtable.admin.v2.GetAppProfileRequest) AppProfile(com.google.cloud.bigtable.admin.v2.models.AppProfile)

Aggregations

GetAppProfileRequest (com.google.bigtable.admin.v2.GetAppProfileRequest)3 AppProfile (com.google.bigtable.admin.v2.AppProfile)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 AppProfileName (com.google.bigtable.admin.v2.AppProfileName)1 AppProfile (com.google.cloud.bigtable.admin.v2.models.AppProfile)1 ByteString (com.google.protobuf.ByteString)1