Update SDK dependency (#177)
* Update dependencies * Update dependencies * Update dependencies * Update dependencies --------- Co-authored-by: Henrique Santos <henrique.santos@freiheit.com>
This commit is contained in:
parent
506d1afdc2
commit
c7effac5c7
62 changed files with 382 additions and 382 deletions
|
|
@ -330,7 +330,7 @@ func testAccCheckArgusDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
||||
got, err := r.client.CreateCredential(ctx, instanceId, projectId).Execute()
|
||||
got, err := r.client.CreateCredentials(ctx, instanceId, projectId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
|
|
@ -167,7 +167,7 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
tflog.Info(ctx, "Argus credential created")
|
||||
}
|
||||
|
||||
func mapFields(r *argus.Credential, model *Model) error {
|
||||
func mapFields(r *argus.Credentials, model *Model) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("response input is nil")
|
||||
}
|
||||
|
|
@ -206,7 +206,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
userName := model.Username.ValueString()
|
||||
_, err := r.client.GetCredential(ctx, instanceId, projectId, userName).Execute()
|
||||
_, err := r.client.GetCredentials(ctx, instanceId, projectId, userName).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
|
|
@ -236,7 +236,7 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
userName := model.Username.ValueString()
|
||||
_, err := r.client.DeleteCredential(ctx, instanceId, projectId, userName).Execute()
|
||||
_, err := r.client.DeleteCredentials(ctx, instanceId, projectId, userName).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ import (
|
|||
func TestMapFields(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
input *argus.Credential
|
||||
input *argus.Credentials
|
||||
expected Model
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"ok",
|
||||
&argus.Credential{
|
||||
&argus.Credentials{
|
||||
Username: utils.Ptr("username"),
|
||||
Password: utils.Ptr("password"),
|
||||
},
|
||||
|
|
@ -39,7 +39,7 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"response_fields_nil_fail",
|
||||
&argus.Credential{
|
||||
&argus.Credentials{
|
||||
Password: nil,
|
||||
Username: nil,
|
||||
},
|
||||
|
|
@ -48,7 +48,7 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&argus.Credential{},
|
||||
&argus.Credentials{},
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ func (r *instanceResource) ImportState(ctx context.Context, req resource.ImportS
|
|||
tflog.Info(ctx, "Argus instance state imported")
|
||||
}
|
||||
|
||||
func mapFields(ctx context.Context, r *argus.InstanceResponse, model *Model) error {
|
||||
func mapFields(ctx context.Context, r *argus.GetInstanceResponse, model *Model) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("response input is nil")
|
||||
}
|
||||
|
|
@ -540,7 +540,7 @@ func toUpdatePayload(model *Model) (*argus.UpdateInstancePayload, error) {
|
|||
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := r.client.GetPlans(ctx, projectId).Execute()
|
||||
res, err := r.client.ListPlans(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ import (
|
|||
func TestMapFields(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
input *argus.InstanceResponse
|
||||
input *argus.GetInstanceResponse
|
||||
expected Model
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_ok",
|
||||
&argus.InstanceResponse{
|
||||
&argus.GetInstanceResponse{
|
||||
Id: utils.Ptr("iid"),
|
||||
},
|
||||
Model{
|
||||
|
|
@ -37,7 +37,7 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"values_ok",
|
||||
&argus.InstanceResponse{
|
||||
&argus.GetInstanceResponse{
|
||||
Id: utils.Ptr("iid"),
|
||||
Name: utils.Ptr("name"),
|
||||
PlanName: utils.Ptr("plan1"),
|
||||
|
|
@ -57,7 +57,7 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nullable_fields_ok",
|
||||
&argus.InstanceResponse{
|
||||
&argus.GetInstanceResponse{
|
||||
Id: utils.Ptr("iid"),
|
||||
Name: nil,
|
||||
},
|
||||
|
|
@ -80,7 +80,7 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&argus.InstanceResponse{},
|
||||
&argus.GetInstanceResponse{},
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -536,7 +536,7 @@ func testAccCheckDnsDestroy(s *terraform.State) error {
|
|||
zonesToDestroy = append(zonesToDestroy, zoneId)
|
||||
}
|
||||
|
||||
zonesResp, err := client.GetZones(ctx, testutil.ProjectId).ActiveEq(true).Execute()
|
||||
zonesResp, err := client.ListZones(ctx, testutil.ProjectId).ActiveEq(true).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting zonesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,12 +318,12 @@ func (r *recordSetResource) Update(ctx context.Context, req resource.UpdateReque
|
|||
return
|
||||
}
|
||||
// Update recordset
|
||||
_, err = r.client.UpdateRecordSet(ctx, projectId, zoneId, recordSetId).UpdateRecordSetPayload(*payload).Execute()
|
||||
_, err = r.client.PartialUpdateRecordSet(ctx, projectId, zoneId, recordSetId).PartialUpdateRecordSetPayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating record set", err.Error())
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateRecordSetWaitHandler(ctx, r.client, projectId, zoneId, recordSetId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateRecordSetWaitHandler(ctx, r.client, projectId, zoneId, recordSetId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating record set", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -465,7 +465,7 @@ func toCreatePayload(model *Model) (*dns.CreateRecordSetPayload, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model) (*dns.UpdateRecordSetPayload, error) {
|
||||
func toUpdatePayload(model *Model) (*dns.PartialUpdateRecordSetPayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
|
@ -481,7 +481,7 @@ func toUpdatePayload(model *Model) (*dns.UpdateRecordSetPayload, error) {
|
|||
})
|
||||
}
|
||||
|
||||
return &dns.UpdateRecordSetPayload{
|
||||
return &dns.PartialUpdateRecordSetPayload{
|
||||
Comment: conversion.StringValueToPointer(model.Comment),
|
||||
Name: conversion.StringValueToPointer(model.Name),
|
||||
Records: &records,
|
||||
|
|
|
|||
|
|
@ -231,13 +231,13 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
tests := []struct {
|
||||
description string
|
||||
input *Model
|
||||
expected *dns.UpdateRecordSetPayload
|
||||
expected *dns.PartialUpdateRecordSetPayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&Model{},
|
||||
&dns.UpdateRecordSetPayload{
|
||||
&dns.PartialUpdateRecordSetPayload{
|
||||
Records: &[]dns.RecordPayload{},
|
||||
},
|
||||
true,
|
||||
|
|
@ -253,7 +253,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
}),
|
||||
TTL: types.Int64Value(1),
|
||||
},
|
||||
&dns.UpdateRecordSetPayload{
|
||||
&dns.PartialUpdateRecordSetPayload{
|
||||
Comment: utils.Ptr("comment"),
|
||||
Name: utils.Ptr("name"),
|
||||
Records: &[]dns.RecordPayload{
|
||||
|
|
@ -272,7 +272,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
Records: types.ListValueMust(types.StringType, nil),
|
||||
TTL: types.Int64Value(2123456789),
|
||||
},
|
||||
&dns.UpdateRecordSetPayload{
|
||||
&dns.PartialUpdateRecordSetPayload{
|
||||
Comment: nil,
|
||||
Name: utils.Ptr(""),
|
||||
Records: &[]dns.RecordPayload{},
|
||||
|
|
|
|||
|
|
@ -398,12 +398,12 @@ func (r *zoneResource) Update(ctx context.Context, req resource.UpdateRequest, r
|
|||
return
|
||||
}
|
||||
// Update existing zone
|
||||
_, err = r.client.UpdateZone(ctx, projectId, zoneId).UpdateZonePayload(*payload).Execute()
|
||||
_, err = r.client.PartialUpdateZone(ctx, projectId, zoneId).PartialUpdateZonePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating zone", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateZoneWaitHandler(ctx, r.client, projectId, zoneId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateZoneWaitHandler(ctx, r.client, projectId, zoneId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating zone", fmt.Sprintf("Zone update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -574,12 +574,12 @@ func toCreatePayload(model *Model) (*dns.CreateZonePayload, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model) (*dns.UpdateZonePayload, error) {
|
||||
func toUpdatePayload(model *Model) (*dns.PartialUpdateZonePayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
return &dns.UpdateZonePayload{
|
||||
return &dns.PartialUpdateZonePayload{
|
||||
Name: conversion.StringValueToPointer(model.Name),
|
||||
ContactEmail: conversion.StringValueToPointer(model.ContactEmail),
|
||||
Description: conversion.StringValueToPointer(model.Description),
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ func TestToPayloadUpdate(t *testing.T) {
|
|||
tests := []struct {
|
||||
description string
|
||||
input *Model
|
||||
expected *dns.UpdateZonePayload
|
||||
expected *dns.PartialUpdateZonePayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
|
|
@ -289,7 +289,7 @@ func TestToPayloadUpdate(t *testing.T) {
|
|||
&Model{
|
||||
Name: types.StringValue("Name"),
|
||||
},
|
||||
&dns.UpdateZonePayload{
|
||||
&dns.PartialUpdateZonePayload{
|
||||
Name: utils.Ptr("Name"),
|
||||
},
|
||||
true,
|
||||
|
|
@ -315,7 +315,7 @@ func TestToPayloadUpdate(t *testing.T) {
|
|||
NegativeCache: types.Int64Value(-4534534),
|
||||
IsReverseZone: types.BoolValue(true),
|
||||
},
|
||||
&dns.UpdateZonePayload{
|
||||
&dns.PartialUpdateZonePayload{
|
||||
Name: utils.Ptr("Name"),
|
||||
Acl: utils.Ptr("Acl"),
|
||||
Description: utils.Ptr("Description"),
|
||||
|
|
|
|||
|
|
@ -485,7 +485,7 @@ func (r *loadBalancerResource) Create(ctx context.Context, req resource.CreateRe
|
|||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
// Get status of load balancer functionality
|
||||
statusResp, err := r.client.GetStatus(ctx, projectId).Execute()
|
||||
statusResp, err := r.client.GetServiceStatus(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error getting status of load balancer functionality", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
|
|
@ -493,13 +493,13 @@ func (r *loadBalancerResource) Create(ctx context.Context, req resource.CreateRe
|
|||
|
||||
// If load balancer functionality is not enabled, enable it
|
||||
if *statusResp.Status != wait.FunctionalityStatusReady {
|
||||
_, err = r.client.EnableLoadBalancing(ctx, projectId).XRequestID(uuid.NewString()).Execute()
|
||||
_, err = r.client.EnableService(ctx, projectId).XRequestID(uuid.NewString()).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error enabling load balancer functionality", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
_, err := wait.EnableLoadBalancingWaitHandler(ctx, r.client, projectId).WaitWithContext(ctx)
|
||||
_, err := wait.EnableServiceWaitHandler(ctx, r.client, projectId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error enabling load balancer functionality", fmt.Sprintf("Waiting for enablement: %v", err))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ func testAccCheckLoadBalancerDestroy(_ *terraform.State) error {
|
|||
}
|
||||
|
||||
// Disabling loadbalancer functionality will delete all load balancers
|
||||
_, err = client.DisableLoadBalancingExecute(ctx, testutil.ProjectId)
|
||||
_, err = client.DisableServiceExecute(ctx, testutil.ProjectId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("disabling loadbalancer functionality: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,12 +361,12 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
// Update existing instance
|
||||
err = r.client.UpdateInstance(ctx, projectId, instanceId).UpdateInstancePayload(*payload).Execute()
|
||||
err = r.client.PartialUpdateInstance(ctx, projectId, instanceId).PartialUpdateInstancePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -594,17 +594,17 @@ func toCreatePayload(model *Model, parameters *parametersModel) (*logme.CreateIn
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*logme.UpdateInstancePayload, error) {
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*logme.PartialUpdateInstancePayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
if parameters == nil {
|
||||
return &logme.UpdateInstancePayload{
|
||||
return &logme.PartialUpdateInstancePayload{
|
||||
PlanId: conversion.StringValueToPointer(model.PlanId),
|
||||
}, nil
|
||||
}
|
||||
return &logme.UpdateInstancePayload{
|
||||
return &logme.PartialUpdateInstancePayload{
|
||||
Parameters: &logme.InstanceParameters{
|
||||
SgwAcl: conversion.StringValueToPointer(parameters.SgwAcl),
|
||||
},
|
||||
|
|
@ -614,7 +614,7 @@ func toUpdatePayload(model *Model, parameters *parametersModel) (*logme.UpdateIn
|
|||
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := r.client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := r.client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting LogMe offerings: %w", err)
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
|||
func loadPlanNameAndVersion(ctx context.Context, client *logme.APIClient, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
planId := model.PlanId.ValueString()
|
||||
res, err := client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting LogMe offerings: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,14 +221,14 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
description string
|
||||
input *Model
|
||||
inputParameters *parametersModel
|
||||
expected *logme.UpdateInstancePayload
|
||||
expected *logme.PartialUpdateInstancePayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&Model{},
|
||||
¶metersModel{},
|
||||
&logme.UpdateInstancePayload{
|
||||
&logme.PartialUpdateInstancePayload{
|
||||
Parameters: &logme.InstanceParameters{},
|
||||
},
|
||||
true,
|
||||
|
|
@ -241,7 +241,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringValue("sgw"),
|
||||
},
|
||||
&logme.UpdateInstancePayload{
|
||||
&logme.PartialUpdateInstancePayload{
|
||||
Parameters: &logme.InstanceParameters{
|
||||
SgwAcl: utils.Ptr("sgw"),
|
||||
},
|
||||
|
|
@ -257,7 +257,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringNull(),
|
||||
},
|
||||
&logme.UpdateInstancePayload{
|
||||
&logme.PartialUpdateInstancePayload{
|
||||
Parameters: &logme.InstanceParameters{
|
||||
SgwAcl: nil,
|
||||
},
|
||||
|
|
@ -278,7 +278,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
PlanId: types.StringValue("plan"),
|
||||
},
|
||||
nil,
|
||||
&logme.UpdateInstancePayload{
|
||||
&logme.PartialUpdateInstancePayload{
|
||||
PlanId: utils.Ptr("plan"),
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ func testAccCheckLogMeDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,12 +361,12 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
// Update existing instance
|
||||
err = r.client.UpdateInstance(ctx, projectId, instanceId).UpdateInstancePayload(*payload).Execute()
|
||||
err = r.client.PartialUpdateInstance(ctx, projectId, instanceId).PartialUpdateInstancePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -594,17 +594,17 @@ func toCreatePayload(model *Model, parameters *parametersModel) (*mariadb.Create
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*mariadb.UpdateInstancePayload, error) {
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*mariadb.PartialUpdateInstancePayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
if parameters == nil {
|
||||
return &mariadb.UpdateInstancePayload{
|
||||
return &mariadb.PartialUpdateInstancePayload{
|
||||
PlanId: conversion.StringValueToPointer(model.PlanId),
|
||||
}, nil
|
||||
}
|
||||
return &mariadb.UpdateInstancePayload{
|
||||
return &mariadb.PartialUpdateInstancePayload{
|
||||
Parameters: &mariadb.InstanceParameters{
|
||||
SgwAcl: conversion.StringValueToPointer(parameters.SgwAcl),
|
||||
},
|
||||
|
|
@ -614,7 +614,7 @@ func toUpdatePayload(model *Model, parameters *parametersModel) (*mariadb.Update
|
|||
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := r.client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := r.client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting MariaDB offerings: %w", err)
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
|||
func loadPlanNameAndVersion(ctx context.Context, client *mariadb.APIClient, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
planId := model.PlanId.ValueString()
|
||||
res, err := client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting MariaDB offerings: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,14 +221,14 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
description string
|
||||
input *Model
|
||||
inputParameters *parametersModel
|
||||
expected *mariadb.UpdateInstancePayload
|
||||
expected *mariadb.PartialUpdateInstancePayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&Model{},
|
||||
¶metersModel{},
|
||||
&mariadb.UpdateInstancePayload{
|
||||
&mariadb.PartialUpdateInstancePayload{
|
||||
Parameters: &mariadb.InstanceParameters{},
|
||||
},
|
||||
true,
|
||||
|
|
@ -241,7 +241,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringValue("sgw"),
|
||||
},
|
||||
&mariadb.UpdateInstancePayload{
|
||||
&mariadb.PartialUpdateInstancePayload{
|
||||
Parameters: &mariadb.InstanceParameters{
|
||||
SgwAcl: utils.Ptr("sgw"),
|
||||
},
|
||||
|
|
@ -257,7 +257,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringNull(),
|
||||
},
|
||||
&mariadb.UpdateInstancePayload{
|
||||
&mariadb.PartialUpdateInstancePayload{
|
||||
Parameters: &mariadb.InstanceParameters{
|
||||
SgwAcl: nil,
|
||||
},
|
||||
|
|
@ -278,7 +278,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
PlanId: types.StringValue("plan"),
|
||||
},
|
||||
nil,
|
||||
&mariadb.UpdateInstancePayload{
|
||||
&mariadb.PartialUpdateInstancePayload{
|
||||
PlanId: utils.Ptr("plan"),
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ func testAccCheckMariaDBDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -669,14 +669,14 @@ func toCreatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
}
|
||||
|
||||
return &mongodbflex.CreateInstancePayload{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &acl,
|
||||
},
|
||||
BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
|
||||
FlavorId: conversion.StringValueToPointer(flavor.Id),
|
||||
Name: conversion.StringValueToPointer(model.Name),
|
||||
Replicas: conversion.Int64ValueToPointer(model.Replicas),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Storage: &mongodbflex.Storage{
|
||||
Class: conversion.StringValueToPointer(storage.Class),
|
||||
Size: conversion.Int64ValueToPointer(storage.Size),
|
||||
},
|
||||
|
|
@ -708,14 +708,14 @@ func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
}
|
||||
|
||||
return &mongodbflex.PartialUpdateInstancePayload{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &acl,
|
||||
},
|
||||
BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
|
||||
FlavorId: conversion.StringValueToPointer(flavor.Id),
|
||||
Name: conversion.StringValueToPointer(model.Name),
|
||||
Replicas: conversion.Int64ValueToPointer(model.Replicas),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Storage: &mongodbflex.Storage{
|
||||
Class: conversion.StringValueToPointer(storage.Class),
|
||||
Size: conversion.Int64ValueToPointer(storage.Size),
|
||||
},
|
||||
|
|
@ -725,7 +725,7 @@ func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
}
|
||||
|
||||
type mongoDBFlexClient interface {
|
||||
GetFlavorsExecute(ctx context.Context, projectId string) (*mongodbflex.GetFlavorsResponse, error)
|
||||
ListFlavorsExecute(ctx context.Context, projectId string) (*mongodbflex.ListFlavorsResponse, error)
|
||||
}
|
||||
|
||||
func loadFlavorId(ctx context.Context, client mongoDBFlexClient, model *Model, flavor *flavorModel) error {
|
||||
|
|
@ -745,7 +745,7 @@ func loadFlavorId(ctx context.Context, client mongoDBFlexClient, model *Model, f
|
|||
}
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := client.GetFlavorsExecute(ctx, projectId)
|
||||
res, err := client.ListFlavorsExecute(ctx, projectId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listing mongodbflex flavors: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ import (
|
|||
)
|
||||
|
||||
type mongoDBFlexClientMocked struct {
|
||||
returnError bool
|
||||
getFlavorsResp *mongodbflex.GetFlavorsResponse
|
||||
returnError bool
|
||||
listFlavorsResp *mongodbflex.ListFlavorsResponse
|
||||
}
|
||||
|
||||
func (c *mongoDBFlexClientMocked) GetFlavorsExecute(_ context.Context, _ string) (*mongodbflex.GetFlavorsResponse, error) {
|
||||
func (c *mongoDBFlexClientMocked) ListFlavorsExecute(_ context.Context, _ string) (*mongodbflex.ListFlavorsResponse, error) {
|
||||
if c.returnError {
|
||||
return nil, fmt.Errorf("get flavors failed")
|
||||
}
|
||||
|
||||
return c.getFlavorsResp, nil
|
||||
return c.listFlavorsResp, nil
|
||||
}
|
||||
|
||||
func TestMapFields(t *testing.T) {
|
||||
|
|
@ -38,7 +38,7 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"default_values",
|
||||
&mongodbflex.GetInstanceResponse{
|
||||
Item: &mongodbflex.InstanceSingleInstance{},
|
||||
Item: &mongodbflex.Instance{},
|
||||
},
|
||||
&flavorModel{},
|
||||
&storageModel{},
|
||||
|
|
@ -71,8 +71,8 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"simple_values",
|
||||
&mongodbflex.GetInstanceResponse{
|
||||
Item: &mongodbflex.InstanceSingleInstance{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Item: &mongodbflex.Instance{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &[]string{
|
||||
"ip1",
|
||||
"ip2",
|
||||
|
|
@ -80,7 +80,7 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
},
|
||||
BackupSchedule: utils.Ptr("schedule"),
|
||||
Flavor: &mongodbflex.InstanceFlavor{
|
||||
Flavor: &mongodbflex.Flavor{
|
||||
Cpu: utils.Ptr(int64(12)),
|
||||
Description: utils.Ptr("description"),
|
||||
Id: utils.Ptr("flavor_id"),
|
||||
|
|
@ -90,7 +90,7 @@ func TestMapFields(t *testing.T) {
|
|||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int64(56)),
|
||||
Status: utils.Ptr("status"),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Storage: &mongodbflex.Storage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int64(78)),
|
||||
},
|
||||
|
|
@ -135,8 +135,8 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"simple_values_no_flavor_and_storage",
|
||||
&mongodbflex.GetInstanceResponse{
|
||||
Item: &mongodbflex.InstanceSingleInstance{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Item: &mongodbflex.Instance{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &[]string{
|
||||
"ip1",
|
||||
"ip2",
|
||||
|
|
@ -257,10 +257,10 @@ func TestToCreatePayload(t *testing.T) {
|
|||
&storageModel{},
|
||||
&optionsModel{},
|
||||
&mongodbflex.CreateInstancePayload{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &[]string{},
|
||||
},
|
||||
Storage: &mongodbflex.InstanceStorage{},
|
||||
Storage: &mongodbflex.Storage{},
|
||||
Options: &map[string]string{},
|
||||
},
|
||||
true,
|
||||
|
|
@ -288,7 +288,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
Type: types.StringValue("type"),
|
||||
},
|
||||
&mongodbflex.CreateInstancePayload{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &[]string{
|
||||
"ip_1",
|
||||
"ip_2",
|
||||
|
|
@ -298,7 +298,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
FlavorId: utils.Ptr("flavor_id"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int64(12)),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Storage: &mongodbflex.Storage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int64(34)),
|
||||
},
|
||||
|
|
@ -329,7 +329,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
Type: types.StringNull(),
|
||||
},
|
||||
&mongodbflex.CreateInstancePayload{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &[]string{
|
||||
"",
|
||||
},
|
||||
|
|
@ -338,7 +338,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
FlavorId: nil,
|
||||
Name: nil,
|
||||
Replicas: utils.Ptr(int64(2123456789)),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Storage: &mongodbflex.Storage{
|
||||
Class: nil,
|
||||
Size: nil,
|
||||
},
|
||||
|
|
@ -436,10 +436,10 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
&storageModel{},
|
||||
&optionsModel{},
|
||||
&mongodbflex.PartialUpdateInstancePayload{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &[]string{},
|
||||
},
|
||||
Storage: &mongodbflex.InstanceStorage{},
|
||||
Storage: &mongodbflex.Storage{},
|
||||
Options: &map[string]string{},
|
||||
},
|
||||
true,
|
||||
|
|
@ -467,7 +467,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
Type: types.StringValue("type"),
|
||||
},
|
||||
&mongodbflex.PartialUpdateInstancePayload{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &[]string{
|
||||
"ip_1",
|
||||
"ip_2",
|
||||
|
|
@ -477,7 +477,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
FlavorId: utils.Ptr("flavor_id"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int64(12)),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Storage: &mongodbflex.Storage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int64(34)),
|
||||
},
|
||||
|
|
@ -508,7 +508,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
Type: types.StringNull(),
|
||||
},
|
||||
&mongodbflex.PartialUpdateInstancePayload{
|
||||
Acl: &mongodbflex.InstanceAcl{
|
||||
Acl: &mongodbflex.ACL{
|
||||
Items: &[]string{
|
||||
"",
|
||||
},
|
||||
|
|
@ -517,7 +517,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
FlavorId: nil,
|
||||
Name: nil,
|
||||
Replicas: utils.Ptr(int64(2123456789)),
|
||||
Storage: &mongodbflex.InstanceStorage{
|
||||
Storage: &mongodbflex.Storage{
|
||||
Class: nil,
|
||||
Size: nil,
|
||||
},
|
||||
|
|
@ -600,7 +600,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
tests := []struct {
|
||||
description string
|
||||
inputFlavor *flavorModel
|
||||
mockedResp *mongodbflex.GetFlavorsResponse
|
||||
mockedResp *mongodbflex.ListFlavorsResponse
|
||||
expected *flavorModel
|
||||
getFlavorsFails bool
|
||||
isValid bool
|
||||
|
|
@ -611,7 +611,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&mongodbflex.GetFlavorsResponse{
|
||||
&mongodbflex.ListFlavorsResponse{
|
||||
Flavors: &[]mongodbflex.HandlersInfraFlavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
|
|
@ -636,7 +636,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&mongodbflex.GetFlavorsResponse{
|
||||
&mongodbflex.ListFlavorsResponse{
|
||||
Flavors: &[]mongodbflex.HandlersInfraFlavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
|
|
@ -667,7 +667,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&mongodbflex.GetFlavorsResponse{
|
||||
&mongodbflex.ListFlavorsResponse{
|
||||
Flavors: &[]mongodbflex.HandlersInfraFlavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
|
|
@ -696,7 +696,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&mongodbflex.GetFlavorsResponse{},
|
||||
&mongodbflex.ListFlavorsResponse{},
|
||||
&flavorModel{
|
||||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
|
|
@ -710,7 +710,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&mongodbflex.GetFlavorsResponse{},
|
||||
&mongodbflex.ListFlavorsResponse{},
|
||||
&flavorModel{
|
||||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
|
|
@ -722,8 +722,8 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.description, func(t *testing.T) {
|
||||
client := &mongoDBFlexClientMocked{
|
||||
returnError: tt.getFlavorsFails,
|
||||
getFlavorsResp: tt.mockedResp,
|
||||
returnError: tt.getFlavorsFails,
|
||||
listFlavorsResp: tt.mockedResp,
|
||||
}
|
||||
model := &Model{
|
||||
ProjectId: types.StringValue("pid"),
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ func testAccCheckMongoDBFlexDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Tag("").Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Tag("").Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"default_values",
|
||||
&mongodbflex.CreateUserResponse{
|
||||
Item: &mongodbflex.InstanceUser{
|
||||
Item: &mongodbflex.User{
|
||||
Id: utils.Ptr("uid"),
|
||||
Password: utils.Ptr(""),
|
||||
},
|
||||
|
|
@ -42,7 +42,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"simple_values",
|
||||
&mongodbflex.CreateUserResponse{
|
||||
Item: &mongodbflex.InstanceUser{
|
||||
Item: &mongodbflex.User{
|
||||
Id: utils.Ptr("uid"),
|
||||
Roles: &[]string{
|
||||
"role_1",
|
||||
|
|
@ -77,7 +77,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&mongodbflex.CreateUserResponse{
|
||||
Item: &mongodbflex.InstanceUser{
|
||||
Item: &mongodbflex.User{
|
||||
Id: utils.Ptr("uid"),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
|
|
@ -116,7 +116,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"no_resource_id",
|
||||
&mongodbflex.CreateUserResponse{
|
||||
Item: &mongodbflex.InstanceUser{},
|
||||
Item: &mongodbflex.User{},
|
||||
},
|
||||
Model{},
|
||||
false,
|
||||
|
|
@ -124,7 +124,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"no_password",
|
||||
&mongodbflex.CreateUserResponse{
|
||||
Item: &mongodbflex.InstanceUser{
|
||||
Item: &mongodbflex.User{
|
||||
Id: utils.Ptr("uid"),
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ func mapFields(bucketResp *objectstorage.GetBucketResponse, model *Model) error
|
|||
}
|
||||
|
||||
type objectStorageClient interface {
|
||||
CreateProjectExecute(ctx context.Context, projectId string) (*objectstorage.GetProjectResponse, error)
|
||||
EnableServiceExecute(ctx context.Context, projectId string) (*objectstorage.ProjectStatus, error)
|
||||
}
|
||||
|
||||
// enableProject enables object storage for the specified project. If the project is already enabled, nothing happens
|
||||
|
|
@ -305,7 +305,7 @@ func enableProject(ctx context.Context, model *Model, client objectStorageClient
|
|||
projectId := model.ProjectId.ValueString()
|
||||
|
||||
// From the object storage OAS: Creation will also be successful if the project is already enabled, but will not create a duplicate
|
||||
_, err := client.CreateProjectExecute(ctx, projectId)
|
||||
_, err := client.EnableServiceExecute(ctx, projectId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create object storage project: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ type objectStorageClientMocked struct {
|
|||
returnError bool
|
||||
}
|
||||
|
||||
func (c *objectStorageClientMocked) CreateProjectExecute(_ context.Context, projectId string) (*objectstorage.GetProjectResponse, error) {
|
||||
func (c *objectStorageClientMocked) EnableServiceExecute(_ context.Context, projectId string) (*objectstorage.ProjectStatus, error) {
|
||||
if c.returnError {
|
||||
return nil, fmt.Errorf("create project failed")
|
||||
}
|
||||
|
||||
return &objectstorage.GetProjectResponse{
|
||||
return &objectstorage.ProjectStatus{
|
||||
Project: utils.Ptr(projectId),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor
|
|||
}
|
||||
|
||||
type objectStorageClient interface {
|
||||
CreateProjectExecute(ctx context.Context, projectId string) (*objectstorage.GetProjectResponse, error)
|
||||
EnableServiceExecute(ctx context.Context, projectId string) (*objectstorage.ProjectStatus, error)
|
||||
}
|
||||
|
||||
// enableProject enables object storage for the specified project. If the project is already enabled, nothing happens
|
||||
|
|
@ -313,7 +313,7 @@ func enableProject(ctx context.Context, model *Model, client objectStorageClient
|
|||
projectId := model.ProjectId.ValueString()
|
||||
|
||||
// From the object storage OAS: Creation will also be successful if the project is already enabled, but will not create a duplicate
|
||||
_, err := client.CreateProjectExecute(ctx, projectId)
|
||||
_, err := client.EnableServiceExecute(ctx, projectId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create object storage project: %w", err)
|
||||
}
|
||||
|
|
@ -394,7 +394,7 @@ func readCredentials(ctx context.Context, model *Model, client *objectstorage.AP
|
|||
credentialsGroupId := model.CredentialsGroupId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
||||
credentialsGroupResp, err := client.GetAccessKeys(ctx, projectId).CredentialsGroup(credentialsGroupId).Execute()
|
||||
credentialsGroupResp, err := client.ListAccessKeys(ctx, projectId).CredentialsGroup(credentialsGroupId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting credentials groups: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ type objectStorageClientMocked struct {
|
|||
returnError bool
|
||||
}
|
||||
|
||||
func (c *objectStorageClientMocked) CreateProjectExecute(_ context.Context, projectId string) (*objectstorage.GetProjectResponse, error) {
|
||||
func (c *objectStorageClientMocked) EnableServiceExecute(_ context.Context, projectId string) (*objectstorage.ProjectStatus, error) {
|
||||
if c.returnError {
|
||||
return nil, fmt.Errorf("create project failed")
|
||||
}
|
||||
|
||||
return &objectstorage.GetProjectResponse{
|
||||
return &objectstorage.ProjectStatus{
|
||||
Project: utils.Ptr(projectId),
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -212,14 +212,14 @@ func TestReadCredentials(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
description string
|
||||
mockedResp *objectstorage.GetAccessKeysResponse
|
||||
mockedResp *objectstorage.ListAccessKeysResponse
|
||||
expected Model
|
||||
getCredentialsFails bool
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&objectstorage.GetAccessKeysResponse{
|
||||
&objectstorage.ListAccessKeysResponse{
|
||||
AccessKeys: &[]objectstorage.AccessKey{
|
||||
{
|
||||
KeyId: utils.Ptr("foo-cid"),
|
||||
|
|
@ -247,7 +247,7 @@ func TestReadCredentials(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"simple_values",
|
||||
&objectstorage.GetAccessKeysResponse{
|
||||
&objectstorage.ListAccessKeysResponse{
|
||||
AccessKeys: &[]objectstorage.AccessKey{
|
||||
{
|
||||
KeyId: utils.Ptr("foo-cid"),
|
||||
|
|
@ -281,7 +281,7 @@ func TestReadCredentials(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"expiration_timestamp_with_fractional_seconds",
|
||||
&objectstorage.GetAccessKeysResponse{
|
||||
&objectstorage.ListAccessKeysResponse{
|
||||
AccessKeys: &[]objectstorage.AccessKey{
|
||||
{
|
||||
KeyId: utils.Ptr("foo-cid"),
|
||||
|
|
@ -315,7 +315,7 @@ func TestReadCredentials(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"empty_credentials",
|
||||
&objectstorage.GetAccessKeysResponse{
|
||||
&objectstorage.ListAccessKeysResponse{
|
||||
AccessKeys: &[]objectstorage.AccessKey{},
|
||||
},
|
||||
Model{},
|
||||
|
|
@ -331,7 +331,7 @@ func TestReadCredentials(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"non_matching_credential",
|
||||
&objectstorage.GetAccessKeysResponse{
|
||||
&objectstorage.ListAccessKeysResponse{
|
||||
AccessKeys: &[]objectstorage.AccessKey{
|
||||
{
|
||||
KeyId: utils.Ptr("foo-cid"),
|
||||
|
|
@ -351,7 +351,7 @@ func TestReadCredentials(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"error_response",
|
||||
&objectstorage.GetAccessKeysResponse{
|
||||
&objectstorage.ListAccessKeysResponse{
|
||||
AccessKeys: &[]objectstorage.AccessKey{
|
||||
{
|
||||
KeyId: utils.Ptr("cid"),
|
||||
|
|
|
|||
|
|
@ -301,8 +301,8 @@ func mapCredentialsGroup(credentialsGroup objectstorage.CredentialsGroup, model
|
|||
}
|
||||
|
||||
type objectStorageClient interface {
|
||||
CreateProjectExecute(ctx context.Context, projectId string) (*objectstorage.GetProjectResponse, error)
|
||||
GetCredentialsGroupsExecute(ctx context.Context, projectId string) (*objectstorage.GetCredentialsGroupsResponse, error)
|
||||
EnableServiceExecute(ctx context.Context, projectId string) (*objectstorage.ProjectStatus, error)
|
||||
ListCredentialsGroupsExecute(ctx context.Context, projectId string) (*objectstorage.ListCredentialsGroupsResponse, error)
|
||||
}
|
||||
|
||||
// enableProject enables object storage for the specified project. If the project is already enabled, nothing happens
|
||||
|
|
@ -310,7 +310,7 @@ func enableProject(ctx context.Context, model *Model, client objectStorageClient
|
|||
projectId := model.ProjectId.ValueString()
|
||||
|
||||
// From the object storage OAS: Creation will also be successful if the project is already enabled, but will not create a duplicate
|
||||
_, err := client.CreateProjectExecute(ctx, projectId)
|
||||
_, err := client.EnableServiceExecute(ctx, projectId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create object storage project: %w", err)
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ func readCredentialsGroups(ctx context.Context, model *Model, client objectStora
|
|||
return fmt.Errorf("missing configuration: either name or credentials group id must be provided")
|
||||
}
|
||||
|
||||
credentialsGroupsResp, err := client.GetCredentialsGroupsExecute(ctx, model.ProjectId.ValueString())
|
||||
credentialsGroupsResp, err := client.ListCredentialsGroupsExecute(ctx, model.ProjectId.ValueString())
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting credentials groups: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,26 +12,26 @@ import (
|
|||
)
|
||||
|
||||
type objectStorageClientMocked struct {
|
||||
returnError bool
|
||||
getCredentialsGroupsResp *objectstorage.GetCredentialsGroupsResponse
|
||||
returnError bool
|
||||
listCredentialsGroupsResp *objectstorage.ListCredentialsGroupsResponse
|
||||
}
|
||||
|
||||
func (c *objectStorageClientMocked) CreateProjectExecute(_ context.Context, projectId string) (*objectstorage.GetProjectResponse, error) {
|
||||
func (c *objectStorageClientMocked) EnableServiceExecute(_ context.Context, projectId string) (*objectstorage.ProjectStatus, error) {
|
||||
if c.returnError {
|
||||
return nil, fmt.Errorf("create project failed")
|
||||
}
|
||||
|
||||
return &objectstorage.GetProjectResponse{
|
||||
return &objectstorage.ProjectStatus{
|
||||
Project: utils.Ptr(projectId),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *objectStorageClientMocked) GetCredentialsGroupsExecute(_ context.Context, _ string) (*objectstorage.GetCredentialsGroupsResponse, error) {
|
||||
func (c *objectStorageClientMocked) ListCredentialsGroupsExecute(_ context.Context, _ string) (*objectstorage.ListCredentialsGroupsResponse, error) {
|
||||
if c.returnError {
|
||||
return nil, fmt.Errorf("get credentials groups failed")
|
||||
}
|
||||
|
||||
return c.getCredentialsGroupsResp, nil
|
||||
return c.listCredentialsGroupsResp, nil
|
||||
}
|
||||
|
||||
func TestMapFields(t *testing.T) {
|
||||
|
|
@ -161,14 +161,14 @@ func TestEnableProject(t *testing.T) {
|
|||
func TestReadCredentialsGroups(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
mockedResp *objectstorage.GetCredentialsGroupsResponse
|
||||
mockedResp *objectstorage.ListCredentialsGroupsResponse
|
||||
expected Model
|
||||
getCredentialsGroupsFails bool
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&objectstorage.GetCredentialsGroupsResponse{
|
||||
&objectstorage.ListCredentialsGroupsResponse{
|
||||
CredentialsGroups: &[]objectstorage.CredentialsGroup{
|
||||
{
|
||||
CredentialsGroupId: utils.Ptr("cid"),
|
||||
|
|
@ -190,7 +190,7 @@ func TestReadCredentialsGroups(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"simple_values",
|
||||
&objectstorage.GetCredentialsGroupsResponse{
|
||||
&objectstorage.ListCredentialsGroupsResponse{
|
||||
CredentialsGroups: &[]objectstorage.CredentialsGroup{
|
||||
{
|
||||
CredentialsGroupId: utils.Ptr("cid"),
|
||||
|
|
@ -216,7 +216,7 @@ func TestReadCredentialsGroups(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"empty_credentials_groups",
|
||||
&objectstorage.GetCredentialsGroupsResponse{
|
||||
&objectstorage.ListCredentialsGroupsResponse{
|
||||
CredentialsGroups: &[]objectstorage.CredentialsGroup{},
|
||||
},
|
||||
Model{},
|
||||
|
|
@ -225,7 +225,7 @@ func TestReadCredentialsGroups(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nil_credentials_groups",
|
||||
&objectstorage.GetCredentialsGroupsResponse{
|
||||
&objectstorage.ListCredentialsGroupsResponse{
|
||||
CredentialsGroups: nil,
|
||||
},
|
||||
Model{},
|
||||
|
|
@ -241,7 +241,7 @@ func TestReadCredentialsGroups(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"non_matching_credentials_group",
|
||||
&objectstorage.GetCredentialsGroupsResponse{
|
||||
&objectstorage.ListCredentialsGroupsResponse{
|
||||
CredentialsGroups: &[]objectstorage.CredentialsGroup{
|
||||
{
|
||||
CredentialsGroupId: utils.Ptr("foo-other"),
|
||||
|
|
@ -256,7 +256,7 @@ func TestReadCredentialsGroups(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"error_response",
|
||||
&objectstorage.GetCredentialsGroupsResponse{
|
||||
&objectstorage.ListCredentialsGroupsResponse{
|
||||
CredentialsGroups: &[]objectstorage.CredentialsGroup{
|
||||
{
|
||||
CredentialsGroupId: utils.Ptr("other_id"),
|
||||
|
|
@ -273,8 +273,8 @@ func TestReadCredentialsGroups(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.description, func(t *testing.T) {
|
||||
client := &objectStorageClientMocked{
|
||||
returnError: tt.getCredentialsGroupsFails,
|
||||
getCredentialsGroupsResp: tt.mockedResp,
|
||||
returnError: tt.getCredentialsGroupsFails,
|
||||
listCredentialsGroupsResp: tt.mockedResp,
|
||||
}
|
||||
model := &Model{
|
||||
ProjectId: tt.expected.ProjectId,
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ func testAccCheckObjectStorageDestroy(s *terraform.State) error {
|
|||
bucketsToDestroy = append(bucketsToDestroy, bucketName)
|
||||
}
|
||||
|
||||
bucketsResp, err := client.GetBuckets(ctx, testutil.ProjectId).Execute()
|
||||
bucketsResp, err := client.ListBuckets(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting bucketsResp: %w", err)
|
||||
}
|
||||
|
|
@ -281,7 +281,7 @@ func testAccCheckObjectStorageDestroy(s *terraform.State) error {
|
|||
credentialsGroupsToDestroy = append(credentialsGroupsToDestroy, credentialsGroupId)
|
||||
}
|
||||
|
||||
credentialsGroupsResp, err := client.GetCredentialsGroups(ctx, testutil.ProjectId).Execute()
|
||||
credentialsGroupsResp, err := client.ListCredentialsGroups(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting bucketsResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,12 +361,12 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
// Update existing instance
|
||||
err = r.client.UpdateInstance(ctx, projectId, instanceId).UpdateInstancePayload(*payload).Execute()
|
||||
err = r.client.PartialUpdateInstance(ctx, projectId, instanceId).PartialUpdateInstancePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -594,17 +594,17 @@ func toCreatePayload(model *Model, parameters *parametersModel) (*opensearch.Cre
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*opensearch.UpdateInstancePayload, error) {
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*opensearch.PartialUpdateInstancePayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
if parameters == nil {
|
||||
return &opensearch.UpdateInstancePayload{
|
||||
return &opensearch.PartialUpdateInstancePayload{
|
||||
PlanId: conversion.StringValueToPointer(model.PlanId),
|
||||
}, nil
|
||||
}
|
||||
return &opensearch.UpdateInstancePayload{
|
||||
return &opensearch.PartialUpdateInstancePayload{
|
||||
Parameters: &opensearch.InstanceParameters{
|
||||
SgwAcl: conversion.StringValueToPointer(parameters.SgwAcl),
|
||||
},
|
||||
|
|
@ -614,7 +614,7 @@ func toUpdatePayload(model *Model, parameters *parametersModel) (*opensearch.Upd
|
|||
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := r.client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := r.client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting OpenSearch offerings: %w", err)
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
|||
func loadPlanNameAndVersion(ctx context.Context, client *opensearch.APIClient, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
planId := model.PlanId.ValueString()
|
||||
res, err := client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting OpenSearch offerings: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,14 +221,14 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
description string
|
||||
input *Model
|
||||
inputParameters *parametersModel
|
||||
expected *opensearch.UpdateInstancePayload
|
||||
expected *opensearch.PartialUpdateInstancePayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&Model{},
|
||||
¶metersModel{},
|
||||
&opensearch.UpdateInstancePayload{
|
||||
&opensearch.PartialUpdateInstancePayload{
|
||||
Parameters: &opensearch.InstanceParameters{},
|
||||
},
|
||||
true,
|
||||
|
|
@ -241,7 +241,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringValue("sgw"),
|
||||
},
|
||||
&opensearch.UpdateInstancePayload{
|
||||
&opensearch.PartialUpdateInstancePayload{
|
||||
Parameters: &opensearch.InstanceParameters{
|
||||
SgwAcl: utils.Ptr("sgw"),
|
||||
},
|
||||
|
|
@ -257,7 +257,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringNull(),
|
||||
},
|
||||
&opensearch.UpdateInstancePayload{
|
||||
&opensearch.PartialUpdateInstancePayload{
|
||||
Parameters: &opensearch.InstanceParameters{
|
||||
SgwAcl: nil,
|
||||
},
|
||||
|
|
@ -278,7 +278,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
PlanId: types.StringValue("plan"),
|
||||
},
|
||||
nil,
|
||||
&opensearch.UpdateInstancePayload{
|
||||
&opensearch.PartialUpdateInstancePayload{
|
||||
PlanId: utils.Ptr("plan"),
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ func testAccCheckOpenSearchDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -412,12 +412,12 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
// Update existing instance
|
||||
_, err = r.client.UpdateInstance(ctx, projectId, instanceId).UpdateInstancePayload(*payload).Execute()
|
||||
_, err = r.client.PartialUpdateInstance(ctx, projectId, instanceId).PartialUpdateInstancePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", err.Error())
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -590,14 +590,14 @@ func toCreatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
}
|
||||
|
||||
return &postgresflex.CreateInstancePayload{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &acl,
|
||||
},
|
||||
BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
|
||||
FlavorId: conversion.StringValueToPointer(flavor.Id),
|
||||
Name: conversion.StringValueToPointer(model.Name),
|
||||
Replicas: conversion.Int64ValueToPointer(model.Replicas),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Storage: &postgresflex.Storage{
|
||||
Class: conversion.StringValueToPointer(storage.Class),
|
||||
Size: conversion.Int64ValueToPointer(storage.Size),
|
||||
},
|
||||
|
|
@ -605,7 +605,7 @@ func toCreatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *storageModel) (*postgresflex.UpdateInstancePayload, error) {
|
||||
func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *storageModel) (*postgresflex.PartialUpdateInstancePayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
|
@ -619,15 +619,15 @@ func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
return nil, fmt.Errorf("nil storage")
|
||||
}
|
||||
|
||||
return &postgresflex.UpdateInstancePayload{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
return &postgresflex.PartialUpdateInstancePayload{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &acl,
|
||||
},
|
||||
BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule),
|
||||
FlavorId: conversion.StringValueToPointer(flavor.Id),
|
||||
Name: conversion.StringValueToPointer(model.Name),
|
||||
Replicas: conversion.Int64ValueToPointer(model.Replicas),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Storage: &postgresflex.Storage{
|
||||
Class: conversion.StringValueToPointer(storage.Class),
|
||||
Size: conversion.Int64ValueToPointer(storage.Size),
|
||||
},
|
||||
|
|
@ -636,7 +636,7 @@ func toUpdatePayload(model *Model, acl []string, flavor *flavorModel, storage *s
|
|||
}
|
||||
|
||||
type postgresFlexClient interface {
|
||||
GetFlavorsExecute(ctx context.Context, projectId string) (*postgresflex.FlavorsResponse, error)
|
||||
ListFlavorsExecute(ctx context.Context, projectId string) (*postgresflex.ListFlavorsResponse, error)
|
||||
}
|
||||
|
||||
func loadFlavorId(ctx context.Context, client postgresFlexClient, model *Model, flavor *flavorModel) error {
|
||||
|
|
@ -656,7 +656,7 @@ func loadFlavorId(ctx context.Context, client postgresFlexClient, model *Model,
|
|||
}
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := client.GetFlavorsExecute(ctx, projectId)
|
||||
res, err := client.ListFlavorsExecute(ctx, projectId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listing postgresflex flavors: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ import (
|
|||
|
||||
type postgresFlexClientMocked struct {
|
||||
returnError bool
|
||||
getFlavorsResp *postgresflex.FlavorsResponse
|
||||
getFlavorsResp *postgresflex.ListFlavorsResponse
|
||||
}
|
||||
|
||||
func (c *postgresFlexClientMocked) GetFlavorsExecute(_ context.Context, _ string) (*postgresflex.FlavorsResponse, error) {
|
||||
func (c *postgresFlexClientMocked) ListFlavorsExecute(_ context.Context, _ string) (*postgresflex.ListFlavorsResponse, error) {
|
||||
if c.returnError {
|
||||
return nil, fmt.Errorf("get flavors failed")
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"default_values",
|
||||
&postgresflex.InstanceResponse{
|
||||
Item: &postgresflex.InstanceSingleInstance{},
|
||||
Item: &postgresflex.Instance{},
|
||||
},
|
||||
&flavorModel{},
|
||||
&storageModel{},
|
||||
|
|
@ -66,8 +66,8 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"simple_values",
|
||||
&postgresflex.InstanceResponse{
|
||||
Item: &postgresflex.InstanceSingleInstance{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
Item: &postgresflex.Instance{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &[]string{
|
||||
"ip1",
|
||||
"ip2",
|
||||
|
|
@ -75,7 +75,7 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
},
|
||||
BackupSchedule: utils.Ptr("schedule"),
|
||||
Flavor: &postgresflex.InstanceFlavor{
|
||||
Flavor: &postgresflex.Flavor{
|
||||
Cpu: utils.Ptr(int64(12)),
|
||||
Description: utils.Ptr("description"),
|
||||
Id: utils.Ptr("flavor_id"),
|
||||
|
|
@ -85,7 +85,7 @@ func TestMapFields(t *testing.T) {
|
|||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int64(56)),
|
||||
Status: utils.Ptr("status"),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Storage: &postgresflex.Storage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int64(78)),
|
||||
},
|
||||
|
|
@ -123,8 +123,8 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"simple_values_no_flavor_and_storage",
|
||||
&postgresflex.InstanceResponse{
|
||||
Item: &postgresflex.InstanceSingleInstance{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
Item: &postgresflex.Instance{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &[]string{
|
||||
"ip1",
|
||||
"ip2",
|
||||
|
|
@ -232,10 +232,10 @@ func TestToCreatePayload(t *testing.T) {
|
|||
&flavorModel{},
|
||||
&storageModel{},
|
||||
&postgresflex.CreateInstancePayload{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &[]string{},
|
||||
},
|
||||
Storage: &postgresflex.InstanceStorage{},
|
||||
Storage: &postgresflex.Storage{},
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -259,7 +259,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
Size: types.Int64Value(34),
|
||||
},
|
||||
&postgresflex.CreateInstancePayload{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &[]string{
|
||||
"ip_1",
|
||||
"ip_2",
|
||||
|
|
@ -269,7 +269,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
FlavorId: utils.Ptr("flavor_id"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int64(12)),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Storage: &postgresflex.Storage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int64(34)),
|
||||
},
|
||||
|
|
@ -296,7 +296,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
Size: types.Int64Null(),
|
||||
},
|
||||
&postgresflex.CreateInstancePayload{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &[]string{
|
||||
"",
|
||||
},
|
||||
|
|
@ -305,7 +305,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
FlavorId: nil,
|
||||
Name: nil,
|
||||
Replicas: utils.Ptr(int64(2123456789)),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Storage: &postgresflex.Storage{
|
||||
Class: nil,
|
||||
Size: nil,
|
||||
},
|
||||
|
|
@ -376,7 +376,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
inputAcl []string
|
||||
inputFlavor *flavorModel
|
||||
inputStorage *storageModel
|
||||
expected *postgresflex.UpdateInstancePayload
|
||||
expected *postgresflex.PartialUpdateInstancePayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
|
|
@ -385,11 +385,11 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
[]string{},
|
||||
&flavorModel{},
|
||||
&storageModel{},
|
||||
&postgresflex.UpdateInstancePayload{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
&postgresflex.PartialUpdateInstancePayload{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &[]string{},
|
||||
},
|
||||
Storage: &postgresflex.InstanceStorage{},
|
||||
Storage: &postgresflex.Storage{},
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -412,8 +412,8 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
Class: types.StringValue("class"),
|
||||
Size: types.Int64Value(34),
|
||||
},
|
||||
&postgresflex.UpdateInstancePayload{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
&postgresflex.PartialUpdateInstancePayload{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &[]string{
|
||||
"ip_1",
|
||||
"ip_2",
|
||||
|
|
@ -423,7 +423,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
FlavorId: utils.Ptr("flavor_id"),
|
||||
Name: utils.Ptr("name"),
|
||||
Replicas: utils.Ptr(int64(12)),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Storage: &postgresflex.Storage{
|
||||
Class: utils.Ptr("class"),
|
||||
Size: utils.Ptr(int64(34)),
|
||||
},
|
||||
|
|
@ -449,8 +449,8 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
Class: types.StringNull(),
|
||||
Size: types.Int64Null(),
|
||||
},
|
||||
&postgresflex.UpdateInstancePayload{
|
||||
Acl: &postgresflex.InstanceAcl{
|
||||
&postgresflex.PartialUpdateInstancePayload{
|
||||
Acl: &postgresflex.ACL{
|
||||
Items: &[]string{
|
||||
"",
|
||||
},
|
||||
|
|
@ -459,7 +459,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
FlavorId: nil,
|
||||
Name: nil,
|
||||
Replicas: utils.Ptr(int64(2123456789)),
|
||||
Storage: &postgresflex.InstanceStorage{
|
||||
Storage: &postgresflex.Storage{
|
||||
Class: nil,
|
||||
Size: nil,
|
||||
},
|
||||
|
|
@ -527,7 +527,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
tests := []struct {
|
||||
description string
|
||||
inputFlavor *flavorModel
|
||||
mockedResp *postgresflex.FlavorsResponse
|
||||
mockedResp *postgresflex.ListFlavorsResponse
|
||||
expected *flavorModel
|
||||
getFlavorsFails bool
|
||||
isValid bool
|
||||
|
|
@ -538,8 +538,8 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&postgresflex.FlavorsResponse{
|
||||
Flavors: &[]postgresflex.InstanceFlavor{
|
||||
&postgresflex.ListFlavorsResponse{
|
||||
Flavors: &[]postgresflex.Flavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
Cpu: utils.Ptr(int64(2)),
|
||||
|
|
@ -563,8 +563,8 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&postgresflex.FlavorsResponse{
|
||||
Flavors: &[]postgresflex.InstanceFlavor{
|
||||
&postgresflex.ListFlavorsResponse{
|
||||
Flavors: &[]postgresflex.Flavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
Cpu: utils.Ptr(int64(2)),
|
||||
|
|
@ -594,8 +594,8 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&postgresflex.FlavorsResponse{
|
||||
Flavors: &[]postgresflex.InstanceFlavor{
|
||||
&postgresflex.ListFlavorsResponse{
|
||||
Flavors: &[]postgresflex.Flavor{
|
||||
{
|
||||
Id: utils.Ptr("fid-1"),
|
||||
Cpu: utils.Ptr(int64(1)),
|
||||
|
|
@ -623,7 +623,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&postgresflex.FlavorsResponse{},
|
||||
&postgresflex.ListFlavorsResponse{},
|
||||
&flavorModel{
|
||||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
|
|
@ -637,7 +637,7 @@ func TestLoadFlavorId(t *testing.T) {
|
|||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
},
|
||||
&postgresflex.FlavorsResponse{},
|
||||
&postgresflex.ListFlavorsResponse{},
|
||||
&flavorModel{
|
||||
CPU: types.Int64Value(2),
|
||||
RAM: types.Int64Value(8),
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ func testAccCheckPostgresFlexDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ func (r *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
tflog.Info(ctx, "PostgresFlex user read")
|
||||
}
|
||||
|
||||
func mapDataSourceFields(userResp *postgresflex.UserResponse, model *DataSourceModel) error {
|
||||
func mapDataSourceFields(userResp *postgresflex.GetUserResponse, model *DataSourceModel) error {
|
||||
if userResp == nil || userResp.Item == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ import (
|
|||
func TestMapDataSourceFields(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
input *postgresflex.UserResponse
|
||||
input *postgresflex.GetUserResponse
|
||||
expected DataSourceModel
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&postgresflex.UserResponse{
|
||||
Item: &postgresflex.UserResponseUser{},
|
||||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{},
|
||||
},
|
||||
DataSourceModel{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
|
|
@ -36,8 +36,8 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"simple_values",
|
||||
&postgresflex.UserResponse{
|
||||
Item: &postgresflex.UserResponseUser{
|
||||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{
|
||||
Roles: &[]string{
|
||||
"role_1",
|
||||
"role_2",
|
||||
|
|
@ -66,8 +66,8 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&postgresflex.UserResponse{
|
||||
Item: &postgresflex.UserResponseUser{
|
||||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{
|
||||
Id: utils.Ptr("uid"),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
|
|
@ -95,14 +95,14 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&postgresflex.UserResponse{},
|
||||
&postgresflex.GetUserResponse{},
|
||||
DataSourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&postgresflex.UserResponse{
|
||||
Item: &postgresflex.UserResponseUser{},
|
||||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{},
|
||||
},
|
||||
DataSourceModel{},
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ func mapFieldsCreate(userResp *postgresflex.CreateUserResponse, model *Model) er
|
|||
return nil
|
||||
}
|
||||
|
||||
func mapFields(userResp *postgresflex.UserResponse, model *Model) error {
|
||||
func mapFields(userResp *postgresflex.GetUserResponse, model *Model) error {
|
||||
if userResp == nil || userResp.Item == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"default_values",
|
||||
&postgresflex.CreateUserResponse{
|
||||
Item: &postgresflex.InstanceUser{
|
||||
Item: &postgresflex.User{
|
||||
Id: utils.Ptr("uid"),
|
||||
Password: utils.Ptr(""),
|
||||
},
|
||||
|
|
@ -41,7 +41,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"simple_values",
|
||||
&postgresflex.CreateUserResponse{
|
||||
Item: &postgresflex.InstanceUser{
|
||||
Item: &postgresflex.User{
|
||||
Id: utils.Ptr("uid"),
|
||||
Roles: &[]string{
|
||||
"role_1",
|
||||
|
|
@ -74,7 +74,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&postgresflex.CreateUserResponse{
|
||||
Item: &postgresflex.InstanceUser{
|
||||
Item: &postgresflex.User{
|
||||
Id: utils.Ptr("uid"),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
|
|
@ -111,7 +111,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"no_resource_id",
|
||||
&postgresflex.CreateUserResponse{
|
||||
Item: &postgresflex.InstanceUser{},
|
||||
Item: &postgresflex.User{},
|
||||
},
|
||||
Model{},
|
||||
false,
|
||||
|
|
@ -119,7 +119,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
{
|
||||
"no_password",
|
||||
&postgresflex.CreateUserResponse{
|
||||
Item: &postgresflex.InstanceUser{
|
||||
Item: &postgresflex.User{
|
||||
Id: utils.Ptr("uid"),
|
||||
},
|
||||
},
|
||||
|
|
@ -153,14 +153,14 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
func TestMapFields(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
input *postgresflex.UserResponse
|
||||
input *postgresflex.GetUserResponse
|
||||
expected Model
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&postgresflex.UserResponse{
|
||||
Item: &postgresflex.UserResponseUser{},
|
||||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{},
|
||||
},
|
||||
Model{
|
||||
Id: types.StringValue("pid,iid,uid"),
|
||||
|
|
@ -176,8 +176,8 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"simple_values",
|
||||
&postgresflex.UserResponse{
|
||||
Item: &postgresflex.UserResponseUser{
|
||||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{
|
||||
Roles: &[]string{
|
||||
"role_1",
|
||||
"role_2",
|
||||
|
|
@ -206,8 +206,8 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&postgresflex.UserResponse{
|
||||
Item: &postgresflex.UserResponseUser{
|
||||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{
|
||||
Id: utils.Ptr("uid"),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
|
|
@ -235,14 +235,14 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&postgresflex.UserResponse{},
|
||||
&postgresflex.GetUserResponse{},
|
||||
Model{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&postgresflex.UserResponse{
|
||||
Item: &postgresflex.UserResponseUser{},
|
||||
&postgresflex.GetUserResponse{
|
||||
Item: &postgresflex.UserResponse{},
|
||||
},
|
||||
Model{},
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -437,12 +437,12 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
// Update existing instance
|
||||
err = r.client.UpdateInstance(ctx, projectId, instanceId).UpdateInstancePayload(*payload).Execute()
|
||||
err = r.client.PartialUpdateInstance(ctx, projectId, instanceId).PartialUpdateInstancePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -463,17 +463,17 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
tflog.Info(ctx, "PostgreSQL instance updated")
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel, parametersPlugins *[]string) (*postgresql.UpdateInstancePayload, error) {
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel, parametersPlugins *[]string) (*postgresql.PartialUpdateInstancePayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
if parameters == nil {
|
||||
return &postgresql.UpdateInstancePayload{
|
||||
return &postgresql.PartialUpdateInstancePayload{
|
||||
PlanId: conversion.StringValueToPointer(model.PlanId),
|
||||
}, nil
|
||||
}
|
||||
return &postgresql.UpdateInstancePayload{
|
||||
return &postgresql.PartialUpdateInstancePayload{
|
||||
Parameters: &postgresql.InstanceParameters{
|
||||
EnableMonitoring: conversion.BoolValueToPointer(parameters.EnableMonitoring),
|
||||
MetricsFrequency: conversion.Int64ValueToPointer(parameters.MetricsFrequency),
|
||||
|
|
@ -674,7 +674,7 @@ func mapParameters(params map[string]interface{}) (types.Object, error) {
|
|||
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := r.client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := r.client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting PostgreSQL offerings: %w", err)
|
||||
}
|
||||
|
|
@ -712,7 +712,7 @@ func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
|||
func loadPlanNameAndVersion(ctx context.Context, client *postgresql.APIClient, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
planId := model.PlanId.ValueString()
|
||||
res, err := client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting PostgreSQL offerings: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
input *Model
|
||||
inputParameters *parametersModel
|
||||
inputParametersPlugins *[]string
|
||||
expected *postgresql.UpdateInstancePayload
|
||||
expected *postgresql.PartialUpdateInstancePayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
|
|
@ -325,7 +325,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
&Model{},
|
||||
¶metersModel{},
|
||||
&[]string{},
|
||||
&postgresql.UpdateInstancePayload{
|
||||
&postgresql.PartialUpdateInstancePayload{
|
||||
Parameters: &postgresql.InstanceParameters{
|
||||
Plugins: &[]string{},
|
||||
},
|
||||
|
|
@ -348,7 +348,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
"plugin_1",
|
||||
"plugin_2",
|
||||
},
|
||||
&postgresql.UpdateInstancePayload{
|
||||
&postgresql.PartialUpdateInstancePayload{
|
||||
Parameters: &postgresql.InstanceParameters{
|
||||
EnableMonitoring: utils.Ptr(true),
|
||||
MetricsFrequency: utils.Ptr(int64(123)),
|
||||
|
|
@ -379,7 +379,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
&[]string{
|
||||
"",
|
||||
},
|
||||
&postgresql.UpdateInstancePayload{
|
||||
&postgresql.PartialUpdateInstancePayload{
|
||||
Parameters: &postgresql.InstanceParameters{
|
||||
EnableMonitoring: nil,
|
||||
MetricsFrequency: utils.Ptr(int64(2123456789)),
|
||||
|
|
@ -409,7 +409,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
},
|
||||
nil,
|
||||
nil,
|
||||
&postgresql.UpdateInstancePayload{
|
||||
&postgresql.PartialUpdateInstancePayload{
|
||||
PlanId: utils.Ptr("plan"),
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ func testAccCheckPostgreSQLDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,12 +361,12 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
// Update existing instance
|
||||
err = r.client.UpdateInstance(ctx, projectId, instanceId).UpdateInstancePayload(*payload).Execute()
|
||||
err = r.client.PartialUpdateInstance(ctx, projectId, instanceId).PartialUpdateInstancePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -594,17 +594,17 @@ func toCreatePayload(model *Model, parameters *parametersModel) (*rabbitmq.Creat
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*rabbitmq.UpdateInstancePayload, error) {
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*rabbitmq.PartialUpdateInstancePayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
if parameters == nil {
|
||||
return &rabbitmq.UpdateInstancePayload{
|
||||
return &rabbitmq.PartialUpdateInstancePayload{
|
||||
PlanId: conversion.StringValueToPointer(model.PlanId),
|
||||
}, nil
|
||||
}
|
||||
return &rabbitmq.UpdateInstancePayload{
|
||||
return &rabbitmq.PartialUpdateInstancePayload{
|
||||
Parameters: &rabbitmq.InstanceParameters{
|
||||
SgwAcl: conversion.StringValueToPointer(parameters.SgwAcl),
|
||||
},
|
||||
|
|
@ -614,7 +614,7 @@ func toUpdatePayload(model *Model, parameters *parametersModel) (*rabbitmq.Updat
|
|||
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := r.client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := r.client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting RabbitMQ offerings: %w", err)
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
|||
func loadPlanNameAndVersion(ctx context.Context, client *rabbitmq.APIClient, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
planId := model.PlanId.ValueString()
|
||||
res, err := client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting RabbitMQ offerings: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,14 +221,14 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
description string
|
||||
input *Model
|
||||
inputParameters *parametersModel
|
||||
expected *rabbitmq.UpdateInstancePayload
|
||||
expected *rabbitmq.PartialUpdateInstancePayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&Model{},
|
||||
¶metersModel{},
|
||||
&rabbitmq.UpdateInstancePayload{
|
||||
&rabbitmq.PartialUpdateInstancePayload{
|
||||
Parameters: &rabbitmq.InstanceParameters{},
|
||||
},
|
||||
true,
|
||||
|
|
@ -241,7 +241,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringValue("sgw"),
|
||||
},
|
||||
&rabbitmq.UpdateInstancePayload{
|
||||
&rabbitmq.PartialUpdateInstancePayload{
|
||||
Parameters: &rabbitmq.InstanceParameters{
|
||||
SgwAcl: utils.Ptr("sgw"),
|
||||
},
|
||||
|
|
@ -257,7 +257,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringNull(),
|
||||
},
|
||||
&rabbitmq.UpdateInstancePayload{
|
||||
&rabbitmq.PartialUpdateInstancePayload{
|
||||
Parameters: &rabbitmq.InstanceParameters{
|
||||
SgwAcl: nil,
|
||||
},
|
||||
|
|
@ -278,7 +278,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
PlanId: types.StringValue("plan"),
|
||||
},
|
||||
nil,
|
||||
&rabbitmq.UpdateInstancePayload{
|
||||
&rabbitmq.PartialUpdateInstancePayload{
|
||||
PlanId: utils.Ptr("plan"),
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ func testAccCheckRabbitMQDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,12 +361,12 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
// Update existing instance
|
||||
err = r.client.UpdateInstance(ctx, projectId, instanceId).UpdateInstancePayload(*payload).Execute()
|
||||
err = r.client.PartialUpdateInstance(ctx, projectId, instanceId).PartialUpdateInstancePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
return
|
||||
|
|
@ -594,17 +594,17 @@ func toCreatePayload(model *Model, parameters *parametersModel) (*redis.CreateIn
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*redis.UpdateInstancePayload, error) {
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel) (*redis.PartialUpdateInstancePayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
if parameters == nil {
|
||||
return &redis.UpdateInstancePayload{
|
||||
return &redis.PartialUpdateInstancePayload{
|
||||
PlanId: conversion.StringValueToPointer(model.PlanId),
|
||||
}, nil
|
||||
}
|
||||
return &redis.UpdateInstancePayload{
|
||||
return &redis.PartialUpdateInstancePayload{
|
||||
Parameters: &redis.InstanceParameters{
|
||||
SgwAcl: conversion.StringValueToPointer(parameters.SgwAcl),
|
||||
},
|
||||
|
|
@ -614,7 +614,7 @@ func toUpdatePayload(model *Model, parameters *parametersModel) (*redis.UpdateIn
|
|||
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := r.client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := r.client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting Redis offerings: %w", err)
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
|||
func loadPlanNameAndVersion(ctx context.Context, client *redis.APIClient, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
planId := model.PlanId.ValueString()
|
||||
res, err := client.GetOfferings(ctx, projectId).Execute()
|
||||
res, err := client.ListOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting Redis offerings: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,14 +221,14 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
description string
|
||||
input *Model
|
||||
inputParameters *parametersModel
|
||||
expected *redis.UpdateInstancePayload
|
||||
expected *redis.PartialUpdateInstancePayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&Model{},
|
||||
¶metersModel{},
|
||||
&redis.UpdateInstancePayload{
|
||||
&redis.PartialUpdateInstancePayload{
|
||||
Parameters: &redis.InstanceParameters{},
|
||||
},
|
||||
true,
|
||||
|
|
@ -241,7 +241,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringValue("sgw"),
|
||||
},
|
||||
&redis.UpdateInstancePayload{
|
||||
&redis.PartialUpdateInstancePayload{
|
||||
Parameters: &redis.InstanceParameters{
|
||||
SgwAcl: utils.Ptr("sgw"),
|
||||
},
|
||||
|
|
@ -257,7 +257,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
¶metersModel{
|
||||
SgwAcl: types.StringNull(),
|
||||
},
|
||||
&redis.UpdateInstancePayload{
|
||||
&redis.PartialUpdateInstancePayload{
|
||||
Parameters: &redis.InstanceParameters{
|
||||
SgwAcl: nil,
|
||||
},
|
||||
|
|
@ -278,7 +278,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
PlanId: types.StringValue("plan"),
|
||||
},
|
||||
nil,
|
||||
&redis.UpdateInstancePayload{
|
||||
&redis.PartialUpdateInstancePayload{
|
||||
PlanId: utils.Ptr("plan"),
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ func testAccCheckRedisDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ func (r *projectResource) Update(ctx context.Context, req resource.UpdateRequest
|
|||
return
|
||||
}
|
||||
// Update existing project
|
||||
_, err = r.client.UpdateProject(ctx, containerId).UpdateProjectPayload(*payload).Execute()
|
||||
_, err = r.client.PartialUpdateProject(ctx, containerId).PartialUpdateProjectPayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating project", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
|
|
@ -454,7 +454,7 @@ func toCreatePayload(model *Model, serviceAccountEmail string) (*resourcemanager
|
|||
}, nil
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model) (*resourcemanager.UpdateProjectPayload, error) {
|
||||
func toUpdatePayload(model *Model) (*resourcemanager.PartialUpdateProjectPayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
|
@ -465,7 +465,7 @@ func toUpdatePayload(model *Model) (*resourcemanager.UpdateProjectPayload, error
|
|||
return nil, fmt.Errorf("converting to GO map: %w", err)
|
||||
}
|
||||
|
||||
return &resourcemanager.UpdateProjectPayload{
|
||||
return &resourcemanager.PartialUpdateProjectPayload{
|
||||
ContainerParentId: conversion.StringValueToPointer(model.ContainerParentId),
|
||||
Name: conversion.StringValueToPointer(model.Name),
|
||||
Labels: labels,
|
||||
|
|
|
|||
|
|
@ -250,14 +250,14 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
description string
|
||||
input *Model
|
||||
inputLabels *map[string]string
|
||||
expected *resourcemanager.UpdateProjectPayload
|
||||
expected *resourcemanager.PartialUpdateProjectPayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_ok",
|
||||
&Model{},
|
||||
nil,
|
||||
&resourcemanager.UpdateProjectPayload{
|
||||
&resourcemanager.PartialUpdateProjectPayload{
|
||||
ContainerParentId: nil,
|
||||
Labels: nil,
|
||||
Name: nil,
|
||||
|
|
@ -275,7 +275,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
"label1": "1",
|
||||
"label2": "2",
|
||||
},
|
||||
&resourcemanager.UpdateProjectPayload{
|
||||
&resourcemanager.PartialUpdateProjectPayload{
|
||||
ContainerParentId: utils.Ptr("pid"),
|
||||
Labels: &map[string]string{
|
||||
"label1": "1",
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ func testAccCheckResourceManagerDestroy(s *terraform.State) error {
|
|||
projectsToDestroy = append(projectsToDestroy, containerId)
|
||||
}
|
||||
|
||||
projectsResp, err := client.GetProjects(ctx).ContainerParentId(projectResource["parent_container_id"]).Execute()
|
||||
projectsResp, err := client.ListProjects(ctx).ContainerParentId(projectResource["parent_container_id"]).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting projectsResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
aclList, err := r.client.GetAcls(ctx, projectId, instanceId).Execute()
|
||||
aclList, err := r.client.ListACLs(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API for ACLs data: %v", err))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Creating ACLs: %v", err))
|
||||
return
|
||||
}
|
||||
aclList, err := r.client.GetAcls(ctx, projectId, instanceId).Execute()
|
||||
aclList, err := r.client.ListACLs(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API for ACLs data: %v", err))
|
||||
return
|
||||
|
|
@ -239,7 +239,7 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
aclList, err := r.client.GetAcls(ctx, projectId, instanceId).Execute()
|
||||
aclList, err := r.client.ListACLs(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API for ACLs data: %v", err))
|
||||
return
|
||||
|
|
@ -295,7 +295,7 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
aclList, err := r.client.GetAcls(ctx, projectId, instanceId).Execute()
|
||||
aclList, err := r.client.ListACLs(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API for ACLs data: %v", err))
|
||||
return
|
||||
|
|
@ -425,7 +425,7 @@ func toCreatePayload(model *Model) (*secretsmanager.CreateInstancePayload, error
|
|||
// updateACLs creates and deletes ACLs so that the instance's ACLs are the ones in the model
|
||||
func updateACLs(ctx context.Context, projectId, instanceId string, acls []string, client *secretsmanager.APIClient) error {
|
||||
// Get ACLs current state
|
||||
currentACLsResp, err := client.GetAcls(ctx, projectId, instanceId).Execute()
|
||||
currentACLsResp, err := client.ListACLs(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("fetching current ACLs: %w", err)
|
||||
}
|
||||
|
|
@ -453,17 +453,17 @@ func updateACLs(ctx context.Context, projectId, instanceId string, acls []string
|
|||
// Create/delete ACLs
|
||||
for cidr, state := range aclsState {
|
||||
if state.isInModel && !state.isCreated {
|
||||
payload := secretsmanager.CreateAclPayload{
|
||||
payload := secretsmanager.CreateACLPayload{
|
||||
Cidr: utils.Ptr(cidr),
|
||||
}
|
||||
_, err := client.CreateAcl(ctx, projectId, instanceId).CreateAclPayload(payload).Execute()
|
||||
_, err := client.CreateACL(ctx, projectId, instanceId).CreateACLPayload(payload).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating ACL '%v': %w", cidr, err)
|
||||
}
|
||||
}
|
||||
|
||||
if !state.isInModel && state.isCreated {
|
||||
err := client.DeleteAcl(ctx, projectId, instanceId, state.id).Execute()
|
||||
err := client.DeleteACL(ctx, projectId, instanceId, state.id).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("deleting ACL '%v': %w", cidr, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ func TestUpdateACLs(t *testing.T) {
|
|||
// Handler for creating ACL
|
||||
createACLHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
var payload secretsmanager.CreateAclPayload
|
||||
var payload secretsmanager.CreateACLPayload
|
||||
err := decoder.Decode(&payload)
|
||||
if err != nil {
|
||||
t.Errorf("Create ACL handler: failed to parse payload")
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ func testAccCheckSecretsManagerDestroy(s *terraform.State) error {
|
|||
instancesToDestroy = append(instancesToDestroy, instanceId)
|
||||
}
|
||||
|
||||
instancesResp, err := client.GetInstances(ctx, testutil.ProjectId).Execute()
|
||||
instancesResp, err := client.ListInstances(ctx, testutil.ProjectId).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting instancesResp: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@ func (r *clusterResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
|
||||
func (r *clusterResource) loadAvaiableVersions(ctx context.Context) ([]ske.KubernetesVersion, error) {
|
||||
c := r.client
|
||||
res, err := c.GetOptions(ctx).Execute()
|
||||
res, err := c.ListProviderOptions(ctx).Execute()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("calling API: %w", err)
|
||||
}
|
||||
|
|
@ -878,7 +878,7 @@ func toMaintenancePayload(ctx context.Context, m *Cluster) (*ske.Maintenance, er
|
|||
}, nil
|
||||
}
|
||||
|
||||
func mapFields(ctx context.Context, cl *ske.ClusterResponse, m *Cluster) error {
|
||||
func mapFields(ctx context.Context, cl *ske.Cluster, m *Cluster) error {
|
||||
if cl == nil {
|
||||
return fmt.Errorf("response input is nil")
|
||||
}
|
||||
|
|
@ -933,7 +933,7 @@ func mapFields(ctx context.Context, cl *ske.ClusterResponse, m *Cluster) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func mapNodePools(ctx context.Context, cl *ske.ClusterResponse, m *Cluster) error {
|
||||
func mapNodePools(ctx context.Context, cl *ske.Cluster, m *Cluster) error {
|
||||
if cl.Nodepools == nil {
|
||||
m.NodePools = types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes})
|
||||
return nil
|
||||
|
|
@ -1039,7 +1039,7 @@ func mapTaints(t *[]ske.Taint, nodePool map[string]attr.Value) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func mapHibernations(cl *ske.ClusterResponse, m *Cluster) error {
|
||||
func mapHibernations(cl *ske.Cluster, m *Cluster) error {
|
||||
if cl.Hibernation == nil {
|
||||
if !m.Hibernations.IsNull() {
|
||||
emptyHibernations, diags := basetypes.NewListValue(basetypes.ObjectType{AttrTypes: hibernationTypes}, []attr.Value{})
|
||||
|
|
@ -1085,7 +1085,7 @@ func mapHibernations(cl *ske.ClusterResponse, m *Cluster) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func mapMaintenance(ctx context.Context, cl *ske.ClusterResponse, m *Cluster) error {
|
||||
func mapMaintenance(ctx context.Context, cl *ske.Cluster, m *Cluster) error {
|
||||
// Aligned with SKE team that a flattened data structure is fine, because no extensions are planned.
|
||||
if cl.Maintenance == nil {
|
||||
m.Maintenance = types.ObjectNull(maintenanceTypes)
|
||||
|
|
@ -1117,7 +1117,7 @@ func mapMaintenance(ctx context.Context, cl *ske.ClusterResponse, m *Cluster) er
|
|||
return nil
|
||||
}
|
||||
|
||||
func getMaintenanceTimes(ctx context.Context, cl *ske.ClusterResponse, m *Cluster) (startTime, endTime string, err error) {
|
||||
func getMaintenanceTimes(ctx context.Context, cl *ske.Cluster, m *Cluster) (startTime, endTime string, err error) {
|
||||
startTimeAPI, err := time.Parse(time.RFC3339, *cl.Maintenance.TimeWindow.Start)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("parsing start time '%s' from API response as RFC3339 datetime: %w", *cl.Maintenance.TimeWindow.Start, err)
|
||||
|
|
@ -1191,7 +1191,7 @@ func checkDisabledExtensions(ctx context.Context, ex extensions) (aclDisabled, a
|
|||
return !acl.Enabled.ValueBool(), !argus.Enabled.ValueBool(), nil
|
||||
}
|
||||
|
||||
func mapExtensions(ctx context.Context, cl *ske.ClusterResponse, m *Cluster) error {
|
||||
func mapExtensions(ctx context.Context, cl *ske.Cluster, m *Cluster) error {
|
||||
if cl.Extensions == nil {
|
||||
m.Extensions = types.ObjectNull(extensionsTypes)
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ func TestMapFields(t *testing.T) {
|
|||
tests := []struct {
|
||||
description string
|
||||
stateExtensions types.Object
|
||||
input *ske.ClusterResponse
|
||||
input *ske.Cluster
|
||||
expected Cluster
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
types.ObjectNull(extensionsTypes),
|
||||
&ske.ClusterResponse{
|
||||
&ske.Cluster{
|
||||
Name: utils.Ptr("name"),
|
||||
},
|
||||
Cluster{
|
||||
|
|
@ -44,7 +44,7 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"simple_values",
|
||||
types.ObjectNull(extensionsTypes),
|
||||
&ske.ClusterResponse{
|
||||
&ske.Cluster{
|
||||
Extensions: &ske.Extension{
|
||||
Acl: &ske.ACL{
|
||||
AllowedCidrs: &[]string{"cidr1"},
|
||||
|
|
@ -210,7 +210,7 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"extensions_mixed_values",
|
||||
types.ObjectNull(extensionsTypes),
|
||||
&ske.ClusterResponse{
|
||||
&ske.Cluster{
|
||||
Extensions: &ske.Extension{
|
||||
Acl: &ske.ACL{
|
||||
AllowedCidrs: nil,
|
||||
|
|
@ -258,7 +258,7 @@ func TestMapFields(t *testing.T) {
|
|||
"argus_instance_id": types.StringNull(),
|
||||
}),
|
||||
}),
|
||||
&ske.ClusterResponse{
|
||||
&ske.Cluster{
|
||||
Extensions: &ske.Extension{},
|
||||
Name: utils.Ptr("name"),
|
||||
},
|
||||
|
|
@ -299,7 +299,7 @@ func TestMapFields(t *testing.T) {
|
|||
"argus_instance_id": types.StringValue("id"),
|
||||
}),
|
||||
}),
|
||||
&ske.ClusterResponse{
|
||||
&ske.Cluster{
|
||||
Extensions: &ske.Extension{
|
||||
Acl: &ske.ACL{
|
||||
AllowedCidrs: &[]string{"cidr1"},
|
||||
|
|
@ -336,7 +336,7 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"extensions_not_set",
|
||||
types.ObjectNull(extensionsTypes),
|
||||
&ske.ClusterResponse{
|
||||
&ske.Cluster{
|
||||
Extensions: &ske.Extension{},
|
||||
Name: utils.Ptr("name"),
|
||||
},
|
||||
|
|
@ -364,7 +364,7 @@ func TestMapFields(t *testing.T) {
|
|||
{
|
||||
"no_resource_id",
|
||||
types.ObjectNull(extensionsTypes),
|
||||
&ske.ClusterResponse{},
|
||||
&ske.Cluster{},
|
||||
Cluster{},
|
||||
false,
|
||||
},
|
||||
|
|
@ -686,7 +686,7 @@ func TestGetMaintenanceTimes(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.description, func(t *testing.T) {
|
||||
apiResponse := &ske.ClusterResponse{
|
||||
apiResponse := &ske.Cluster{
|
||||
Maintenance: &ske.Maintenance{
|
||||
TimeWindow: &ske.TimeWindow{
|
||||
Start: utils.Ptr(tt.startAPI),
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ func (r *projectDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
_, err := r.client.GetProject(ctx, projectId).Execute()
|
||||
_, err := r.client.GetServiceStatus(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading project", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -118,14 +118,14 @@ func (r *projectResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
return
|
||||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
_, err := r.client.CreateProject(ctx, projectId).Execute()
|
||||
_, err := r.client.EnableService(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating project", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
model.Id = types.StringValue(projectId)
|
||||
_, err = wait.CreateProjectWaitHandler(ctx, r.client, projectId).WaitWithContext(ctx)
|
||||
_, err = wait.EnableServiceWaitHandler(ctx, r.client, projectId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating cluster", fmt.Sprintf("Project creation waiting: %v", err))
|
||||
return
|
||||
|
|
@ -148,7 +148,7 @@ func (r *projectResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
_, err := r.client.GetProject(ctx, projectId).Execute()
|
||||
_, err := r.client.GetServiceStatus(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading project", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
|
|
@ -180,12 +180,12 @@ func (r *projectResource) Delete(ctx context.Context, req resource.DeleteRequest
|
|||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
c := r.client
|
||||
_, err := c.DeleteProject(ctx, projectId).Execute()
|
||||
_, err := c.DisableService(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
_, err = wait.DeleteProjectWaitHandler(ctx, r.client, projectId).WaitWithContext(ctx)
|
||||
_, err = wait.DisableServiceWaitHandler(ctx, r.client, projectId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Project deletion waiting: %v", err))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ func testAccCheckSKEDestroy(s *terraform.State) error {
|
|||
projectsToDestroy = append(projectsToDestroy, rs.Primary.ID)
|
||||
}
|
||||
for _, projectId := range projectsToDestroy {
|
||||
_, err := client.GetProject(ctx, projectId).Execute()
|
||||
_, err := client.GetServiceStatus(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
|
||||
if !ok {
|
||||
|
|
@ -540,11 +540,11 @@ func testAccCheckSKEDestroy(s *terraform.State) error {
|
|||
return fmt.Errorf("getting project: %w", err)
|
||||
}
|
||||
|
||||
_, err = client.DeleteProjectExecute(ctx, projectId)
|
||||
_, err = client.DisableServiceExecute(ctx, projectId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("destroying project %s during CheckDestroy: %w", projectId, err)
|
||||
}
|
||||
_, err = wait.DeleteProjectWaitHandler(ctx, client, projectId).WaitWithContext(ctx)
|
||||
_, err = wait.DisableServiceWaitHandler(ctx, client, projectId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("destroying project %s during CheckDestroy: waiting for deletion %w", projectId, err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue