Search in sources :

Example 11 with ServiceLevelObjective

use of com.google.monitoring.v3.ServiceLevelObjective 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 12 with ServiceLevelObjective

use of com.google.monitoring.v3.ServiceLevelObjective in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method createServiceLevelObjectiveTest2.

@Test
public void createServiceLevelObjectiveTest2() throws Exception {
    ServiceLevelObjective expectedResponse = ServiceLevelObjective.newBuilder().setName(ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]").toString()).setDisplayName("displayName1714148973").setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()).setGoal(3178259).putAllUserLabels(new HashMap<String, String>()).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
    ServiceLevelObjective actualResponse = client.createServiceLevelObjective(parent, serviceLevelObjective);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateServiceLevelObjectiveRequest actualRequest = ((CreateServiceLevelObjectiveRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(serviceLevelObjective, actualRequest.getServiceLevelObjective());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ServiceLevelObjective(com.google.monitoring.v3.ServiceLevelObjective) HashMap(java.util.HashMap) CreateServiceLevelObjectiveRequest(com.google.monitoring.v3.CreateServiceLevelObjectiveRequest) Test(org.junit.Test)

Aggregations

ServiceLevelObjective (com.google.monitoring.v3.ServiceLevelObjective)10 Test (org.junit.Test)10 AbstractMessage (com.google.protobuf.AbstractMessage)7 HashMap (java.util.HashMap)5 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)3 ServiceName (com.google.monitoring.v3.ServiceName)3 StatusRuntimeException (io.grpc.StatusRuntimeException)3 ListServiceLevelObjectivesPagedResponse (com.google.cloud.monitoring.v3.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse)2 CreateServiceLevelObjectiveRequest (com.google.monitoring.v3.CreateServiceLevelObjectiveRequest)2 DeleteServiceLevelObjectiveRequest (com.google.monitoring.v3.DeleteServiceLevelObjectiveRequest)2 GetServiceLevelObjectiveRequest (com.google.monitoring.v3.GetServiceLevelObjectiveRequest)2 ListServiceLevelObjectivesRequest (com.google.monitoring.v3.ListServiceLevelObjectivesRequest)2 ListServiceLevelObjectivesResponse (com.google.monitoring.v3.ListServiceLevelObjectivesResponse)2 ServiceLevelObjectiveName (com.google.monitoring.v3.ServiceLevelObjectiveName)1 UpdateServiceLevelObjectiveRequest (com.google.monitoring.v3.UpdateServiceLevelObjectiveRequest)1