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
Add vnet param to routes #912
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -19,47 +19,53 @@ var ( | |||
|
||||
// TunnelRoute is the full record for a route. | ||||
type TunnelRoute struct { | ||||
Network string `json:"network"` | ||||
TunnelID string `json:"tunnel_id"` | ||||
TunnelName string `json:"tunnel_name"` | ||||
Comment string `json:"comment"` | ||||
CreatedAt *time.Time `json:"created_at"` | ||||
DeletedAt *time.Time `json:"deleted_at"` | ||||
Network string `json:"network"` | ||||
TunnelID string `json:"tunnel_id"` | ||||
TunnelName string `json:"tunnel_name"` | ||||
Comment string `json:"comment"` | ||||
CreatedAt *time.Time `json:"created_at"` | ||||
DeletedAt *time.Time `json:"deleted_at"` | ||||
VirtualNetworkID string `json:"virtual_network_id"` | ||||
} | ||||
|
||||
type TunnelRoutesListParams struct { | ||||
AccountID string `url:"-"` | ||||
TunnelID string `url:"tunnel_id,omitempty"` | ||||
Comment string `url:"comment,omitempty"` | ||||
IsDeleted *bool `url:"is_deleted,omitempty"` | ||||
NetworkSubset string `url:"network_subset,omitempty"` | ||||
NetworkSuperset string `url:"network_superset,omitempty"` | ||||
ExistedAt *time.Time `url:"existed_at,omitempty"` | ||||
AccountID string `url:"-"` | ||||
TunnelID string `url:"tunnel_id,omitempty"` | ||||
Comment string `url:"comment,omitempty"` | ||||
IsDeleted *bool `url:"is_deleted,omitempty"` | ||||
NetworkSubset string `url:"network_subset,omitempty"` | ||||
NetworkSuperset string `url:"network_superset,omitempty"` | ||||
ExistedAt *time.Time `url:"existed_at,omitempty"` | ||||
VirtualNetworkID string `url:"virtual_network_id,omitempty"` | ||||
PaginationOptions | ||||
} | ||||
|
||||
type TunnelRoutesCreateParams struct { | ||||
AccountID string `json:"-"` | ||||
Network string `json:"-"` | ||||
TunnelID string `json:"tunnel_id"` | ||||
Comment string `json:"comment,omitempty"` | ||||
AccountID string `json:"-"` | ||||
Network string `json:"-"` | ||||
TunnelID string `json:"tunnel_id"` | ||||
Comment string `json:"comment,omitempty"` | ||||
VirtualNetworkID string `json:"virtual_network_id,omitempty"` | ||||
} | ||||
|
||||
type TunnelRoutesUpdateParams struct { | ||||
AccountID string `json:"-"` | ||||
Network string `json:"network"` | ||||
TunnelID string `json:"tunnel_id"` | ||||
Comment string `json:"comment,omitempty"` | ||||
AccountID string `json:"-"` | ||||
Network string `json:"network"` | ||||
TunnelID string `json:"tunnel_id"` | ||||
Comment string `json:"comment,omitempty"` | ||||
VirtualNetworkID string `json:"virtual_network_id,omitempty"` | ||||
} | ||||
|
||||
type TunnelRoutesForIPParams struct { | ||||
AccountID string `json:"-"` | ||||
Network string `json:"-"` | ||||
AccountID string `url:"-"` | ||||
Network string `url:"-"` | ||||
VirtualNetworkID string `url:"virtual_network_id,omitempty"` | ||||
} | ||||
|
||||
type TunnelRoutesDeleteParams struct { | ||||
AccountID string `json:"-"` | ||||
Network string `json:"-"` | ||||
AccountID string `json:"-"` | ||||
Network string `json:"-"` | ||||
VirtualNetworkID string `url:"virtual_network_id,omitempty"` | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
} | ||||
|
||||
// tunnelRouteListResponse is the API response for listing tunnel routes. | ||||
|
@@ -112,7 +118,7 @@ func (api *API) GetTunnelRouteForIP(ctx context.Context, params TunnelRoutesForI | |||
return TunnelRoute{}, ErrInvalidNetworkValue | ||||
} | ||||
|
||||
uri := fmt.Sprintf("/%s/%s/teamnet/routes/ip/%s", AccountRouteRoot, params.AccountID, params.Network) | ||||
uri := buildURI(fmt.Sprintf("/%s/%s/teamnet/routes/ip/%s", AccountRouteRoot, params.AccountID, params.Network), params) | ||||
|
||||
responseBody, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil) | ||||
if err != nil { | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ func TestListTunnelRoutes(t *testing.T) { | |
"tunnel_name": "blog", | ||
"comment": "Example comment for this route", | ||
"created_at": "2021-01-25T18:22:34.317854Z", | ||
"deleted_at": "2021-01-25T18:22:34.317854Z" | ||
"deleted_at": "2021-01-25T18:22:34.317854Z", | ||
"virtual_network_id": "9f322de4-5988-4945-b770-f1d6ac200f86" | ||
} | ||
] | ||
}`) | ||
|
@@ -46,6 +47,7 @@ func TestListTunnelRoutes(t *testing.T) { | |
"Example comment for this route", | ||
&ts, | ||
&ts, | ||
"9f322de4-5988-4945-b770-f1d6ac200f86", | ||
}, | ||
} | ||
|
||
|
@@ -74,7 +76,8 @@ func TestTunnelRouteForIP(t *testing.T) { | |
"tunnel_name": "blog", | ||
"comment": "Example comment for this route", | ||
"created_at": "2021-01-25T18:22:34.317854Z", | ||
"deleted_at": "2021-01-25T18:22:34.317854Z" | ||
"deleted_at": "2021-01-25T18:22:34.317854Z", | ||
"virtual_network_id": "9f322de4-5988-4945-b770-f1d6ac200f86" | ||
} | ||
}`) | ||
} | ||
|
@@ -83,12 +86,13 @@ func TestTunnelRouteForIP(t *testing.T) { | |
|
||
ts, _ := time.Parse(time.RFC3339Nano, "2021-01-25T18:22:34.317854Z") | ||
want := TunnelRoute{ | ||
Network: "ff01::/32", | ||
TunnelID: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", | ||
TunnelName: "blog", | ||
Comment: "Example comment for this route", | ||
CreatedAt: &ts, | ||
DeletedAt: &ts, | ||
Network: "ff01::/32", | ||
TunnelID: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", | ||
TunnelName: "blog", | ||
Comment: "Example comment for this route", | ||
CreatedAt: &ts, | ||
DeletedAt: &ts, | ||
VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86", | ||
} | ||
|
||
got, err := client.GetTunnelRouteForIP(context.Background(), TunnelRoutesForIPParams{AccountID: testAccountID, Network: "10.1.0.137"}) | ||
|
@@ -115,7 +119,8 @@ func TestCreateTunnelRoute(t *testing.T) { | |
"tunnel_name": "blog", | ||
"comment": "Example comment for this route", | ||
"created_at": "2021-01-25T18:22:34.317854Z", | ||
"deleted_at": "2021-01-25T18:22:34.317854Z" | ||
"deleted_at": "2021-01-25T18:22:34.317854Z", | ||
"virtual_network_id": "9f322de4-5988-4945-b770-f1d6ac200f86" | ||
} | ||
}`) | ||
} | ||
|
@@ -124,15 +129,16 @@ func TestCreateTunnelRoute(t *testing.T) { | |
|
||
ts, _ := time.Parse(time.RFC3339Nano, "2021-01-25T18:22:34.317854Z") | ||
want := TunnelRoute{ | ||
Network: "10.0.0.0/16", | ||
TunnelID: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", | ||
TunnelName: "blog", | ||
Comment: "Example comment for this route", | ||
CreatedAt: &ts, | ||
DeletedAt: &ts, | ||
Network: "10.0.0.0/16", | ||
TunnelID: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", | ||
TunnelName: "blog", | ||
Comment: "Example comment for this route", | ||
CreatedAt: &ts, | ||
DeletedAt: &ts, | ||
VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86", | ||
} | ||
|
||
tunnel, err := client.CreateTunnelRoute(context.Background(), TunnelRoutesCreateParams{AccountID: testAccountID, TunnelID: testTunnelID, Network: "10.0.0.0/16", Comment: "foo"}) | ||
tunnel, err := client.CreateTunnelRoute(context.Background(), TunnelRoutesCreateParams{AccountID: testAccountID, TunnelID: testTunnelID, Network: "10.0.0.0/16", Comment: "foo", VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86"}) | ||
if assert.NoError(t, err) { | ||
assert.Equal(t, want, tunnel) | ||
} | ||
|
@@ -161,23 +167,25 @@ func TestUpdateTunnelRoute(t *testing.T) { | |
"tunnel_name": "blog", | ||
"comment": "Example comment for this route", | ||
"created_at": "2021-01-25T18:22:34.317854Z", | ||
"deleted_at": "2021-01-25T18:22:34.317854Z" | ||
"deleted_at": "2021-01-25T18:22:34.317854Z", | ||
"virtual_network_id": "9f322de4-5988-4945-b770-f1d6ac200f86" | ||
} | ||
}`) | ||
} | ||
|
||
ts, _ := time.Parse(time.RFC3339Nano, "2021-01-25T18:22:34.317854Z") | ||
want := TunnelRoute{ | ||
Network: "10.0.0.0/16", | ||
TunnelID: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", | ||
TunnelName: "blog", | ||
Comment: "Example comment for this route", | ||
CreatedAt: &ts, | ||
DeletedAt: &ts, | ||
Network: "10.0.0.0/16", | ||
TunnelID: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", | ||
TunnelName: "blog", | ||
Comment: "Example comment for this route", | ||
CreatedAt: &ts, | ||
DeletedAt: &ts, | ||
VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86", | ||
} | ||
|
||
mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/network/10.0.0.0/16", handler) | ||
tunnel, err := client.UpdateTunnelRoute(context.Background(), TunnelRoutesUpdateParams{AccountID: testAccountID, TunnelID: testTunnelID, Network: "10.0.0.0/16", Comment: "foo"}) | ||
tunnel, err := client.UpdateTunnelRoute(context.Background(), TunnelRoutesUpdateParams{AccountID: testAccountID, TunnelID: testTunnelID, Network: "10.0.0.0/16", Comment: "foo", VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86"}) | ||
|
||
if assert.NoError(t, err) { | ||
assert.Equal(t, want, tunnel) | ||
|
@@ -202,12 +210,13 @@ func TestDeleteTunnelRoute(t *testing.T) { | |
"tunnel_name": "blog", | ||
"comment": "Example comment for this route", | ||
"created_at": "2021-01-25T18:22:34.317854Z", | ||
"deleted_at": "2021-01-25T18:22:34.317854Z" | ||
"deleted_at": "2021-01-25T18:22:34.317854Z", | ||
"virtual_network_id": "9f322de4-5988-4945-b770-f1d6ac200f86" | ||
} | ||
}`) | ||
} | ||
|
||
mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/network/10.0.0.0/16", handler) | ||
err := client.DeleteTunnelRoute(context.Background(), TunnelRoutesDeleteParams{AccountID: testAccountID, Network: "10.0.0.0/16"}) | ||
err := client.DeleteTunnelRoute(context.Background(), TunnelRoutesDeleteParams{AccountID: testAccountID, Network: "10.0.0.0/16", VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need to send There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a question here. For example, How do I remove only vnetProd route without specifying It's not some specific non-real case. I will have exactly this situation on my environment after we merge this PR. Delete without There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah.. I see that it's not reflected in docs. You may test it in Postman/insomnia as I did. I couldn't remove the route from non-default vnet until I explicitly specified vnetid as Get param. I guess we need to update api docs s bit. It's super important for those folks who use vnets. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gotcha, one to raise with a support ticket if you can in order to get the docs reflecting the correct state of affairs here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Purchased paid cloudflare plan and created a support ticket to change the docs. |
||
assert.NoError(t, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.