1919import com .google .api .core .ApiFuture ;
2020import com .google .api .core .ApiFutures ;
2121import com .google .api .gax .core .BackgroundResource ;
22+ import com .google .api .gax .httpjson .longrunning .OperationsClient ;
2223import com .google .api .gax .longrunning .OperationFuture ;
2324import com .google .api .gax .paging .AbstractFixedSizeCollection ;
2425import com .google .api .gax .paging .AbstractPage ;
2829import com .google .api .gax .rpc .UnaryCallable ;
2930import com .google .cloud .dialogflow .cx .v3 .stub .AgentsStub ;
3031import com .google .cloud .dialogflow .cx .v3 .stub .AgentsStubSettings ;
32+ import com .google .cloud .location .GetLocationRequest ;
33+ import com .google .cloud .location .ListLocationsRequest ;
34+ import com .google .cloud .location .ListLocationsResponse ;
35+ import com .google .cloud .location .Location ;
3136import com .google .common .util .concurrent .MoreExecutors ;
3237import com .google .longrunning .Operation ;
33- import com .google .longrunning .OperationsClient ;
3438import com .google .protobuf .Empty ;
3539import com .google .protobuf .FieldMask ;
3640import com .google .protobuf .Struct ;
102106 * AgentsClient agentsClient = AgentsClient.create(agentsSettings);
103107 * }</pre>
104108 *
109+ * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
110+ * the wire:
111+ *
112+ * <pre>{@code
113+ * // This snippet has been automatically generated for illustrative purposes only.
114+ * // It may require modifications to work in your environment.
115+ * AgentsSettings agentsSettings =
116+ * AgentsSettings.newBuilder()
117+ * .setTransportChannelProvider(
118+ * AgentsSettings.defaultHttpJsonTransportProviderBuilder().build())
119+ * .build();
120+ * AgentsClient agentsClient = AgentsClient.create(agentsSettings);
121+ * }</pre>
122+ *
105123 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
106124 */
107125@ Generated ("by gapic-generator-java" )
108126public class AgentsClient implements BackgroundResource {
109127 private final AgentsSettings settings ;
110128 private final AgentsStub stub ;
111- private final OperationsClient operationsClient ;
129+ private final OperationsClient httpJsonOperationsClient ;
130+ private final com .google .longrunning .OperationsClient operationsClient ;
112131
113132 /** Constructs an instance of AgentsClient with default settings. */
114133 public static final AgentsClient create () throws IOException {
@@ -138,13 +157,17 @@ public static final AgentsClient create(AgentsStub stub) {
138157 protected AgentsClient (AgentsSettings settings ) throws IOException {
139158 this .settings = settings ;
140159 this .stub = ((AgentsStubSettings ) settings .getStubSettings ()).createStub ();
141- this .operationsClient = OperationsClient .create (this .stub .getOperationsStub ());
160+ this .operationsClient =
161+ com .google .longrunning .OperationsClient .create (this .stub .getOperationsStub ());
162+ this .httpJsonOperationsClient = OperationsClient .create (this .stub .getHttpJsonOperationsStub ());
142163 }
143164
144165 protected AgentsClient (AgentsStub stub ) {
145166 this .settings = null ;
146167 this .stub = stub ;
147- this .operationsClient = OperationsClient .create (this .stub .getOperationsStub ());
168+ this .operationsClient =
169+ com .google .longrunning .OperationsClient .create (this .stub .getOperationsStub ());
170+ this .httpJsonOperationsClient = OperationsClient .create (this .stub .getHttpJsonOperationsStub ());
148171 }
149172
150173 public final AgentsSettings getSettings () {
@@ -159,10 +182,18 @@ public AgentsStub getStub() {
159182 * Returns the OperationsClient that can be used to query the status of a long-running operation
160183 * returned by another API method call.
161184 */
162- public final OperationsClient getOperationsClient () {
185+ public final com . google . longrunning . OperationsClient getOperationsClient () {
163186 return operationsClient ;
164187 }
165188
189+ /**
190+ * Returns the OperationsClient that can be used to query the status of a long-running operation
191+ * returned by another API method call.
192+ */
193+ public final OperationsClient getHttpJsonOperationsClient () {
194+ return httpJsonOperationsClient ;
195+ }
196+
166197 // AUTO-GENERATED DOCUMENTATION AND METHOD.
167198 /**
168199 * Returns the list of all agents in the specified location.
@@ -291,7 +322,7 @@ public final UnaryCallable<ListAgentsRequest, ListAgentsPagedResponse> listAgent
291322 * .build();
292323 * while (true) {
293324 * ListAgentsResponse response = agentsClient.listAgentsCallable().call(request);
294- * for (Agent element : response.getResponsesList ()) {
325+ * for (Agent element : response.getAgentsList ()) {
295326 * // doThingsWith(element);
296327 * }
297328 * String nextPageToken = response.getNextPageToken();
@@ -1112,6 +1143,145 @@ public final AgentValidationResult getAgentValidationResult(
11121143 return stub .getAgentValidationResultCallable ();
11131144 }
11141145
1146+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
1147+ /**
1148+ * Lists information about the supported locations for this service.
1149+ *
1150+ * <p>Sample code:
1151+ *
1152+ * <pre>{@code
1153+ * // This snippet has been automatically generated for illustrative purposes only.
1154+ * // It may require modifications to work in your environment.
1155+ * try (AgentsClient agentsClient = AgentsClient.create()) {
1156+ * ListLocationsRequest request =
1157+ * ListLocationsRequest.newBuilder()
1158+ * .setName("name3373707")
1159+ * .setFilter("filter-1274492040")
1160+ * .setPageSize(883849137)
1161+ * .setPageToken("pageToken873572522")
1162+ * .build();
1163+ * for (Location element : agentsClient.listLocations(request).iterateAll()) {
1164+ * // doThingsWith(element);
1165+ * }
1166+ * }
1167+ * }</pre>
1168+ *
1169+ * @param request The request object containing all of the parameters for the API call.
1170+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1171+ */
1172+ public final ListLocationsPagedResponse listLocations (ListLocationsRequest request ) {
1173+ return listLocationsPagedCallable ().call (request );
1174+ }
1175+
1176+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
1177+ /**
1178+ * Lists information about the supported locations for this service.
1179+ *
1180+ * <p>Sample code:
1181+ *
1182+ * <pre>{@code
1183+ * // This snippet has been automatically generated for illustrative purposes only.
1184+ * // It may require modifications to work in your environment.
1185+ * try (AgentsClient agentsClient = AgentsClient.create()) {
1186+ * ListLocationsRequest request =
1187+ * ListLocationsRequest.newBuilder()
1188+ * .setName("name3373707")
1189+ * .setFilter("filter-1274492040")
1190+ * .setPageSize(883849137)
1191+ * .setPageToken("pageToken873572522")
1192+ * .build();
1193+ * ApiFuture<Location> future = agentsClient.listLocationsPagedCallable().futureCall(request);
1194+ * // Do something.
1195+ * for (Location element : future.get().iterateAll()) {
1196+ * // doThingsWith(element);
1197+ * }
1198+ * }
1199+ * }</pre>
1200+ */
1201+ public final UnaryCallable <ListLocationsRequest , ListLocationsPagedResponse >
1202+ listLocationsPagedCallable () {
1203+ return stub .listLocationsPagedCallable ();
1204+ }
1205+
1206+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
1207+ /**
1208+ * Lists information about the supported locations for this service.
1209+ *
1210+ * <p>Sample code:
1211+ *
1212+ * <pre>{@code
1213+ * // This snippet has been automatically generated for illustrative purposes only.
1214+ * // It may require modifications to work in your environment.
1215+ * try (AgentsClient agentsClient = AgentsClient.create()) {
1216+ * ListLocationsRequest request =
1217+ * ListLocationsRequest.newBuilder()
1218+ * .setName("name3373707")
1219+ * .setFilter("filter-1274492040")
1220+ * .setPageSize(883849137)
1221+ * .setPageToken("pageToken873572522")
1222+ * .build();
1223+ * while (true) {
1224+ * ListLocationsResponse response = agentsClient.listLocationsCallable().call(request);
1225+ * for (Location element : response.getLocationsList()) {
1226+ * // doThingsWith(element);
1227+ * }
1228+ * String nextPageToken = response.getNextPageToken();
1229+ * if (!Strings.isNullOrEmpty(nextPageToken)) {
1230+ * request = request.toBuilder().setPageToken(nextPageToken).build();
1231+ * } else {
1232+ * break;
1233+ * }
1234+ * }
1235+ * }
1236+ * }</pre>
1237+ */
1238+ public final UnaryCallable <ListLocationsRequest , ListLocationsResponse > listLocationsCallable () {
1239+ return stub .listLocationsCallable ();
1240+ }
1241+
1242+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
1243+ /**
1244+ * Gets information about a location.
1245+ *
1246+ * <p>Sample code:
1247+ *
1248+ * <pre>{@code
1249+ * // This snippet has been automatically generated for illustrative purposes only.
1250+ * // It may require modifications to work in your environment.
1251+ * try (AgentsClient agentsClient = AgentsClient.create()) {
1252+ * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
1253+ * Location response = agentsClient.getLocation(request);
1254+ * }
1255+ * }</pre>
1256+ *
1257+ * @param request The request object containing all of the parameters for the API call.
1258+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
1259+ */
1260+ public final Location getLocation (GetLocationRequest request ) {
1261+ return getLocationCallable ().call (request );
1262+ }
1263+
1264+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
1265+ /**
1266+ * Gets information about a location.
1267+ *
1268+ * <p>Sample code:
1269+ *
1270+ * <pre>{@code
1271+ * // This snippet has been automatically generated for illustrative purposes only.
1272+ * // It may require modifications to work in your environment.
1273+ * try (AgentsClient agentsClient = AgentsClient.create()) {
1274+ * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
1275+ * ApiFuture<Location> future = agentsClient.getLocationCallable().futureCall(request);
1276+ * // Do something.
1277+ * Location response = future.get();
1278+ * }
1279+ * }</pre>
1280+ */
1281+ public final UnaryCallable <GetLocationRequest , Location > getLocationCallable () {
1282+ return stub .getLocationCallable ();
1283+ }
1284+
11151285 @ Override
11161286 public final void close () {
11171287 stub .close ();
@@ -1214,4 +1384,80 @@ protected ListAgentsFixedSizeCollection createCollection(
12141384 return new ListAgentsFixedSizeCollection (pages , collectionSize );
12151385 }
12161386 }
1387+
1388+ public static class ListLocationsPagedResponse
1389+ extends AbstractPagedListResponse <
1390+ ListLocationsRequest ,
1391+ ListLocationsResponse ,
1392+ Location ,
1393+ ListLocationsPage ,
1394+ ListLocationsFixedSizeCollection > {
1395+
1396+ public static ApiFuture <ListLocationsPagedResponse > createAsync (
1397+ PageContext <ListLocationsRequest , ListLocationsResponse , Location > context ,
1398+ ApiFuture <ListLocationsResponse > futureResponse ) {
1399+ ApiFuture <ListLocationsPage > futurePage =
1400+ ListLocationsPage .createEmptyPage ().createPageAsync (context , futureResponse );
1401+ return ApiFutures .transform (
1402+ futurePage ,
1403+ input -> new ListLocationsPagedResponse (input ),
1404+ MoreExecutors .directExecutor ());
1405+ }
1406+
1407+ private ListLocationsPagedResponse (ListLocationsPage page ) {
1408+ super (page , ListLocationsFixedSizeCollection .createEmptyCollection ());
1409+ }
1410+ }
1411+
1412+ public static class ListLocationsPage
1413+ extends AbstractPage <
1414+ ListLocationsRequest , ListLocationsResponse , Location , ListLocationsPage > {
1415+
1416+ private ListLocationsPage (
1417+ PageContext <ListLocationsRequest , ListLocationsResponse , Location > context ,
1418+ ListLocationsResponse response ) {
1419+ super (context , response );
1420+ }
1421+
1422+ private static ListLocationsPage createEmptyPage () {
1423+ return new ListLocationsPage (null , null );
1424+ }
1425+
1426+ @ Override
1427+ protected ListLocationsPage createPage (
1428+ PageContext <ListLocationsRequest , ListLocationsResponse , Location > context ,
1429+ ListLocationsResponse response ) {
1430+ return new ListLocationsPage (context , response );
1431+ }
1432+
1433+ @ Override
1434+ public ApiFuture <ListLocationsPage > createPageAsync (
1435+ PageContext <ListLocationsRequest , ListLocationsResponse , Location > context ,
1436+ ApiFuture <ListLocationsResponse > futureResponse ) {
1437+ return super .createPageAsync (context , futureResponse );
1438+ }
1439+ }
1440+
1441+ public static class ListLocationsFixedSizeCollection
1442+ extends AbstractFixedSizeCollection <
1443+ ListLocationsRequest ,
1444+ ListLocationsResponse ,
1445+ Location ,
1446+ ListLocationsPage ,
1447+ ListLocationsFixedSizeCollection > {
1448+
1449+ private ListLocationsFixedSizeCollection (List <ListLocationsPage > pages , int collectionSize ) {
1450+ super (pages , collectionSize );
1451+ }
1452+
1453+ private static ListLocationsFixedSizeCollection createEmptyCollection () {
1454+ return new ListLocationsFixedSizeCollection (null , 0 );
1455+ }
1456+
1457+ @ Override
1458+ protected ListLocationsFixedSizeCollection createCollection (
1459+ List <ListLocationsPage > pages , int collectionSize ) {
1460+ return new ListLocationsFixedSizeCollection (pages , collectionSize );
1461+ }
1462+ }
12171463}
0 commit comments