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.compute.v1.stub; 18 19 import static com.google.cloud.compute.v1.SslPoliciesClient.AggregatedListPagedResponse; 20 import static com.google.cloud.compute.v1.SslPoliciesClient.ListPagedResponse; 21 22 import com.google.api.core.BetaApi; 23 import com.google.api.core.InternalApi; 24 import com.google.api.gax.core.BackgroundResource; 25 import com.google.api.gax.core.BackgroundResourceAggregation; 26 import com.google.api.gax.httpjson.ApiMethodDescriptor; 27 import com.google.api.gax.httpjson.HttpJsonCallSettings; 28 import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; 29 import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; 30 import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; 31 import com.google.api.gax.httpjson.ProtoMessageResponseParser; 32 import com.google.api.gax.httpjson.ProtoRestSerializer; 33 import com.google.api.gax.rpc.ClientContext; 34 import com.google.api.gax.rpc.OperationCallable; 35 import com.google.api.gax.rpc.UnaryCallable; 36 import com.google.cloud.compute.v1.AggregatedListSslPoliciesRequest; 37 import com.google.cloud.compute.v1.DeleteSslPolicyRequest; 38 import com.google.cloud.compute.v1.GetSslPolicyRequest; 39 import com.google.cloud.compute.v1.InsertSslPolicyRequest; 40 import com.google.cloud.compute.v1.ListAvailableFeaturesSslPoliciesRequest; 41 import com.google.cloud.compute.v1.ListSslPoliciesRequest; 42 import com.google.cloud.compute.v1.Operation; 43 import com.google.cloud.compute.v1.Operation.Status; 44 import com.google.cloud.compute.v1.PatchSslPolicyRequest; 45 import com.google.cloud.compute.v1.SslPoliciesAggregatedList; 46 import com.google.cloud.compute.v1.SslPoliciesList; 47 import com.google.cloud.compute.v1.SslPoliciesListAvailableFeaturesResponse; 48 import com.google.cloud.compute.v1.SslPolicy; 49 import com.google.protobuf.TypeRegistry; 50 import java.io.IOException; 51 import java.util.ArrayList; 52 import java.util.HashMap; 53 import java.util.List; 54 import java.util.Map; 55 import java.util.concurrent.TimeUnit; 56 import javax.annotation.Generated; 57 58 // AUTO-GENERATED DOCUMENTATION AND CLASS. 59 /** 60 * REST stub implementation for the SslPolicies service API. 61 * 62 * <p>This class is for advanced usage and reflects the underlying API directly. 63 */ 64 @Generated("by gapic-generator-java") 65 @BetaApi 66 public class HttpJsonSslPoliciesStub extends SslPoliciesStub { 67 private static final TypeRegistry typeRegistry = 68 TypeRegistry.newBuilder().add(Operation.getDescriptor()).build(); 69 70 private static final ApiMethodDescriptor< 71 AggregatedListSslPoliciesRequest, SslPoliciesAggregatedList> 72 aggregatedListMethodDescriptor = 73 ApiMethodDescriptor 74 .<AggregatedListSslPoliciesRequest, SslPoliciesAggregatedList>newBuilder() 75 .setFullMethodName("google.cloud.compute.v1.SslPolicies/AggregatedList") 76 .setHttpMethod("GET") 77 .setType(ApiMethodDescriptor.MethodType.UNARY) 78 .setRequestFormatter( 79 ProtoMessageRequestFormatter.<AggregatedListSslPoliciesRequest>newBuilder() 80 .setPath( 81 "/compute/v1/projects/{project}/aggregated/sslPolicies", 82 request -> { 83 Map<String, String> fields = new HashMap<>(); 84 ProtoRestSerializer<AggregatedListSslPoliciesRequest> serializer = 85 ProtoRestSerializer.create(); 86 serializer.putPathParam(fields, "project", request.getProject()); 87 return fields; 88 }) 89 .setQueryParamsExtractor( 90 request -> { 91 Map<String, List<String>> fields = new HashMap<>(); 92 ProtoRestSerializer<AggregatedListSslPoliciesRequest> serializer = 93 ProtoRestSerializer.create(); 94 if (request.hasFilter()) { 95 serializer.putQueryParam(fields, "filter", request.getFilter()); 96 } 97 if (request.hasIncludeAllScopes()) { 98 serializer.putQueryParam( 99 fields, "includeAllScopes", request.getIncludeAllScopes()); 100 } 101 if (request.hasMaxResults()) { 102 serializer.putQueryParam( 103 fields, "maxResults", request.getMaxResults()); 104 } 105 if (request.hasOrderBy()) { 106 serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); 107 } 108 if (request.hasPageToken()) { 109 serializer.putQueryParam(fields, "pageToken", request.getPageToken()); 110 } 111 if (request.hasReturnPartialSuccess()) { 112 serializer.putQueryParam( 113 fields, 114 "returnPartialSuccess", 115 request.getReturnPartialSuccess()); 116 } 117 return fields; 118 }) 119 .setRequestBodyExtractor(request -> null) 120 .build()) 121 .setResponseParser( 122 ProtoMessageResponseParser.<SslPoliciesAggregatedList>newBuilder() 123 .setDefaultInstance(SslPoliciesAggregatedList.getDefaultInstance()) 124 .setDefaultTypeRegistry(typeRegistry) 125 .build()) 126 .build(); 127 128 private static final ApiMethodDescriptor<DeleteSslPolicyRequest, Operation> 129 deleteMethodDescriptor = 130 ApiMethodDescriptor.<DeleteSslPolicyRequest, Operation>newBuilder() 131 .setFullMethodName("google.cloud.compute.v1.SslPolicies/Delete") 132 .setHttpMethod("DELETE") 133 .setType(ApiMethodDescriptor.MethodType.UNARY) 134 .setRequestFormatter( 135 ProtoMessageRequestFormatter.<DeleteSslPolicyRequest>newBuilder() 136 .setPath( 137 "/compute/v1/projects/{project}/global/sslPolicies/{sslPolicy}", 138 request -> { 139 Map<String, String> fields = new HashMap<>(); 140 ProtoRestSerializer<DeleteSslPolicyRequest> serializer = 141 ProtoRestSerializer.create(); 142 serializer.putPathParam(fields, "project", request.getProject()); 143 serializer.putPathParam(fields, "sslPolicy", request.getSslPolicy()); 144 return fields; 145 }) 146 .setQueryParamsExtractor( 147 request -> { 148 Map<String, List<String>> fields = new HashMap<>(); 149 ProtoRestSerializer<DeleteSslPolicyRequest> serializer = 150 ProtoRestSerializer.create(); 151 if (request.hasRequestId()) { 152 serializer.putQueryParam(fields, "requestId", request.getRequestId()); 153 } 154 return fields; 155 }) 156 .setRequestBodyExtractor(request -> null) 157 .build()) 158 .setResponseParser( 159 ProtoMessageResponseParser.<Operation>newBuilder() 160 .setDefaultInstance(Operation.getDefaultInstance()) 161 .setDefaultTypeRegistry(typeRegistry) 162 .build()) 163 .setOperationSnapshotFactory( 164 (DeleteSslPolicyRequest request, Operation response) -> { 165 StringBuilder opName = new StringBuilder(response.getName()); 166 opName.append(":").append(request.getProject()); 167 return HttpJsonOperationSnapshot.newBuilder() 168 .setName(opName.toString()) 169 .setMetadata(response) 170 .setDone(Status.DONE.equals(response.getStatus())) 171 .setResponse(response) 172 .setError(response.getHttpErrorStatusCode(), response.getHttpErrorMessage()) 173 .build(); 174 }) 175 .build(); 176 177 private static final ApiMethodDescriptor<GetSslPolicyRequest, SslPolicy> getMethodDescriptor = 178 ApiMethodDescriptor.<GetSslPolicyRequest, SslPolicy>newBuilder() 179 .setFullMethodName("google.cloud.compute.v1.SslPolicies/Get") 180 .setHttpMethod("GET") 181 .setType(ApiMethodDescriptor.MethodType.UNARY) 182 .setRequestFormatter( 183 ProtoMessageRequestFormatter.<GetSslPolicyRequest>newBuilder() 184 .setPath( 185 "/compute/v1/projects/{project}/global/sslPolicies/{sslPolicy}", 186 request -> { 187 Map<String, String> fields = new HashMap<>(); 188 ProtoRestSerializer<GetSslPolicyRequest> serializer = 189 ProtoRestSerializer.create(); 190 serializer.putPathParam(fields, "project", request.getProject()); 191 serializer.putPathParam(fields, "sslPolicy", request.getSslPolicy()); 192 return fields; 193 }) 194 .setQueryParamsExtractor( 195 request -> { 196 Map<String, List<String>> fields = new HashMap<>(); 197 ProtoRestSerializer<GetSslPolicyRequest> serializer = 198 ProtoRestSerializer.create(); 199 return fields; 200 }) 201 .setRequestBodyExtractor(request -> null) 202 .build()) 203 .setResponseParser( 204 ProtoMessageResponseParser.<SslPolicy>newBuilder() 205 .setDefaultInstance(SslPolicy.getDefaultInstance()) 206 .setDefaultTypeRegistry(typeRegistry) 207 .build()) 208 .build(); 209 210 private static final ApiMethodDescriptor<InsertSslPolicyRequest, Operation> 211 insertMethodDescriptor = 212 ApiMethodDescriptor.<InsertSslPolicyRequest, Operation>newBuilder() 213 .setFullMethodName("google.cloud.compute.v1.SslPolicies/Insert") 214 .setHttpMethod("POST") 215 .setType(ApiMethodDescriptor.MethodType.UNARY) 216 .setRequestFormatter( 217 ProtoMessageRequestFormatter.<InsertSslPolicyRequest>newBuilder() 218 .setPath( 219 "/compute/v1/projects/{project}/global/sslPolicies", 220 request -> { 221 Map<String, String> fields = new HashMap<>(); 222 ProtoRestSerializer<InsertSslPolicyRequest> serializer = 223 ProtoRestSerializer.create(); 224 serializer.putPathParam(fields, "project", request.getProject()); 225 return fields; 226 }) 227 .setQueryParamsExtractor( 228 request -> { 229 Map<String, List<String>> fields = new HashMap<>(); 230 ProtoRestSerializer<InsertSslPolicyRequest> serializer = 231 ProtoRestSerializer.create(); 232 if (request.hasRequestId()) { 233 serializer.putQueryParam(fields, "requestId", request.getRequestId()); 234 } 235 return fields; 236 }) 237 .setRequestBodyExtractor( 238 request -> 239 ProtoRestSerializer.create() 240 .toBody( 241 "sslPolicyResource", request.getSslPolicyResource(), false)) 242 .build()) 243 .setResponseParser( 244 ProtoMessageResponseParser.<Operation>newBuilder() 245 .setDefaultInstance(Operation.getDefaultInstance()) 246 .setDefaultTypeRegistry(typeRegistry) 247 .build()) 248 .setOperationSnapshotFactory( 249 (InsertSslPolicyRequest request, Operation response) -> { 250 StringBuilder opName = new StringBuilder(response.getName()); 251 opName.append(":").append(request.getProject()); 252 return HttpJsonOperationSnapshot.newBuilder() 253 .setName(opName.toString()) 254 .setMetadata(response) 255 .setDone(Status.DONE.equals(response.getStatus())) 256 .setResponse(response) 257 .setError(response.getHttpErrorStatusCode(), response.getHttpErrorMessage()) 258 .build(); 259 }) 260 .build(); 261 262 private static final ApiMethodDescriptor<ListSslPoliciesRequest, SslPoliciesList> 263 listMethodDescriptor = 264 ApiMethodDescriptor.<ListSslPoliciesRequest, SslPoliciesList>newBuilder() 265 .setFullMethodName("google.cloud.compute.v1.SslPolicies/List") 266 .setHttpMethod("GET") 267 .setType(ApiMethodDescriptor.MethodType.UNARY) 268 .setRequestFormatter( 269 ProtoMessageRequestFormatter.<ListSslPoliciesRequest>newBuilder() 270 .setPath( 271 "/compute/v1/projects/{project}/global/sslPolicies", 272 request -> { 273 Map<String, String> fields = new HashMap<>(); 274 ProtoRestSerializer<ListSslPoliciesRequest> serializer = 275 ProtoRestSerializer.create(); 276 serializer.putPathParam(fields, "project", request.getProject()); 277 return fields; 278 }) 279 .setQueryParamsExtractor( 280 request -> { 281 Map<String, List<String>> fields = new HashMap<>(); 282 ProtoRestSerializer<ListSslPoliciesRequest> serializer = 283 ProtoRestSerializer.create(); 284 if (request.hasFilter()) { 285 serializer.putQueryParam(fields, "filter", request.getFilter()); 286 } 287 if (request.hasMaxResults()) { 288 serializer.putQueryParam( 289 fields, "maxResults", request.getMaxResults()); 290 } 291 if (request.hasOrderBy()) { 292 serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); 293 } 294 if (request.hasPageToken()) { 295 serializer.putQueryParam(fields, "pageToken", request.getPageToken()); 296 } 297 if (request.hasReturnPartialSuccess()) { 298 serializer.putQueryParam( 299 fields, 300 "returnPartialSuccess", 301 request.getReturnPartialSuccess()); 302 } 303 return fields; 304 }) 305 .setRequestBodyExtractor(request -> null) 306 .build()) 307 .setResponseParser( 308 ProtoMessageResponseParser.<SslPoliciesList>newBuilder() 309 .setDefaultInstance(SslPoliciesList.getDefaultInstance()) 310 .setDefaultTypeRegistry(typeRegistry) 311 .build()) 312 .build(); 313 314 private static final ApiMethodDescriptor< 315 ListAvailableFeaturesSslPoliciesRequest, SslPoliciesListAvailableFeaturesResponse> 316 listAvailableFeaturesMethodDescriptor = 317 ApiMethodDescriptor 318 .<ListAvailableFeaturesSslPoliciesRequest, SslPoliciesListAvailableFeaturesResponse> 319 newBuilder() 320 .setFullMethodName("google.cloud.compute.v1.SslPolicies/ListAvailableFeatures") 321 .setHttpMethod("GET") 322 .setType(ApiMethodDescriptor.MethodType.UNARY) 323 .setRequestFormatter( 324 ProtoMessageRequestFormatter.<ListAvailableFeaturesSslPoliciesRequest>newBuilder() 325 .setPath( 326 "/compute/v1/projects/{project}/global/sslPolicies/listAvailableFeatures", 327 request -> { 328 Map<String, String> fields = new HashMap<>(); 329 ProtoRestSerializer<ListAvailableFeaturesSslPoliciesRequest> 330 serializer = ProtoRestSerializer.create(); 331 serializer.putPathParam(fields, "project", request.getProject()); 332 return fields; 333 }) 334 .setQueryParamsExtractor( 335 request -> { 336 Map<String, List<String>> fields = new HashMap<>(); 337 ProtoRestSerializer<ListAvailableFeaturesSslPoliciesRequest> 338 serializer = ProtoRestSerializer.create(); 339 if (request.hasFilter()) { 340 serializer.putQueryParam(fields, "filter", request.getFilter()); 341 } 342 if (request.hasMaxResults()) { 343 serializer.putQueryParam( 344 fields, "maxResults", request.getMaxResults()); 345 } 346 if (request.hasOrderBy()) { 347 serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); 348 } 349 if (request.hasPageToken()) { 350 serializer.putQueryParam(fields, "pageToken", request.getPageToken()); 351 } 352 if (request.hasReturnPartialSuccess()) { 353 serializer.putQueryParam( 354 fields, 355 "returnPartialSuccess", 356 request.getReturnPartialSuccess()); 357 } 358 return fields; 359 }) 360 .setRequestBodyExtractor(request -> null) 361 .build()) 362 .setResponseParser( 363 ProtoMessageResponseParser.<SslPoliciesListAvailableFeaturesResponse>newBuilder() 364 .setDefaultInstance( 365 SslPoliciesListAvailableFeaturesResponse.getDefaultInstance()) 366 .setDefaultTypeRegistry(typeRegistry) 367 .build()) 368 .build(); 369 370 private static final ApiMethodDescriptor<PatchSslPolicyRequest, Operation> patchMethodDescriptor = 371 ApiMethodDescriptor.<PatchSslPolicyRequest, Operation>newBuilder() 372 .setFullMethodName("google.cloud.compute.v1.SslPolicies/Patch") 373 .setHttpMethod("PATCH") 374 .setType(ApiMethodDescriptor.MethodType.UNARY) 375 .setRequestFormatter( 376 ProtoMessageRequestFormatter.<PatchSslPolicyRequest>newBuilder() 377 .setPath( 378 "/compute/v1/projects/{project}/global/sslPolicies/{sslPolicy}", 379 request -> { 380 Map<String, String> fields = new HashMap<>(); 381 ProtoRestSerializer<PatchSslPolicyRequest> serializer = 382 ProtoRestSerializer.create(); 383 serializer.putPathParam(fields, "project", request.getProject()); 384 serializer.putPathParam(fields, "sslPolicy", request.getSslPolicy()); 385 return fields; 386 }) 387 .setQueryParamsExtractor( 388 request -> { 389 Map<String, List<String>> fields = new HashMap<>(); 390 ProtoRestSerializer<PatchSslPolicyRequest> serializer = 391 ProtoRestSerializer.create(); 392 if (request.hasRequestId()) { 393 serializer.putQueryParam(fields, "requestId", request.getRequestId()); 394 } 395 return fields; 396 }) 397 .setRequestBodyExtractor( 398 request -> 399 ProtoRestSerializer.create() 400 .toBody("sslPolicyResource", request.getSslPolicyResource(), false)) 401 .build()) 402 .setResponseParser( 403 ProtoMessageResponseParser.<Operation>newBuilder() 404 .setDefaultInstance(Operation.getDefaultInstance()) 405 .setDefaultTypeRegistry(typeRegistry) 406 .build()) 407 .setOperationSnapshotFactory( 408 (PatchSslPolicyRequest request, Operation response) -> { 409 StringBuilder opName = new StringBuilder(response.getName()); 410 opName.append(":").append(request.getProject()); 411 return HttpJsonOperationSnapshot.newBuilder() 412 .setName(opName.toString()) 413 .setMetadata(response) 414 .setDone(Status.DONE.equals(response.getStatus())) 415 .setResponse(response) 416 .setError(response.getHttpErrorStatusCode(), response.getHttpErrorMessage()) 417 .build(); 418 }) 419 .build(); 420 421 private final UnaryCallable<AggregatedListSslPoliciesRequest, SslPoliciesAggregatedList> 422 aggregatedListCallable; 423 private final UnaryCallable<AggregatedListSslPoliciesRequest, AggregatedListPagedResponse> 424 aggregatedListPagedCallable; 425 private final UnaryCallable<DeleteSslPolicyRequest, Operation> deleteCallable; 426 private final OperationCallable<DeleteSslPolicyRequest, Operation, Operation> 427 deleteOperationCallable; 428 private final UnaryCallable<GetSslPolicyRequest, SslPolicy> getCallable; 429 private final UnaryCallable<InsertSslPolicyRequest, Operation> insertCallable; 430 private final OperationCallable<InsertSslPolicyRequest, Operation, Operation> 431 insertOperationCallable; 432 private final UnaryCallable<ListSslPoliciesRequest, SslPoliciesList> listCallable; 433 private final UnaryCallable<ListSslPoliciesRequest, ListPagedResponse> listPagedCallable; 434 private final UnaryCallable< 435 ListAvailableFeaturesSslPoliciesRequest, SslPoliciesListAvailableFeaturesResponse> 436 listAvailableFeaturesCallable; 437 private final UnaryCallable<PatchSslPolicyRequest, Operation> patchCallable; 438 private final OperationCallable<PatchSslPolicyRequest, Operation, Operation> 439 patchOperationCallable; 440 441 private final BackgroundResource backgroundResources; 442 private final HttpJsonGlobalOperationsStub httpJsonOperationsStub; 443 private final HttpJsonStubCallableFactory callableFactory; 444 create(SslPoliciesStubSettings settings)445 public static final HttpJsonSslPoliciesStub create(SslPoliciesStubSettings settings) 446 throws IOException { 447 return new HttpJsonSslPoliciesStub(settings, ClientContext.create(settings)); 448 } 449 create(ClientContext clientContext)450 public static final HttpJsonSslPoliciesStub create(ClientContext clientContext) 451 throws IOException { 452 return new HttpJsonSslPoliciesStub(SslPoliciesStubSettings.newBuilder().build(), clientContext); 453 } 454 create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory)455 public static final HttpJsonSslPoliciesStub create( 456 ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { 457 return new HttpJsonSslPoliciesStub( 458 SslPoliciesStubSettings.newBuilder().build(), clientContext, callableFactory); 459 } 460 461 /** 462 * Constructs an instance of HttpJsonSslPoliciesStub, using the given settings. This is protected 463 * so that it is easy to make a subclass, but otherwise, the static factory methods should be 464 * preferred. 465 */ HttpJsonSslPoliciesStub(SslPoliciesStubSettings settings, ClientContext clientContext)466 protected HttpJsonSslPoliciesStub(SslPoliciesStubSettings settings, ClientContext clientContext) 467 throws IOException { 468 this(settings, clientContext, new HttpJsonSslPoliciesCallableFactory()); 469 } 470 471 /** 472 * Constructs an instance of HttpJsonSslPoliciesStub, using the given settings. This is protected 473 * so that it is easy to make a subclass, but otherwise, the static factory methods should be 474 * preferred. 475 */ HttpJsonSslPoliciesStub( SslPoliciesStubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory)476 protected HttpJsonSslPoliciesStub( 477 SslPoliciesStubSettings settings, 478 ClientContext clientContext, 479 HttpJsonStubCallableFactory callableFactory) 480 throws IOException { 481 this.callableFactory = callableFactory; 482 this.httpJsonOperationsStub = 483 HttpJsonGlobalOperationsStub.create(clientContext, callableFactory); 484 485 HttpJsonCallSettings<AggregatedListSslPoliciesRequest, SslPoliciesAggregatedList> 486 aggregatedListTransportSettings = 487 HttpJsonCallSettings 488 .<AggregatedListSslPoliciesRequest, SslPoliciesAggregatedList>newBuilder() 489 .setMethodDescriptor(aggregatedListMethodDescriptor) 490 .setTypeRegistry(typeRegistry) 491 .build(); 492 HttpJsonCallSettings<DeleteSslPolicyRequest, Operation> deleteTransportSettings = 493 HttpJsonCallSettings.<DeleteSslPolicyRequest, Operation>newBuilder() 494 .setMethodDescriptor(deleteMethodDescriptor) 495 .setTypeRegistry(typeRegistry) 496 .build(); 497 HttpJsonCallSettings<GetSslPolicyRequest, SslPolicy> getTransportSettings = 498 HttpJsonCallSettings.<GetSslPolicyRequest, SslPolicy>newBuilder() 499 .setMethodDescriptor(getMethodDescriptor) 500 .setTypeRegistry(typeRegistry) 501 .build(); 502 HttpJsonCallSettings<InsertSslPolicyRequest, Operation> insertTransportSettings = 503 HttpJsonCallSettings.<InsertSslPolicyRequest, Operation>newBuilder() 504 .setMethodDescriptor(insertMethodDescriptor) 505 .setTypeRegistry(typeRegistry) 506 .build(); 507 HttpJsonCallSettings<ListSslPoliciesRequest, SslPoliciesList> listTransportSettings = 508 HttpJsonCallSettings.<ListSslPoliciesRequest, SslPoliciesList>newBuilder() 509 .setMethodDescriptor(listMethodDescriptor) 510 .setTypeRegistry(typeRegistry) 511 .build(); 512 HttpJsonCallSettings< 513 ListAvailableFeaturesSslPoliciesRequest, SslPoliciesListAvailableFeaturesResponse> 514 listAvailableFeaturesTransportSettings = 515 HttpJsonCallSettings 516 .<ListAvailableFeaturesSslPoliciesRequest, SslPoliciesListAvailableFeaturesResponse> 517 newBuilder() 518 .setMethodDescriptor(listAvailableFeaturesMethodDescriptor) 519 .setTypeRegistry(typeRegistry) 520 .build(); 521 HttpJsonCallSettings<PatchSslPolicyRequest, Operation> patchTransportSettings = 522 HttpJsonCallSettings.<PatchSslPolicyRequest, Operation>newBuilder() 523 .setMethodDescriptor(patchMethodDescriptor) 524 .setTypeRegistry(typeRegistry) 525 .build(); 526 527 this.aggregatedListCallable = 528 callableFactory.createUnaryCallable( 529 aggregatedListTransportSettings, settings.aggregatedListSettings(), clientContext); 530 this.aggregatedListPagedCallable = 531 callableFactory.createPagedCallable( 532 aggregatedListTransportSettings, settings.aggregatedListSettings(), clientContext); 533 this.deleteCallable = 534 callableFactory.createUnaryCallable( 535 deleteTransportSettings, settings.deleteSettings(), clientContext); 536 this.deleteOperationCallable = 537 callableFactory.createOperationCallable( 538 deleteTransportSettings, 539 settings.deleteOperationSettings(), 540 clientContext, 541 httpJsonOperationsStub); 542 this.getCallable = 543 callableFactory.createUnaryCallable( 544 getTransportSettings, settings.getSettings(), clientContext); 545 this.insertCallable = 546 callableFactory.createUnaryCallable( 547 insertTransportSettings, settings.insertSettings(), clientContext); 548 this.insertOperationCallable = 549 callableFactory.createOperationCallable( 550 insertTransportSettings, 551 settings.insertOperationSettings(), 552 clientContext, 553 httpJsonOperationsStub); 554 this.listCallable = 555 callableFactory.createUnaryCallable( 556 listTransportSettings, settings.listSettings(), clientContext); 557 this.listPagedCallable = 558 callableFactory.createPagedCallable( 559 listTransportSettings, settings.listSettings(), clientContext); 560 this.listAvailableFeaturesCallable = 561 callableFactory.createUnaryCallable( 562 listAvailableFeaturesTransportSettings, 563 settings.listAvailableFeaturesSettings(), 564 clientContext); 565 this.patchCallable = 566 callableFactory.createUnaryCallable( 567 patchTransportSettings, settings.patchSettings(), clientContext); 568 this.patchOperationCallable = 569 callableFactory.createOperationCallable( 570 patchTransportSettings, 571 settings.patchOperationSettings(), 572 clientContext, 573 httpJsonOperationsStub); 574 575 this.backgroundResources = 576 new BackgroundResourceAggregation(clientContext.getBackgroundResources()); 577 } 578 579 @InternalApi getMethodDescriptors()580 public static List<ApiMethodDescriptor> getMethodDescriptors() { 581 List<ApiMethodDescriptor> methodDescriptors = new ArrayList<>(); 582 methodDescriptors.add(aggregatedListMethodDescriptor); 583 methodDescriptors.add(deleteMethodDescriptor); 584 methodDescriptors.add(getMethodDescriptor); 585 methodDescriptors.add(insertMethodDescriptor); 586 methodDescriptors.add(listMethodDescriptor); 587 methodDescriptors.add(listAvailableFeaturesMethodDescriptor); 588 methodDescriptors.add(patchMethodDescriptor); 589 return methodDescriptors; 590 } 591 592 @Override 593 public UnaryCallable<AggregatedListSslPoliciesRequest, SslPoliciesAggregatedList> aggregatedListCallable()594 aggregatedListCallable() { 595 return aggregatedListCallable; 596 } 597 598 @Override 599 public UnaryCallable<AggregatedListSslPoliciesRequest, AggregatedListPagedResponse> aggregatedListPagedCallable()600 aggregatedListPagedCallable() { 601 return aggregatedListPagedCallable; 602 } 603 604 @Override deleteCallable()605 public UnaryCallable<DeleteSslPolicyRequest, Operation> deleteCallable() { 606 return deleteCallable; 607 } 608 609 @Override deleteOperationCallable()610 public OperationCallable<DeleteSslPolicyRequest, Operation, Operation> deleteOperationCallable() { 611 return deleteOperationCallable; 612 } 613 614 @Override getCallable()615 public UnaryCallable<GetSslPolicyRequest, SslPolicy> getCallable() { 616 return getCallable; 617 } 618 619 @Override insertCallable()620 public UnaryCallable<InsertSslPolicyRequest, Operation> insertCallable() { 621 return insertCallable; 622 } 623 624 @Override insertOperationCallable()625 public OperationCallable<InsertSslPolicyRequest, Operation, Operation> insertOperationCallable() { 626 return insertOperationCallable; 627 } 628 629 @Override listCallable()630 public UnaryCallable<ListSslPoliciesRequest, SslPoliciesList> listCallable() { 631 return listCallable; 632 } 633 634 @Override listPagedCallable()635 public UnaryCallable<ListSslPoliciesRequest, ListPagedResponse> listPagedCallable() { 636 return listPagedCallable; 637 } 638 639 @Override 640 public UnaryCallable< 641 ListAvailableFeaturesSslPoliciesRequest, SslPoliciesListAvailableFeaturesResponse> listAvailableFeaturesCallable()642 listAvailableFeaturesCallable() { 643 return listAvailableFeaturesCallable; 644 } 645 646 @Override patchCallable()647 public UnaryCallable<PatchSslPolicyRequest, Operation> patchCallable() { 648 return patchCallable; 649 } 650 651 @Override patchOperationCallable()652 public OperationCallable<PatchSslPolicyRequest, Operation, Operation> patchOperationCallable() { 653 return patchOperationCallable; 654 } 655 656 @Override close()657 public final void close() { 658 try { 659 backgroundResources.close(); 660 } catch (RuntimeException e) { 661 throw e; 662 } catch (Exception e) { 663 throw new IllegalStateException("Failed to close resource", e); 664 } 665 } 666 667 @Override shutdown()668 public void shutdown() { 669 backgroundResources.shutdown(); 670 } 671 672 @Override isShutdown()673 public boolean isShutdown() { 674 return backgroundResources.isShutdown(); 675 } 676 677 @Override isTerminated()678 public boolean isTerminated() { 679 return backgroundResources.isTerminated(); 680 } 681 682 @Override shutdownNow()683 public void shutdownNow() { 684 backgroundResources.shutdownNow(); 685 } 686 687 @Override awaitTermination(long duration, TimeUnit unit)688 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 689 return backgroundResources.awaitTermination(duration, unit); 690 } 691 } 692