Skip to content

Commit

Permalink
[samplecode] Implement rpc default method sample code (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
summer-ji-eng committed Jan 5, 2021
1 parent f585598 commit 746ecd2
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions test/integration/goldens/logging/MetricsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ public final ListLogMetricsPagedResponse listLogMetrics(String parent) {
/**
* Lists logs-based metrics.
*
* <p>Sample code:
*
* <pre>{@code
* try (MetricsClient metricsClient = MetricsClient.create()) {
* ListLogMetricsRequest request =
* ListLogMetricsRequest.newBuilder()
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setPageToken("pageToken873572522")
* .setPageSize(883849137)
* .build();
* for (LogMetric element : metricsClient.listLogMetrics(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -300,6 +316,18 @@ public final LogMetric getLogMetric(String metricName) {
/**
* Gets a logs-based metric.
*
* <p>Sample code:
*
* <pre>{@code
* try (MetricsClient metricsClient = MetricsClient.create()) {
* GetLogMetricRequest request =
* GetLogMetricRequest.newBuilder()
* .setMetricName(LogMetricName.of("[PROJECT]", "[METRIC]").toString())
* .build();
* LogMetric response = metricsClient.getLogMetric(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -378,6 +406,19 @@ public final LogMetric createLogMetric(String parent, LogMetric metric) {
/**
* Creates a logs-based metric.
*
* <p>Sample code:
*
* <pre>{@code
* try (MetricsClient metricsClient = MetricsClient.create()) {
* CreateLogMetricRequest request =
* CreateLogMetricRequest.newBuilder()
* .setParent(LogMetricName.of("[PROJECT]", "[METRIC]").toString())
* .setMetric(LogMetric.newBuilder().build())
* .build();
* LogMetric response = metricsClient.createLogMetric(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -458,6 +499,19 @@ public final LogMetric updateLogMetric(String metricName, LogMetric metric) {
/**
* Creates or updates a logs-based metric.
*
* <p>Sample code:
*
* <pre>{@code
* try (MetricsClient metricsClient = MetricsClient.create()) {
* UpdateLogMetricRequest request =
* UpdateLogMetricRequest.newBuilder()
* .setMetricName(LogMetricName.of("[PROJECT]", "[METRIC]").toString())
* .setMetric(LogMetric.newBuilder().build())
* .build();
* LogMetric response = metricsClient.updateLogMetric(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -527,6 +581,18 @@ public final void deleteLogMetric(String metricName) {
/**
* Deletes a logs-based metric.
*
* <p>Sample code:
*
* <pre>{@code
* try (MetricsClient metricsClient = MetricsClient.create()) {
* DeleteLogMetricRequest request =
* DeleteLogMetricRequest.newBuilder()
* .setMetricName(LogMetricName.of("[PROJECT]", "[METRIC]").toString())
* .build();
* metricsClient.deleteLogMetric(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down

0 comments on commit 746ecd2

Please sign in to comment.