Skip to content

Use ListAllPages methods for fetching lists #507

@lgfa29

Description

@lgfa29

The current resources and data sources that fetch a list of entities currently use a large page size and sometimes have a note like this:

// TODO: It would be preferable to us the client.Images.ListAllPages method instead.
// Unfortunately, currently that method has a bug where it returns twice as many results
// as there are in reality. For now I'll use the List method with a limit of 1,000,000,000 results.
// Seems unlikely anyone will have more than one billion images.

Testing the SDK, I found that this bug was fixed on commit https://github.com/oxidecomputer/oxide.go/tree/e5aaa35f6fb3d2d3dc46a336f12b9dd62fc9ffb3, so we should now able to use the ListAllPages methods instead of requesting a single page with Limit set to oxide.NewPointer(1000000000).

Examples of where this pattern is found:

params := oxide.InstanceDiskListParams{
Limit: oxide.NewPointer(1000000000),
Instance: oxide.NameOrId(instanceID),
}

// TODO: It would be preferable to us the client.Images.ListAllPages method instead.
// Unfortunately, currently that method has a bug where it returns twice as many results
// as there are in reality. For now I'll use the List method with a limit of 1,000,000,000 results.
// Seems unlikely anyone will have more than one billion images.
params := oxide.ImageListParams{
Project: oxide.NameOrId(state.ProjectID.ValueString()),
Limit: oxide.NewPointer(1000000000),
SortBy: oxide.NameOrIdSortModeIdAscending,
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions