Skip to content

Commit

Permalink
mgmt, fix child with parent flatten (#3004)
Browse files Browse the repository at this point in the history
* bump core

* add fluent test

* bump core

* bump core

* sync-test
  • Loading branch information
XiaofeiCao authored Jan 6, 2025
1 parent 90d9987 commit c5e58aa
Show file tree
Hide file tree
Showing 19 changed files with 1,025 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core
Submodule core updated 303 files
3 changes: 3 additions & 0 deletions fluent-tests/Initialize-Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ $job = @(
# stream-style-serialization
"--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"

# child model with flattened property from parent
"--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"

# empty-model
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=./swagger/empty-model.json --java.namespace=com.azure.mgmtlitetest.emptymodel"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.azure.mgmtlitetest.storage.models.StorageAccountListKeysResult;
import com.azure.mgmtlitetest.storage.models.StorageAccountRegenerateKeyParameters;
import com.azure.mgmtlitetest.storage.models.StorageAccounts;
import com.azure.mgmtlitetest.streamanalytics.models.AggregateFunctionProperties;
import com.azure.mgmtlitetest.streamstyleserialization.implementation.CommunityGalleriesClientImpl;
import com.azure.mgmttest.azurestack.fluent.models.ExtendedProductInner;
import com.azure.mgmttest.education.fluent.models.LabDetailsInner;
Expand Down Expand Up @@ -210,4 +211,8 @@ public void testPageableWithInheritance() {
SavingsPlansClient savingsPlansClient = mock(SavingsPlansClient.class);
PagedIterable<SavingsPlanModelInner> result = savingsPlansClient.listByBillingAccount("myBillingAccount");
}

public void testChildWithParentFlattenedProperties() {
AggregateFunctionProperties aggregateFunctionProperties = new AggregateFunctionProperties();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import tsptest.armstreamstyleserialization.fluent.ArmStreamStyleSerializationClient;
import tsptest.armstreamstyleserialization.implementation.ArmStreamStyleSerializationClientBuilder;
import tsptest.armstreamstyleserialization.implementation.FishesImpl;
import tsptest.armstreamstyleserialization.implementation.FunctionsImpl;
import tsptest.armstreamstyleserialization.implementation.TopLevelArmResourcesImpl;
import tsptest.armstreamstyleserialization.models.Fishes;
import tsptest.armstreamstyleserialization.models.Functions;
import tsptest.armstreamstyleserialization.models.TopLevelArmResources;

/**
Expand All @@ -45,6 +47,8 @@ public final class ArmStreamStyleSerializationManager {

private TopLevelArmResources topLevelArmResources;

private Functions functions;

private final ArmStreamStyleSerializationClient clientObject;

private ArmStreamStyleSerializationManager(HttpPipeline httpPipeline, AzureProfile profile,
Expand Down Expand Up @@ -281,6 +285,18 @@ public TopLevelArmResources topLevelArmResources() {
return topLevelArmResources;
}

/**
* Gets the resource collection API of Functions.
*
* @return Resource collection API of Functions.
*/
public Functions functions() {
if (this.functions == null) {
this.functions = new FunctionsImpl(clientObject.getFunctions(), this);
}
return functions;
}

/**
* Gets wrapped service client ArmStreamStyleSerializationClient providing direct access to the underlying
* auto-generated API implementation, based on Azure REST API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,11 @@ public interface ArmStreamStyleSerializationClient {
* @return the TopLevelArmResourcesClient object.
*/
TopLevelArmResourcesClient getTopLevelArmResources();

/**
* Gets the FunctionsClient object to access its operations.
*
* @return the FunctionsClient object.
*/
FunctionsClient getFunctions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package tsptest.armstreamstyleserialization.fluent;

import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import tsptest.armstreamstyleserialization.fluent.models.FunctionInner;

/**
* An instance of this class provides access to all the operations defined in FunctionsClient.
*/
public interface FunctionsClient {
/**
* The createFunction operation.
*
* @param function The function parameter.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response body along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
Response<FunctionInner> createFunctionWithResponse(FunctionInner function, Context context);

/**
* The createFunction operation.
*
* @param function The function parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
FunctionInner createFunction(FunctionInner function);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package tsptest.armstreamstyleserialization.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
* The FunctionConfiguration model.
*/
@Fluent
public final class FunctionConfiguration implements JsonSerializable<FunctionConfiguration> {
/*
* The input property.
*/
private String input;

/*
* The output property.
*/
private String output;

/**
* Creates an instance of FunctionConfiguration class.
*/
public FunctionConfiguration() {
}

/**
* Get the input property: The input property.
*
* @return the input value.
*/
public String input() {
return this.input;
}

/**
* Set the input property: The input property.
*
* @param input the input value to set.
* @return the FunctionConfiguration object itself.
*/
public FunctionConfiguration withInput(String input) {
this.input = input;
return this;
}

/**
* Get the output property: The output property.
*
* @return the output value.
*/
public String output() {
return this.output;
}

/**
* Set the output property: The output property.
*
* @param output the output value to set.
* @return the FunctionConfiguration object itself.
*/
public FunctionConfiguration withOutput(String output) {
this.output = output;
return this;
}

/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
}

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("input", this.input);
jsonWriter.writeStringField("output", this.output);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of FunctionConfiguration from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of FunctionConfiguration if the JsonReader was pointing to an instance of it, or null if it
* was pointing to JSON null.
* @throws IOException If an error occurs while reading the FunctionConfiguration.
*/
public static FunctionConfiguration fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
FunctionConfiguration deserializedFunctionConfiguration = new FunctionConfiguration();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("input".equals(fieldName)) {
deserializedFunctionConfiguration.input = reader.getString();
} else if ("output".equals(fieldName)) {
deserializedFunctionConfiguration.output = reader.getString();
} else {
reader.skipChildren();
}
}

return deserializedFunctionConfiguration;
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package tsptest.armstreamstyleserialization.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import tsptest.armstreamstyleserialization.models.FunctionProperties;

/**
* The Function model.
*/
@Fluent
public final class FunctionInner implements JsonSerializable<FunctionInner> {
/*
* The properties property.
*/
private FunctionProperties properties;

/**
* Creates an instance of FunctionInner class.
*/
public FunctionInner() {
}

/**
* Get the properties property: The properties property.
*
* @return the properties value.
*/
public FunctionProperties properties() {
return this.properties;
}

/**
* Set the properties property: The properties property.
*
* @param properties the properties value to set.
* @return the FunctionInner object itself.
*/
public FunctionInner withProperties(FunctionProperties properties) {
this.properties = properties;
return this;
}

/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (properties() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property properties in model FunctionInner"));
} else {
properties().validate();
}
}

private static final ClientLogger LOGGER = new ClientLogger(FunctionInner.class);

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("properties", this.properties);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of FunctionInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of FunctionInner if the JsonReader was pointing to an instance of it, or null if it was
* pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the FunctionInner.
*/
public static FunctionInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
FunctionInner deserializedFunctionInner = new FunctionInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("properties".equals(fieldName)) {
deserializedFunctionInner.properties = FunctionProperties.fromJson(reader);
} else {
reader.skipChildren();
}
}

return deserializedFunctionInner;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import reactor.core.publisher.Mono;
import tsptest.armstreamstyleserialization.fluent.ArmStreamStyleSerializationClient;
import tsptest.armstreamstyleserialization.fluent.FishesClient;
import tsptest.armstreamstyleserialization.fluent.FunctionsClient;
import tsptest.armstreamstyleserialization.fluent.TopLevelArmResourcesClient;

/**
Expand Down Expand Up @@ -152,6 +153,20 @@ public TopLevelArmResourcesClient getTopLevelArmResources() {
return this.topLevelArmResources;
}

/**
* The FunctionsClient object to access its operations.
*/
private final FunctionsClient functions;

/**
* Gets the FunctionsClient object to access its operations.
*
* @return the FunctionsClient object.
*/
public FunctionsClient getFunctions() {
return this.functions;
}

/**
* Initializes an instance of ArmStreamStyleSerializationClient client.
*
Expand All @@ -172,6 +187,7 @@ public TopLevelArmResourcesClient getTopLevelArmResources() {
this.apiVersion = "2023-12-01-preview";
this.fishes = new FishesClientImpl(this);
this.topLevelArmResources = new TopLevelArmResourcesClientImpl(this);
this.functions = new FunctionsClientImpl(this);
}

/**
Expand Down
Loading

0 comments on commit c5e58aa

Please sign in to comment.