Skip to content

Commit

Permalink
Merge d44afda into 5658259
Browse files Browse the repository at this point in the history
  • Loading branch information
ozerovandrei committed May 26, 2018
2 parents 5658259 + d44afda commit ccc39fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
11 changes: 10 additions & 1 deletion selvpcclient/resell/v2/subnets/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@ func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*S
}

// List gets a list of subnets in the current domain.
func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Subnet, *selvpcclient.ResponseResult, error) {
func List(ctx context.Context, client *selvpcclient.ServiceClient, opts ListOpts) ([]*Subnet, *selvpcclient.ResponseResult, error) {
url := strings.Join([]string{client.Endpoint, resourceURL}, "/")

queryParams, err := selvpcclient.BuildQueryParameters(opts)
if err != nil {
return nil, nil, err
}
if queryParams != "" {
url = strings.Join([]string{url, queryParams}, "?")
}

responseResult, err := client.DoRequest(ctx, "GET", url, nil)
if err != nil {
return nil, nil, err
Expand Down
5 changes: 5 additions & 0 deletions selvpcclient/resell/v2/subnets/requests_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ type SubnetOpt struct {
// PrefixLength represents length of the subnet prefix.
PrefixLength int `json:"prefix_length"`
}

// ListOpts represents options for the licenses List request.
type ListOpts struct {
Detailed bool `param:"detailed"`
}
10 changes: 5 additions & 5 deletions selvpcclient/resell/v2/subnets/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestListSubnets(t *testing.T) {
TestListSubnetsResponseRaw, http.MethodGet, http.StatusOK, &endpointCalled, t)

ctx := context.Background()
actual, _, err := subnets.List(ctx, testEnv.Client)
actual, _, err := subnets.List(ctx, testEnv.Client, subnets.ListOpts{})
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestListSubnetsSingle(t *testing.T) {
TestListSubnetsSingleResponseRaw, http.MethodGet, http.StatusOK, &endpointCalled, t)

ctx := context.Background()
actual, _, err := subnets.List(ctx, testEnv.Client)
actual, _, err := subnets.List(ctx, testEnv.Client, subnets.ListOpts{})
if err != nil {
t.Fatal(err)
}
Expand All @@ -170,7 +170,7 @@ func TestListSubnetsHTTPError(t *testing.T) {
&endpointCalled, t)

ctx := context.Background()
allSubnet, httpResponse, err := subnets.List(ctx, testEnv.Client)
allSubnet, httpResponse, err := subnets.List(ctx, testEnv.Client, subnets.ListOpts{})

if !endpointCalled {
t.Fatal("endpoint wasn't called")
Expand All @@ -194,7 +194,7 @@ func TestListSubnetsTimeoutError(t *testing.T) {
testEnv.NewTestResellV2Client()

ctx := context.Background()
allSubnet, _, err := subnets.List(ctx, testEnv.Client)
allSubnet, _, err := subnets.List(ctx, testEnv.Client, subnets.ListOpts{})

if allSubnet != nil {
t.Fatal("expected no subnets from the List method")
Expand All @@ -215,7 +215,7 @@ func TestListSubnetsUnmarshalError(t *testing.T) {
&endpointCalled, t)

ctx := context.Background()
allSubnet, _, err := subnets.List(ctx, testEnv.Client)
allSubnet, _, err := subnets.List(ctx, testEnv.Client, subnets.ListOpts{})

if !endpointCalled {
t.Fatal("endpoint wasn't called")
Expand Down

0 comments on commit ccc39fe

Please sign in to comment.