Skip to content

Commit d499dad

Browse files
committed
chore: update method names
1 parent a28d26c commit d499dad

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

internal/provider/branch_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (d *BranchDataSource) Read(ctx context.Context, req datasource.ReadRequest,
105105

106106
// If applicable, this is a great opportunity to initialize any necessary
107107
// provider client data and make a call using it.
108-
httpResp, err := d.client.GetBranchesWithResponse(ctx, projectRef.ValueString())
108+
httpResp, err := d.client.V1ListAllBranchesWithResponse(ctx, projectRef.ValueString())
109109
if err != nil {
110110
msg := fmt.Sprintf("Unable to read branch, got error: %s", err)
111111
resp.Diagnostics.AddError("Client Error", msg)

internal/provider/branch_resource.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (r *BranchResource) ImportState(ctx context.Context, req resource.ImportSta
240240
}
241241

242242
func updateBranch(ctx context.Context, plan *BranchResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
243-
httpResp, err := client.UpdateBranchWithResponse(ctx, plan.Id.ValueString(), api.UpdateBranchBody{
243+
httpResp, err := client.V1UpdateABranchConfigWithResponse(ctx, plan.Id.ValueString(), api.UpdateBranchBody{
244244
BranchName: plan.GitBranch.ValueStringPointer(),
245245
GitBranch: plan.GitBranch.ValueStringPointer(),
246246
})
@@ -268,7 +268,7 @@ func readBranch(ctx context.Context, state *BranchResourceModel, client *api.Cli
268268
}
269269

270270
func readBranchDatabase(ctx context.Context, state *BranchResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
271-
httpResp, err := client.GetBranchDetailsWithResponse(ctx, state.Id.ValueString())
271+
httpResp, err := client.V1GetABranchConfigWithResponse(ctx, state.Id.ValueString())
272272
if err != nil {
273273
msg := fmt.Sprintf("Unable to read branch database, got error: %s", err)
274274
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -294,14 +294,14 @@ func readBranchDatabase(ctx context.Context, state *BranchResourceModel, client
294294
}
295295

296296
func createBranch(ctx context.Context, plan *BranchResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
297-
resp, err := client.GetBranches(ctx, plan.ParentProjectRef.ValueString())
297+
resp, err := client.V1ListAllBranches(ctx, plan.ParentProjectRef.ValueString())
298298
if err != nil {
299299
msg := fmt.Sprintf("Unable to enable branching, got error: %s", err)
300300
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
301301
}
302302
// 1. Enable branching
303303
if resp.StatusCode == http.StatusUnprocessableEntity {
304-
httpResp, err := client.CreateBranchWithResponse(ctx, plan.ParentProjectRef.ValueString(), api.CreateBranchBody{
304+
httpResp, err := client.V1CreateABranchWithResponse(ctx, plan.ParentProjectRef.ValueString(), api.CreateBranchBody{
305305
BranchName: "Production",
306306
})
307307
if err != nil {
@@ -314,7 +314,7 @@ func createBranch(ctx context.Context, plan *BranchResourceModel, client *api.Cl
314314
}
315315
}
316316
// 2. Create branch database
317-
httpResp, err := client.CreateBranchWithResponse(ctx, plan.ParentProjectRef.ValueString(), api.CreateBranchBody{
317+
httpResp, err := client.V1CreateABranchWithResponse(ctx, plan.ParentProjectRef.ValueString(), api.CreateBranchBody{
318318
BranchName: plan.GitBranch.ValueString(),
319319
GitBranch: plan.GitBranch.ValueStringPointer(),
320320
Region: plan.Region.ValueStringPointer(),
@@ -338,7 +338,7 @@ func createBranch(ctx context.Context, plan *BranchResourceModel, client *api.Cl
338338
}
339339

340340
func deleteBranch(ctx context.Context, state *BranchResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
341-
httpResp, err := client.DeleteBranchWithResponse(ctx, state.Id.ValueString())
341+
httpResp, err := client.V1DeleteABranchWithResponse(ctx, state.Id.ValueString())
342342
if err != nil {
343343
msg := fmt.Sprintf("Unable to delete branch, got error: %s", err)
344344
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}

internal/provider/pooler_data_source.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (d *PoolerDataSource) Read(ctx context.Context, req datasource.ReadRequest,
8787

8888
// If applicable, this is a great opportunity to initialize any necessary
8989
// provider client data and make a call using it.
90-
httpResp, err := d.client.V1GetPgbouncerConfigWithResponse(ctx, projectRef.ValueString())
90+
httpResp, err := d.client.V1GetSupavisorConfigWithResponse(ctx, projectRef.ValueString())
9191
if err != nil {
9292
msg := fmt.Sprintf("Unable to read pooler, got error: %s", err)
9393
resp.Diagnostics.AddError("Client Error", msg)
@@ -100,9 +100,10 @@ func (d *PoolerDataSource) Read(ctx context.Context, req datasource.ReadRequest,
100100
}
101101

102102
url := map[string]string{}
103-
if httpResp.JSON200.PoolMode != nil && httpResp.JSON200.ConnectionString != nil {
104-
mode := string(*httpResp.JSON200.PoolMode)
105-
url[mode] = *httpResp.JSON200.ConnectionString
103+
for _, pooler := range *httpResp.JSON200 {
104+
if pooler.DatabaseType == api.PRIMARY {
105+
url[string(pooler.PoolMode)] = pooler.ConnectionString
106+
}
106107
}
107108

108109
// Write logs using the tflog package

internal/provider/project_resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (r *ProjectResource) ImportState(ctx context.Context, req resource.ImportSt
180180
}
181181

182182
func createProject(ctx context.Context, data *ProjectResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
183-
body := api.CreateProjectJSONRequestBody{
183+
body := api.V1CreateProjectBody{
184184
OrganizationId: data.OrganizationId.ValueString(),
185185
Name: data.Name.ValueString(),
186186
DbPass: data.DatabasePassword.ValueString(),
@@ -190,7 +190,7 @@ func createProject(ctx context.Context, data *ProjectResourceModel, client *api.
190190
body.DesiredInstanceSize = Ptr(api.DesiredInstanceSize(data.InstanceSize.ValueString()))
191191
}
192192

193-
httpResp, err := client.CreateProjectWithResponse(ctx, body)
193+
httpResp, err := client.V1CreateAProjectWithResponse(ctx, body)
194194
if err != nil {
195195
msg := fmt.Sprintf("Unable to create project, got error: %s", err)
196196
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -206,7 +206,7 @@ func createProject(ctx context.Context, data *ProjectResourceModel, client *api.
206206
}
207207

208208
func readProject(ctx context.Context, data *ProjectResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
209-
httpResp, err := client.GetProjectsWithResponse(ctx)
209+
httpResp, err := client.V1ListAllProjectsWithResponse(ctx)
210210
if err != nil {
211211
msg := fmt.Sprintf("Unable to read project, got error: %s", err)
212212
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -232,7 +232,7 @@ func readProject(ctx context.Context, data *ProjectResourceModel, client *api.Cl
232232
}
233233

234234
func deleteProject(ctx context.Context, data *ProjectResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
235-
httpResp, err := client.DeleteProjectWithResponse(ctx, data.Id.ValueString())
235+
httpResp, err := client.V1DeleteAProjectWithResponse(ctx, data.Id.ValueString())
236236
if err != nil {
237237
msg := fmt.Sprintf("Unable to delete project, got error: %s", err)
238238
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}

internal/provider/settings_resource.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func (r *SettingsResource) ImportState(ctx context.Context, req resource.ImportS
251251
}
252252

253253
func readApiConfig(ctx context.Context, state *SettingsResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
254-
httpResp, err := client.GetPostgRESTConfigWithResponse(ctx, state.Id.ValueString())
254+
httpResp, err := client.V1GetPostgrestServiceConfigWithResponse(ctx, state.Id.ValueString())
255255
if err != nil {
256256
msg := fmt.Sprintf("Unable to read api settings, got error: %s", err)
257257
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -280,7 +280,7 @@ func updateApiConfig(ctx context.Context, plan *SettingsResourceModel, client *a
280280
return diags
281281
}
282282

283-
httpResp, err := client.UpdatePostgRESTConfigWithResponse(ctx, plan.ProjectRef.ValueString(), body)
283+
httpResp, err := client.V1UpdatePostgrestServiceConfigWithResponse(ctx, plan.ProjectRef.ValueString(), body)
284284
if err != nil {
285285
msg := fmt.Sprintf("Unable to update api settings, got error: %s", err)
286286
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -298,7 +298,7 @@ func updateApiConfig(ctx context.Context, plan *SettingsResourceModel, client *a
298298
}
299299

300300
func readAuthConfig(ctx context.Context, state *SettingsResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
301-
httpResp, err := client.GetV1AuthConfigWithResponse(ctx, state.Id.ValueString())
301+
httpResp, err := client.V1GetAuthServiceConfigWithResponse(ctx, state.Id.ValueString())
302302
if err != nil {
303303
msg := fmt.Sprintf("Unable to read auth settings, got error: %s", err)
304304
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -325,7 +325,7 @@ func updateAuthConfig(ctx context.Context, plan *SettingsResourceModel, client *
325325
return diags
326326
}
327327

328-
httpResp, err := client.UpdateV1AuthConfigWithResponse(ctx, plan.ProjectRef.ValueString(), body)
328+
httpResp, err := client.V1UpdateAuthServiceConfigWithResponse(ctx, plan.ProjectRef.ValueString(), body)
329329
if err != nil {
330330
msg := fmt.Sprintf("Unable to update auth settings, got error: %s", err)
331331
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -343,7 +343,7 @@ func updateAuthConfig(ctx context.Context, plan *SettingsResourceModel, client *
343343
}
344344

345345
func readDatabaseConfig(ctx context.Context, state *SettingsResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
346-
httpResp, err := client.GetConfigWithResponse(ctx, state.Id.ValueString())
346+
httpResp, err := client.V1GetPostgresConfigWithResponse(ctx, state.Id.ValueString())
347347
if err != nil {
348348
msg := fmt.Sprintf("Unable to read database settings, got error: %s", err)
349349
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -370,7 +370,7 @@ func updateDatabaseConfig(ctx context.Context, plan *SettingsResourceModel, clie
370370
return diags
371371
}
372372

373-
httpResp, err := client.UpdateConfigWithResponse(ctx, plan.ProjectRef.ValueString(), body)
373+
httpResp, err := client.V1UpdatePostgresConfigWithResponse(ctx, plan.ProjectRef.ValueString(), body)
374374
if err != nil {
375375
msg := fmt.Sprintf("Unable to update database settings, got error: %s", err)
376376
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -434,7 +434,7 @@ type NetworkConfig struct {
434434
}
435435

436436
func readNetworkConfig(ctx context.Context, state *SettingsResourceModel, client *api.ClientWithResponses) diag.Diagnostics {
437-
httpResp, err := client.GetNetworkRestrictionsWithResponse(ctx, state.Id.ValueString())
437+
httpResp, err := client.V1GetNetworkRestrictionsWithResponse(ctx, state.Id.ValueString())
438438
if err != nil {
439439
msg := fmt.Sprintf("Unable to read network settings, got error: %s", err)
440440
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}
@@ -470,7 +470,7 @@ func updateNetworkConfig(ctx context.Context, plan *SettingsResourceModel, clien
470470
return diags
471471
}
472472

473-
body := api.ApplyNetworkRestrictionsJSONRequestBody{
473+
body := api.NetworkRestrictionsRequest{
474474
DbAllowedCidrs: &[]string{},
475475
DbAllowedCidrsV6: &[]string{},
476476
}
@@ -491,7 +491,7 @@ func updateNetworkConfig(ctx context.Context, plan *SettingsResourceModel, clien
491491
}
492492
}
493493

494-
httpResp, err := client.ApplyNetworkRestrictionsWithResponse(ctx, plan.ProjectRef.ValueString(), body)
494+
httpResp, err := client.V1UpdateNetworkRestrictionsWithResponse(ctx, plan.ProjectRef.ValueString(), body)
495495
if err != nil {
496496
msg := fmt.Sprintf("Unable to update network settings, got error: %s", err)
497497
return diag.Diagnostics{diag.NewErrorDiagnostic("Client Error", msg)}

0 commit comments

Comments
 (0)