Search in sources :

Example 16 with Service

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

Example 17 with Service

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

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

Example 19 with Service

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

Example 20 with Service

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) CreateServiceRequest(com.google.monitoring.v3.CreateServiceRequest) 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