use of com.google.logging.v2.LogExclusionName in project java-logging by googleapis.
the class ConfigClientTest method deleteExclusionTest.
@Test
public void deleteExclusionTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockConfigServiceV2.addResponse(expectedResponse);
LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
client.deleteExclusion(name);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteExclusionRequest actualRequest = ((DeleteExclusionRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.LogExclusionName in project java-logging by googleapis.
the class ConfigClientTest method updateExclusionTest.
@Test
public void updateExclusionTest() throws Exception {
LogExclusion expectedResponse = LogExclusion.newBuilder().setName(LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]").toString()).setDescription("description-1724546052").setFilter("filter-1274492040").setDisabled(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
mockConfigServiceV2.addResponse(expectedResponse);
LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
LogExclusion exclusion = LogExclusion.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
LogExclusion actualResponse = client.updateExclusion(name, exclusion, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateExclusionRequest actualRequest = ((UpdateExclusionRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(exclusion, actualRequest.getExclusion());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.logging.v2.LogExclusionName in project java-logging by googleapis.
the class ConfigClientTest method getExclusionExceptionTest.
@Test
public void getExclusionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
client.getExclusion(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.LogExclusionName in project java-logging by googleapis.
the class ConfigClient method deleteExclusion.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes an exclusion in the _Default sink.
*
* <p>Sample code:
*
* <pre>{@code
* try (ConfigClient configClient = ConfigClient.create()) {
* LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
* configClient.deleteExclusion(name);
* }
* }</pre>
*
* @param name Required. The resource name of an existing exclusion to delete:
* <p>"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]"
* "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]"
* "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]"
* "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]"
* <p>For example:
* <p>`"projects/my-project/exclusions/my-exclusion"`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteExclusion(LogExclusionName name) {
DeleteExclusionRequest request = DeleteExclusionRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteExclusion(request);
}
use of com.google.logging.v2.LogExclusionName in project java-logging by googleapis.
the class ConfigClientTest method updateExclusionExceptionTest.
@Test
public void updateExclusionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
LogExclusion exclusion = LogExclusion.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateExclusion(name, exclusion, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations