Search in sources :

Example 16 with SchemaName

use of com.google.pubsub.v1.SchemaName in project gapic-generator-java by googleapis.

the class SchemaServiceClient method deleteSchema.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a schema.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * // This snippet has been automatically generated for illustrative purposes only.
 * // It may require modifications to work in your environment.
 * try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) {
 *   SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]");
 *   schemaServiceClient.deleteSchema(name);
 * }
 * }</pre>
 *
 * @param name Required. Name of the schema to delete. Format is
 *     `projects/{project}/schemas/{schema}`.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteSchema(SchemaName name) {
    DeleteSchemaRequest request = DeleteSchemaRequest.newBuilder().setName(name == null ? null : name.toString()).build();
    deleteSchema(request);
}
Also used : DeleteSchemaRequest(com.google.pubsub.v1.DeleteSchemaRequest)

Example 17 with SchemaName

use of com.google.pubsub.v1.SchemaName in project gapic-generator-java by googleapis.

the class SchemaServiceClientTest method deleteSchemaExceptionTest.

@Test
public void deleteSchemaExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockSchemaService.addException(exception);
    try {
        SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]");
        client.deleteSchema(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) SchemaName(com.google.pubsub.v1.SchemaName) Test(org.junit.Test)

Aggregations

SchemaName (com.google.pubsub.v1.SchemaName)15 Test (org.junit.Test)8 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)6 Schema (com.google.pubsub.v1.Schema)6 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 DeleteSchemaRequest (com.google.pubsub.v1.DeleteSchemaRequest)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 AlreadyExistsException (com.google.api.gax.rpc.AlreadyExistsException)3 NotFoundException (com.google.api.gax.rpc.NotFoundException)2 Empty (com.google.protobuf.Empty)2 GetSchemaRequest (com.google.pubsub.v1.GetSchemaRequest)2 ProjectName (com.google.pubsub.v1.ProjectName)2 TopicAdminClient (com.google.cloud.pubsub.v1.TopicAdminClient)1 SchemaSettings (com.google.pubsub.v1.SchemaSettings)1 Topic (com.google.pubsub.v1.Topic)1 TopicName (com.google.pubsub.v1.TopicName)1