@Generated(value="by gapic-generator-java") public class ServiceMonitoringServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ResourceName parent = ResourceName.of("[FOLDER]");
Service service = Service.newBuilder().build();
Service response = serviceMonitoringServiceClient.createService(parent, service);
}
Note: close() needs to be called on the ServiceMonitoringServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
CreateService |
Create a `Service`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetService |
Get the named `Service`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListServices |
List `Service`s for this Metrics Scope. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateService |
Update this `Service`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteService |
Soft delete this `Service`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateServiceLevelObjective |
Create a `ServiceLevelObjective` for the given `Service`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetServiceLevelObjective |
Get a `ServiceLevelObjective` by name. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListServiceLevelObjectives |
List the `ServiceLevelObjective`s for the given `Service`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateServiceLevelObjective |
Update the given `ServiceLevelObjective`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteServiceLevelObjective |
Delete the given `ServiceLevelObjective`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ServiceMonitoringServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ServiceMonitoringServiceSettings serviceMonitoringServiceSettings =
ServiceMonitoringServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create(serviceMonitoringServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ServiceMonitoringServiceSettings serviceMonitoringServiceSettings =
ServiceMonitoringServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create(serviceMonitoringServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
ServiceMonitoringServiceClient.ListServiceLevelObjectivesFixedSizeCollection |
static class |
ServiceMonitoringServiceClient.ListServiceLevelObjectivesPage |
static class |
ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse |
static class |
ServiceMonitoringServiceClient.ListServicesFixedSizeCollection |
static class |
ServiceMonitoringServiceClient.ListServicesPage |
static class |
ServiceMonitoringServiceClient.ListServicesPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
ServiceMonitoringServiceClient(ServiceMonitoringServiceSettings settings)
Constructs an instance of ServiceMonitoringServiceClient, using the given settings.
|
protected |
ServiceMonitoringServiceClient(ServiceMonitoringServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ServiceMonitoringServiceClient |
create()
Constructs an instance of ServiceMonitoringServiceClient with default settings.
|
static ServiceMonitoringServiceClient |
create(ServiceMonitoringServiceSettings settings)
Constructs an instance of ServiceMonitoringServiceClient, using the given settings.
|
static ServiceMonitoringServiceClient |
create(ServiceMonitoringServiceStub stub)
Constructs an instance of ServiceMonitoringServiceClient, using the given stub for making
calls.
|
Service |
createService(CreateServiceRequest request)
Create a `Service`.
|
Service |
createService(OrganizationName parent,
Service service)
Create a `Service`.
|
Service |
createService(ProjectName parent,
Service service)
Create a `Service`.
|
Service |
createService(com.google.api.resourcenames.ResourceName parent,
Service service)
Create a `Service`.
|
Service |
createService(String parent,
Service service)
Create a `Service`.
|
com.google.api.gax.rpc.UnaryCallable<CreateServiceRequest,Service> |
createServiceCallable()
Create a `Service`.
|
ServiceLevelObjective |
createServiceLevelObjective(CreateServiceLevelObjectiveRequest request)
Create a `ServiceLevelObjective` for the given `Service`.
|
ServiceLevelObjective |
createServiceLevelObjective(ServiceName parent,
ServiceLevelObjective serviceLevelObjective)
Create a `ServiceLevelObjective` for the given `Service`.
|
ServiceLevelObjective |
createServiceLevelObjective(String parent,
ServiceLevelObjective serviceLevelObjective)
Create a `ServiceLevelObjective` for the given `Service`.
|
com.google.api.gax.rpc.UnaryCallable<CreateServiceLevelObjectiveRequest,ServiceLevelObjective> |
createServiceLevelObjectiveCallable()
Create a `ServiceLevelObjective` for the given `Service`.
|
void |
deleteService(DeleteServiceRequest request)
Soft delete this `Service`.
|
void |
deleteService(ServiceName name)
Soft delete this `Service`.
|
void |
deleteService(String name)
Soft delete this `Service`.
|
com.google.api.gax.rpc.UnaryCallable<DeleteServiceRequest,com.google.protobuf.Empty> |
deleteServiceCallable()
Soft delete this `Service`.
|
void |
deleteServiceLevelObjective(DeleteServiceLevelObjectiveRequest request)
Delete the given `ServiceLevelObjective`.
|
void |
deleteServiceLevelObjective(ServiceLevelObjectiveName name)
Delete the given `ServiceLevelObjective`.
|
void |
deleteServiceLevelObjective(String name)
Delete the given `ServiceLevelObjective`.
|
com.google.api.gax.rpc.UnaryCallable<DeleteServiceLevelObjectiveRequest,com.google.protobuf.Empty> |
deleteServiceLevelObjectiveCallable()
Delete the given `ServiceLevelObjective`.
|
Service |
getService(GetServiceRequest request)
Get the named `Service`.
|
Service |
getService(ServiceName name)
Get the named `Service`.
|
Service |
getService(String name)
Get the named `Service`.
|
com.google.api.gax.rpc.UnaryCallable<GetServiceRequest,Service> |
getServiceCallable()
Get the named `Service`.
|
ServiceLevelObjective |
getServiceLevelObjective(GetServiceLevelObjectiveRequest request)
Get a `ServiceLevelObjective` by name.
|
ServiceLevelObjective |
getServiceLevelObjective(ServiceLevelObjectiveName name)
Get a `ServiceLevelObjective` by name.
|
ServiceLevelObjective |
getServiceLevelObjective(String name)
Get a `ServiceLevelObjective` by name.
|
com.google.api.gax.rpc.UnaryCallable<GetServiceLevelObjectiveRequest,ServiceLevelObjective> |
getServiceLevelObjectiveCallable()
Get a `ServiceLevelObjective` by name.
|
ServiceMonitoringServiceSettings |
getSettings() |
ServiceMonitoringServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse |
listServiceLevelObjectives(ListServiceLevelObjectivesRequest request)
List the `ServiceLevelObjective`s for the given `Service`.
|
ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse |
listServiceLevelObjectives(ServiceName parent)
List the `ServiceLevelObjective`s for the given `Service`.
|
ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse |
listServiceLevelObjectives(String parent)
List the `ServiceLevelObjective`s for the given `Service`.
|
com.google.api.gax.rpc.UnaryCallable<ListServiceLevelObjectivesRequest,ListServiceLevelObjectivesResponse> |
listServiceLevelObjectivesCallable()
List the `ServiceLevelObjective`s for the given `Service`.
|
com.google.api.gax.rpc.UnaryCallable<ListServiceLevelObjectivesRequest,ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse> |
listServiceLevelObjectivesPagedCallable()
List the `ServiceLevelObjective`s for the given `Service`.
|
ServiceMonitoringServiceClient.ListServicesPagedResponse |
listServices(ListServicesRequest request)
List `Service`s for this Metrics Scope.
|
ServiceMonitoringServiceClient.ListServicesPagedResponse |
listServices(OrganizationName parent)
List `Service`s for this Metrics Scope.
|
ServiceMonitoringServiceClient.ListServicesPagedResponse |
listServices(ProjectName parent)
List `Service`s for this Metrics Scope.
|
ServiceMonitoringServiceClient.ListServicesPagedResponse |
listServices(com.google.api.resourcenames.ResourceName parent)
List `Service`s for this Metrics Scope.
|
ServiceMonitoringServiceClient.ListServicesPagedResponse |
listServices(String parent)
List `Service`s for this Metrics Scope.
|
com.google.api.gax.rpc.UnaryCallable<ListServicesRequest,ListServicesResponse> |
listServicesCallable()
List `Service`s for this Metrics Scope.
|
com.google.api.gax.rpc.UnaryCallable<ListServicesRequest,ServiceMonitoringServiceClient.ListServicesPagedResponse> |
listServicesPagedCallable()
List `Service`s for this Metrics Scope.
|
void |
shutdown() |
void |
shutdownNow() |
Service |
updateService(Service service)
Update this `Service`.
|
Service |
updateService(UpdateServiceRequest request)
Update this `Service`.
|
com.google.api.gax.rpc.UnaryCallable<UpdateServiceRequest,Service> |
updateServiceCallable()
Update this `Service`.
|
ServiceLevelObjective |
updateServiceLevelObjective(ServiceLevelObjective serviceLevelObjective)
Update the given `ServiceLevelObjective`.
|
ServiceLevelObjective |
updateServiceLevelObjective(UpdateServiceLevelObjectiveRequest request)
Update the given `ServiceLevelObjective`.
|
com.google.api.gax.rpc.UnaryCallable<UpdateServiceLevelObjectiveRequest,ServiceLevelObjective> |
updateServiceLevelObjectiveCallable()
Update the given `ServiceLevelObjective`.
|
protected ServiceMonitoringServiceClient(ServiceMonitoringServiceSettings settings) throws IOException
IOExceptionprotected ServiceMonitoringServiceClient(ServiceMonitoringServiceStub stub)
public static final ServiceMonitoringServiceClient create() throws IOException
IOExceptionpublic static final ServiceMonitoringServiceClient create(ServiceMonitoringServiceSettings settings) throws IOException
IOExceptionpublic static final ServiceMonitoringServiceClient create(ServiceMonitoringServiceStub stub)
public final ServiceMonitoringServiceSettings getSettings()
public ServiceMonitoringServiceStub getStub()
public final Service createService(com.google.api.resourcenames.ResourceName parent, Service service)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ResourceName parent = ResourceName.of("[FOLDER]");
Service service = Service.newBuilder().build();
Service response = serviceMonitoringServiceClient.createService(parent, service);
}
parent - Required. Resource
[name](https://cloud.google.com/monitoring/api/v3#project_name) of the parent Metrics
Scope. The format is:
projects/[PROJECT_ID_OR_NUMBER]
service - Required. The `Service` to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Service createService(OrganizationName parent, Service service)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
Service service = Service.newBuilder().build();
Service response = serviceMonitoringServiceClient.createService(parent, service);
}
parent - Required. Resource
[name](https://cloud.google.com/monitoring/api/v3#project_name) of the parent Metrics
Scope. The format is:
projects/[PROJECT_ID_OR_NUMBER]
service - Required. The `Service` to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Service createService(ProjectName parent, Service service)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Service service = Service.newBuilder().build();
Service response = serviceMonitoringServiceClient.createService(parent, service);
}
parent - Required. Resource
[name](https://cloud.google.com/monitoring/api/v3#project_name) of the parent Metrics
Scope. The format is:
projects/[PROJECT_ID_OR_NUMBER]
service - Required. The `Service` to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Service createService(String parent, Service service)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
Service service = Service.newBuilder().build();
Service response = serviceMonitoringServiceClient.createService(parent, service);
}
parent - Required. Resource
[name](https://cloud.google.com/monitoring/api/v3#project_name) of the parent Metrics
Scope. The format is:
projects/[PROJECT_ID_OR_NUMBER]
service - Required. The `Service` to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Service createService(CreateServiceRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
CreateServiceRequest request =
CreateServiceRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setServiceId("serviceId-194185552")
.setService(Service.newBuilder().build())
.build();
Service response = serviceMonitoringServiceClient.createService(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateServiceRequest,Service> createServiceCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
CreateServiceRequest request =
CreateServiceRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setServiceId("serviceId-194185552")
.setService(Service.newBuilder().build())
.build();
ApiFuture<Service> future =
serviceMonitoringServiceClient.createServiceCallable().futureCall(request);
// Do something.
Service response = future.get();
}
public final Service getService(ServiceName name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
Service response = serviceMonitoringServiceClient.getService(name);
}
name - Required. Resource name of the `Service`. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final Service getService(String name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
String name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString();
Service response = serviceMonitoringServiceClient.getService(name);
}
name - Required. Resource name of the `Service`. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final Service getService(GetServiceRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
GetServiceRequest request =
GetServiceRequest.newBuilder()
.setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.build();
Service response = serviceMonitoringServiceClient.getService(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetServiceRequest,Service> getServiceCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
GetServiceRequest request =
GetServiceRequest.newBuilder()
.setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.build();
ApiFuture<Service> future =
serviceMonitoringServiceClient.getServiceCallable().futureCall(request);
// Do something.
Service response = future.get();
}
public final ServiceMonitoringServiceClient.ListServicesPagedResponse listServices(com.google.api.resourcenames.ResourceName parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ResourceName parent = ResourceName.of("[FOLDER]");
for (Service element : serviceMonitoringServiceClient.listServices(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Resource name of the parent containing the listed services, either a
[project](https://cloud.google.com/monitoring/api/v3#project_name) or a Monitoring Metrics
Scope. The formats are:
projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceMonitoringServiceClient.ListServicesPagedResponse listServices(OrganizationName parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
for (Service element : serviceMonitoringServiceClient.listServices(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Resource name of the parent containing the listed services, either a
[project](https://cloud.google.com/monitoring/api/v3#project_name) or a Monitoring Metrics
Scope. The formats are:
projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceMonitoringServiceClient.ListServicesPagedResponse listServices(ProjectName parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Service element : serviceMonitoringServiceClient.listServices(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Resource name of the parent containing the listed services, either a
[project](https://cloud.google.com/monitoring/api/v3#project_name) or a Monitoring Metrics
Scope. The formats are:
projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceMonitoringServiceClient.ListServicesPagedResponse listServices(String parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
for (Service element : serviceMonitoringServiceClient.listServices(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Resource name of the parent containing the listed services, either a
[project](https://cloud.google.com/monitoring/api/v3#project_name) or a Monitoring Metrics
Scope. The formats are:
projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceMonitoringServiceClient.ListServicesPagedResponse listServices(ListServicesRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ListServicesRequest request =
ListServicesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Service element : serviceMonitoringServiceClient.listServices(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListServicesRequest,ServiceMonitoringServiceClient.ListServicesPagedResponse> listServicesPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ListServicesRequest request =
ListServicesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Service> future =
serviceMonitoringServiceClient.listServicesPagedCallable().futureCall(request);
// Do something.
for (Service element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListServicesRequest,ListServicesResponse> listServicesCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ListServicesRequest request =
ListServicesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListServicesResponse response =
serviceMonitoringServiceClient.listServicesCallable().call(request);
for (Service element : response.getServicesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Service updateService(Service service)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
Service service = Service.newBuilder().build();
Service response = serviceMonitoringServiceClient.updateService(service);
}
service - Required. The `Service` to draw updates from. The given `name` specifies the
resource to update.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Service updateService(UpdateServiceRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
UpdateServiceRequest request =
UpdateServiceRequest.newBuilder()
.setService(Service.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Service response = serviceMonitoringServiceClient.updateService(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateServiceRequest,Service> updateServiceCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
UpdateServiceRequest request =
UpdateServiceRequest.newBuilder()
.setService(Service.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Service> future =
serviceMonitoringServiceClient.updateServiceCallable().futureCall(request);
// Do something.
Service response = future.get();
}
public final void deleteService(ServiceName name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
serviceMonitoringServiceClient.deleteService(name);
}
name - Required. Resource name of the `Service` to delete. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteService(String name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
String name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString();
serviceMonitoringServiceClient.deleteService(name);
}
name - Required. Resource name of the `Service` to delete. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteService(DeleteServiceRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
DeleteServiceRequest request =
DeleteServiceRequest.newBuilder()
.setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.build();
serviceMonitoringServiceClient.deleteService(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteServiceRequest,com.google.protobuf.Empty> deleteServiceCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
DeleteServiceRequest request =
DeleteServiceRequest.newBuilder()
.setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.build();
ApiFuture<Empty> future =
serviceMonitoringServiceClient.deleteServiceCallable().futureCall(request);
// Do something.
future.get();
}
public final ServiceLevelObjective createServiceLevelObjective(ServiceName parent, ServiceLevelObjective serviceLevelObjective)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
ServiceLevelObjective response =
serviceMonitoringServiceClient.createServiceLevelObjective(parent, serviceLevelObjective);
}
parent - Required. Resource name of the parent `Service`. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
serviceLevelObjective - Required. The `ServiceLevelObjective` to create. The provided
`name` will be respected if no `ServiceLevelObjective` exists with this name.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceLevelObjective createServiceLevelObjective(String parent, ServiceLevelObjective serviceLevelObjective)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
String parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString();
ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
ServiceLevelObjective response =
serviceMonitoringServiceClient.createServiceLevelObjective(parent, serviceLevelObjective);
}
parent - Required. Resource name of the parent `Service`. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
serviceLevelObjective - Required. The `ServiceLevelObjective` to create. The provided
`name` will be respected if no `ServiceLevelObjective` exists with this name.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceLevelObjective createServiceLevelObjective(CreateServiceLevelObjectiveRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
CreateServiceLevelObjectiveRequest request =
CreateServiceLevelObjectiveRequest.newBuilder()
.setParent(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.setServiceLevelObjectiveId("serviceLevelObjectiveId-240792859")
.setServiceLevelObjective(ServiceLevelObjective.newBuilder().build())
.build();
ServiceLevelObjective response =
serviceMonitoringServiceClient.createServiceLevelObjective(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateServiceLevelObjectiveRequest,ServiceLevelObjective> createServiceLevelObjectiveCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
CreateServiceLevelObjectiveRequest request =
CreateServiceLevelObjectiveRequest.newBuilder()
.setParent(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.setServiceLevelObjectiveId("serviceLevelObjectiveId-240792859")
.setServiceLevelObjective(ServiceLevelObjective.newBuilder().build())
.build();
ApiFuture<ServiceLevelObjective> future =
serviceMonitoringServiceClient.createServiceLevelObjectiveCallable().futureCall(request);
// Do something.
ServiceLevelObjective response = future.get();
}
public final ServiceLevelObjective getServiceLevelObjective(ServiceLevelObjectiveName name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ServiceLevelObjectiveName name =
ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
"[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
ServiceLevelObjective response =
serviceMonitoringServiceClient.getServiceLevelObjective(name);
}
name - Required. Resource name of the `ServiceLevelObjective` to get. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceLevelObjective getServiceLevelObjective(String name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
String name =
ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
"[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]")
.toString();
ServiceLevelObjective response =
serviceMonitoringServiceClient.getServiceLevelObjective(name);
}
name - Required. Resource name of the `ServiceLevelObjective` to get. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceLevelObjective getServiceLevelObjective(GetServiceLevelObjectiveRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
GetServiceLevelObjectiveRequest request =
GetServiceLevelObjectiveRequest.newBuilder()
.setName(
ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
"[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]")
.toString())
.build();
ServiceLevelObjective response =
serviceMonitoringServiceClient.getServiceLevelObjective(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetServiceLevelObjectiveRequest,ServiceLevelObjective> getServiceLevelObjectiveCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
GetServiceLevelObjectiveRequest request =
GetServiceLevelObjectiveRequest.newBuilder()
.setName(
ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
"[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]")
.toString())
.build();
ApiFuture<ServiceLevelObjective> future =
serviceMonitoringServiceClient.getServiceLevelObjectiveCallable().futureCall(request);
// Do something.
ServiceLevelObjective response = future.get();
}
public final ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse listServiceLevelObjectives(ServiceName parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
for (ServiceLevelObjective element :
serviceMonitoringServiceClient.listServiceLevelObjectives(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Resource name of the parent containing the listed SLOs, either a
project or a Monitoring Metrics Scope. The formats are:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/-
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse listServiceLevelObjectives(String parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
String parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString();
for (ServiceLevelObjective element :
serviceMonitoringServiceClient.listServiceLevelObjectives(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Resource name of the parent containing the listed SLOs, either a
project or a Monitoring Metrics Scope. The formats are:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/-
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse listServiceLevelObjectives(ListServiceLevelObjectivesRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ListServiceLevelObjectivesRequest request =
ListServiceLevelObjectivesRequest.newBuilder()
.setParent(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (ServiceLevelObjective element :
serviceMonitoringServiceClient.listServiceLevelObjectives(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListServiceLevelObjectivesRequest,ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse> listServiceLevelObjectivesPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ListServiceLevelObjectivesRequest request =
ListServiceLevelObjectivesRequest.newBuilder()
.setParent(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<ServiceLevelObjective> future =
serviceMonitoringServiceClient
.listServiceLevelObjectivesPagedCallable()
.futureCall(request);
// Do something.
for (ServiceLevelObjective element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListServiceLevelObjectivesRequest,ListServiceLevelObjectivesResponse> listServiceLevelObjectivesCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ListServiceLevelObjectivesRequest request =
ListServiceLevelObjectivesRequest.newBuilder()
.setParent(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListServiceLevelObjectivesResponse response =
serviceMonitoringServiceClient.listServiceLevelObjectivesCallable().call(request);
for (ServiceLevelObjective element : response.getServiceLevelObjectivesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final ServiceLevelObjective updateServiceLevelObjective(ServiceLevelObjective serviceLevelObjective)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
ServiceLevelObjective response =
serviceMonitoringServiceClient.updateServiceLevelObjective(serviceLevelObjective);
}
serviceLevelObjective - Required. The `ServiceLevelObjective` to draw updates from. The
given `name` specifies the resource to update.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ServiceLevelObjective updateServiceLevelObjective(UpdateServiceLevelObjectiveRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
UpdateServiceLevelObjectiveRequest request =
UpdateServiceLevelObjectiveRequest.newBuilder()
.setServiceLevelObjective(ServiceLevelObjective.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ServiceLevelObjective response =
serviceMonitoringServiceClient.updateServiceLevelObjective(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateServiceLevelObjectiveRequest,ServiceLevelObjective> updateServiceLevelObjectiveCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
UpdateServiceLevelObjectiveRequest request =
UpdateServiceLevelObjectiveRequest.newBuilder()
.setServiceLevelObjective(ServiceLevelObjective.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<ServiceLevelObjective> future =
serviceMonitoringServiceClient.updateServiceLevelObjectiveCallable().futureCall(request);
// Do something.
ServiceLevelObjective response = future.get();
}
public final void deleteServiceLevelObjective(ServiceLevelObjectiveName name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
ServiceLevelObjectiveName name =
ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
"[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
serviceMonitoringServiceClient.deleteServiceLevelObjective(name);
}
name - Required. Resource name of the `ServiceLevelObjective` to delete. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteServiceLevelObjective(String name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
String name =
ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
"[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]")
.toString();
serviceMonitoringServiceClient.deleteServiceLevelObjective(name);
}
name - Required. Resource name of the `ServiceLevelObjective` to delete. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteServiceLevelObjective(DeleteServiceLevelObjectiveRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
DeleteServiceLevelObjectiveRequest request =
DeleteServiceLevelObjectiveRequest.newBuilder()
.setName(
ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
"[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]")
.toString())
.build();
serviceMonitoringServiceClient.deleteServiceLevelObjective(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteServiceLevelObjectiveRequest,com.google.protobuf.Empty> deleteServiceLevelObjectiveCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
ServiceMonitoringServiceClient.create()) {
DeleteServiceLevelObjectiveRequest request =
DeleteServiceLevelObjectiveRequest.newBuilder()
.setName(
ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
"[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]")
.toString())
.build();
ApiFuture<Empty> future =
serviceMonitoringServiceClient.deleteServiceLevelObjectiveCallable().futureCall(request);
// Do something.
future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.