/** * Sends a request to update current sink. If the sink does not exist, it is created. This method * returns a {@code ApiFuture} object to consume the result. {@link ApiFuture#get()} returns a * {@code Sink} object with updated information. * * <p>Example of asynchronously updating the sink's information. * * <pre>{@code * ApiFuture<Sink> future = sink.toBuilder() * .setFilter("severity<=ERROR") * .build() * .updateAsync(); * // ... * Sink updatedSink = future.get(); * }</pre> * * @throws LoggingException upon failure */ public ApiFuture<Sink> updateAsync() { return logging.updateAsync(this); }
/** * Sends a request to update current metric. If the metric does not exist, it is created. This * method returns a {@code ApiFuture} object to consume the result. {@link ApiFuture#get()} * returns a {@code Metric} object with updated information. * * <p>Example of asynchronously updating the metric's information. * * <pre>{@code * ApiFuture<Metric> future = metric.toBuilder() * .setDescription("A more detailed description") * .build() * .updateAsync(); * // ... * Metric updatedMetric = future.get(); * }</pre> * * @throws LoggingException upon failure */ public ApiFuture<Metric> updateAsync() { return logging.updateAsync(this); }
/** Example of asynchronously updating a metric. */ // [TARGET updateAsync(MetricInfo)] // [VARIABLE "my_metric_name"] public Metric updateMetricAsync(String metricName) throws ExecutionException, InterruptedException { // [START updateMetricAsync] MetricInfo metricInfo = MetricInfo.newBuilder(metricName, "severity>=ERROR") .setDescription("new description") .build(); Future<Metric> future = logging.updateAsync(metricInfo); // ... Metric metric = future.get(); // [END updateMetricAsync] return metric; }
/** Example of asynchronously updating a sink. */ // [TARGET updateAsync(SinkInfo)] // [VARIABLE "my_sink_name"] // [VARIABLE "my_dataset"] public Sink updateSinkAsync(String sinkName, String datasetName) throws ExecutionException, InterruptedException { // [START updateSinkAsync] SinkInfo sinkInfo = SinkInfo.newBuilder(sinkName, DatasetDestination.of(datasetName)) .setVersionFormat(SinkInfo.VersionFormat.V2) .setFilter("severity>=ERROR") .build(); Future<Sink> future = logging.updateAsync(sinkInfo); // ... Sink sink = future.get(); // [END updateSinkAsync] return sink; }
@Test public void testUpdateAsync() throws ExecutionException, InterruptedException { initializeExpectedSink(2); SinkInfo updatedInfo = SINK_INFO.toBuilder().setFilter(NEW_FILTER).build(); Sink expectedSink = new Sink(serviceMockReturnsOptions, new SinkInfo.BuilderImpl(updatedInfo)); expect(logging.getOptions()).andReturn(mockOptions).times(2); expect(logging.updateAsync(expectedSink)).andReturn(ApiFutures.immediateFuture(expectedSink)); replay(logging); initializeSink(); Sink updatedSink = sink.toBuilder().setFilter(NEW_FILTER).build().updateAsync().get(); compareSink(expectedSink, updatedSink); }
@Test public void testUpdateSinkAsync() throws ExecutionException, InterruptedException { LogSink sinkPb = SINK_INFO.toPb(PROJECT); ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb); UpdateSinkRequest request = UpdateSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).setSink(sinkPb).build(); EasyMock.expect(loggingRpcMock.update(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Sink sink = logging.updateAsync(SINK_INFO).get(); assertEquals(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), sink); }
@Test public void testUpdateMetricAsync() throws ExecutionException, InterruptedException { LogMetric sinkPb = METRIC_INFO.toPb(); ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb); UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).setMetric(sinkPb).build(); EasyMock.expect(loggingRpcMock.update(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Metric sink = logging.updateAsync(METRIC_INFO).get(); assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink); }
@Test public void testUpdateAsync() throws ExecutionException, InterruptedException { initializeExpectedMetric(2); MetricInfo updatedInfo = METRIC_INFO.toBuilder().setFilter(NEW_FILTER).build(); Metric expectedMetric = new Metric(serviceMockReturnsOptions, new MetricInfo.BuilderImpl(updatedInfo)); expect(logging.getOptions()).andReturn(mockOptions).times(2); expect(logging.updateAsync(expectedMetric)) .andReturn(ApiFutures.immediateFuture(expectedMetric)); replay(logging); initializeMetric(); Metric updatedMetric = metric.toBuilder().setFilter(NEW_FILTER).build().updateAsync().get(); compareMetric(expectedMetric, updatedMetric); }
/** * Sends a request to update current sink. If the sink does not exist, it is created. This method * returns a {@code ApiFuture} object to consume the result. {@link ApiFuture#get()} returns a * {@code Sink} object with updated information. * * <p>Example of asynchronously updating the sink's information. * * <pre>{@code * ApiFuture<Sink> future = sink.toBuilder() * .setFilter("severity<=ERROR") * .build() * .updateAsync(); * // ... * Sink updatedSink = future.get(); * }</pre> * * @throws LoggingException upon failure */ public ApiFuture<Sink> updateAsync() { return logging.updateAsync(this); }
/** * Sends a request to update current metric. If the metric does not exist, it is created. This * method returns a {@code ApiFuture} object to consume the result. {@link ApiFuture#get()} * returns a {@code Metric} object with updated information. * * <p>Example of asynchronously updating the metric's information. * * <pre>{@code * ApiFuture<Metric> future = metric.toBuilder() * .setDescription("A more detailed description") * .build() * .updateAsync(); * // ... * Metric updatedMetric = future.get(); * }</pre> * * @throws LoggingException upon failure */ public ApiFuture<Metric> updateAsync() { return logging.updateAsync(this); }