|
11 | 11 | import com.azure.core.annotation.Host; |
12 | 12 | import com.azure.core.annotation.HostParam; |
13 | 13 | import com.azure.core.annotation.PathParam; |
| 14 | +import com.azure.core.annotation.Post; |
14 | 15 | import com.azure.core.annotation.Put; |
15 | 16 | import com.azure.core.annotation.QueryParam; |
16 | 17 | import com.azure.core.annotation.ReturnType; |
|
30 | 31 | import reactor.core.publisher.Flux; |
31 | 32 | import reactor.core.publisher.Mono; |
32 | 33 | import tsptest.armresourceprovider.fluent.LroNoBodiesClient; |
| 34 | +import tsptest.armresourceprovider.models.ActionFinalResult; |
33 | 35 | import tsptest.armresourceprovider.models.ResourceLroNoBody; |
34 | 36 |
|
35 | 37 | /** |
@@ -85,6 +87,26 @@ Response<BinaryData> createOrUpdateSync(@HostParam("endpoint") String endpoint, |
85 | 87 | @PathParam("resourceLroNoBodyName") String resourceLroNoBodyName, |
86 | 88 | @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") ResourceLroNoBody resource, |
87 | 89 | Context context); |
| 90 | + |
| 91 | + @Headers({ "Content-Type: application/json" }) |
| 92 | + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmResourceProvider/resourceLroNoBody/{resourceLroNoBodyName}/action") |
| 93 | + @ExpectedResponses({ 200, 202 }) |
| 94 | + @UnexpectedResponseExceptionType(ManagementException.class) |
| 95 | + Mono<Response<Flux<ByteBuffer>>> action(@HostParam("endpoint") String endpoint, |
| 96 | + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, |
| 97 | + @PathParam("resourceGroupName") String resourceGroupName, |
| 98 | + @PathParam("resourceLroNoBodyName") String resourceLroNoBodyName, @HeaderParam("Accept") String accept, |
| 99 | + Context context); |
| 100 | + |
| 101 | + @Headers({ "Content-Type: application/json" }) |
| 102 | + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmResourceProvider/resourceLroNoBody/{resourceLroNoBodyName}/action") |
| 103 | + @ExpectedResponses({ 200, 202 }) |
| 104 | + @UnexpectedResponseExceptionType(ManagementException.class) |
| 105 | + Response<BinaryData> actionSync(@HostParam("endpoint") String endpoint, |
| 106 | + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, |
| 107 | + @PathParam("resourceGroupName") String resourceGroupName, |
| 108 | + @PathParam("resourceLroNoBodyName") String resourceLroNoBodyName, @HeaderParam("Accept") String accept, |
| 109 | + Context context); |
88 | 110 | } |
89 | 111 |
|
90 | 112 | /** |
@@ -261,4 +283,162 @@ public ResourceLroNoBody createOrUpdate(String resourceGroupName, String resourc |
261 | 283 | ResourceLroNoBody resource, Context context) { |
262 | 284 | return beginCreateOrUpdate(resourceGroupName, resourceLroNoBodyName, resource, context).getFinalResult(); |
263 | 285 | } |
| 286 | + |
| 287 | + /** |
| 288 | + * A long-running resource action. |
| 289 | + * |
| 290 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 291 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 292 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 293 | + * @throws ManagementException thrown if the request is rejected by server. |
| 294 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 295 | + * @return the response body along with {@link Response} on successful completion of {@link Mono}. |
| 296 | + */ |
| 297 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 298 | + public Mono<Response<Flux<ByteBuffer>>> actionWithResponseAsync(String resourceGroupName, |
| 299 | + String resourceLroNoBodyName) { |
| 300 | + final String accept = "application/json"; |
| 301 | + return FluxUtil |
| 302 | + .withContext(context -> service.action(this.client.getEndpoint(), this.client.getApiVersion(), |
| 303 | + this.client.getSubscriptionId(), resourceGroupName, resourceLroNoBodyName, accept, context)) |
| 304 | + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); |
| 305 | + } |
| 306 | + |
| 307 | + /** |
| 308 | + * A long-running resource action. |
| 309 | + * |
| 310 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 311 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 312 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 313 | + * @throws ManagementException thrown if the request is rejected by server. |
| 314 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 315 | + * @return the response body along with {@link Response}. |
| 316 | + */ |
| 317 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 318 | + private Response<BinaryData> actionWithResponse(String resourceGroupName, String resourceLroNoBodyName) { |
| 319 | + final String accept = "application/json"; |
| 320 | + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), |
| 321 | + this.client.getSubscriptionId(), resourceGroupName, resourceLroNoBodyName, accept, Context.NONE); |
| 322 | + } |
| 323 | + |
| 324 | + /** |
| 325 | + * A long-running resource action. |
| 326 | + * |
| 327 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 328 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 329 | + * @param context The context to associate with this operation. |
| 330 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 331 | + * @throws ManagementException thrown if the request is rejected by server. |
| 332 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 333 | + * @return the response body along with {@link Response}. |
| 334 | + */ |
| 335 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 336 | + private Response<BinaryData> actionWithResponse(String resourceGroupName, String resourceLroNoBodyName, |
| 337 | + Context context) { |
| 338 | + final String accept = "application/json"; |
| 339 | + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), |
| 340 | + this.client.getSubscriptionId(), resourceGroupName, resourceLroNoBodyName, accept, context); |
| 341 | + } |
| 342 | + |
| 343 | + /** |
| 344 | + * A long-running resource action. |
| 345 | + * |
| 346 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 347 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 348 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 349 | + * @throws ManagementException thrown if the request is rejected by server. |
| 350 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 351 | + * @return the {@link PollerFlux} for polling of long-running operation. |
| 352 | + */ |
| 353 | + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) |
| 354 | + public PollerFlux<PollResult<ActionFinalResult>, ActionFinalResult> beginActionAsync(String resourceGroupName, |
| 355 | + String resourceLroNoBodyName) { |
| 356 | + Mono<Response<Flux<ByteBuffer>>> mono = actionWithResponseAsync(resourceGroupName, resourceLroNoBodyName); |
| 357 | + return this.client.<ActionFinalResult, ActionFinalResult>getLroResult(mono, this.client.getHttpPipeline(), |
| 358 | + ActionFinalResult.class, ActionFinalResult.class, this.client.getContext()); |
| 359 | + } |
| 360 | + |
| 361 | + /** |
| 362 | + * A long-running resource action. |
| 363 | + * |
| 364 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 365 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 366 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 367 | + * @throws ManagementException thrown if the request is rejected by server. |
| 368 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 369 | + * @return the {@link SyncPoller} for polling of long-running operation. |
| 370 | + */ |
| 371 | + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) |
| 372 | + public SyncPoller<PollResult<ActionFinalResult>, ActionFinalResult> beginAction(String resourceGroupName, |
| 373 | + String resourceLroNoBodyName) { |
| 374 | + Response<BinaryData> response = actionWithResponse(resourceGroupName, resourceLroNoBodyName); |
| 375 | + return this.client.<ActionFinalResult, ActionFinalResult>getLroResult(response, ActionFinalResult.class, |
| 376 | + ActionFinalResult.class, Context.NONE); |
| 377 | + } |
| 378 | + |
| 379 | + /** |
| 380 | + * A long-running resource action. |
| 381 | + * |
| 382 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 383 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 384 | + * @param context The context to associate with this operation. |
| 385 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 386 | + * @throws ManagementException thrown if the request is rejected by server. |
| 387 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 388 | + * @return the {@link SyncPoller} for polling of long-running operation. |
| 389 | + */ |
| 390 | + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) |
| 391 | + public SyncPoller<PollResult<ActionFinalResult>, ActionFinalResult> beginAction(String resourceGroupName, |
| 392 | + String resourceLroNoBodyName, Context context) { |
| 393 | + Response<BinaryData> response = actionWithResponse(resourceGroupName, resourceLroNoBodyName, context); |
| 394 | + return this.client.<ActionFinalResult, ActionFinalResult>getLroResult(response, ActionFinalResult.class, |
| 395 | + ActionFinalResult.class, context); |
| 396 | + } |
| 397 | + |
| 398 | + /** |
| 399 | + * A long-running resource action. |
| 400 | + * |
| 401 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 402 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 403 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 404 | + * @throws ManagementException thrown if the request is rejected by server. |
| 405 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 406 | + * @return the response body on successful completion of {@link Mono}. |
| 407 | + */ |
| 408 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 409 | + public Mono<ActionFinalResult> actionAsync(String resourceGroupName, String resourceLroNoBodyName) { |
| 410 | + return beginActionAsync(resourceGroupName, resourceLroNoBodyName).last() |
| 411 | + .flatMap(this.client::getLroFinalResultOrError); |
| 412 | + } |
| 413 | + |
| 414 | + /** |
| 415 | + * A long-running resource action. |
| 416 | + * |
| 417 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 418 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 419 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 420 | + * @throws ManagementException thrown if the request is rejected by server. |
| 421 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 422 | + * @return the response. |
| 423 | + */ |
| 424 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 425 | + public ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName) { |
| 426 | + return beginAction(resourceGroupName, resourceLroNoBodyName).getFinalResult(); |
| 427 | + } |
| 428 | + |
| 429 | + /** |
| 430 | + * A long-running resource action. |
| 431 | + * |
| 432 | + * @param resourceGroupName The name of the resource group. The name is case insensitive. |
| 433 | + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. |
| 434 | + * @param context The context to associate with this operation. |
| 435 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 436 | + * @throws ManagementException thrown if the request is rejected by server. |
| 437 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 438 | + * @return the response. |
| 439 | + */ |
| 440 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 441 | + public ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName, Context context) { |
| 442 | + return beginAction(resourceGroupName, resourceLroNoBodyName, context).getFinalResult(); |
| 443 | + } |
264 | 444 | } |
0 commit comments