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:
Henrique Santos 2023-12-21 09:33:36 +00:00 committed by GitHub
parent 506d1afdc2
commit c7effac5c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 382 additions and 382 deletions

View file

@ -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)
}

View file

@ -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),