Search in sources :

Example 76 with Service

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());
}
Also used : ServiceStatusBuilder(io.fabric8.knative.serving.v1.ServiceStatusBuilder) ServiceList(io.fabric8.knative.serving.v1.ServiceList) Service(io.fabric8.knative.serving.v1.Service) ServiceBuilder(io.fabric8.knative.serving.v1.ServiceBuilder) Test(org.junit.jupiter.api.Test)

Example 77 with Service

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);
}
Also used : DeleteServiceLevelObjectiveRequest(com.google.monitoring.v3.DeleteServiceLevelObjectiveRequest)

Example 78 with Service

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);
}
Also used : CreateTimeSeriesRequest(com.google.monitoring.v3.CreateTimeSeriesRequest)

Example 79 with Service

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) GetServiceRequest(com.google.monitoring.v3.GetServiceRequest) Test(org.junit.Test)

Example 80 with Service

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.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.monitoring.v3.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)33 Test (org.junit.Test)30 Service (io.fabric8.knative.serving.v1.Service)28 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 AbstractMessage (com.google.protobuf.AbstractMessage)19 CoreException (org.eclipse.core.runtime.CoreException)18 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)16 Service (com.google.monitoring.v3.Service)16 IOException (java.io.IOException)16 HashMap (java.util.HashMap)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 ArrayList (java.util.ArrayList)12 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)11 StatusRuntimeException (io.grpc.StatusRuntimeException)11 ProdBuildResults (io.quarkus.test.ProdBuildResults)11 ProdModeTestResults (io.quarkus.test.ProdModeTestResults)11 QuarkusProdModeTest (io.quarkus.test.QuarkusProdModeTest)11 Path (java.nio.file.Path)11