Search in sources :

Example 1 with ListMonitoredResourceDescriptorsPagedResponse

use of com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse in project java-docs-samples by GoogleCloudPlatform.

the class Snippets method listMonitoredResources.

/**
 * Gets all monitored resource descriptors.
 */
void listMonitoredResources() throws IOException {
    // [START monitoring_list_resources]
    // Your Google Cloud Platform project ID
    String projectId = System.getProperty("projectId");
    final MetricServiceClient client = MetricServiceClient.create();
    ProjectName name = ProjectName.of(projectId);
    ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder().setName(name.toString()).build();
    System.out.println("Listing monitored resource descriptors: ");
    ListMonitoredResourceDescriptorsPagedResponse response = client.listMonitoredResourceDescriptors(request);
    for (MonitoredResourceDescriptor d : response.iterateAll()) {
        System.out.println(d.getType());
    }
// [END monitoring_list_resources]
}
Also used : MetricServiceClient(com.google.cloud.monitoring.v3.MetricServiceClient) ProjectName(com.google.monitoring.v3.ProjectName) ListMonitoredResourceDescriptorsRequest(com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest) MonitoredResourceDescriptor(com.google.api.MonitoredResourceDescriptor) ListMonitoredResourceDescriptorsPagedResponse(com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse)

Aggregations

MonitoredResourceDescriptor (com.google.api.MonitoredResourceDescriptor)1 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)1 ListMonitoredResourceDescriptorsPagedResponse (com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse)1 ListMonitoredResourceDescriptorsRequest (com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest)1 ProjectName (com.google.monitoring.v3.ProjectName)1