VSChina / magic-modules

Magic Modules: Automagically generate Google Cloud Platform support for OSS
Apache License 2.0
1 stars 4 forks source link

MM should flatten the property when the property only includes id #37

Closed neil-yechenwei closed 5 years ago

neil-yechenwei commented 5 years ago

Terraform suggests us to flatten the property when the property only includes id. See the comment in the link https://github.com/neil-yechenwei/terraform-provider-azurerm/pull/5

houkms commented 5 years ago

I think Magic-Modules supports it well, and let's take the following block as an example.

  - !ruby/object:Api::Type::NestedObject
        name: 'vpnGateway'
        description: 'The VpnGateway associated with this VirtualHub.'
        required: false
        azure_sdk_references: ['/vpnGateway', '/properties/vpnGateway']
        properties:
          - !ruby/object:Api::Type::String
            name: 'id'
            description: 'Resource ID.'
            required: false
            azure_sdk_references: ['/vpnGateway/id', '/properties/vpnGateway/id']

When you want to flatten the property id in vpnGateway, just move it to an upper layer and delete its father property if necessary.

   - !ruby/object:Api::Type::String
        name: 'vpnGatewayID'
        description: 'Resource ID.'
        required: false
        azure_sdk_references: ['/vpnGateway/id', '/properties/vpnGateway/id']

Remember: DO NOT modify the paths in azure_sdk_references and the declarations in azure_sdk_definitions.