/
schema.go
71 lines (62 loc) · 2.18 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
65
66
67
68
69
70
71
package credential
import (
"context"
"fmt"
"github.com/SchwarzIT/terraform-provider-stackit/stackit/internal/common"
"github.com/SchwarzIT/terraform-provider-stackit/stackit/pkg/validate"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
)
// Credential is the schema model
type Credential struct {
ID types.String `tfsdk:"id"`
ProjectID types.String `tfsdk:"project_id"`
ObjectStorageProjectID types.String `tfsdk:"object_storage_project_id"`
CredentialsGroupID types.String `tfsdk:"credentials_group_id"`
Expiry types.String `tfsdk:"expiry"`
DisplayName types.String `tfsdk:"display_name"`
}
// 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 Object Storage credentials\n%s",
common.EnvironmentInfo(d.urls),
),
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Description: "the credential ID",
Optional: true,
Computed: true,
},
"object_storage_project_id": schema.StringAttribute{
Description: "The ID returned from `stackit_object_storage_project`",
DeprecationMessage: "Use `project_id` instead.",
Optional: true,
Validators: []validator.String{
validate.ProjectID(),
},
},
"project_id": schema.StringAttribute{
Description: "The ID returned from `stackit_object_storage_project`",
Required: true,
Validators: []validator.String{
validate.ProjectID(),
},
},
"credentials_group_id": schema.StringAttribute{
Description: "the credentials group ID",
Required: true,
},
"expiry": schema.StringAttribute{
Computed: true,
},
"display_name": schema.StringAttribute{
Description: "the credential's display name in the portal",
Computed: true,
Optional: true,
},
},
}
}