Skip to content

Commit bed7927

Browse files
tsp, fix Generate.ps1 script (#3123)
1 parent 5a14b2f commit bed7927

26 files changed

Lines changed: 1684 additions & 5 deletions

File tree

azure-tests/src/main/java/fixtures/azureparametergrouping/ParameterGroupings.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,12 @@ public Mono<Response<Void>> postMultiParamGroupsWithResponseAsync(FirstParameter
526526
return Mono
527527
.error(new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null."));
528528
}
529-
if (firstParameterGroup != null) {
530-
firstParameterGroup.validate();
531-
}
532529
if (parameterGroupingPostMultiParamGroupsSecondParamGroup != null) {
533530
parameterGroupingPostMultiParamGroupsSecondParamGroup.validate();
534531
}
532+
if (firstParameterGroup != null) {
533+
firstParameterGroup.validate();
534+
}
535535
final String accept = "application/json";
536536
String headerOneInternal = null;
537537
if (firstParameterGroup != null) {

core

Submodule core updated 94 files

extension-base/src/main/java/com/azure/autorest/extension/base/plugin/JavaSettings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,12 @@ public boolean isAndroid() {
16901690

16911691
private final boolean useEclipseLanguageServer;
16921692

1693+
/**
1694+
* If there is Postprocessor code customizations to run, this determines whether to use the Eclipse Language
1695+
* Server to run the code customizations.
1696+
*
1697+
* @return Whether to use the Eclipse Language Server to run the code customizations.
1698+
*/
16931699
public boolean isUseEclipseLanguageServer() {
16941700
return useEclipseLanguageServer;
16951701
}

typespec-tests/Generate.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ $generateScript = {
7373
$tspOptions += " --option ""@azure-tools/typespec-java.service-version-exclude-preview=true"""
7474
# enable sync-stack
7575
$tspOptions += " --option ""@azure-tools/typespec-java.enable-sync-stack=true"""
76+
# rename model
77+
$tspOptions += " --option ""@azure-tools/typespec-java.rename-model=TopLevelArmResourceListResult:ResourceListResult,CustomTemplateResourcePropertiesAnonymousEmptyModel:AnonymousEmptyModel"""
7678
} elseif ($tspFile -match "arm-stream-style-serialization.tsp") {
7779
# for mgmt, do not generate tests due to random mock values
7880
$tspOptions += " --option ""@azure-tools/typespec-java.generate-tests=false"""

typespec-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@typespec/spec-api": "0.1.0-alpha.6",
1313
"@typespec/spector": "0.1.0-alpha.14",
1414
"@typespec/http-specs": "0.1.0-alpha.22",
15-
"@azure-tools/azure-http-specs": "0.1.0-alpha.17",
15+
"@azure-tools/azure-http-specs": "0.1.0-alpha.18",
1616
"@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.31.0.tgz"
1717
},
1818
"devDependencies": {
Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
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 azure.resourcemanager.largeheader;
6+
7+
import azure.resourcemanager.largeheader.fluent.LargeHeaderClient;
8+
import azure.resourcemanager.largeheader.implementation.LargeHeaderClientBuilder;
9+
import azure.resourcemanager.largeheader.implementation.LargeHeadersImpl;
10+
import azure.resourcemanager.largeheader.models.LargeHeaders;
11+
import com.azure.core.credential.TokenCredential;
12+
import com.azure.core.http.HttpClient;
13+
import com.azure.core.http.HttpPipeline;
14+
import com.azure.core.http.HttpPipelineBuilder;
15+
import com.azure.core.http.HttpPipelinePosition;
16+
import com.azure.core.http.policy.AddDatePolicy;
17+
import com.azure.core.http.policy.AddHeadersFromContextPolicy;
18+
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
19+
import com.azure.core.http.policy.HttpLogOptions;
20+
import com.azure.core.http.policy.HttpLoggingPolicy;
21+
import com.azure.core.http.policy.HttpPipelinePolicy;
22+
import com.azure.core.http.policy.HttpPolicyProviders;
23+
import com.azure.core.http.policy.RequestIdPolicy;
24+
import com.azure.core.http.policy.RetryOptions;
25+
import com.azure.core.http.policy.RetryPolicy;
26+
import com.azure.core.http.policy.UserAgentPolicy;
27+
import com.azure.core.management.profile.AzureProfile;
28+
import com.azure.core.util.Configuration;
29+
import com.azure.core.util.CoreUtils;
30+
import com.azure.core.util.logging.ClientLogger;
31+
import java.time.Duration;
32+
import java.time.temporal.ChronoUnit;
33+
import java.util.ArrayList;
34+
import java.util.List;
35+
import java.util.Map;
36+
import java.util.Objects;
37+
import java.util.stream.Collectors;
38+
39+
/**
40+
* Entry point to LargeHeaderManager.
41+
* Arm Resource Provider management API.
42+
*/
43+
public final class LargeHeaderManager {
44+
private LargeHeaders largeHeaders;
45+
46+
private final LargeHeaderClient clientObject;
47+
48+
private LargeHeaderManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) {
49+
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
50+
Objects.requireNonNull(profile, "'profile' cannot be null.");
51+
this.clientObject = new LargeHeaderClientBuilder().pipeline(httpPipeline)
52+
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
53+
.subscriptionId(profile.getSubscriptionId())
54+
.defaultPollInterval(defaultPollInterval)
55+
.buildClient();
56+
}
57+
58+
/**
59+
* Creates an instance of LargeHeader service API entry point.
60+
*
61+
* @param credential the credential to use.
62+
* @param profile the Azure profile for client.
63+
* @return the LargeHeader service API instance.
64+
*/
65+
public static LargeHeaderManager authenticate(TokenCredential credential, AzureProfile profile) {
66+
Objects.requireNonNull(credential, "'credential' cannot be null.");
67+
Objects.requireNonNull(profile, "'profile' cannot be null.");
68+
return configure().authenticate(credential, profile);
69+
}
70+
71+
/**
72+
* Creates an instance of LargeHeader service API entry point.
73+
*
74+
* @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential.
75+
* @param profile the Azure profile for client.
76+
* @return the LargeHeader service API instance.
77+
*/
78+
public static LargeHeaderManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
79+
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
80+
Objects.requireNonNull(profile, "'profile' cannot be null.");
81+
return new LargeHeaderManager(httpPipeline, profile, null);
82+
}
83+
84+
/**
85+
* Gets a Configurable instance that can be used to create LargeHeaderManager with optional configuration.
86+
*
87+
* @return the Configurable instance allowing configurations.
88+
*/
89+
public static Configurable configure() {
90+
return new LargeHeaderManager.Configurable();
91+
}
92+
93+
/**
94+
* The Configurable allowing configurations to be set.
95+
*/
96+
public static final class Configurable {
97+
private static final ClientLogger LOGGER = new ClientLogger(Configurable.class);
98+
private static final String SDK_VERSION = "version";
99+
private static final Map<String, String> PROPERTIES
100+
= CoreUtils.getProperties("azure-resourcemanager-largeheader-generated.properties");
101+
102+
private HttpClient httpClient;
103+
private HttpLogOptions httpLogOptions;
104+
private final List<HttpPipelinePolicy> policies = new ArrayList<>();
105+
private final List<String> scopes = new ArrayList<>();
106+
private RetryPolicy retryPolicy;
107+
private RetryOptions retryOptions;
108+
private Duration defaultPollInterval;
109+
110+
private Configurable() {
111+
}
112+
113+
/**
114+
* Sets the http client.
115+
*
116+
* @param httpClient the HTTP client.
117+
* @return the configurable object itself.
118+
*/
119+
public Configurable withHttpClient(HttpClient httpClient) {
120+
this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null.");
121+
return this;
122+
}
123+
124+
/**
125+
* Sets the logging options to the HTTP pipeline.
126+
*
127+
* @param httpLogOptions the HTTP log options.
128+
* @return the configurable object itself.
129+
*/
130+
public Configurable withLogOptions(HttpLogOptions httpLogOptions) {
131+
this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null.");
132+
return this;
133+
}
134+
135+
/**
136+
* Adds the pipeline policy to the HTTP pipeline.
137+
*
138+
* @param policy the HTTP pipeline policy.
139+
* @return the configurable object itself.
140+
*/
141+
public Configurable withPolicy(HttpPipelinePolicy policy) {
142+
this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null."));
143+
return this;
144+
}
145+
146+
/**
147+
* Adds the scope to permission sets.
148+
*
149+
* @param scope the scope.
150+
* @return the configurable object itself.
151+
*/
152+
public Configurable withScope(String scope) {
153+
this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null."));
154+
return this;
155+
}
156+
157+
/**
158+
* Sets the retry policy to the HTTP pipeline.
159+
*
160+
* @param retryPolicy the HTTP pipeline retry policy.
161+
* @return the configurable object itself.
162+
*/
163+
public Configurable withRetryPolicy(RetryPolicy retryPolicy) {
164+
this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null.");
165+
return this;
166+
}
167+
168+
/**
169+
* Sets the retry options for the HTTP pipeline retry policy.
170+
* <p>
171+
* This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}.
172+
*
173+
* @param retryOptions the retry options for the HTTP pipeline retry policy.
174+
* @return the configurable object itself.
175+
*/
176+
public Configurable withRetryOptions(RetryOptions retryOptions) {
177+
this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null.");
178+
return this;
179+
}
180+
181+
/**
182+
* Sets the default poll interval, used when service does not provide "Retry-After" header.
183+
*
184+
* @param defaultPollInterval the default poll interval.
185+
* @return the configurable object itself.
186+
*/
187+
public Configurable withDefaultPollInterval(Duration defaultPollInterval) {
188+
this.defaultPollInterval
189+
= Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null.");
190+
if (this.defaultPollInterval.isNegative()) {
191+
throw LOGGER
192+
.logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative"));
193+
}
194+
return this;
195+
}
196+
197+
/**
198+
* Creates an instance of LargeHeader service API entry point.
199+
*
200+
* @param credential the credential to use.
201+
* @param profile the Azure profile for client.
202+
* @return the LargeHeader service API instance.
203+
*/
204+
public LargeHeaderManager authenticate(TokenCredential credential, AzureProfile profile) {
205+
Objects.requireNonNull(credential, "'credential' cannot be null.");
206+
Objects.requireNonNull(profile, "'profile' cannot be null.");
207+
208+
String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion");
209+
210+
StringBuilder userAgentBuilder = new StringBuilder();
211+
userAgentBuilder.append("azsdk-java")
212+
.append("-")
213+
.append("azure.resourcemanager.largeheader")
214+
.append("/")
215+
.append(clientVersion);
216+
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
217+
userAgentBuilder.append(" (")
218+
.append(Configuration.getGlobalConfiguration().get("java.version"))
219+
.append("; ")
220+
.append(Configuration.getGlobalConfiguration().get("os.name"))
221+
.append("; ")
222+
.append(Configuration.getGlobalConfiguration().get("os.version"))
223+
.append("; auto-generated)");
224+
} else {
225+
userAgentBuilder.append(" (auto-generated)");
226+
}
227+
228+
if (scopes.isEmpty()) {
229+
scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default");
230+
}
231+
if (retryPolicy == null) {
232+
if (retryOptions != null) {
233+
retryPolicy = new RetryPolicy(retryOptions);
234+
} else {
235+
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
236+
}
237+
}
238+
List<HttpPipelinePolicy> policies = new ArrayList<>();
239+
policies.add(new UserAgentPolicy(userAgentBuilder.toString()));
240+
policies.add(new AddHeadersFromContextPolicy());
241+
policies.add(new RequestIdPolicy());
242+
policies.addAll(this.policies.stream()
243+
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
244+
.collect(Collectors.toList()));
245+
HttpPolicyProviders.addBeforeRetryPolicies(policies);
246+
policies.add(retryPolicy);
247+
policies.add(new AddDatePolicy());
248+
policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0])));
249+
policies.addAll(this.policies.stream()
250+
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
251+
.collect(Collectors.toList()));
252+
HttpPolicyProviders.addAfterRetryPolicies(policies);
253+
policies.add(new HttpLoggingPolicy(httpLogOptions));
254+
HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient)
255+
.policies(policies.toArray(new HttpPipelinePolicy[0]))
256+
.build();
257+
return new LargeHeaderManager(httpPipeline, profile, defaultPollInterval);
258+
}
259+
}
260+
261+
/**
262+
* Gets the resource collection API of LargeHeaders.
263+
*
264+
* @return Resource collection API of LargeHeaders.
265+
*/
266+
public LargeHeaders largeHeaders() {
267+
if (this.largeHeaders == null) {
268+
this.largeHeaders = new LargeHeadersImpl(clientObject.getLargeHeaders(), this);
269+
}
270+
return largeHeaders;
271+
}
272+
273+
/**
274+
* Gets wrapped service client LargeHeaderClient providing direct access to the underlying auto-generated API
275+
* implementation, based on Azure REST API.
276+
*
277+
* @return Wrapped service client LargeHeaderClient.
278+
*/
279+
public LargeHeaderClient serviceClient() {
280+
return this.clientObject;
281+
}
282+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 azure.resourcemanager.largeheader.fluent;
6+
7+
import com.azure.core.http.HttpPipeline;
8+
import java.time.Duration;
9+
10+
/**
11+
* The interface for LargeHeaderClient class.
12+
*/
13+
public interface LargeHeaderClient {
14+
/**
15+
* Gets Service host.
16+
*
17+
* @return the endpoint value.
18+
*/
19+
String getEndpoint();
20+
21+
/**
22+
* Gets Version parameter.
23+
*
24+
* @return the apiVersion value.
25+
*/
26+
String getApiVersion();
27+
28+
/**
29+
* Gets The ID of the target subscription. The value must be an UUID.
30+
*
31+
* @return the subscriptionId value.
32+
*/
33+
String getSubscriptionId();
34+
35+
/**
36+
* Gets The HTTP pipeline to send requests through.
37+
*
38+
* @return the httpPipeline value.
39+
*/
40+
HttpPipeline getHttpPipeline();
41+
42+
/**
43+
* Gets The default poll interval for long-running operation.
44+
*
45+
* @return the defaultPollInterval value.
46+
*/
47+
Duration getDefaultPollInterval();
48+
49+
/**
50+
* Gets the LargeHeadersClient object to access its operations.
51+
*
52+
* @return the LargeHeadersClient object.
53+
*/
54+
LargeHeadersClient getLargeHeaders();
55+
}

0 commit comments

Comments
 (0)