Skip to content

Commit

Permalink
Allow releasing egress IP addresses from a machine (#110)
Browse files Browse the repository at this point in the history
Signed-off-by: Akshit Garg <[email protected]>
  • Loading branch information
gargakshit authored Oct 3, 2024
1 parent 58245f0 commit ac13e4f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
23 changes: 23 additions & 0 deletions resource_ip_addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,29 @@ func (c *Client) GetEgressIPAddresses(ctx context.Context, appName string) (map[
return ret, nil
}

func (c *Client) ReleaseEgressIPAddress(ctx context.Context, appName, machineID string) (net.IP, net.IP, error) {
query := `
mutation($input: ReleaseEgressIPAddressInput!) {
releaseEgressIpAddress(input: $input) {
v4
v6
clientMutationId
}
}
`

req := c.NewRequest(query)
ctx = ctxWithAction(ctx, "release_egress_ip_address")
req.Var("input", ReleaseEgressIPAddressInput{AppID: appName, MachineID: machineID})

data, err := c.RunWithContext(ctx, req)
if err != nil {
return nil, nil, err
}

return net.ParseIP(data.ReleaseEgressIPAddress.V4), net.ParseIP(data.ReleaseEgressIPAddress.V6), nil
}

func (c *Client) ReleaseIPAddress(ctx context.Context, appName string, ip string) error {
query := `
mutation($input: ReleaseIPAddressInput!) {
Expand Down
9 changes: 9 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ type Query struct {
V4 string
V6 string
}
ReleaseEgressIPAddress struct {
V4 string
V6 string
}
ReleaseIPAddress struct {
App App
}
Expand Down Expand Up @@ -700,6 +704,11 @@ type AllocateEgressIPAddressInput struct {
MachineID string `json:"machineId"`
}

type ReleaseEgressIPAddressInput struct {
AppID string `json:"appId"`
MachineID string `json:"machineId"`
}

type ReleaseIPAddressInput struct {
AppID *string `json:"appId"`
IPAddressID *string `json:"ipAddressId"`
Expand Down

0 comments on commit ac13e4f

Please sign in to comment.