Search in sources :

Example 6 with UptimeCheckServiceClient

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

the class UptimeSample method getUptimeCheckConfig.

// [END monitoring_uptime_check_list_ips]]
// [START monitoring_uptime_check_get]]
private static void getUptimeCheckConfig(String projectId, String checkName) throws IOException {
    try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create()) {
        String fullCheckName = UptimeCheckConfigName.format(projectId, checkName);
        UptimeCheckConfig config = client.getUptimeCheckConfig(fullCheckName);
        if (config != null) {
            System.out.println(config.toString());
        } else {
            System.out.println("No uptime check config found with name " + checkName + " in project " + projectId);
        }
    } catch (Exception e) {
        usage("Exception getting uptime check: " + e.toString());
        throw e;
    }
}
Also used : UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) UptimeCheckServiceClient(com.google.cloud.monitoring.v3.UptimeCheckServiceClient) IOException(java.io.IOException) ParseException(org.apache.commons.cli.ParseException)

Aggregations

UptimeCheckServiceClient (com.google.cloud.monitoring.v3.UptimeCheckServiceClient)6 UptimeCheckConfig (com.google.monitoring.v3.UptimeCheckConfig)6 IOException (java.io.IOException)6 ParseException (org.apache.commons.cli.ParseException)6 CreateUptimeCheckConfigRequest (com.google.monitoring.v3.CreateUptimeCheckConfigRequest)2 UpdateUptimeCheckConfigRequest (com.google.monitoring.v3.UpdateUptimeCheckConfigRequest)2 UptimeCheckServiceSettings (com.google.cloud.monitoring.v3.UptimeCheckServiceSettings)1