Skip to content

Commit

Permalink
http-client-java, update cadl-ranch, handle TCGC multipart logic (#4352)
Browse files Browse the repository at this point in the history
pending issue at Azure/typespec-azure#1488
  • Loading branch information
weidongxu-microsoft authored Sep 6, 2024
1 parent f329e03 commit 7219aa4
Show file tree
Hide file tree
Showing 123 changed files with 13,992 additions and 819 deletions.
13 changes: 1 addition & 12 deletions packages/http-client-java/Setup.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
param (
[switch] $RebuildJar = $false
)

if ($RebuildJar) {
mvn clean install -f generator/pom.xml -DskipTests
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}

# re-build http-client-java
npm install
npm run clean && npm run build

npm pack
9 changes: 9 additions & 0 deletions packages/http-client-java/emitter/src/code-model-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,15 @@ export class CodeModelBuilder {
// TODO: handle MultipartOptions.isMulti
if (prop.multipartOptions.isFilePart) {
schema = this.processMultipartFormDataFilePropertySchemaFromSdkType(prop);
} else if (
prop.type.kind === "model" &&
prop.type.properties.some((it) => it.kind === "body")
) {
// TODO: this is HttpPart of non-File. TCGC should help handle this.
schema = this.processSchemaFromSdkType(
prop.type.properties.find((it) => it.kind === "body")!.type,
""
);
} else {
schema = this.processSchemaFromSdkType(nonNullType, "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ Set-Location ./generator/http-client-generator-test


if (Test-Path node_modules) {
Remove-Item node_modules -Recurse -Force
Remove-Item node_modules -Recurse -Force
}

if (Test-Path package-lock.json) {
Remove-Item package-lock.json
Remove-Item package-lock.json
}

# delete output
if (Test-Path tsp-output) {
Remove-Item tsp-output -Recurse -Force
Remove-Item tsp-output -Recurse -Force
}
npm install

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"testserver-stop": "npx cadl-ranch server stop"
},
"dependencies": {
"@azure-tools/cadl-ranch-specs": "0.36.1",
"@azure-tools/cadl-ranch-specs": "0.37.1",
"@typespec/http-client-java": "file:/../../typespec-http-client-java-0.1.0.tgz",
"@typespec/http-client-java-tests": "file:"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.clientgenerator.core.flattenproperty;
package com._specs_.azure.clientgenerator.core.flattenproperty;

import com.azure.clientgenerator.core.flattenproperty.implementation.FlattenPropertyClientImpl;
import com.azure.clientgenerator.core.flattenproperty.models.FlattenModel;
import com.azure.clientgenerator.core.flattenproperty.models.NestedFlattenModel;
import com._specs_.azure.clientgenerator.core.flattenproperty.implementation.FlattenPropertyClientImpl;
import com._specs_.azure.clientgenerator.core.flattenproperty.models.FlattenModel;
import com._specs_.azure.clientgenerator.core.flattenproperty.models.NestedFlattenModel;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.clientgenerator.core.flattenproperty;
package com._specs_.azure.clientgenerator.core.flattenproperty;

import com.azure.clientgenerator.core.flattenproperty.implementation.FlattenPropertyClientImpl;
import com.azure.clientgenerator.core.flattenproperty.models.FlattenModel;
import com.azure.clientgenerator.core.flattenproperty.models.NestedFlattenModel;
import com._specs_.azure.clientgenerator.core.flattenproperty.implementation.FlattenPropertyClientImpl;
import com._specs_.azure.clientgenerator.core.flattenproperty.models.FlattenModel;
import com._specs_.azure.clientgenerator.core.flattenproperty.models.NestedFlattenModel;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.clientgenerator.core.flattenproperty;
package com._specs_.azure.clientgenerator.core.flattenproperty;

import com.azure.clientgenerator.core.flattenproperty.implementation.FlattenPropertyClientImpl;
import com._specs_.azure.clientgenerator.core.flattenproperty.implementation.FlattenPropertyClientImpl;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.client.traits.ConfigurationTrait;
Expand Down Expand Up @@ -51,7 +51,7 @@ public final class FlattenPropertyClientBuilder implements HttpTrait<FlattenProp

@Generated
private static final Map<String, String> PROPERTIES
= CoreUtils.getProperties("azure-clientgenerator-core-flattenproperty.properties");
= CoreUtils.getProperties("_specs_-azure-clientgenerator-core-flattenproperty.properties");

@Generated
private final List<HttpPipelinePolicy> pipelinePolicies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.clientgenerator.core.flattenproperty.implementation;
package com._specs_.azure.clientgenerator.core.flattenproperty.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* Illustrates the model flatten cases.
* <!-- end generated doc -->
*/
package com.azure.clientgenerator.core.flattenproperty.implementation;
package com._specs_.azure.clientgenerator.core.flattenproperty.implementation;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.clientgenerator.core.flattenproperty.models;
package com._specs_.azure.clientgenerator.core.flattenproperty.models;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.Immutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.clientgenerator.core.flattenproperty.models;
package com._specs_.azure.clientgenerator.core.flattenproperty.models;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.Immutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.clientgenerator.core.flattenproperty.models;
package com._specs_.azure.clientgenerator.core.flattenproperty.models;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.Immutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.clientgenerator.core.flattenproperty.models;
package com._specs_.azure.clientgenerator.core.flattenproperty.models;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.Immutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* Illustrates the model flatten cases.
* <!-- end generated doc -->
*/
package com.azure.clientgenerator.core.flattenproperty.models;
package com._specs_.azure.clientgenerator.core.flattenproperty.models;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* Illustrates the model flatten cases.
* <!-- end generated doc -->
*/
package com.azure.clientgenerator.core.flattenproperty;
package com._specs_.azure.clientgenerator.core.flattenproperty;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com._specs_.azure.core.basic.implementation.BasicClientImpl;
import com._specs_.azure.core.basic.implementation.JsonMergePatchHelper;
import com._specs_.azure.core.basic.models.User;
import com._specs_.azure.core.basic.models.UserList;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand Down Expand Up @@ -295,6 +296,45 @@ public Mono<Response<BinaryData>> exportWithResponse(int id, String format, Requ
return this.serviceClient.exportWithResponseAsync(id, format, requestOptions);
}

/**
* Exports all users.
*
* Exports all users.
* <p><strong>Response Body Schema</strong></p>
*
* <pre>{@code
* {
* users (Required): [
* (Required){
* id: int (Required)
* name: String (Optional, Required on create)
* orders (Optional): [
* (Optional){
* id: int (Required)
* userId: int (Optional, Required on create)
* detail: String (Optional, Required on create)
* }
* ]
* etag: String (Required)
* }
* ]
* }
* }</pre>
*
* @param format The format of the data.
* @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>> exportAllUsersWithResponse(String format, RequestOptions requestOptions) {
return this.serviceClient.exportAllUsersWithResponseAsync(format, requestOptions);
}

/**
* Adds a user or updates a user's fields.
*
Expand Down Expand Up @@ -521,4 +561,27 @@ public Mono<User> export(int id, String format) {
return exportWithResponse(id, format, requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(User.class));
}

/**
* Exports all users.
*
* Exports all users.
*
* @param format The format of the data.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @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<UserList> exportAllUsers(String format) {
// Generated convenience method for exportAllUsersWithResponse
RequestOptions requestOptions = new RequestOptions();
return exportAllUsersWithResponse(format, requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(UserList.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com._specs_.azure.core.basic.implementation.BasicClientImpl;
import com._specs_.azure.core.basic.implementation.JsonMergePatchHelper;
import com._specs_.azure.core.basic.models.User;
import com._specs_.azure.core.basic.models.UserList;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand Down Expand Up @@ -288,6 +289,45 @@ public Response<BinaryData> exportWithResponse(int id, String format, RequestOpt
return this.serviceClient.exportWithResponse(id, format, requestOptions);
}

/**
* Exports all users.
*
* Exports all users.
* <p><strong>Response Body Schema</strong></p>
*
* <pre>{@code
* {
* users (Required): [
* (Required){
* id: int (Required)
* name: String (Optional, Required on create)
* orders (Optional): [
* (Optional){
* id: int (Required)
* userId: int (Optional, Required on create)
* detail: String (Optional, Required on create)
* }
* ]
* etag: String (Required)
* }
* ]
* }
* }</pre>
*
* @param format The format of the data.
* @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> exportAllUsersWithResponse(String format, RequestOptions requestOptions) {
return this.serviceClient.exportAllUsersWithResponse(format, requestOptions);
}

/**
* Adds a user or updates a user's fields.
*
Expand Down Expand Up @@ -485,4 +525,26 @@ public User export(int id, String format) {
RequestOptions requestOptions = new RequestOptions();
return exportWithResponse(id, format, requestOptions).getValue().toObject(User.class);
}

/**
* Exports all users.
*
* Exports all users.
*
* @param format The format of the data.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @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 UserList exportAllUsers(String format) {
// Generated convenience method for exportAllUsersWithResponse
RequestOptions requestOptions = new RequestOptions();
return exportAllUsersWithResponse(format, requestOptions).getValue().toObject(UserList.class);
}
}
Loading

0 comments on commit 7219aa4

Please sign in to comment.