use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClient method deleteService.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Soft delete this `Service`.
*
* <p>Sample code:
*
* <pre>{@code
* try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
* ServiceMonitoringServiceClient.create()) {
* ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
* serviceMonitoringServiceClient.deleteService(name);
* }
* }</pre>
*
* @param name Required. Resource name of the `Service` to delete. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteService(ServiceName name) {
DeleteServiceRequest request = DeleteServiceRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteService(request);
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClient method deleteService.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Soft delete this `Service`.
*
* <p>Sample code:
*
* <pre>{@code
* try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
* ServiceMonitoringServiceClient.create()) {
* String name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString();
* serviceMonitoringServiceClient.deleteService(name);
* }
* }</pre>
*
* @param name Required. Resource name of the `Service` to delete. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteService(String name) {
DeleteServiceRequest request = DeleteServiceRequest.newBuilder().setName(name).build();
deleteService(request);
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class MetricServiceClient method createServiceTimeSeries.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates or adds data to one or more service time series. A service time series is a time series
* for a metric from a Google Cloud service. 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. This endpoint rejects writes to user-defined metrics. This
* method is only for use by Google Cloud services. Use
* [projects.timeSeries.create][google.monitoring.v3.MetricService.CreateTimeSeries] instead.
*
* <p>Sample code:
*
* <pre>{@code
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
* ProjectName name = ProjectName.of("[PROJECT]");
* List<TimeSeries> timeSeries = new ArrayList<>();
* metricServiceClient.createServiceTimeSeries(name, timeSeries);
* }
* }</pre>
*
* @param name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on
* which to execute the request. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]
* @param timeSeries Required. 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.
* <p>The maximum number of `TimeSeries` objects per `Create` request is 200.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void createServiceTimeSeries(ProjectName name, List<TimeSeries> timeSeries) {
CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder().setName(name == null ? null : name.toString()).addAllTimeSeries(timeSeries).build();
createServiceTimeSeries(request);
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method updateServiceExceptionTest.
@Test
public void updateServiceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
Service service = Service.newBuilder().build();
client.updateService(service);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method createServiceTest4.
@Test
public void createServiceTest4() throws Exception {
Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
mockServiceMonitoringService.addResponse(expectedResponse);
String parent = "parent-995424086";
Service service = Service.newBuilder().build();
Service actualResponse = client.createService(parent, service);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertEquals(service, actualRequest.getService());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations