Search in sources :

Example 1 with AppProfileName

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

the class BaseBigtableInstanceAdminClientTest method deleteAppProfileExceptionTest.

@Test
public void deleteAppProfileExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
        client.deleteAppProfile(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) AppProfileName(com.google.bigtable.admin.v2.AppProfileName) Test(org.junit.Test)

Example 2 with AppProfileName

use of com.google.bigtable.admin.v2.AppProfileName 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 3 with AppProfileName

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

the class BaseBigtableInstanceAdminClientTest method getAppProfileExceptionTest.

@Test
public void getAppProfileExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
        client.getAppProfile(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) AppProfileName(com.google.bigtable.admin.v2.AppProfileName) Test(org.junit.Test)

Example 4 with AppProfileName

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

the class BaseBigtableInstanceAdminClientTest method deleteAppProfileTest.

@Test
public void deleteAppProfileTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
    client.deleteAppProfile(name);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteAppProfileRequest actualRequest = ((DeleteAppProfileRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) DeleteAppProfileRequest(com.google.bigtable.admin.v2.DeleteAppProfileRequest) AbstractMessage(com.google.protobuf.AbstractMessage) AppProfileName(com.google.bigtable.admin.v2.AppProfileName) Test(org.junit.Test)

Example 5 with AppProfileName

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

the class BaseBigtableInstanceAdminClient method deleteAppProfile.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes an app profile from an instance.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient =
 *     BaseBigtableInstanceAdminClient.create()) {
 *   AppProfileName name = AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]");
 *   baseBigtableInstanceAdminClient.deleteAppProfile(name);
 * }
 * }</pre>
 *
 * @param name Required. The unique name of the app profile to be deleted. Values are of the form
 *     `projects/{project}/instances/{instance}/appProfiles/{app_profile}`.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteAppProfile(AppProfileName name) {
    DeleteAppProfileRequest request = DeleteAppProfileRequest.newBuilder().setName(name == null ? null : name.toString()).build();
    deleteAppProfile(request);
}
Also used : DeleteAppProfileRequest(com.google.bigtable.admin.v2.DeleteAppProfileRequest)

Aggregations

AppProfileName (com.google.bigtable.admin.v2.AppProfileName)4 Test (org.junit.Test)4 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)2 DeleteAppProfileRequest (com.google.bigtable.admin.v2.DeleteAppProfileRequest)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 AppProfile (com.google.bigtable.admin.v2.AppProfile)1 GetAppProfileRequest (com.google.bigtable.admin.v2.GetAppProfileRequest)1 Empty (com.google.protobuf.Empty)1