forked from hashicorp/go-tfe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_setting_customization.go
75 lines (62 loc) · 2.44 KB
/
admin_setting_customization.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
package tfe
import (
"context"
)
// Compile-time proof of interface implementation.
var _ CustomizationSettings = (*adminCustomizationSettings)(nil)
// CustomizationSettings describes all the Customization admin settings.
type CustomizationSettings interface {
// Read returns the customization settings.
Read(ctx context.Context) (*AdminCustomizationSetting, error)
// Update updates the customization settings.
Update(ctx context.Context, options AdminCustomizationSettingsUpdateOptions) (*AdminCustomizationSetting, error)
}
type adminCustomizationSettings struct {
client *Client
}
// AdminCustomizationSetting represents the Customization settings in Terraform Enterprise for the Admin Settings API.
// https://www.terraform.io/cloud-docs/api-docs/admin/settings
type AdminCustomizationSetting struct {
ID string `jsonapi:"primary,customization-settings"`
SupportEmail string `jsonapi:"attr,support-email-address"`
LoginHelp string `jsonapi:"attr,login-help"`
Footer string `jsonapi:"attr,footer"`
Error string `jsonapi:"attr,error"`
NewUser string `jsonapi:"attr,new-user"`
}
// Read returns the Customization settings.
func (a *adminCustomizationSettings) Read(ctx context.Context) (*AdminCustomizationSetting, error) {
req, err := a.client.NewRequest("GET", "admin/customization-settings", nil)
if err != nil {
return nil, err
}
cs := &AdminCustomizationSetting{}
err = req.Do(ctx, cs)
if err != nil {
return nil, err
}
return cs, nil
}
// AdminCustomizationSettingsUpdateOptions represents the admin options for updating
// Customization settings.
// https://www.terraform.io/docs/cloud/api/admin/settings.html#request-body-6
type AdminCustomizationSettingsUpdateOptions struct {
SupportEmail *string `jsonapi:"attr,support-email-address,omitempty"`
LoginHelp *string `jsonapi:"attr,login-help,omitempty"`
Footer *string `jsonapi:"attr,footer,omitempty"`
Error *string `jsonapi:"attr,error,omitempty"`
NewUser *string `jsonapi:"attr,new-user,omitempty"`
}
// Update updates the customization settings.
func (a *adminCustomizationSettings) Update(ctx context.Context, options AdminCustomizationSettingsUpdateOptions) (*AdminCustomizationSetting, error) {
req, err := a.client.NewRequest("PATCH", "admin/customization-settings", &options)
if err != nil {
return nil, err
}
cs := &AdminCustomizationSetting{}
err = req.Do(ctx, cs)
if err != nil {
return nil, err
}
return cs, nil
}