|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | +// Code generated by Microsoft (R) TypeSpec Code Generator. |
| 4 | + |
| 5 | +package tsptest.clientoption; |
| 6 | + |
| 7 | +import com.azure.core.annotation.Generated; |
| 8 | +import com.azure.core.annotation.ReturnType; |
| 9 | +import com.azure.core.annotation.ServiceClient; |
| 10 | +import com.azure.core.annotation.ServiceMethod; |
| 11 | +import com.azure.core.exception.ClientAuthenticationException; |
| 12 | +import com.azure.core.exception.HttpResponseException; |
| 13 | +import com.azure.core.exception.ResourceModifiedException; |
| 14 | +import com.azure.core.exception.ResourceNotFoundException; |
| 15 | +import com.azure.core.http.rest.RequestOptions; |
| 16 | +import com.azure.core.http.rest.Response; |
| 17 | +import com.azure.core.util.BinaryData; |
| 18 | +import com.azure.core.util.FluxUtil; |
| 19 | +import reactor.core.publisher.Mono; |
| 20 | +import tsptest.clientoption.implementation.ClientRequiredsImpl; |
| 21 | +import tsptest.clientoption.models.ClientRequiredRequest; |
| 22 | + |
| 23 | +/** |
| 24 | + * Initializes a new instance of the asynchronous ClientOptionClient type. |
| 25 | + */ |
| 26 | +@ServiceClient(builder = ClientOptionClientBuilder.class, isAsync = true) |
| 27 | +public final class ClientOptionAsyncClient { |
| 28 | + @Generated |
| 29 | + private final ClientRequiredsImpl serviceClient; |
| 30 | + |
| 31 | + /** |
| 32 | + * Initializes an instance of ClientOptionAsyncClient class. |
| 33 | + * |
| 34 | + * @param serviceClient the service client implementation. |
| 35 | + */ |
| 36 | + @Generated |
| 37 | + ClientOptionAsyncClient(ClientRequiredsImpl serviceClient) { |
| 38 | + this.serviceClient = serviceClient; |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * The post operation. |
| 43 | + * <p><strong>Query Parameters</strong></p> |
| 44 | + * <table border="1"> |
| 45 | + * <caption>Query Parameters</caption> |
| 46 | + * <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr> |
| 47 | + * <tr><td>filter</td><td>String</td><td>No</td><td>The filter parameter</td></tr> |
| 48 | + * </table> |
| 49 | + * You can add these to a request with {@link RequestOptions#addQueryParam} |
| 50 | + * <p><strong>Request Body Schema</strong></p> |
| 51 | + * |
| 52 | + * <pre> |
| 53 | + * {@code |
| 54 | + * { |
| 55 | + * name: String (Required) |
| 56 | + * timespan: Duration (Required) |
| 57 | + * } |
| 58 | + * } |
| 59 | + * </pre> |
| 60 | + * |
| 61 | + * @param body The body parameter. |
| 62 | + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. |
| 63 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 64 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 65 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 66 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 67 | + * @return the {@link Response} on successful completion of {@link Mono}. |
| 68 | + */ |
| 69 | + @Generated |
| 70 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 71 | + public Mono<Response<Void>> postWithResponse(BinaryData body, RequestOptions requestOptions) { |
| 72 | + return this.serviceClient.postWithResponseAsync(body, requestOptions); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * The post operation. |
| 77 | + * |
| 78 | + * @param body The body parameter. |
| 79 | + * @param filter The filter parameter. |
| 80 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 81 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 82 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 83 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 84 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 85 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 86 | + * @return A {@link Mono} that completes when a successful response is received. |
| 87 | + */ |
| 88 | + @Generated |
| 89 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 90 | + public Mono<Void> post(ClientRequiredRequest body, String filter) { |
| 91 | + // Generated convenience method for postWithResponse |
| 92 | + RequestOptions requestOptions = new RequestOptions(); |
| 93 | + if (filter != null) { |
| 94 | + requestOptions.addQueryParam("filter", filter, false); |
| 95 | + } |
| 96 | + return postWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * The post operation. |
| 101 | + * |
| 102 | + * @param body The body parameter. |
| 103 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 104 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 105 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 106 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 107 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 108 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 109 | + * @return A {@link Mono} that completes when a successful response is received. |
| 110 | + */ |
| 111 | + @Generated |
| 112 | + @ServiceMethod(returns = ReturnType.SINGLE) |
| 113 | + public Mono<Void> post(ClientRequiredRequest body) { |
| 114 | + // Generated convenience method for postWithResponse |
| 115 | + RequestOptions requestOptions = new RequestOptions(); |
| 116 | + return postWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono); |
| 117 | + } |
| 118 | +} |
0 commit comments