Skip to content

Support type 'list' for output_wrapper_field_path #1285

@brycahta

Description

@brycahta

Is your feature request related to a problem?
I am unable to generate Instance CRD for ec2-controller because code-generator cannot unwrap the list responses from RunInstances and DescribeInstances, the Create and List operations, respectively.

RunInstances is a "create many" call in that a single request can create multiple instances. As a result, the output shape returns a list of Instances (within a Reservation struct). Similarly, DescribeInstances returns a list of Reservations each containing a list of Instances.

The Instance CRD implementation will only allow requesting/creating a single instance at a time; therefore, we only want the first instance in the RunInstances output shape, Reservation.Instances[0], and the first instance of the first reservation in the DescribeInstances output shape, Reservations[0].Instances[0].

Describe the solution you'd like
Extend the functionality of output_wrapper_field_path config to support type "list" (only supports struct today). Unwrapping a list element will always take the first element.

Desired generator.yaml for Instance:

  RunInstances:
    output_wrapper_field_path: Reservation.Instances
    operation_type:
      - Create
    resource_name: Instance
  DescribeInstances:
    output_wrapper_field_path: Reservations.Instances
    operation_type:
      - List
    resource_name: Instance
  • refactor setResourceReadMany to setListResource (or something similar) and use this function for ReadMany and unwrapping list elements.

Describe alternatives you've considered

  • map RunInstances to CreateBatch operation and create a setResourceCreateMany()

Metadata

Metadata

Assignees

Labels

kind/enhancementCategorizes issue or PR as related to existing feature enhancements.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions