-
Notifications
You must be signed in to change notification settings - Fork 91
/
schema_resource.go
156 lines (151 loc) · 4.57 KB
/
schema_resource.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package user
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
var resourceSchema = map[string]*schema.Schema{
"email": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The email of the user.",
},
"username": {
Type: schema.TypeString,
Required: true,
Description: "The username of the user.",
},
"restricted": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If true, the user must be explicitly granted access to platform actions and entities.",
},
"ssh_keys": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Description: "SSH keys to add to the user profile.",
},
"tfa_enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "If the User has Two Factor Authentication (TFA) enabled.",
},
"global_grants": {
Type: schema.TypeList,
Description: "A structure containing the Account-level grants a User has.",
Optional: true,
Computed: true,
MaxItems: 1,
Elem: resourceLinodeUserGrantsGlobal(),
},
"domain_grant": resourceLinodeUserGrantsEntitySet(),
"firewall_grant": resourceLinodeUserGrantsEntitySet(),
"image_grant": resourceLinodeUserGrantsEntitySet(),
"linode_grant": resourceLinodeUserGrantsEntitySet(),
"longview_grant": resourceLinodeUserGrantsEntitySet(),
"nodebalancer_grant": resourceLinodeUserGrantsEntitySet(),
"stackscript_grant": resourceLinodeUserGrantsEntitySet(),
"volume_grant": resourceLinodeUserGrantsEntitySet(),
}
func resourceLinodeUserGrantsGlobal() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"account_access": {
Type: schema.TypeString,
Description: "The level of access this User has to Account-level actions, like billing information. " +
"A restricted User will never be able to manage users.",
Optional: true,
},
"add_domains": {
Type: schema.TypeBool,
Description: "If true, this User may add Domains.",
Optional: true,
Default: false,
},
"add_databases": {
Type: schema.TypeBool,
Description: "If true, this User may add Databases.",
Optional: true,
Default: false,
},
"add_firewalls": {
Type: schema.TypeBool,
Description: "If true, this User may add Firewalls.",
Optional: true,
Default: false,
},
"add_images": {
Type: schema.TypeBool,
Description: "If true, this User may add Images.",
Optional: true,
Default: false,
},
"add_linodes": {
Type: schema.TypeBool,
Description: "If true, this User may create Linodes.",
Optional: true,
Default: false,
},
"add_longview": {
Type: schema.TypeBool,
Description: "If true, this User may create Longview clients and view the current plan.",
Optional: true,
Default: false,
},
"add_nodebalancers": {
Type: schema.TypeBool,
Description: "If true, this User may add NodeBalancers.",
Optional: true,
Default: false,
},
"add_stackscripts": {
Type: schema.TypeBool,
Description: "If true, this User may add StackScripts.",
Optional: true,
Default: false,
},
"add_volumes": {
Type: schema.TypeBool,
Description: "If true, this User may add Volumes.",
Optional: true,
Default: false,
},
"cancel_account": {
Type: schema.TypeBool,
Description: "If true, this User may cancel the entire Account.",
Optional: true,
Default: false,
},
"longview_subscription": {
Type: schema.TypeBool,
Description: "If true, this User may manage the Account’s Longview subscription.",
Optional: true,
Default: false,
},
},
}
}
func resourceLinodeUserGrantsEntity() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Required: true,
Description: "The ID of the entity this grant applies to.",
},
"permissions": {
Type: schema.TypeString,
Required: true,
Description: "The level of access this User has to this entity. If null, this User has no access.",
},
},
}
}
func resourceLinodeUserGrantsEntitySet() *schema.Schema {
return &schema.Schema{
Type: schema.TypeSet,
Description: "A set containing all of the user's active grants.",
Optional: true,
Computed: true,
Elem: resourceLinodeUserGrantsEntity(),
}
}