public static List<String> toStringList(List<MetricDescriptorName> values) { List<String> list = new ArrayList<String>(values.size()); for (MetricDescriptorName value : values) { if (value == null) { list.add(""); } else { list.add(value.toString()); } } return list; }
public static String format(String project, String metricDescriptor) { return newBuilder() .setProject(project) .setMetricDescriptor(metricDescriptor) .build() .toString(); }
/** * Gets a single metric descriptor. This method does not require a Stackdriver account. * * <p>Sample code: * * <pre><code> * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) { * MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]"); * MetricDescriptor response = metricServiceClient.getMetricDescriptor(name); * } * </code></pre> * * @param name The metric descriptor on which to execute the request. The format is * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example value of * `{metric_id}` is `"compute.googleapis.com/instance/disk/read_bytes_count"`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final MetricDescriptor getMetricDescriptor(MetricDescriptorName name) { GetMetricDescriptorRequest request = GetMetricDescriptorRequest.newBuilder() .setName(name == null ? null : name.toString()) .build(); return getMetricDescriptor(request); }
/** * Deletes a metric descriptor. Only user-created [custom metrics](/monitoring/custom-metrics) can * be deleted. * * <p>Sample code: * * <pre><code> * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) { * MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]"); * metricServiceClient.deleteMetricDescriptor(name); * } * </code></pre> * * @param name The metric descriptor on which to execute the request. The format is * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example of * `{metric_id}` is: `"custom.googleapis.com/my_test_metric"`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteMetricDescriptor(MetricDescriptorName name) { DeleteMetricDescriptorRequest request = DeleteMetricDescriptorRequest.newBuilder() .setName(name == null ? null : name.toString()) .build(); deleteMetricDescriptor(request); }
/** * Gets a single metric descriptor. This method does not require a Stackdriver account. * * <p>Sample code: * * <pre><code> * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) { * MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]"); * MetricDescriptor response = metricServiceClient.getMetricDescriptor(name); * } * </code></pre> * * @param name The metric descriptor on which to execute the request. The format is * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example value of * `{metric_id}` is `"compute.googleapis.com/instance/disk/read_bytes_count"`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final MetricDescriptor getMetricDescriptor(MetricDescriptorName name) { GetMetricDescriptorRequest request = GetMetricDescriptorRequest.newBuilder() .setName(name == null ? null : name.toString()) .build(); return getMetricDescriptor(request); }
/** * Deletes a metric descriptor. Only user-created [custom metrics](/monitoring/custom-metrics) can * be deleted. * * <p>Sample code: * * <pre><code> * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) { * MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]"); * metricServiceClient.deleteMetricDescriptor(name); * } * </code></pre> * * @param name The metric descriptor on which to execute the request. The format is * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example of * `{metric_id}` is: `"custom.googleapis.com/my_test_metric"`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteMetricDescriptor(MetricDescriptorName name) { DeleteMetricDescriptorRequest request = DeleteMetricDescriptorRequest.newBuilder() .setName(name == null ? null : name.toString()) .build(); deleteMetricDescriptor(request); }