use of com.google.logging.v2.LogSinkName in project java-logging by googleapis.
the class ConfigClientTest method deleteSinkTest.
@Test
public void deleteSinkTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockConfigServiceV2.addResponse(expectedResponse);
LogSinkName sinkName = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
client.deleteSink(sinkName);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteSinkRequest actualRequest = ((DeleteSinkRequest) actualRequests.get(0));
Assert.assertEquals(sinkName.toString(), actualRequest.getSinkName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.LogSinkName in project java-logging by googleapis.
the class ConfigClientTest method getSinkExceptionTest.
@Test
public void getSinkExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
LogSinkName sinkName = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
client.getSink(sinkName);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.LogSinkName in project java-logging by googleapis.
the class ConfigClientTest method updateSinkExceptionTest3.
@Test
public void updateSinkExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
LogSinkName sinkName = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
LogSink sink = LogSink.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateSink(sinkName, sink, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.LogSinkName in project java-logging by googleapis.
the class ConfigClientTest method deleteSinkExceptionTest.
@Test
public void deleteSinkExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
LogSinkName sinkName = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
client.deleteSink(sinkName);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.LogSinkName in project java-logging by googleapis.
the class ConfigClient method deleteSink.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a sink. If the sink has a unique `writer_identity`, then that service account is also
* deleted.
*
* <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 (ConfigClient configClient = ConfigClient.create()) {
* LogSinkName sinkName = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
* configClient.deleteSink(sinkName);
* }
* }</pre>
*
* @param sinkName Required. The full resource name of the sink to delete, including the parent
* resource and the sink identifier:
* <p>"projects/[PROJECT_ID]/sinks/[SINK_ID]"
* "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
* "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
* "folders/[FOLDER_ID]/sinks/[SINK_ID]"
* <p>For example:
* <p>`"projects/my-project/sinks/my-sink"`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteSink(LogSinkName sinkName) {
DeleteSinkRequest request = DeleteSinkRequest.newBuilder().setSinkName(sinkName == null ? null : sinkName.toString()).build();
deleteSink(request);
}
Aggregations