1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.showcase.v1beta1.samples;
18 
19 // [START localhost7469_v1beta1_generated_Echo_Block_async]
20 import com.google.api.core.ApiFuture;
21 import com.google.protobuf.Duration;
22 import com.google.showcase.v1beta1.BlockRequest;
23 import com.google.showcase.v1beta1.BlockResponse;
24 import com.google.showcase.v1beta1.EchoClient;
25 
26 public class AsyncBlock {
27 
main(String[] args)28   public static void main(String[] args) throws Exception {
29     asyncBlock();
30   }
31 
asyncBlock()32   public static void asyncBlock() throws Exception {
33     // This snippet has been automatically generated and should be regarded as a code template only.
34     // It will require modifications to work:
35     // - It may require correct/in-range values for request initialization.
36     // - It may require specifying regional endpoints when creating the service client as shown in
37     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
38     try (EchoClient echoClient = EchoClient.create()) {
39       BlockRequest request =
40           BlockRequest.newBuilder().setResponseDelay(Duration.newBuilder().build()).build();
41       ApiFuture<BlockResponse> future = echoClient.blockCallable().futureCall(request);
42       // Do something.
43       BlockResponse response = future.get();
44     }
45   }
46 }
47 // [END localhost7469_v1beta1_generated_Echo_Block_async]
48