Skip to content

Commit c5e58aa

Browse files
authored
mgmt, fix child with parent flatten (#3004)
* bump core * add fluent test * bump core * bump core * sync-test
1 parent 90d9987 commit c5e58aa

File tree

19 files changed

+1025
-2
lines changed

19 files changed

+1025
-2
lines changed

core

Submodule core updated 303 files

fluent-tests/Initialize-Tests.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ $job = @(
144144
# stream-style-serialization
145145
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=./swagger/stream-style-serialization.json --java.namespace=com.azure.mgmtlitetest.streamstyleserialization --stream-style-serialization=true"
146146

147+
# child model with flattened property from parent
148+
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=https://github.com/Azure/azure-rest-api-specs/blob/692cb8b5eb71505afa267cfbbee322d520eb15ff/specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/functions.json --java.namespace=com.azure.mgmtlitetest.streamanalytics --generate-tests=false"
149+
147150
# empty-model
148151
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=./swagger/empty-model.json --java.namespace=com.azure.mgmtlitetest.emptymodel"
149152

fluent-tests/src/test/java/com/azure/mgmttest/LiteCompilationTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.azure.mgmtlitetest.storage.models.StorageAccountListKeysResult;
4343
import com.azure.mgmtlitetest.storage.models.StorageAccountRegenerateKeyParameters;
4444
import com.azure.mgmtlitetest.storage.models.StorageAccounts;
45+
import com.azure.mgmtlitetest.streamanalytics.models.AggregateFunctionProperties;
4546
import com.azure.mgmtlitetest.streamstyleserialization.implementation.CommunityGalleriesClientImpl;
4647
import com.azure.mgmttest.azurestack.fluent.models.ExtendedProductInner;
4748
import com.azure.mgmttest.education.fluent.models.LabDetailsInner;
@@ -210,4 +211,8 @@ public void testPageableWithInheritance() {
210211
SavingsPlansClient savingsPlansClient = mock(SavingsPlansClient.class);
211212
PagedIterable<SavingsPlanModelInner> result = savingsPlansClient.listByBillingAccount("myBillingAccount");
212213
}
214+
215+
public void testChildWithParentFlattenedProperties() {
216+
AggregateFunctionProperties aggregateFunctionProperties = new AggregateFunctionProperties();
217+
}
213218
}

typespec-tests/src/main/java/tsptest/armstreamstyleserialization/ArmStreamStyleSerializationManager.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
import tsptest.armstreamstyleserialization.fluent.ArmStreamStyleSerializationClient;
3333
import tsptest.armstreamstyleserialization.implementation.ArmStreamStyleSerializationClientBuilder;
3434
import tsptest.armstreamstyleserialization.implementation.FishesImpl;
35+
import tsptest.armstreamstyleserialization.implementation.FunctionsImpl;
3536
import tsptest.armstreamstyleserialization.implementation.TopLevelArmResourcesImpl;
3637
import tsptest.armstreamstyleserialization.models.Fishes;
38+
import tsptest.armstreamstyleserialization.models.Functions;
3739
import tsptest.armstreamstyleserialization.models.TopLevelArmResources;
3840

3941
/**
@@ -45,6 +47,8 @@ public final class ArmStreamStyleSerializationManager {
4547

4648
private TopLevelArmResources topLevelArmResources;
4749

50+
private Functions functions;
51+
4852
private final ArmStreamStyleSerializationClient clientObject;
4953

5054
private ArmStreamStyleSerializationManager(HttpPipeline httpPipeline, AzureProfile profile,
@@ -281,6 +285,18 @@ public TopLevelArmResources topLevelArmResources() {
281285
return topLevelArmResources;
282286
}
283287

288+
/**
289+
* Gets the resource collection API of Functions.
290+
*
291+
* @return Resource collection API of Functions.
292+
*/
293+
public Functions functions() {
294+
if (this.functions == null) {
295+
this.functions = new FunctionsImpl(clientObject.getFunctions(), this);
296+
}
297+
return functions;
298+
}
299+
284300
/**
285301
* Gets wrapped service client ArmStreamStyleSerializationClient providing direct access to the underlying
286302
* auto-generated API implementation, based on Azure REST API.

typespec-tests/src/main/java/tsptest/armstreamstyleserialization/fluent/ArmStreamStyleSerializationClient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,11 @@ public interface ArmStreamStyleSerializationClient {
5959
* @return the TopLevelArmResourcesClient object.
6060
*/
6161
TopLevelArmResourcesClient getTopLevelArmResources();
62+
63+
/**
64+
* Gets the FunctionsClient object to access its operations.
65+
*
66+
* @return the FunctionsClient object.
67+
*/
68+
FunctionsClient getFunctions();
6269
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.armstreamstyleserialization.fluent;
6+
7+
import com.azure.core.annotation.ReturnType;
8+
import com.azure.core.annotation.ServiceMethod;
9+
import com.azure.core.http.rest.Response;
10+
import com.azure.core.util.Context;
11+
import tsptest.armstreamstyleserialization.fluent.models.FunctionInner;
12+
13+
/**
14+
* An instance of this class provides access to all the operations defined in FunctionsClient.
15+
*/
16+
public interface FunctionsClient {
17+
/**
18+
* The createFunction operation.
19+
*
20+
* @param function The function parameter.
21+
* @param context The context to associate with this operation.
22+
* @throws IllegalArgumentException thrown if parameters fail the validation.
23+
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
24+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
25+
* @return the response body along with {@link Response}.
26+
*/
27+
@ServiceMethod(returns = ReturnType.SINGLE)
28+
Response<FunctionInner> createFunctionWithResponse(FunctionInner function, Context context);
29+
30+
/**
31+
* The createFunction operation.
32+
*
33+
* @param function The function parameter.
34+
* @throws IllegalArgumentException thrown if parameters fail the validation.
35+
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
36+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
37+
* @return the response.
38+
*/
39+
@ServiceMethod(returns = ReturnType.SINGLE)
40+
FunctionInner createFunction(FunctionInner function);
41+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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.armstreamstyleserialization.fluent.models;
6+
7+
import com.azure.core.annotation.Fluent;
8+
import com.azure.json.JsonReader;
9+
import com.azure.json.JsonSerializable;
10+
import com.azure.json.JsonToken;
11+
import com.azure.json.JsonWriter;
12+
import java.io.IOException;
13+
14+
/**
15+
* The FunctionConfiguration model.
16+
*/
17+
@Fluent
18+
public final class FunctionConfiguration implements JsonSerializable<FunctionConfiguration> {
19+
/*
20+
* The input property.
21+
*/
22+
private String input;
23+
24+
/*
25+
* The output property.
26+
*/
27+
private String output;
28+
29+
/**
30+
* Creates an instance of FunctionConfiguration class.
31+
*/
32+
public FunctionConfiguration() {
33+
}
34+
35+
/**
36+
* Get the input property: The input property.
37+
*
38+
* @return the input value.
39+
*/
40+
public String input() {
41+
return this.input;
42+
}
43+
44+
/**
45+
* Set the input property: The input property.
46+
*
47+
* @param input the input value to set.
48+
* @return the FunctionConfiguration object itself.
49+
*/
50+
public FunctionConfiguration withInput(String input) {
51+
this.input = input;
52+
return this;
53+
}
54+
55+
/**
56+
* Get the output property: The output property.
57+
*
58+
* @return the output value.
59+
*/
60+
public String output() {
61+
return this.output;
62+
}
63+
64+
/**
65+
* Set the output property: The output property.
66+
*
67+
* @param output the output value to set.
68+
* @return the FunctionConfiguration object itself.
69+
*/
70+
public FunctionConfiguration withOutput(String output) {
71+
this.output = output;
72+
return this;
73+
}
74+
75+
/**
76+
* Validates the instance.
77+
*
78+
* @throws IllegalArgumentException thrown if the instance is not valid.
79+
*/
80+
public void validate() {
81+
}
82+
83+
/**
84+
* {@inheritDoc}
85+
*/
86+
@Override
87+
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
88+
jsonWriter.writeStartObject();
89+
jsonWriter.writeStringField("input", this.input);
90+
jsonWriter.writeStringField("output", this.output);
91+
return jsonWriter.writeEndObject();
92+
}
93+
94+
/**
95+
* Reads an instance of FunctionConfiguration from the JsonReader.
96+
*
97+
* @param jsonReader The JsonReader being read.
98+
* @return An instance of FunctionConfiguration if the JsonReader was pointing to an instance of it, or null if it
99+
* was pointing to JSON null.
100+
* @throws IOException If an error occurs while reading the FunctionConfiguration.
101+
*/
102+
public static FunctionConfiguration fromJson(JsonReader jsonReader) throws IOException {
103+
return jsonReader.readObject(reader -> {
104+
FunctionConfiguration deserializedFunctionConfiguration = new FunctionConfiguration();
105+
while (reader.nextToken() != JsonToken.END_OBJECT) {
106+
String fieldName = reader.getFieldName();
107+
reader.nextToken();
108+
109+
if ("input".equals(fieldName)) {
110+
deserializedFunctionConfiguration.input = reader.getString();
111+
} else if ("output".equals(fieldName)) {
112+
deserializedFunctionConfiguration.output = reader.getString();
113+
} else {
114+
reader.skipChildren();
115+
}
116+
}
117+
118+
return deserializedFunctionConfiguration;
119+
});
120+
}
121+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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.armstreamstyleserialization.fluent.models;
6+
7+
import com.azure.core.annotation.Fluent;
8+
import com.azure.core.util.logging.ClientLogger;
9+
import com.azure.json.JsonReader;
10+
import com.azure.json.JsonSerializable;
11+
import com.azure.json.JsonToken;
12+
import com.azure.json.JsonWriter;
13+
import java.io.IOException;
14+
import tsptest.armstreamstyleserialization.models.FunctionProperties;
15+
16+
/**
17+
* The Function model.
18+
*/
19+
@Fluent
20+
public final class FunctionInner implements JsonSerializable<FunctionInner> {
21+
/*
22+
* The properties property.
23+
*/
24+
private FunctionProperties properties;
25+
26+
/**
27+
* Creates an instance of FunctionInner class.
28+
*/
29+
public FunctionInner() {
30+
}
31+
32+
/**
33+
* Get the properties property: The properties property.
34+
*
35+
* @return the properties value.
36+
*/
37+
public FunctionProperties properties() {
38+
return this.properties;
39+
}
40+
41+
/**
42+
* Set the properties property: The properties property.
43+
*
44+
* @param properties the properties value to set.
45+
* @return the FunctionInner object itself.
46+
*/
47+
public FunctionInner withProperties(FunctionProperties properties) {
48+
this.properties = properties;
49+
return this;
50+
}
51+
52+
/**
53+
* Validates the instance.
54+
*
55+
* @throws IllegalArgumentException thrown if the instance is not valid.
56+
*/
57+
public void validate() {
58+
if (properties() == null) {
59+
throw LOGGER.atError()
60+
.log(new IllegalArgumentException("Missing required property properties in model FunctionInner"));
61+
} else {
62+
properties().validate();
63+
}
64+
}
65+
66+
private static final ClientLogger LOGGER = new ClientLogger(FunctionInner.class);
67+
68+
/**
69+
* {@inheritDoc}
70+
*/
71+
@Override
72+
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
73+
jsonWriter.writeStartObject();
74+
jsonWriter.writeJsonField("properties", this.properties);
75+
return jsonWriter.writeEndObject();
76+
}
77+
78+
/**
79+
* Reads an instance of FunctionInner from the JsonReader.
80+
*
81+
* @param jsonReader The JsonReader being read.
82+
* @return An instance of FunctionInner if the JsonReader was pointing to an instance of it, or null if it was
83+
* pointing to JSON null.
84+
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
85+
* @throws IOException If an error occurs while reading the FunctionInner.
86+
*/
87+
public static FunctionInner fromJson(JsonReader jsonReader) throws IOException {
88+
return jsonReader.readObject(reader -> {
89+
FunctionInner deserializedFunctionInner = new FunctionInner();
90+
while (reader.nextToken() != JsonToken.END_OBJECT) {
91+
String fieldName = reader.getFieldName();
92+
reader.nextToken();
93+
94+
if ("properties".equals(fieldName)) {
95+
deserializedFunctionInner.properties = FunctionProperties.fromJson(reader);
96+
} else {
97+
reader.skipChildren();
98+
}
99+
}
100+
101+
return deserializedFunctionInner;
102+
});
103+
}
104+
}

typespec-tests/src/main/java/tsptest/armstreamstyleserialization/implementation/ArmStreamStyleSerializationClientImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import reactor.core.publisher.Mono;
3434
import tsptest.armstreamstyleserialization.fluent.ArmStreamStyleSerializationClient;
3535
import tsptest.armstreamstyleserialization.fluent.FishesClient;
36+
import tsptest.armstreamstyleserialization.fluent.FunctionsClient;
3637
import tsptest.armstreamstyleserialization.fluent.TopLevelArmResourcesClient;
3738

3839
/**
@@ -152,6 +153,20 @@ public TopLevelArmResourcesClient getTopLevelArmResources() {
152153
return this.topLevelArmResources;
153154
}
154155

156+
/**
157+
* The FunctionsClient object to access its operations.
158+
*/
159+
private final FunctionsClient functions;
160+
161+
/**
162+
* Gets the FunctionsClient object to access its operations.
163+
*
164+
* @return the FunctionsClient object.
165+
*/
166+
public FunctionsClient getFunctions() {
167+
return this.functions;
168+
}
169+
155170
/**
156171
* Initializes an instance of ArmStreamStyleSerializationClient client.
157172
*
@@ -172,6 +187,7 @@ public TopLevelArmResourcesClient getTopLevelArmResources() {
172187
this.apiVersion = "2023-12-01-preview";
173188
this.fishes = new FishesClientImpl(this);
174189
this.topLevelArmResources = new TopLevelArmResourcesClientImpl(this);
190+
this.functions = new FunctionsClientImpl(this);
175191
}
176192

177193
/**

0 commit comments

Comments
 (0)