use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ReportErrorsServiceClientTest method reportErrorEventExceptionTest.
@Test
@SuppressWarnings("all")
public void reportErrorEventExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockReportErrorsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
ReportedErrorEvent event = ReportedErrorEvent.newBuilder().build();
client.reportErrorEvent(projectName, event);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClient method createTimeSeries.
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Creates or adds data to one or more time series. The response is empty if all time series in
* the request were written. If any time series could not be written, a corresponding failure
* message is included in the error response.
*
* <p>Sample code:
*
* <pre><code>
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
* ProjectName name = ProjectName.create("[PROJECT]");
* List<TimeSeries> timeSeries = new ArrayList<>();
* metricServiceClient.createTimeSeries(name, timeSeries);
* }
* </code></pre>
*
* @param name The project on which to execute the request. The format is
* `"projects/{project_id_or_number}"`.
* @param timeSeries The new data to be added to a list of time series. Adds at most one data
* point to each of several time series. The new data point must be more recent than any other
* point in its time series. Each `TimeSeries` value must fully specify a unique time series
* by supplying all label values for the metric and the monitored resource.
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final void createTimeSeries(ProjectName name, List<TimeSeries> timeSeries) {
CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder().setNameWithProjectName(name).addAllTimeSeries(timeSeries).build();
createTimeSeries(request);
}
use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class GroupServiceClientTest method createGroupTest.
@Test
@SuppressWarnings("all")
public void createGroupTest() {
GroupName name2 = GroupName.create("[PROJECT]", "[GROUP]");
String displayName = "displayName1615086568";
GroupName parentName = GroupName.create("[PROJECT]", "[GROUP]");
String filter = "filter-1274492040";
boolean isCluster = false;
Group expectedResponse = Group.newBuilder().setNameWithGroupName(name2).setDisplayName(displayName).setParentNameWithGroupName(parentName).setFilter(filter).setIsCluster(isCluster).build();
mockGroupService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
Group group = Group.newBuilder().build();
Group actualResponse = client.createGroup(name, group);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateGroupRequest actualRequest = (CreateGroupRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
Assert.assertEquals(group, actualRequest.getGroup());
}
use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class GroupServiceClientTest method createGroupExceptionTest.
@Test
@SuppressWarnings("all")
public void createGroupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGroupService.addException(exception);
try {
ProjectName name = ProjectName.create("[PROJECT]");
Group group = Group.newBuilder().build();
client.createGroup(name, group);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method listSnapshotsExceptionTest.
@Test
@SuppressWarnings("all")
public void listSnapshotsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
ProjectName project = ProjectName.create("[PROJECT]");
client.listSnapshots(project);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations