use of com.google.monitoring.v3.Service in project kubernetes-client by fabric8io.
the class ServiceCrudTest method shouldIncludeServiceStatus.
@Test
void shouldIncludeServiceStatus() {
Service service = new ServiceBuilder().withNewMetadata().withName("service").endMetadata().build();
Service created = client.services().inNamespace("ns2").create(service);
ServiceList serviceList = client.services().inNamespace("ns2").list();
assertNotNull(serviceList);
assertEquals(1, serviceList.getItems().size());
created.setStatus(new ServiceStatusBuilder().withNewAddress("http://my-service").build());
assertNotNull(client.services().inNamespace("ns2").withName("service").updateStatus(created).getStatus());
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClient method deleteServiceLevelObjective.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Delete the given `ServiceLevelObjective`.
*
* <p>Sample code:
*
* <pre>{@code
* try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
* ServiceMonitoringServiceClient.create()) {
* ServiceLevelObjectiveName name =
* ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
* "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
* serviceMonitoringServiceClient.deleteServiceLevelObjective(name);
* }
* }</pre>
*
* @param name Required. Resource name of the `ServiceLevelObjective` to delete. The format is:
* <p>projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteServiceLevelObjective(ServiceLevelObjectiveName name) {
DeleteServiceLevelObjectiveRequest request = DeleteServiceLevelObjectiveRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteServiceLevelObjective(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()) {
* String name = ProjectName.of("[PROJECT]").toString();
* 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(String name, List<TimeSeries> timeSeries) {
CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder().setName(name).addAllTimeSeries(timeSeries).build();
createServiceTimeSeries(request);
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method getServiceTest2.
@Test
public void getServiceTest2() 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 name = "name3373707";
Service actualResponse = client.getService(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetServiceRequest actualRequest = ((GetServiceRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method createServiceExceptionTest3.
@Test
public void createServiceExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
Service service = Service.newBuilder().build();
client.createService(parent, service);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations