/
schema.go
64 lines (55 loc) · 1.83 KB
/
schema.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package project
import (
"context"
"fmt"
"github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/common"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
)
// Project is the schema model
type Project struct {
ID types.String `tfsdk:"id"`
ContainerID types.String `tfsdk:"container_id"`
ParentContainerID types.String `tfsdk:"parent_container_id"`
Name types.String `tfsdk:"name"`
BillingRef types.String `tfsdk:"billing_ref"`
Labels map[string]string `tfsdk:"labels"`
}
// Schema returns the terraform schema structure
func (d *DataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: fmt.Sprintf("Data source for STACKIT projects\n%s",
common.EnvironmentInfo(d.urls),
),
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Description: "the project UUID",
Computed: true,
},
"container_id": schema.StringAttribute{
Description: "the project container ID",
Required: true,
},
"parent_container_id": schema.StringAttribute{
Description: "the project's parent container ID",
Computed: true,
},
"name": schema.StringAttribute{
Description: "the project name",
Computed: true,
},
"billing_ref": schema.StringAttribute{
Description: "billing reference for cost transparency",
Computed: true,
},
"labels": schema.MapAttribute{
Description: "Extend project information with custom label values.",
Required: false,
Computed: false,
Optional: true,
ElementType: types.StringType,
},
},
}
}