|
| 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.cloud.networkconnectivity.v1.samples; |
| 18 | + |
| 19 | +// [START networkconnectivity_v1_generated_hubserviceclient_createhub_lro_async] |
| 20 | +import com.google.api.gax.longrunning.OperationFuture; |
| 21 | +import com.google.cloud.networkconnectivity.v1.CreateHubRequest; |
| 22 | +import com.google.cloud.networkconnectivity.v1.Hub; |
| 23 | +import com.google.cloud.networkconnectivity.v1.HubServiceClient; |
| 24 | +import com.google.cloud.networkconnectivity.v1.LocationName; |
| 25 | +import com.google.cloud.networkconnectivity.v1.OperationMetadata; |
| 26 | + |
| 27 | +public class AsyncCreateHubLRO { |
| 28 | + |
| 29 | + public static void main(String[] args) throws Exception { |
| 30 | + asyncCreateHubLRO(); |
| 31 | + } |
| 32 | + |
| 33 | + public static void asyncCreateHubLRO() throws Exception { |
| 34 | + // This snippet has been automatically generated for illustrative purposes only. |
| 35 | + // It may require modifications to work in your environment. |
| 36 | + try (HubServiceClient hubServiceClient = HubServiceClient.create()) { |
| 37 | + CreateHubRequest request = |
| 38 | + CreateHubRequest.newBuilder() |
| 39 | + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) |
| 40 | + .setHubId("hubId99628272") |
| 41 | + .setHub(Hub.newBuilder().build()) |
| 42 | + .setRequestId("requestId693933066") |
| 43 | + .build(); |
| 44 | + OperationFuture<Hub, OperationMetadata> future = |
| 45 | + hubServiceClient.createHubOperationCallable().futureCall(request); |
| 46 | + // Do something. |
| 47 | + Hub response = future.get(); |
| 48 | + } |
| 49 | + } |
| 50 | +} |
| 51 | +// [END networkconnectivity_v1_generated_hubserviceclient_createhub_lro_async] |
0 commit comments