Azure / autorest.java

Extension for AutoRest (https://github.com/Azure/autorest) that generates Java code
MIT License
33 stars 82 forks source link

[MPG investigate] Premium code generation #2508

Open XiaofeiCao opened 8 months ago

XiaofeiCao commented 8 months ago

Goal:

  1. Save time for new premium features by generating starter fluent premium interfaces and default implementations. First we support generating specific resource's premium interfaces, not all of them. e.g. configuration generate-for=StorageAccount, StorageBlob will generate premium interfaces for resource StorageAccount, StorageBlob. If not specified, will not generate any premium interfaces.

  2. Customize convenience layer by using typespec definition.

  3. (Optional) Support defining child resources in parent resource's definition/update stage. e.g. In current lite, when we define BatchAccount, we need to define its parent resource ResourceGroup first.

    // define resourceGroup
    ResourceGroup rg = resourceManager.resourceGroups().define("rg-name").withRegion("eastus").create();
    // define BatchAccount
    manager.batchAccounts().define("sampleacct").withRegion("eastus")
            .withExistingResourceGroup(rg.name())
            .xxx()
            .create();

Now:

manager.batchAccounts().define("sampleacct").withRegion("eastus")
            .withNewResourceGroup("rg-name")
            .xxx()
            .create();

Non-Goal

  1. Support generating for all resources, without any manual intervene.
  2. Backward compatibility with existing fluent premium interfaces.

It acts like a tool box to use locally for new fluent premium interfaces.

### Tasks
- [ ] Generate script
- [x] Entry for configuring resources to generate Resource/Collection premium
- [ ] Resource model interface signature
- [ ] Resource model interface property methods
- [ ] Resource model interface define stage
- [ ] Resource model interface update stage
- [ ] Resource model implementation class signature
- [ ] Resource model implementation methods implementation
- [ ] Resource collection interface signature
- [ ] Resource collection implementation class signature
- [ ] Resource collection implementation methods implementation
- [ ] Resource model properties flattening(withProperties -> withProperty1, withProperty2, etc)
XiaofeiCao commented 7 months ago

Add one potential goal from Monthly sprint review: Build convenience layer to mitigate gaps between track1 and track2.