-
Notifications
You must be signed in to change notification settings - Fork 20
/
instances.go
92 lines (74 loc) · 3.31 KB
/
instances.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
package clerk
import (
"net/http"
)
type InstanceService service
type UpdateInstanceParams struct {
// TestMode can be used to toggle test mode for this instance.
// Defaults to true for development instances.
TestMode *bool `json:"test_mode,omitempty"`
// HIBP is used to configure whether Clerk should use the
// "Have I Been Pawned" service to check passwords against
// known security breaches.
// By default, this is enabled in all instances.
HIBP *bool `json:"hibp,omitempty"`
// EnhancedEmailDeliverability controls how Clerk delivers emails.
// Specifically, when set to true, if the instance is a production
// instance, OTP verification emails are sent by the Clerk's shared
// domain via Postmark.
EnhancedEmailDeliverability *bool `json:"enhanced_email_deliverability,omitempty"`
// SupportEmail is the contact email address that will be displayed
// on the frontend, in case your instance users need support.
// If the empty string is provided, the support email that is currently
// configured in the instance will be removed.
SupportEmail *string `json:"support_email,omitempty"`
// ClerkJSVersion allows you to request a specific Clerk JS version on the Clerk Hosted Account pages.
// If an empty string is provided, the stored version will be removed.
// If an explicit version is not set, the Clerk JS version will be automatically be resolved.
ClerkJSVersion *string `json:"clerk_js_version,omitempty"`
// CookielessDev can be used to enable the new mode in which no third-party
// cookies are used in development instances. Make sure to also enable the
// setting in Clerk.js
CookielessDev *bool `json:"cookieless_dev,omitempty"`
}
func (s *InstanceService) Update(params UpdateInstanceParams) error {
req, _ := s.client.NewRequest(http.MethodPatch, "instance", ¶ms)
_, err := s.client.Do(req, nil)
return err
}
type InstanceRestrictionsResponse struct {
Object string `json:"object"`
Allowlist bool `json:"allowlist"`
Blocklist bool `json:"blocklist"`
}
type UpdateRestrictionsParams struct {
Allowlist *bool `json:"allowlist,omitempty"`
Blocklist *bool `json:"blocklist,omitempty"`
}
func (s *InstanceService) UpdateRestrictions(params UpdateRestrictionsParams) (*InstanceRestrictionsResponse, error) {
req, _ := s.client.NewRequest(http.MethodPatch, "instance/restrictions", ¶ms)
var instanceRestrictionsResponse InstanceRestrictionsResponse
_, err := s.client.Do(req, &instanceRestrictionsResponse)
if err != nil {
return nil, err
}
return &instanceRestrictionsResponse, nil
}
type OrganizationSettingsResponse struct {
Object string `json:"object"`
Enabled bool `json:"enabled"`
MaxAllowedMemberships int `json:"max_allowed_memberships"`
}
type UpdateOrganizationSettingsParams struct {
Enabled *bool `json:"enabled,omitempty"`
MaxAllowedMemberships *int `json:"max_allowed_memberships,omitempty"`
}
func (s *InstanceService) UpdateOrganizationSettings(params UpdateOrganizationSettingsParams) (*OrganizationSettingsResponse, error) {
req, _ := s.client.NewRequest(http.MethodPatch, "instance/organization_settings", ¶ms)
var organizationSettingsResponse OrganizationSettingsResponse
_, err := s.client.Do(req, &organizationSettingsResponse)
if err != nil {
return nil, err
}
return &organizationSettingsResponse, nil
}