Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

tsp, mgmt, move Paged model to implementation.models #2701

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.azure.autorest.fluent.util.Utils;
import com.azure.autorest.mapper.Mappers;
import com.azure.autorest.model.clientmodel.Client;
import com.azure.autorest.model.clientmodel.ClientModels;
import com.azure.autorest.model.clientmodel.ModuleInfo;
import org.slf4j.Logger;

Expand Down Expand Up @@ -123,7 +124,10 @@ public FluentClient map(CodeModel codeModel, Client client) {
FluentClient basicMap(CodeModel codeModel, Client client) {
FluentClient fluentClient = new FluentClient(client);

fluentClient.setModuleInfo(moduleInfo());
final String implementationModelsPackage = JavaSettings.getInstance().getImplementationSubpackage() + "." + JavaSettings.getInstance().getModelsSubpackage();
final boolean hasImplementationModels = ClientModels.getInstance().getModels().stream()
.anyMatch(m -> m.getPackage().endsWith(implementationModelsPackage));
fluentClient.setModuleInfo(getModuleInfo(hasImplementationModels));

FluentStatic.setFluentClient(fluentClient);

Expand Down Expand Up @@ -153,7 +157,7 @@ FluentClient basicMap(CodeModel codeModel, Client client) {
return fluentClient;
}

private static ModuleInfo moduleInfo() {
private static ModuleInfo getModuleInfo(boolean hasImplementationModels) {
JavaSettings settings = JavaSettings.getInstance();
ModuleInfo moduleInfo = new ModuleInfo(settings.getPackage());

Expand All @@ -170,6 +174,9 @@ private static ModuleInfo moduleInfo() {
List<ModuleInfo.OpenModule> openModules = moduleInfo.getOpenModules();
openModules.add(new ModuleInfo.OpenModule(settings.getPackage(settings.getFluentModelsSubpackage()), openToModules));
openModules.add(new ModuleInfo.OpenModule(settings.getPackage(settings.getModelsSubpackage()), openToModules));
if (hasImplementationModels) {
openModules.add(new ModuleInfo.OpenModule(settings.getPackage(settings.getImplementationSubpackage(), settings.getModelsSubpackage()), openToModules));
}

return moduleInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ private ClassType createClassType(ObjectSchema compositeType) {
} else if (settings.isFluent() && compositeType.isFlattenedSchema()) {
// put class of flattened type to implementation package
classPackage = settings.getPackage(settings.getFluentModelsSubpackage());
} else if (settings.isDataPlaneClient() && (isPageModel(compositeType) || isInternalModel(compositeType))) {
} else if (settings.isDataPlaneClient() && isInternalModel(compositeType)) {
// internal type is not exposed to user
classPackage = settings.getPackage(settings.getImplementationSubpackage(), settings.getModelsSubpackage());
} else if (isPageModel(compositeType)) {
// put class of Page<> type to implementation package
// For TypeSpec, these are not generated to class
// for DPG from TypeSpec, these are not generated to class

// this would not affect mgmt from Swagger, as the "usage" from m4 does not have this information.

// same for internal type, which is not exposed to user
classPackage = settings.getPackage(settings.getImplementationSubpackage(), settings.getModelsSubpackage());
} else {
classPackage = settings.getPackage(settings.getModelsSubpackage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import com.azure.core.util.polling.SyncPoller;
import com.cadl.armresourceprovider.fluent.ChildResourcesInterfacesClient;
import com.cadl.armresourceprovider.fluent.models.ChildResourceInner;
import com.cadl.armresourceprovider.models.ChildResourceListResult;
import com.cadl.armresourceprovider.implementation.models.ChildResourceListResult;
import com.cadl.armresourceprovider.models.ChildResourceUpdate;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.azure.core.util.FluxUtil;
import com.cadl.armresourceprovider.fluent.OperationsClient;
import com.cadl.armresourceprovider.fluent.models.OperationInner;
import com.cadl.armresourceprovider.models.PagedOperation;
import com.cadl.armresourceprovider.implementation.models.PagedOperation;
import reactor.core.publisher.Mono;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import com.azure.core.util.polling.SyncPoller;
import com.cadl.armresourceprovider.fluent.TopLevelArmResourceInterfacesClient;
import com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner;
import com.cadl.armresourceprovider.models.TopLevelArmResourceListResult;
import com.cadl.armresourceprovider.implementation.models.TopLevelArmResourceListResult;
import com.cadl.armresourceprovider.models.TopLevelArmResourceUpdate;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
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.cadl.armresourceprovider.models;
package com.cadl.armresourceprovider.implementation.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
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.cadl.armresourceprovider.models;
package com.cadl.armresourceprovider.implementation.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
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.cadl.armresourceprovider.models;
package com.cadl.armresourceprovider.implementation.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.models.ChildResourceListResult",
"name" : "com.cadl.armresourceprovider.implementation.models.ChildResourceListResult",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
Expand All @@ -39,7 +39,7 @@
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.models.TopLevelArmResourceListResult",
"name" : "com.cadl.armresourceprovider.implementation.models.TopLevelArmResourceListResult",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
Expand Down Expand Up @@ -69,7 +69,7 @@
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.models.PagedOperation",
"name" : "com.cadl.armresourceprovider.implementation.models.PagedOperation",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
Expand Down
Loading