Skip to content

Commit

Permalink
http-client-java, pageable for unbranded (#5551)
Browse files Browse the repository at this point in the history
depends on Azure/azure-sdk-for-java#43484 and
release of clientcore beta.2

back to draft: there is lots of changes to clientcore right now

test
827f4ec
code is scattered as there is multiple commits to adapt core changes
  • Loading branch information
weidongxu-microsoft authored Jan 20, 2025
1 parent eefc06e commit 04182d2
Show file tree
Hide file tree
Showing 65 changed files with 295 additions and 196 deletions.
5 changes: 0 additions & 5 deletions packages/http-client-java/emitter/src/code-model-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,11 +966,6 @@ export class CodeModelBuilder {
responses: SdkHttpResponse[],
sdkMethod: SdkMethod<SdkHttpOperation>,
) {
if (!this.isBranded()) {
// TODO: currently unbranded does not support paged operation
return;
}

if (sdkMethod.kind === "paging" || sdkMethod.kind === "lropaging") {
for (const response of responses) {
const bodyType = response.type;
Expand Down
4 changes: 2 additions & 2 deletions packages/http-client-java/emitter/src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CodeModelBuilder } from "./code-model-builder.js";
import { CodeModel } from "./common/code-model.js";
import { logError, spawnAsync, SpawnError } from "./utils.js";
import {
CODE_RUNTIME_DEPENDENCY,
CODE_JAVA_SDK_DEPENDENCY,
JDK_NOT_FOUND_MESSAGE,
validateDependencies,
} from "./validate.js";
Expand Down Expand Up @@ -197,7 +197,7 @@ export async function $onEmit(context: EmitContext<EmitterOptions>) {
program.trace("http-client-java", `Code generation log: ${result.stdout}`);
} catch (error: any) {
if (error && "code" in error && error["code"] === "ENOENT") {
logError(program, JDK_NOT_FOUND_MESSAGE, CODE_RUNTIME_DEPENDENCY);
logError(program, JDK_NOT_FOUND_MESSAGE, CODE_JAVA_SDK_DEPENDENCY);
} else {
logError(
program,
Expand Down
8 changes: 4 additions & 4 deletions packages/http-client-java/emitter/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { logError, spawnAsync, trace } from "./utils.js";

export const JDK_NOT_FOUND_MESSAGE =
"Java Development Kit (JDK) is not found in PATH. Please install JDK 17 or above. Microsoft Build of OpenJDK can be downloaded from https://learn.microsoft.com/java/openjdk/download";
export const CODE_RUNTIME_DEPENDENCY = "invalid-runtime-dependency";
export const CODE_JAVA_SDK_DEPENDENCY = "invalid-java-sdk-dependency";

export async function validateDependencies(
program: Program | undefined,
Expand All @@ -25,7 +25,7 @@ export async function validateDependencies(
// // eslint-disable-next-line no-console
// console.log("[ERROR] " + message);
if (program && logDiagnostic) {
logError(program, message, CODE_RUNTIME_DEPENDENCY);
logError(program, message, CODE_JAVA_SDK_DEPENDENCY);
}
}
}
Expand All @@ -37,7 +37,7 @@ export async function validateDependencies(
// // eslint-disable-next-line no-console
// console.log("[ERROR] " + message);
if (program && logDiagnostic) {
logError(program, message, CODE_RUNTIME_DEPENDENCY);
logError(program, message, CODE_JAVA_SDK_DEPENDENCY);
}
}

Expand All @@ -61,7 +61,7 @@ export async function validateDependencies(
// // eslint-disable-next-line no-console
// console.log("[ERROR] " + message);
if (program && logDiagnostic) {
logError(program, message, CODE_RUNTIME_DEPENDENCY);
logError(program, message, CODE_JAVA_SDK_DEPENDENCY);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@typespec/http-specs": "0.1.0-alpha.7",
"@typespec/http-client-java": "file:../../typespec-http-client-java-0.1.7.tgz",
"@typespec/http-client-java": "file:../../typespec-http-client-java-0.1.8.tgz",
"@typespec/http-client-java-tests": "file:"
},
"overrides": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>io.clientcore</groupId>
<artifactId>core</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0-beta.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.http.pipeline.KeyCredentialPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.KeyCredentialTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -244,7 +244,7 @@ private HttpPipeline createHttpPipeline() {
if (keyCredential != null) {
policies.add(new KeyCredentialPolicy("x-ms-api-key", keyCredential, null));
}
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.http.pipeline.KeyCredentialPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.KeyCredentialTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -244,7 +244,7 @@ private HttpPipeline createHttpPipeline() {
if (keyCredential != null) {
policies.add(new KeyCredentialPolicy("authorization", keyCredential, "SharedAccessKey"));
}
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.http.pipeline.KeyCredentialPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.KeyCredentialTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -244,7 +244,7 @@ private HttpPipeline createHttpPipeline() {
if (keyCredential != null) {
policies.add(new KeyCredentialPolicy("authorization", keyCredential, "Bearer"));
}
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.http.pipeline.KeyCredentialPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.KeyCredentialTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -243,7 +243,7 @@ private HttpPipeline createHttpPipeline() {
if (keyCredential != null) {
policies.add(new KeyCredentialPolicy("authorization", keyCredential, "Bearer"));
}
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -221,7 +221,7 @@ private HttpPipeline createHttpPipeline() {
policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions));
policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions));
this.pipelinePolicies.stream().forEach(p -> policies.add(p));
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -221,7 +221,7 @@ private HttpPipeline createHttpPipeline() {
policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions));
policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions));
this.pipelinePolicies.stream().forEach(p -> policies.add(p));
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -222,7 +222,7 @@ private HttpPipeline createHttpPipeline() {
policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions));
policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions));
this.pipelinePolicies.stream().forEach(p -> policies.add(p));
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -222,7 +222,7 @@ private HttpPipeline createHttpPipeline() {
policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions));
policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions));
this.pipelinePolicies.stream().forEach(p -> policies.add(p));
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -221,7 +221,7 @@ private HttpPipeline createHttpPipeline() {
policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions));
policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions));
this.pipelinePolicies.stream().forEach(p -> policies.add(p));
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import io.clientcore.core.http.models.HttpRedirectOptions;
import io.clientcore.core.http.models.HttpRetryOptions;
import io.clientcore.core.http.models.ProxyOptions;
import io.clientcore.core.http.pipeline.HttpLoggingPolicy;
import io.clientcore.core.http.pipeline.HttpInstrumentationPolicy;
import io.clientcore.core.http.pipeline.HttpPipeline;
import io.clientcore.core.http.pipeline.HttpPipelineBuilder;
import io.clientcore.core.http.pipeline.HttpPipelinePolicy;
import io.clientcore.core.http.pipeline.HttpRedirectPolicy;
import io.clientcore.core.http.pipeline.HttpRetryPolicy;
import io.clientcore.core.instrumentation.logging.ClientLogger;
import io.clientcore.core.models.traits.ConfigurationTrait;
import io.clientcore.core.models.traits.EndpointTrait;
import io.clientcore.core.models.traits.HttpTrait;
import io.clientcore.core.models.traits.ProxyTrait;
import io.clientcore.core.util.ClientLogger;
import io.clientcore.core.util.configuration.Configuration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -222,7 +222,7 @@ private HttpPipeline createHttpPipeline() {
policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions));
policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions));
this.pipelinePolicies.stream().forEach(p -> policies.add(p));
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
policies.add(new HttpInstrumentationPolicy(null, localHttpLogOptions));
httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
return httpPipelineBuilder.build();
}
Expand Down
Loading

0 comments on commit 04182d2

Please sign in to comment.