func List()

in pkg/api/platformapi/allocatorapi/list.go [69:100]


func List(params ListParams) (*models.AllocatorOverview, error) {
	if err := params.Validate(); err != nil {
		return nil, err
	}

	p := platform_infrastructure.NewGetAllocatorsParams().
		WithContext(api.WithRegion(context.Background(), params.Region)).
		WithQ(ec.String(params.Query))

	if params.Size > 0 {
		p.SetSize(&params.Size)
	}

	res, err := params.API.V1API.PlatformInfrastructure.GetAllocators(
		p, params.AuthWriter,
	)

	if err != nil {
		return nil, apierror.Wrap(err)
	}
	if !params.ShowAll {
		for _, z := range res.Payload.Zones {
			z.Allocators = FilterConnectedOrWithInstances(z.Allocators)
		}
	}

	for _, z := range res.Payload.Zones {
		z.Allocators = FilterByTag(tagsToMap(params.FilterTags), z.Allocators)
	}

	return res.Payload, nil
}