fix: adjust to new generator and sdk use
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m33s
CI Workflow / CI run tests (pull_request) Failing after 4m51s
CI Workflow / CI run build and linting (pull_request) Failing after 4m37s
CI Workflow / Code coverage report (pull_request) Has been skipped
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m33s
CI Workflow / CI run tests (pull_request) Failing after 4m51s
CI Workflow / CI run build and linting (pull_request) Failing after 4m37s
CI Workflow / Code coverage report (pull_request) Has been skipped
This commit is contained in:
parent
ca0f646526
commit
826bb5b36a
36 changed files with 2089 additions and 1166 deletions
|
|
@ -14,7 +14,7 @@ import (
|
|||
sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||
|
||||
sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
|
||||
sqlserverflexalphaPkg "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3alpha1api"
|
||||
sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user/datasources_gen"
|
||||
)
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
ctx = tflog.SetField(ctx, "user_id", userId)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
||||
recordSetResp, err := d.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
|
||||
recordSetResp, err := d.client.DefaultAPI.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
|
||||
if err != nil {
|
||||
utils.LogError(
|
||||
ctx,
|
||||
|
|
|
|||
|
|
@ -8,14 +8,13 @@ import (
|
|||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
|
||||
"github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3alpha1api"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||
)
|
||||
|
||||
// mapDataSourceFields maps the API response to a dataSourceModel.
|
||||
func mapDataSourceFields(userResp *sqlserverflexalpha.GetUserResponse, model *dataSourceModel, region string) error {
|
||||
func mapDataSourceFields(userResp *v3alpha1api.GetUserResponse, model *dataSourceModel, region string) error {
|
||||
if userResp == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
|
|
@ -28,8 +27,8 @@ func mapDataSourceFields(userResp *sqlserverflexalpha.GetUserResponse, model *da
|
|||
var userId int64
|
||||
if model.UserId.ValueInt64() != 0 {
|
||||
userId = model.UserId.ValueInt64()
|
||||
} else if user.Id != nil {
|
||||
userId = *user.Id
|
||||
} else if user.Id != 0 {
|
||||
userId = user.Id
|
||||
} else {
|
||||
return fmt.Errorf("user id not present")
|
||||
}
|
||||
|
|
@ -39,13 +38,13 @@ func mapDataSourceFields(userResp *sqlserverflexalpha.GetUserResponse, model *da
|
|||
model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), strconv.FormatInt(userId, 10),
|
||||
)
|
||||
model.UserId = types.Int64Value(userId)
|
||||
model.Username = types.StringPointerValue(user.Username)
|
||||
model.Username = types.StringValue(user.Username)
|
||||
|
||||
// Map roles
|
||||
if user.Roles == nil {
|
||||
model.Roles = types.List(types.SetNull(types.StringType))
|
||||
} else {
|
||||
resRoles := *user.Roles
|
||||
resRoles := user.Roles
|
||||
slices.Sort(resRoles)
|
||||
|
||||
var roles []attr.Value
|
||||
|
|
@ -60,17 +59,17 @@ func mapDataSourceFields(userResp *sqlserverflexalpha.GetUserResponse, model *da
|
|||
}
|
||||
|
||||
// Set remaining attributes
|
||||
model.Host = types.StringPointerValue(user.Host)
|
||||
model.Port = types.Int64PointerValue(user.Port)
|
||||
model.Host = types.StringValue(user.Host)
|
||||
model.Port = types.Int64Value(int64(user.Port))
|
||||
model.Region = types.StringValue(region)
|
||||
model.Status = types.StringPointerValue(user.Status)
|
||||
model.DefaultDatabase = types.StringPointerValue(user.DefaultDatabase)
|
||||
model.Status = types.StringValue(user.Status)
|
||||
model.DefaultDatabase = types.StringValue(user.DefaultDatabase)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// mapFields maps the API response to a resourceModel.
|
||||
func mapFields(userResp *sqlserverflexalpha.GetUserResponse, model *resourceModel, region string) error {
|
||||
func mapFields(userResp *v3alpha1api.GetUserResponse, model *resourceModel, region string) error {
|
||||
if userResp == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
|
|
@ -83,8 +82,8 @@ func mapFields(userResp *sqlserverflexalpha.GetUserResponse, model *resourceMode
|
|||
var userId int64
|
||||
if model.UserId.ValueInt64() != 0 {
|
||||
userId = model.UserId.ValueInt64()
|
||||
} else if user.Id != nil {
|
||||
userId = *user.Id
|
||||
} else if user.Id != 0 {
|
||||
userId = user.Id
|
||||
} else {
|
||||
return fmt.Errorf("user id not present")
|
||||
}
|
||||
|
|
@ -92,11 +91,11 @@ func mapFields(userResp *sqlserverflexalpha.GetUserResponse, model *resourceMode
|
|||
// Set main attributes
|
||||
model.Id = types.Int64Value(userId)
|
||||
model.UserId = types.Int64Value(userId)
|
||||
model.Username = types.StringPointerValue(user.Username)
|
||||
model.Username = types.StringValue(user.Username)
|
||||
|
||||
// Map roles
|
||||
if user.Roles != nil {
|
||||
resRoles := *user.Roles
|
||||
resRoles := user.Roles
|
||||
slices.Sort(resRoles)
|
||||
|
||||
var roles []attr.Value
|
||||
|
|
@ -116,14 +115,14 @@ func mapFields(userResp *sqlserverflexalpha.GetUserResponse, model *resourceMode
|
|||
}
|
||||
|
||||
// Set connection details
|
||||
model.Host = types.StringPointerValue(user.Host)
|
||||
model.Port = types.Int64PointerValue(user.Port)
|
||||
model.Host = types.StringValue(user.Host)
|
||||
model.Port = types.Int64Value(int64(user.Port))
|
||||
model.Region = types.StringValue(region)
|
||||
return nil
|
||||
}
|
||||
|
||||
// mapFieldsCreate maps the API response from creating a user to a resourceModel.
|
||||
func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *resourceModel, region string) error {
|
||||
func mapFieldsCreate(userResp *v3alpha1api.CreateUserResponse, model *resourceModel, region string) error {
|
||||
if userResp == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
|
|
@ -132,21 +131,21 @@ func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *res
|
|||
}
|
||||
user := userResp
|
||||
|
||||
if user.Id == nil {
|
||||
if user.Id == 0 {
|
||||
return fmt.Errorf("user id not present")
|
||||
}
|
||||
userId := *user.Id
|
||||
userId := user.Id
|
||||
model.Id = types.Int64Value(userId)
|
||||
model.UserId = types.Int64Value(userId)
|
||||
model.Username = types.StringPointerValue(user.Username)
|
||||
model.Username = types.StringValue(user.Username)
|
||||
|
||||
if user.Password == nil {
|
||||
if user.Password == "" {
|
||||
return fmt.Errorf("user password not present")
|
||||
}
|
||||
model.Password = types.StringValue(*user.Password)
|
||||
model.Password = types.StringValue(user.Password)
|
||||
|
||||
if user.Roles != nil {
|
||||
resRoles := *user.Roles
|
||||
if len(user.Roles) > 0 {
|
||||
resRoles := user.Roles
|
||||
slices.Sort(resRoles)
|
||||
|
||||
var roles []attr.Value
|
||||
|
|
@ -164,14 +163,14 @@ func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *res
|
|||
model.Roles = types.List(types.SetNull(types.StringType))
|
||||
}
|
||||
|
||||
model.Password = types.StringPointerValue(user.Password)
|
||||
model.Uri = types.StringPointerValue(user.Uri)
|
||||
model.Password = types.StringValue(user.Password)
|
||||
model.Uri = types.StringValue(user.Uri)
|
||||
|
||||
model.Host = types.StringPointerValue(user.Host)
|
||||
model.Port = types.Int64PointerValue(user.Port)
|
||||
model.Host = types.StringValue(user.Host)
|
||||
model.Port = types.Int64Value(int64(user.Port))
|
||||
model.Region = types.StringValue(region)
|
||||
model.Status = types.StringPointerValue(user.Status)
|
||||
model.DefaultDatabase = types.StringPointerValue(user.DefaultDatabase)
|
||||
model.Status = types.StringValue(user.Status)
|
||||
model.DefaultDatabase = types.StringValue(user.DefaultDatabase)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -180,14 +179,14 @@ func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *res
|
|||
func toCreatePayload(
|
||||
model *resourceModel,
|
||||
roles []string,
|
||||
) (*sqlserverflexalpha.CreateUserRequestPayload, error) {
|
||||
) (*v3alpha1api.CreateUserRequestPayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
return &sqlserverflexalpha.CreateUserRequestPayload{
|
||||
Username: conversion.StringValueToPointer(model.Username),
|
||||
DefaultDatabase: conversion.StringValueToPointer(model.DefaultDatabase),
|
||||
Roles: &roles,
|
||||
return &v3alpha1api.CreateUserRequestPayload{
|
||||
Username: model.Username.ValueString(),
|
||||
DefaultDatabase: model.DefaultDatabase.ValueStringPointer(),
|
||||
Roles: roles,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,23 +6,22 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
|
||||
"github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3alpha1api"
|
||||
)
|
||||
|
||||
func TestMapDataSourceFields(t *testing.T) {
|
||||
const testRegion = "region"
|
||||
tests := []struct {
|
||||
description string
|
||||
input *sqlserverflexalpha.GetUserResponse
|
||||
input *v3alpha1api.GetUserResponse
|
||||
region string
|
||||
expected dataSourceModel
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&sqlserverflexalpha.GetUserResponse{},
|
||||
&v3alpha1api.GetUserResponse{},
|
||||
testRegion,
|
||||
dataSourceModel{
|
||||
Id: types.StringValue("pid,region,iid,1"),
|
||||
|
|
@ -41,8 +40,8 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"simple_values",
|
||||
&sqlserverflexalpha.GetUserResponse{
|
||||
Roles: &[]string{
|
||||
&v3alpha1api.GetUserResponse{
|
||||
Roles: []string{
|
||||
"##STACKIT_SQLAgentUser##",
|
||||
"##STACKIT_DatabaseManager##",
|
||||
"##STACKIT_LoginManager##",
|
||||
|
|
@ -50,11 +49,11 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
"##STACKIT_ProcessManager##",
|
||||
"##STACKIT_ServerManager##",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
Host: utils.Ptr("host"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
Status: utils.Ptr("active"),
|
||||
DefaultDatabase: utils.Ptr("default_db"),
|
||||
Username: "username",
|
||||
Host: "host",
|
||||
Port: int32(1234),
|
||||
Status: "active",
|
||||
DefaultDatabase: "default_db",
|
||||
},
|
||||
testRegion,
|
||||
dataSourceModel{
|
||||
|
|
@ -85,12 +84,12 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&sqlserverflexalpha.GetUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
Host: nil,
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
&v3alpha1api.GetUserResponse{
|
||||
Id: int64(1),
|
||||
Roles: []string{},
|
||||
Username: "",
|
||||
Host: "",
|
||||
Port: int32(2123456789),
|
||||
},
|
||||
testRegion,
|
||||
dataSourceModel{
|
||||
|
|
@ -115,14 +114,14 @@ func TestMapDataSourceFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&sqlserverflexalpha.GetUserResponse{},
|
||||
&v3alpha1api.GetUserResponse{},
|
||||
testRegion,
|
||||
dataSourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&sqlserverflexalpha.GetUserResponse{},
|
||||
&v3alpha1api.GetUserResponse{},
|
||||
testRegion,
|
||||
dataSourceModel{},
|
||||
false,
|
||||
|
|
@ -158,16 +157,16 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
const testRegion = "region"
|
||||
tests := []struct {
|
||||
description string
|
||||
input *sqlserverflexalpha.CreateUserResponse
|
||||
input *v3alpha1api.CreateUserResponse
|
||||
region string
|
||||
expected resourceModel
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&sqlserverflexalpha.CreateUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Password: utils.Ptr(""),
|
||||
&v3alpha1api.CreateUserResponse{
|
||||
Id: (int64(1)),
|
||||
Password: (""),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -186,19 +185,19 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"simple_values",
|
||||
&sqlserverflexalpha.CreateUserResponse{
|
||||
Id: utils.Ptr(int64(2)),
|
||||
Roles: &[]string{
|
||||
&v3alpha1api.CreateUserResponse{
|
||||
Id: (int64(2)),
|
||||
Roles: []string{
|
||||
"role_2",
|
||||
"role_1",
|
||||
"",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
Password: utils.Ptr("password"),
|
||||
Host: utils.Ptr("host"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
Status: utils.Ptr("status"),
|
||||
DefaultDatabase: utils.Ptr("default_db"),
|
||||
Username: "username",
|
||||
Password: "password",
|
||||
Host: "host",
|
||||
Port: int32(1234),
|
||||
Status: "status",
|
||||
DefaultDatabase: "default_db",
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -227,13 +226,13 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&sqlserverflexalpha.CreateUserResponse{
|
||||
Id: utils.Ptr(int64(3)),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
Password: utils.Ptr(""),
|
||||
Host: nil,
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
&v3alpha1api.CreateUserResponse{
|
||||
Id: int64(3),
|
||||
Roles: []string{},
|
||||
Username: "",
|
||||
Password: "",
|
||||
Host: "",
|
||||
Port: int32(256789),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -261,22 +260,22 @@ func TestMapFieldsCreate(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&sqlserverflexalpha.CreateUserResponse{},
|
||||
&v3alpha1api.CreateUserResponse{},
|
||||
testRegion,
|
||||
resourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&sqlserverflexalpha.CreateUserResponse{},
|
||||
&v3alpha1api.CreateUserResponse{},
|
||||
testRegion,
|
||||
resourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_password",
|
||||
&sqlserverflexalpha.CreateUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
&v3alpha1api.CreateUserResponse{
|
||||
Id: int64(1),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{},
|
||||
|
|
@ -312,14 +311,14 @@ func TestMapFields(t *testing.T) {
|
|||
const testRegion = "region"
|
||||
tests := []struct {
|
||||
description string
|
||||
input *sqlserverflexalpha.GetUserResponse
|
||||
input *v3alpha1api.GetUserResponse
|
||||
region string
|
||||
expected resourceModel
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&sqlserverflexalpha.GetUserResponse{},
|
||||
&v3alpha1api.GetUserResponse{},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
Id: types.Int64Value(1),
|
||||
|
|
@ -336,15 +335,15 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"simple_values",
|
||||
&sqlserverflexalpha.GetUserResponse{
|
||||
Roles: &[]string{
|
||||
&v3alpha1api.GetUserResponse{
|
||||
Roles: []string{
|
||||
"role_2",
|
||||
"role_1",
|
||||
"",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
Host: utils.Ptr("host"),
|
||||
Port: utils.Ptr(int64(1234)),
|
||||
Username: ("username"),
|
||||
Host: ("host"),
|
||||
Port: (int32(1234)),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -370,12 +369,12 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"null_fields_and_int_conversions",
|
||||
&sqlserverflexalpha.GetUserResponse{
|
||||
Id: utils.Ptr(int64(1)),
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
Host: nil,
|
||||
Port: utils.Ptr(int64(2123456789)),
|
||||
&v3alpha1api.GetUserResponse{
|
||||
Id: int64(1),
|
||||
Roles: []string{},
|
||||
Username: "",
|
||||
Host: "",
|
||||
Port: int32(2123456789),
|
||||
},
|
||||
testRegion,
|
||||
resourceModel{
|
||||
|
|
@ -400,14 +399,14 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"nil_response_2",
|
||||
&sqlserverflexalpha.GetUserResponse{},
|
||||
&v3alpha1api.GetUserResponse{},
|
||||
testRegion,
|
||||
resourceModel{},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"no_resource_id",
|
||||
&sqlserverflexalpha.GetUserResponse{},
|
||||
&v3alpha1api.GetUserResponse{},
|
||||
testRegion,
|
||||
resourceModel{},
|
||||
false,
|
||||
|
|
@ -444,16 +443,16 @@ func TestToCreatePayload(t *testing.T) {
|
|||
description string
|
||||
input *resourceModel
|
||||
inputRoles []string
|
||||
expected *sqlserverflexalpha.CreateUserRequestPayload
|
||||
expected *v3alpha1api.CreateUserRequestPayload
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
"default_values",
|
||||
&resourceModel{},
|
||||
[]string{},
|
||||
&sqlserverflexalpha.CreateUserRequestPayload{
|
||||
Roles: &[]string{},
|
||||
Username: nil,
|
||||
&v3alpha1api.CreateUserRequestPayload{
|
||||
Roles: []string{},
|
||||
Username: "",
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -466,12 +465,12 @@ func TestToCreatePayload(t *testing.T) {
|
|||
"role_1",
|
||||
"role_2",
|
||||
},
|
||||
&sqlserverflexalpha.CreateUserRequestPayload{
|
||||
Roles: &[]string{
|
||||
&v3alpha1api.CreateUserRequestPayload{
|
||||
Roles: []string{
|
||||
"role_1",
|
||||
"role_2",
|
||||
},
|
||||
Username: utils.Ptr("username"),
|
||||
Username: "username",
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -483,11 +482,11 @@ func TestToCreatePayload(t *testing.T) {
|
|||
[]string{
|
||||
"",
|
||||
},
|
||||
&sqlserverflexalpha.CreateUserRequestPayload{
|
||||
Roles: &[]string{
|
||||
&v3alpha1api.CreateUserRequestPayload{
|
||||
Roles: []string{
|
||||
"",
|
||||
},
|
||||
Username: nil,
|
||||
Username: "",
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -504,9 +503,9 @@ func TestToCreatePayload(t *testing.T) {
|
|||
Username: types.StringValue("username"),
|
||||
},
|
||||
[]string{},
|
||||
&sqlserverflexalpha.CreateUserRequestPayload{
|
||||
Roles: &[]string{},
|
||||
Username: utils.Ptr("username"),
|
||||
&v3alpha1api.CreateUserRequestPayload{
|
||||
Roles: []string{},
|
||||
Username: "username",
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
|
||||
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
|
||||
sqlserverflexalpha "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3alpha1api"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
|
||||
sqlserverflexalphaUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils"
|
||||
sqlserverflexalphaWait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexalpha"
|
||||
|
|
@ -231,7 +231,7 @@ func (r *userResource) Create(
|
|||
return
|
||||
}
|
||||
// Create new user
|
||||
userResp, err := r.client.CreateUserRequest(
|
||||
userResp, err := r.client.DefaultAPI.CreateUserRequest(
|
||||
ctx,
|
||||
projectId,
|
||||
region,
|
||||
|
|
@ -244,7 +244,7 @@ func (r *userResource) Create(
|
|||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if userResp == nil || userResp.Id == nil || *userResp.Id == 0 {
|
||||
if userResp == nil || userResp.Id == 0 {
|
||||
core.LogAndAddError(
|
||||
ctx,
|
||||
&resp.Diagnostics,
|
||||
|
|
@ -254,7 +254,7 @@ func (r *userResource) Create(
|
|||
return
|
||||
}
|
||||
|
||||
userId := *userResp.Id
|
||||
userId := userResp.Id
|
||||
ctx = tflog.SetField(ctx, "user_id", userId)
|
||||
|
||||
// Set data returned by API in identity
|
||||
|
|
@ -282,7 +282,7 @@ func (r *userResource) Create(
|
|||
|
||||
waitResp, err := sqlserverflexalphaWait.CreateUserWaitHandler(
|
||||
ctx,
|
||||
r.client,
|
||||
r.client.DefaultAPI,
|
||||
projectId,
|
||||
instanceId,
|
||||
region,
|
||||
|
|
@ -303,7 +303,7 @@ func (r *userResource) Create(
|
|||
return
|
||||
}
|
||||
|
||||
if waitResp.Id == nil {
|
||||
if waitResp.Id == 0 {
|
||||
core.LogAndAddError(
|
||||
ctx,
|
||||
&resp.Diagnostics,
|
||||
|
|
@ -357,7 +357,7 @@ func (r *userResource) Read(
|
|||
ctx = tflog.SetField(ctx, "user_id", userId)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
||||
recordSetResp, err := r.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
|
||||
recordSetResp, err := r.client.DefaultAPI.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute()
|
||||
if err != nil {
|
||||
var oapiErr *oapierror.GenericOpenAPIError
|
||||
ok := errors.As(
|
||||
|
|
@ -445,7 +445,7 @@ func (r *userResource) Delete(
|
|||
|
||||
// Delete existing record set
|
||||
// err := r.client.DeleteUserRequest(ctx, projectId, region, instanceId, userId).Execute()
|
||||
err := r.client.DeleteUserRequestExecute(ctx, projectId, region, instanceId, userId)
|
||||
err := r.client.DefaultAPI.DeleteUserRequest(ctx, projectId, region, instanceId, userId).Execute()
|
||||
if err != nil {
|
||||
var oapiErr *oapierror.GenericOpenAPIError
|
||||
ok := errors.As(err, &oapiErr)
|
||||
|
|
@ -467,7 +467,7 @@ func (r *userResource) Delete(
|
|||
}
|
||||
}
|
||||
// Delete existing record set
|
||||
_, err = sqlserverflexalphaWait.DeleteUserWaitHandler(ctx, r.client, projectId, region, instanceId, userId).
|
||||
_, err = sqlserverflexalphaWait.DeleteUserWaitHandler(ctx, r.client.DefaultAPI, projectId, region, instanceId, userId).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "User Delete Error", fmt.Sprintf("Calling API: %v", err))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue