Skip to content

Commit df6254a

Browse files
authored
Fix response payload for cluster SKUs (#231)
* Fix response payload for cluster SKUs * Remove unused struct
1 parent 115268f commit df6254a

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

planetscale/organizations.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ func (o *organizationsService) ListRegions(ctx context.Context, listReq *ListOrg
128128
return listResponse.Regions, nil
129129
}
130130

131-
type listClusterSKUsResponse struct {
132-
ClusterSKUs []*ClusterSKU `json:"data"`
133-
}
134-
135131
func (o *organizationsService) ListClusterSKUs(ctx context.Context, listReq *ListOrganizationClusterSKUsRequest, opts ...ListOption) ([]*ClusterSKU, error) {
136132
path := fmt.Sprintf("%s/%s/cluster-size-skus", organizationsAPIPath, listReq.Organization)
137133

@@ -149,10 +145,10 @@ func (o *organizationsService) ListClusterSKUs(ctx context.Context, listReq *Lis
149145
return nil, errors.Wrap(err, "error creating http request")
150146
}
151147

152-
listResponse := &listClusterSKUsResponse{}
153-
if err := o.client.do(ctx, req, &listResponse); err != nil {
148+
clusterSKUs := []*ClusterSKU{}
149+
if err := o.client.do(ctx, req, &clusterSKUs); err != nil {
154150
return nil, err
155151
}
156152

157-
return listResponse.ClusterSKUs, nil
153+
return clusterSKUs, nil
158154
}

planetscale/organizations_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ func TestOrganizations_ListClusterSKUs(t *testing.T) {
135135
w.WriteHeader(200)
136136

137137
c.Assert(r.URL.String(), qt.Equals, "/v1/organizations/my-cool-org/cluster-size-skus")
138-
out := `{
139-
"data": [
138+
out := `[
140139
{
141140
"name": "PS_10",
142141
"type": "ClusterSizeSku",
@@ -153,8 +152,7 @@ func TestOrganizations_ListClusterSKUs(t *testing.T) {
153152
"default_vtgate": "VTG_5",
154153
"default_vtgate_rate": null
155154
}
156-
]
157-
}`
155+
]`
158156

159157
_, err := w.Write([]byte(out))
160158
c.Assert(err, qt.IsNil)
@@ -191,8 +189,7 @@ func TestOrganizations_ListClusterSKUsWithRates(t *testing.T) {
191189
w.WriteHeader(200)
192190

193191
c.Assert(r.URL.String(), qt.Equals, "/v1/organizations/my-cool-org/cluster-size-skus?rates=true")
194-
out := `{
195-
"data": [
192+
out := `[
196193
{
197194
"name": "PS_10",
198195
"type": "ClusterSizeSku",
@@ -209,8 +206,7 @@ func TestOrganizations_ListClusterSKUsWithRates(t *testing.T) {
209206
"default_vtgate": "VTG_5",
210207
"default_vtgate_rate": null
211208
}
212-
]
213-
}`
209+
]`
214210

215211
_, err := w.Write([]byte(out))
216212
c.Assert(err, qt.IsNil)

0 commit comments

Comments
 (0)