Skip to content

Commit 95e95bd

Browse files
Added support for missing User-related fields (linode#622)
* Added support for missing user fields * Reran GetMonthlyTransfer fixture
1 parent 6106012 commit 95e95bd

14 files changed

+822
-380
lines changed

account_user_grants.go

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ type GlobalUserGrants struct {
2020
AddLinodes bool `json:"add_linodes"`
2121
AddLongview bool `json:"add_longview"`
2222
AddNodeBalancers bool `json:"add_nodebalancers"`
23+
AddPlacementGroups bool `json:"add_placement_groups"`
2324
AddStackScripts bool `json:"add_stackscripts"`
2425
AddVolumes bool `json:"add_volumes"`
26+
AddVPCs bool `json:"add_vpcs"`
2527
CancelAccount bool `json:"cancel_account"`
28+
ChildAccountAccess bool `json:"child_account_access"`
2629
LongviewSubscription bool `json:"longview_subscription"`
2730
}
2831

@@ -38,29 +41,33 @@ type GrantedEntity struct {
3841
}
3942

4043
type UserGrants struct {
41-
Database []GrantedEntity `json:"database"`
42-
Domain []GrantedEntity `json:"domain"`
43-
Firewall []GrantedEntity `json:"firewall"`
44-
Image []GrantedEntity `json:"image"`
45-
Linode []GrantedEntity `json:"linode"`
46-
Longview []GrantedEntity `json:"longview"`
47-
NodeBalancer []GrantedEntity `json:"nodebalancer"`
48-
StackScript []GrantedEntity `json:"stackscript"`
49-
Volume []GrantedEntity `json:"volume"`
44+
Database []GrantedEntity `json:"database"`
45+
Domain []GrantedEntity `json:"domain"`
46+
Firewall []GrantedEntity `json:"firewall"`
47+
Image []GrantedEntity `json:"image"`
48+
Linode []GrantedEntity `json:"linode"`
49+
Longview []GrantedEntity `json:"longview"`
50+
NodeBalancer []GrantedEntity `json:"nodebalancer"`
51+
PlacementGroup []GrantedEntity `json:"placement_group"`
52+
StackScript []GrantedEntity `json:"stackscript"`
53+
Volume []GrantedEntity `json:"volume"`
54+
VPC []GrantedEntity `json:"vpc"`
5055

5156
Global GlobalUserGrants `json:"global"`
5257
}
5358

5459
type UserGrantsUpdateOptions struct {
55-
Database []GrantedEntity `json:"database,omitempty"`
56-
Domain []EntityUserGrant `json:"domain,omitempty"`
57-
Firewall []EntityUserGrant `json:"firewall,omitempty"`
58-
Image []EntityUserGrant `json:"image,omitempty"`
59-
Linode []EntityUserGrant `json:"linode,omitempty"`
60-
Longview []EntityUserGrant `json:"longview,omitempty"`
61-
NodeBalancer []EntityUserGrant `json:"nodebalancer,omitempty"`
62-
StackScript []EntityUserGrant `json:"stackscript,omitempty"`
63-
Volume []EntityUserGrant `json:"volume,omitempty"`
60+
Database []GrantedEntity `json:"database,omitempty"`
61+
Domain []EntityUserGrant `json:"domain,omitempty"`
62+
Firewall []EntityUserGrant `json:"firewall,omitempty"`
63+
Image []EntityUserGrant `json:"image,omitempty"`
64+
Linode []EntityUserGrant `json:"linode,omitempty"`
65+
Longview []EntityUserGrant `json:"longview,omitempty"`
66+
NodeBalancer []EntityUserGrant `json:"nodebalancer,omitempty"`
67+
PlacementGroup []EntityUserGrant `json:"placement_group,omitempty"`
68+
StackScript []EntityUserGrant `json:"stackscript,omitempty"`
69+
Volume []EntityUserGrant `json:"volume,omitempty"`
70+
VPC []EntityUserGrant `json:"vpc,omitempty"`
6471

6572
Global GlobalUserGrants `json:"global"`
6673
}

account_users.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type UserCreateOptions struct {
4747
type UserUpdateOptions struct {
4848
Username string `json:"username,omitempty"`
4949
Restricted *bool `json:"restricted,omitempty"`
50+
Email string `json:"email,omitempty"`
5051
}
5152

5253
// UnmarshalJSON implements the json.Unmarshaler interface
@@ -102,6 +103,7 @@ func (i User) GetCreateOptions() (o UserCreateOptions) {
102103
func (i User) GetUpdateOptions() (o UserUpdateOptions) {
103104
o.Username = i.Username
104105
o.Restricted = copyBool(&i.Restricted)
106+
o.Email = i.Email
105107

106108
return
107109
}

test/integration/account_user_grants_test.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ func TestUserGrants_Update(t *testing.T) {
2323
accessLevel := linodego.AccessLevelReadOnly
2424

2525
globalGrants := linodego.GlobalUserGrants{
26-
AccountAccess: &accessLevel,
27-
AddDomains: false,
28-
AddDatabases: true,
29-
AddFirewalls: true,
30-
AddImages: true,
31-
AddLinodes: false,
32-
AddLongview: true,
33-
AddNodeBalancers: false,
34-
AddStackScripts: true,
35-
AddVolumes: true,
36-
CancelAccount: false,
26+
AccountAccess: &accessLevel,
27+
AddDomains: false,
28+
AddDatabases: true,
29+
AddFirewalls: true,
30+
AddImages: true,
31+
AddLinodes: false,
32+
AddLongview: true,
33+
AddNodeBalancers: false,
34+
AddPlacementGroups: false,
35+
AddStackScripts: true,
36+
AddVolumes: true,
37+
AddVPCs: true,
38+
CancelAccount: false,
3739
}
3840

3941
grants, err := client.UpdateUserGrants(context.TODO(), username, linodego.UserGrantsUpdateOptions{
@@ -83,8 +85,10 @@ func TestUserGrants_UpdateNoAccess(t *testing.T) {
8385
grants.Linode,
8486
grants.Longview,
8587
grants.NodeBalancer,
88+
grants.PlacementGroup,
8689
grants.StackScript,
8790
grants.Volume,
91+
grants.VPC,
8892
}
8993

9094
for _, grantField := range grantFields {

0 commit comments

Comments
 (0)