9
9
"github.com/hashicorp/terraform-plugin-framework/datasource"
10
10
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
11
11
"github.com/hashicorp/terraform-plugin-framework/types"
12
- "log"
13
12
"time"
14
13
)
15
14
@@ -27,13 +26,12 @@ type dataSourceHYOKCustomerKeyVersion struct {
27
26
}
28
27
29
28
type HYOKCustomerKeyVersionDataSourceModel struct {
30
- ID types.String `tfsdk:"id"`
31
- Status types.String `tfsdk:"status"`
32
- Error types.String `tfsdk:"error"`
33
- KeyVersion types.String `tfsdk:"key_version"`
34
- CreatedAt types.String `tfsdk:"created_at"`
35
- UpdatedAt types.String `tfsdk:"updated_at"`
36
- RevokedAt types.String `tfsdk:"revoked_at"`
29
+ ID types.String `tfsdk:"id"`
30
+ Status types.String `tfsdk:"status"`
31
+ Error types.String `tfsdk:"error"`
32
+ KeyVersion types.String `tfsdk:"key_version"`
33
+ CreatedAt types.String `tfsdk:"created_at"`
34
+ WorkspacesSecured types.Int64 `tfsdk:"workspaces_secured"`
37
35
}
38
36
39
37
func (d * dataSourceHYOKCustomerKeyVersion ) Configure (_ context.Context , req datasource.ConfigureRequest , resp * datasource.ConfigureResponse ) {
@@ -74,19 +72,15 @@ func (d *dataSourceHYOKCustomerKeyVersion) Schema(ctx context.Context, req datas
74
72
Computed : true ,
75
73
},
76
74
"key_version" : schema.StringAttribute {
77
- Description : "The version number of the customer key." ,
75
+ Description : "The version number of the customer key version ." ,
78
76
Computed : true ,
79
77
},
80
- "created_at" : schema.StringAttribute {
81
- Description : "The timestamp when the key version was created." ,
82
- Computed : true ,
83
- },
84
- "updated_at" : schema.StringAttribute {
85
- Description : "The timestamp when the key version was last updated." ,
78
+ "workspaces_secured" : schema.Int64Attribute {
79
+ Description : "The number workspaces secured by this customer key version." ,
86
80
Computed : true ,
87
81
},
88
- "revoked_at " : schema.StringAttribute {
89
- Description : "The timestamp when the key version was revoked, if applicable ." ,
82
+ "created_at " : schema.StringAttribute {
83
+ Description : "The timestamp when the key version was created ." ,
90
84
Computed : true ,
91
85
},
92
86
},
@@ -102,8 +96,6 @@ func (d *dataSourceHYOKCustomerKeyVersion) Read(ctx context.Context, req datasou
102
96
return
103
97
}
104
98
105
- log .Printf ("[DEBUG] Reading HYOK customer key version: %s" , data .ID .ValueString ())
106
-
107
99
// Make API call to fetch the HYOK customer key version
108
100
keyVersion , err := d .config .Client .HYOKCustomerKeyVersions .Read (ctx , data .ID .ValueString ())
109
101
if err != nil {
@@ -114,9 +106,8 @@ func (d *dataSourceHYOKCustomerKeyVersion) Read(ctx context.Context, req datasou
114
106
// Set the computed attributes from the API response
115
107
data .Status = types .StringValue (string (keyVersion .Status ))
116
108
data .KeyVersion = types .StringValue (keyVersion .KeyVersion )
117
- data .CreatedAt = types .StringValue (keyVersion .CreatedAt .Format (time .RFC3339 )) // TODO DOM: Check this format
118
- data .UpdatedAt = types .StringValue (keyVersion .UpdatedAt .Format (time .RFC3339 )) // TODO DOM: Check this format
119
- data .RevokedAt = types .StringValue (keyVersion .RevokedAt .Format (time .RFC3339 )) // TODO DOM: Check this format
109
+ data .CreatedAt = types .StringValue (keyVersion .CreatedAt .Format (time .RFC3339 ))
110
+ data .WorkspacesSecured = types .Int64Value (int64 (keyVersion .WorkspacesSecured ))
120
111
data .Error = types .StringValue (keyVersion .Error )
121
112
122
113
// Save data into Terraform state
0 commit comments