Skip to content

Commit a36774c

Browse files
committed
fix: adapt tenant v4 client to actual implementation
1 parent 29713a0 commit a36774c

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed

client/tenant_v4.go

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,54 @@ import (
99
"net/url"
1010
)
1111

12-
const CONTENT_TYPE_TENANT_V4 = "application/vnd.meshcloud.api.meshtenant.v4.hal+json"
12+
const CONTENT_TYPE_TENANT_V4 = "application/vnd.meshcloud.api.meshtenant.v4-preview.hal+json"
1313

1414
type MeshTenantV4 struct {
1515
ApiVersion string `json:"apiVersion" tfsdk:"api_version"`
1616
Kind string `json:"kind" tfsdk:"kind"`
17-
Metadata MeshTenantMetadataV4 `json:"metadata" tfsdk:"metadata"`
18-
Spec MeshTenantSpecV4 `json:"spec" tfsdk:"spec"`
19-
Status MeshTenantStatusV4 `json:"status" tfsdk:"status"`
17+
Metadata MeshTenantV4Metadata `json:"metadata" tfsdk:"metadata"`
18+
Spec MeshTenantV4Spec `json:"spec" tfsdk:"spec"`
19+
Status MeshTenantV4Status `json:"status" tfsdk:"status"`
2020
}
2121

22-
type MeshTenantMetadataV4 struct {
23-
UUID string `json:"uuid" tfsdk:"uuid"`
24-
OwnedByProject string `json:"ownedByProject" tfsdk:"owned_by_project"`
25-
OwnedByWorkspace string `json:"ownedByWorkspace" tfsdk:"owned_by_workspace"`
26-
DeletedOn *string `json:"deletedOn" tfsdk:"deleted_on"`
27-
CreatedOn *string `json:"createdOn" tfsdk:"created_on"`
22+
type MeshTenantV4Metadata struct {
23+
Uuid string `json:"uuid" tfsdk:"uuid"`
24+
OwnedByProject string `json:"ownedByProject" tfsdk:"owned_by_project"`
25+
OwnedByWorkspace string `json:"ownedByWorkspace" tfsdk:"owned_by_workspace"`
26+
CreatedOn string `json:"createdOn" tfsdk:"created_on"`
27+
MarkedForDeletionOn *string `json:"markedForDeletionOn" tfsdk:"marked_for_deletion_on"`
28+
DeletedOn *string `json:"deletedOn" tfsdk:"deleted_on"`
2829
}
2930

30-
type MeshTenantSpecV4 struct {
31-
PlatformIdentifier string `json:"platformIdentifier" tfsdk:"platform_identifier"`
32-
LocalId *string `json:"localId" tfsdk:"local_id"`
33-
LandingZoneIdentifier string `json:"landingZoneIdentifier" tfsdk:"landing_zone_identifier"`
34-
Quotas []MeshTenantQuota `json:"quotas" tfsdk:"quotas"`
31+
type MeshTenantV4Spec struct {
32+
PlatformIdentifier string `json:"platformIdentifier" tfsdk:"platform_identifier"`
33+
PlatformTenantId *string `json:"platformTenantId" tfsdk:"platform_tenant_id"`
34+
LandingZoneIdentifier *string `json:"landingZoneIdentifier" tfsdk:"landing_zone_identifier"`
35+
Quotas *[]MeshTenantQuota `json:"quotas" tfsdk:"quotas"`
3536
}
3637

37-
type MeshTenantStatusV4 struct {
38-
Tags map[string][]string `json:"tags" tfsdk:"tags"`
39-
LastReplicated *string `json:"lastReplicated" tfsdk:"last_replicated"`
40-
CurrentReplicationStatus string `json:"currentReplicationStatus" tfsdk:"current_replication_status"`
38+
type MeshTenantV4Status struct {
39+
TenantName string `json:"tenantName" tfsdk:"tenant_name"`
40+
PlatformTypeIdentifier string `json:"platformTypeIdentifier" tfsdk:"platform_type_identifier"`
41+
PlatformWorkspaceIdentifier *string `json:"platformWorkspaceIdentifier" tfsdk:"platform_workspace_identifier"`
42+
Tags map[string][]string `json:"tags" tfsdk:"tags"`
4143
}
4244

43-
type MeshTenantCreateV4 struct {
44-
Metadata MeshTenantCreateMetadataV4 `json:"metadata" tfsdk:"metadata"`
45-
Spec MeshTenantCreateSpecV4 `json:"spec" tfsdk:"spec"`
45+
type MeshTenantV4Create struct {
46+
Metadata MeshTenantV4CreateMetadata `json:"metadata" tfsdk:"metadata"`
47+
Spec MeshTenantV4CreateSpec `json:"spec" tfsdk:"spec"`
4648
}
4749

48-
type MeshTenantCreateMetadataV4 struct {
49-
UUID string `json:"uuid" tfsdk:"uuid"`
50+
type MeshTenantV4CreateMetadata struct {
5051
OwnedByProject string `json:"ownedByProject" tfsdk:"owned_by_project"`
5152
OwnedByWorkspace string `json:"ownedByWorkspace" tfsdk:"owned_by_workspace"`
5253
}
5354

54-
type MeshTenantCreateSpecV4 struct {
55-
PlatformIdentifier string `json:"platformIdentifier" tfsdk:"platform_identifier"`
56-
LocalId *string `json:"localId" tfsdk:"local_id"`
57-
LandingZoneIdentifier string `json:"landingZoneIdentifier" tfsdk:"landing_zone_identifier"`
58-
Quotas []MeshTenantQuota `json:"quotas" tfsdk:"quotas"`
55+
type MeshTenantV4CreateSpec struct {
56+
PlatformIdentifier string `json:"platformIdentifier" tfsdk:"platform_identifier"`
57+
LandingZoneIdentifier *string `json:"landingZoneIdentifier" tfsdk:"landing_zone_identifier"`
58+
PlatformTenantId *string `json:"platformTenantId" tfsdk:"platform_tenant_id"`
59+
Quotas *[]MeshTenantQuota `json:"quotas" tfsdk:"quotas"`
5960
}
6061

6162
func (c *MeshStackProviderClient) urlForTenantV4(uuid string) *url.URL {
@@ -99,7 +100,7 @@ func (c *MeshStackProviderClient) ReadTenantV4(uuid string) (*MeshTenantV4, erro
99100
return &tenant, nil
100101
}
101102

102-
func (c *MeshStackProviderClient) CreateTenantV4(tenant *MeshTenantCreateV4) (*MeshTenantV4, error) {
103+
func (c *MeshStackProviderClient) CreateTenantV4(tenant *MeshTenantV4Create) (*MeshTenantV4, error) {
103104
payload, err := json.Marshal(tenant)
104105
if err != nil {
105106
return nil, err
@@ -124,7 +125,7 @@ func (c *MeshStackProviderClient) CreateTenantV4(tenant *MeshTenantCreateV4) (*M
124125
return nil, err
125126
}
126127

127-
if res.StatusCode != 200 {
128+
if !isSuccessHTTPStatus(res) {
128129
return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, data)
129130
}
130131

internal/provider/tenant_v4_resource.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,17 @@ func (r *tenantV4Resource) Schema(_ context.Context, _ resource.SchemaRequest, r
159159
}
160160

161161
func (r *tenantV4Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
162-
var metadata client.MeshTenantCreateMetadataV4
162+
var metadata client.MeshTenantV4CreateMetadata
163163
resp.Diagnostics.Append(req.Plan.GetAttribute(ctx, path.Root("metadata"), &metadata)...)
164164

165-
var spec client.MeshTenantCreateSpecV4
165+
var spec client.MeshTenantV4CreateSpec
166166
resp.Diagnostics.Append(req.Plan.GetAttribute(ctx, path.Root("spec"), &spec)...)
167167

168168
if resp.Diagnostics.HasError() {
169169
return
170170
}
171171

172-
create := client.MeshTenantCreateV4{
172+
create := client.MeshTenantV4Create{
173173
Metadata: metadata,
174174
Spec: spec,
175175
}
@@ -212,17 +212,17 @@ func (r *tenantV4Resource) Read(ctx context.Context, req resource.ReadRequest, r
212212
}
213213

214214
func (r *tenantV4Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
215-
var metadata client.MeshTenantCreateMetadataV4
215+
var metadata client.MeshTenantV4CreateMetadata
216216
resp.Diagnostics.Append(req.Plan.GetAttribute(ctx, path.Root("metadata"), &metadata)...)
217217

218-
var spec client.MeshTenantCreateSpecV4
218+
var spec client.MeshTenantV4CreateSpec
219219
resp.Diagnostics.Append(req.Plan.GetAttribute(ctx, path.Root("spec"), &spec)...)
220220

221221
if resp.Diagnostics.HasError() {
222222
return
223223
}
224224

225-
update := client.MeshTenantCreateV4{
225+
update := client.MeshTenantV4Create{
226226
Metadata: metadata,
227227
Spec: spec,
228228
}

0 commit comments

Comments
 (0)