Skip to content

Commit

Permalink
feat(ipam): allow filtering on pn, subnet or vpc id (#2071)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot committed May 17, 2024
1 parent 6a6b25d commit c93d25d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions api/ipam/v1/ipam_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,20 @@ type ListIPsRequest struct {
ProjectID *string `json:"-"`

// Zonal: zone to filter for. Only IPs that are zonal, and in this zone, will be returned.
// Precisely one of Zonal, PrivateNetworkID must be set.
// Precisely one of Zonal, PrivateNetworkID, SubnetID must be set.
Zonal *string `json:"zonal,omitempty"`

// PrivateNetworkID: only IPs that are private, and in this Private Network, will be returned.
// Precisely one of Zonal, PrivateNetworkID must be set.
// Precisely one of Zonal, PrivateNetworkID, SubnetID must be set.
PrivateNetworkID *string `json:"private_network_id,omitempty"`

// SubnetID: only IPs inside this exact subnet will be returned.
// Precisely one of Zonal, PrivateNetworkID, SubnetID must be set.
SubnetID *string `json:"subnet_id,omitempty"`

// VpcID: only IPs owned by resources in this VPC will be returned.
VpcID *string `json:"-"`

// Attached: defines whether to filter only for IPs which are attached to a resource.
Attached *bool `json:"-"`

Expand Down Expand Up @@ -499,6 +506,7 @@ func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsR
parameter.AddToQuery(query, "page", req.Page)
parameter.AddToQuery(query, "page_size", req.PageSize)
parameter.AddToQuery(query, "project_id", req.ProjectID)
parameter.AddToQuery(query, "vpc_id", req.VpcID)
parameter.AddToQuery(query, "attached", req.Attached)
parameter.AddToQuery(query, "resource_id", req.ResourceID)
parameter.AddToQuery(query, "resource_type", req.ResourceType)
Expand All @@ -509,6 +517,7 @@ func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsR
parameter.AddToQuery(query, "resource_name", req.ResourceName)
parameter.AddToQuery(query, "zonal", req.Zonal)
parameter.AddToQuery(query, "private_network_id", req.PrivateNetworkID)
parameter.AddToQuery(query, "subnet_id", req.SubnetID)

if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
Expand Down

0 comments on commit c93d25d

Please sign in to comment.