Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ipam): allow filtering on pn, subnet or vpc id #2071

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 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 @@ -327,7 +334,7 @@ type UpdateIPRequest struct {
Reverses []*Reverse `json:"reverses"`
}

// This API allows you to manage IP addresses with Scaleway's IP Address Management tool.
// This API allows you to manage your Scaleway IP addresses with our IP Address Management tool.
type API struct {
client *scw.Client
}
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
2 changes: 1 addition & 1 deletion api/ipam/v1alpha1/ipam_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint64, error) {
return uint64(len(results.IPs)), nil
}

// IPAM API.
// This API allows you to manage your Scaleway IP addresses with our IP Address Management tool.
type API struct {
client *scw.Client
}
Expand Down
Loading