-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Porting fix from autorest.java (#4371)
Azure/autorest.java#2943 Co-authored-by: Weidong Xu <weidxu@microsoft.com>
- Loading branch information
1 parent
a714eea
commit c6809aa
Showing
19 changed files
with
1,141 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
...test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// Code generated by Microsoft (R) TypeSpec Code Generator. | ||
|
||
package com.cadl.discriminatoredgecases; | ||
|
||
import com.azure.core.annotation.Generated; | ||
import com.azure.core.annotation.ReturnType; | ||
import com.azure.core.annotation.ServiceClient; | ||
import com.azure.core.annotation.ServiceMethod; | ||
import com.azure.core.exception.ClientAuthenticationException; | ||
import com.azure.core.exception.HttpResponseException; | ||
import com.azure.core.exception.ResourceModifiedException; | ||
import com.azure.core.exception.ResourceNotFoundException; | ||
import com.azure.core.http.rest.RequestOptions; | ||
import com.azure.core.http.rest.Response; | ||
import com.azure.core.util.BinaryData; | ||
import com.azure.core.util.FluxUtil; | ||
import com.cadl.discriminatoredgecases.implementation.DiscriminatorEdgeCasesClientImpl; | ||
import com.cadl.discriminatoredgecases.models.ChildWithAnotherDiscriminator; | ||
import com.cadl.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* Initializes a new instance of the asynchronous DiscriminatorEdgeCasesClient type. | ||
*/ | ||
@ServiceClient(builder = DiscriminatorEdgeCasesClientBuilder.class, isAsync = true) | ||
public final class DiscriminatorEdgeCasesAsyncClient { | ||
@Generated | ||
private final DiscriminatorEdgeCasesClientImpl serviceClient; | ||
|
||
/** | ||
* Initializes an instance of DiscriminatorEdgeCasesAsyncClient class. | ||
* | ||
* @param serviceClient the service client implementation. | ||
*/ | ||
@Generated | ||
DiscriminatorEdgeCasesAsyncClient(DiscriminatorEdgeCasesClientImpl serviceClient) { | ||
this.serviceClient = serviceClient; | ||
} | ||
|
||
/** | ||
* The getChildRequiredDiscrim operation. | ||
* <p><strong>Response Body Schema</strong></p> | ||
* | ||
* <pre>{@code | ||
* { | ||
* discriminator: String (Required) | ||
* aProperty: String (Required) | ||
* anotherProperty: String (Required) | ||
* } | ||
* }</pre> | ||
* | ||
* @param requestOptions The options to configure the HTTP request before HTTP client sends it. | ||
* @throws HttpResponseException thrown if the request is rejected by server. | ||
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. | ||
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. | ||
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. | ||
* @return the response body along with {@link Response} on successful completion of {@link Mono}. | ||
*/ | ||
@Generated | ||
@ServiceMethod(returns = ReturnType.SINGLE) | ||
public Mono<Response<BinaryData>> getChildRequiredDiscrimWithResponse(RequestOptions requestOptions) { | ||
return this.serviceClient.getChildRequiredDiscrimWithResponseAsync(requestOptions); | ||
} | ||
|
||
/** | ||
* The getChildNewDiscrim operation. | ||
* <p><strong>Response Body Schema</strong></p> | ||
* | ||
* <pre>{@code | ||
* { | ||
* discriminator: String (Required) | ||
* aProperty: String (Required) | ||
* differentDiscriminator: String (Required) | ||
* yetAnotherProperty: String (Required) | ||
* } | ||
* }</pre> | ||
* | ||
* @param requestOptions The options to configure the HTTP request before HTTP client sends it. | ||
* @throws HttpResponseException thrown if the request is rejected by server. | ||
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. | ||
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. | ||
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. | ||
* @return the response body along with {@link Response} on successful completion of {@link Mono}. | ||
*/ | ||
@Generated | ||
@ServiceMethod(returns = ReturnType.SINGLE) | ||
public Mono<Response<BinaryData>> getChildNewDiscrimWithResponse(RequestOptions requestOptions) { | ||
return this.serviceClient.getChildNewDiscrimWithResponseAsync(requestOptions); | ||
} | ||
|
||
/** | ||
* The getChildRequiredDiscrim operation. | ||
* | ||
* @throws HttpResponseException thrown if the request is rejected by server. | ||
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. | ||
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. | ||
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. | ||
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. | ||
* @return the response body on successful completion of {@link Mono}. | ||
*/ | ||
@Generated | ||
@ServiceMethod(returns = ReturnType.SINGLE) | ||
public Mono<ChildWithRequiredPropertyAsDiscriminator> getChildRequiredDiscrim() { | ||
// Generated convenience method for getChildRequiredDiscrimWithResponse | ||
RequestOptions requestOptions = new RequestOptions(); | ||
return getChildRequiredDiscrimWithResponse(requestOptions).flatMap(FluxUtil::toMono) | ||
.map(protocolMethodData -> protocolMethodData.toObject(ChildWithRequiredPropertyAsDiscriminator.class)); | ||
} | ||
|
||
/** | ||
* The getChildNewDiscrim operation. | ||
* | ||
* @throws HttpResponseException thrown if the request is rejected by server. | ||
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. | ||
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. | ||
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. | ||
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. | ||
* @return the response body on successful completion of {@link Mono}. | ||
*/ | ||
@Generated | ||
@ServiceMethod(returns = ReturnType.SINGLE) | ||
public Mono<ChildWithAnotherDiscriminator> getChildNewDiscrim() { | ||
// Generated convenience method for getChildNewDiscrimWithResponse | ||
RequestOptions requestOptions = new RequestOptions(); | ||
return getChildNewDiscrimWithResponse(requestOptions).flatMap(FluxUtil::toMono) | ||
.map(protocolMethodData -> protocolMethodData.toObject(ChildWithAnotherDiscriminator.class)); | ||
} | ||
} |
127 changes: 127 additions & 0 deletions
127
...ator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// Code generated by Microsoft (R) TypeSpec Code Generator. | ||
|
||
package com.cadl.discriminatoredgecases; | ||
|
||
import com.azure.core.annotation.Generated; | ||
import com.azure.core.annotation.ReturnType; | ||
import com.azure.core.annotation.ServiceClient; | ||
import com.azure.core.annotation.ServiceMethod; | ||
import com.azure.core.exception.ClientAuthenticationException; | ||
import com.azure.core.exception.HttpResponseException; | ||
import com.azure.core.exception.ResourceModifiedException; | ||
import com.azure.core.exception.ResourceNotFoundException; | ||
import com.azure.core.http.rest.RequestOptions; | ||
import com.azure.core.http.rest.Response; | ||
import com.azure.core.util.BinaryData; | ||
import com.cadl.discriminatoredgecases.implementation.DiscriminatorEdgeCasesClientImpl; | ||
import com.cadl.discriminatoredgecases.models.ChildWithAnotherDiscriminator; | ||
import com.cadl.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator; | ||
|
||
/** | ||
* Initializes a new instance of the synchronous DiscriminatorEdgeCasesClient type. | ||
*/ | ||
@ServiceClient(builder = DiscriminatorEdgeCasesClientBuilder.class) | ||
public final class DiscriminatorEdgeCasesClient { | ||
@Generated | ||
private final DiscriminatorEdgeCasesClientImpl serviceClient; | ||
|
||
/** | ||
* Initializes an instance of DiscriminatorEdgeCasesClient class. | ||
* | ||
* @param serviceClient the service client implementation. | ||
*/ | ||
@Generated | ||
DiscriminatorEdgeCasesClient(DiscriminatorEdgeCasesClientImpl serviceClient) { | ||
this.serviceClient = serviceClient; | ||
} | ||
|
||
/** | ||
* The getChildRequiredDiscrim operation. | ||
* <p><strong>Response Body Schema</strong></p> | ||
* | ||
* <pre>{@code | ||
* { | ||
* discriminator: String (Required) | ||
* aProperty: String (Required) | ||
* anotherProperty: String (Required) | ||
* } | ||
* }</pre> | ||
* | ||
* @param requestOptions The options to configure the HTTP request before HTTP client sends it. | ||
* @throws HttpResponseException thrown if the request is rejected by server. | ||
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. | ||
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. | ||
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. | ||
* @return the response body along with {@link Response}. | ||
*/ | ||
@Generated | ||
@ServiceMethod(returns = ReturnType.SINGLE) | ||
public Response<BinaryData> getChildRequiredDiscrimWithResponse(RequestOptions requestOptions) { | ||
return this.serviceClient.getChildRequiredDiscrimWithResponse(requestOptions); | ||
} | ||
|
||
/** | ||
* The getChildNewDiscrim operation. | ||
* <p><strong>Response Body Schema</strong></p> | ||
* | ||
* <pre>{@code | ||
* { | ||
* discriminator: String (Required) | ||
* aProperty: String (Required) | ||
* differentDiscriminator: String (Required) | ||
* yetAnotherProperty: String (Required) | ||
* } | ||
* }</pre> | ||
* | ||
* @param requestOptions The options to configure the HTTP request before HTTP client sends it. | ||
* @throws HttpResponseException thrown if the request is rejected by server. | ||
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. | ||
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. | ||
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. | ||
* @return the response body along with {@link Response}. | ||
*/ | ||
@Generated | ||
@ServiceMethod(returns = ReturnType.SINGLE) | ||
public Response<BinaryData> getChildNewDiscrimWithResponse(RequestOptions requestOptions) { | ||
return this.serviceClient.getChildNewDiscrimWithResponse(requestOptions); | ||
} | ||
|
||
/** | ||
* The getChildRequiredDiscrim operation. | ||
* | ||
* @throws HttpResponseException thrown if the request is rejected by server. | ||
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. | ||
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. | ||
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. | ||
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. | ||
* @return the response. | ||
*/ | ||
@Generated | ||
@ServiceMethod(returns = ReturnType.SINGLE) | ||
public ChildWithRequiredPropertyAsDiscriminator getChildRequiredDiscrim() { | ||
// Generated convenience method for getChildRequiredDiscrimWithResponse | ||
RequestOptions requestOptions = new RequestOptions(); | ||
return getChildRequiredDiscrimWithResponse(requestOptions).getValue() | ||
.toObject(ChildWithRequiredPropertyAsDiscriminator.class); | ||
} | ||
|
||
/** | ||
* The getChildNewDiscrim operation. | ||
* | ||
* @throws HttpResponseException thrown if the request is rejected by server. | ||
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. | ||
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. | ||
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. | ||
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. | ||
* @return the response. | ||
*/ | ||
@Generated | ||
@ServiceMethod(returns = ReturnType.SINGLE) | ||
public ChildWithAnotherDiscriminator getChildNewDiscrim() { | ||
// Generated convenience method for getChildNewDiscrimWithResponse | ||
RequestOptions requestOptions = new RequestOptions(); | ||
return getChildNewDiscrimWithResponse(requestOptions).getValue().toObject(ChildWithAnotherDiscriminator.class); | ||
} | ||
} |
Oops, something went wrong.