github.com/clerkinc/clerk-sdk-go@v1.49.1/clerk/instances.go (about) 1 package clerk 2 3 import ( 4 "net/http" 5 ) 6 7 type InstanceService service 8 9 type UpdateInstanceParams struct { 10 // TestMode can be used to toggle test mode for this instance. 11 // Defaults to true for development instances. 12 TestMode *bool `json:"test_mode,omitempty"` 13 14 // HIBP is used to configure whether Clerk should use the 15 // "Have I Been Pawned" service to check passwords against 16 // known security breaches. 17 // By default, this is enabled in all instances. 18 HIBP *bool `json:"hibp,omitempty"` 19 20 // EnhancedEmailDeliverability controls how Clerk delivers emails. 21 // Specifically, when set to true, if the instance is a production 22 // instance, OTP verification emails are sent by the Clerk's shared 23 // domain via Postmark. 24 EnhancedEmailDeliverability *bool `json:"enhanced_email_deliverability,omitempty"` 25 26 // SupportEmail is the contact email address that will be displayed 27 // on the frontend, in case your instance users need support. 28 // If the empty string is provided, the support email that is currently 29 // configured in the instance will be removed. 30 SupportEmail *string `json:"support_email,omitempty"` 31 32 // ClerkJSVersion allows you to request a specific Clerk JS version on the Clerk Hosted Account pages. 33 // If an empty string is provided, the stored version will be removed. 34 // If an explicit version is not set, the Clerk JS version will be automatically be resolved. 35 ClerkJSVersion *string `json:"clerk_js_version,omitempty"` 36 37 // CookielessDev can be used to enable the new mode in which no third-party 38 // cookies are used in development instances. Make sure to also enable the 39 // setting in Clerk.js 40 // 41 // Deprecated: Use URLBasedSessionSyncing instead 42 CookielessDev *bool `json:"cookieless_dev,omitempty"` 43 44 // URLBasedSessionSyncing can be used to enable the new mode in which no third-party 45 // cookies are used in development instances. Make sure to also enable the 46 // setting in Clerk.js 47 URLBasedSessionSyncing *bool `json:"url_based_session_syncing,omitempty"` 48 49 // URL that is going to be used in development instances in order to create custom redirects 50 // and fix the third-party cookies issues. 51 DevelopmentOrigin *string `json:"development_origin,omitempty"` 52 } 53 54 func (s *InstanceService) Update(params UpdateInstanceParams) error { 55 req, _ := s.client.NewRequest(http.MethodPatch, "instance", ¶ms) 56 57 _, err := s.client.Do(req, nil) 58 return err 59 } 60 61 type InstanceRestrictionsResponse struct { 62 Object string `json:"object"` 63 Allowlist bool `json:"allowlist"` 64 Blocklist bool `json:"blocklist"` 65 BlockEmailSubaddresses bool `json:"block_email_subaddresses"` 66 BlockDisposableEmailDomains bool `json:"block_disposable_email_domains"` 67 IgnoreDotsForGmailAddresses bool `json:"ignore_dots_for_gmail_addresses"` 68 } 69 70 type UpdateRestrictionsParams struct { 71 Allowlist *bool `json:"allowlist,omitempty"` 72 Blocklist *bool `json:"blocklist,omitempty"` 73 BlockEmailSubaddresses *bool `json:"block_email_subaddresses,omitempty"` 74 BlockDisposableEmailDomains *bool `json:"block_disposable_email_domains,omitempty"` 75 IgnoreDotsForGmailAddresses *bool `json:"ignore_dots_for_gmail_addresses,omitempty"` 76 } 77 78 func (s *InstanceService) UpdateRestrictions(params UpdateRestrictionsParams) (*InstanceRestrictionsResponse, error) { 79 req, _ := s.client.NewRequest(http.MethodPatch, "instance/restrictions", ¶ms) 80 81 var instanceRestrictionsResponse InstanceRestrictionsResponse 82 _, err := s.client.Do(req, &instanceRestrictionsResponse) 83 if err != nil { 84 return nil, err 85 } 86 return &instanceRestrictionsResponse, nil 87 } 88 89 type OrganizationSettingsResponse struct { 90 Object string `json:"object"` 91 Enabled bool `json:"enabled"` 92 MaxAllowedMemberships int `json:"max_allowed_memberships"` 93 MaxAllowedRoles int `json:"max_allowed_roles"` 94 MaxAllowedPermissions int `json:"max_allowed_permissions"` 95 CreatorRole string `json:"creator_role"` 96 AdminDeleteEnabled bool `json:"admin_delete_enabled"` 97 DomainsEnabled bool `json:"domains_enabled"` 98 DomainsEnrollmentModes []string `json:"domains_enrollment_modes"` 99 DomainsDefaultRole string `json:"domains_default_role"` 100 } 101 102 type UpdateOrganizationSettingsParams struct { 103 Enabled *bool `json:"enabled,omitempty"` 104 MaxAllowedMemberships *int `json:"max_allowed_memberships,omitempty"` 105 CreatorRoleID *string `json:"creator_role_id,omitempty"` 106 AdminDeleteEnabled *bool `json:"admin_delete_enabled,omitempty"` 107 DomainsEnabled *bool `json:"domains_enabled,omitempty"` 108 DomainsEnrollmentModes []string `json:"domains_enrollment_modes,omitempty"` 109 DomainsDefaultRoleID *string `json:"domains_default_role_id,omitempty"` 110 } 111 112 func (s *InstanceService) UpdateOrganizationSettings(params UpdateOrganizationSettingsParams) (*OrganizationSettingsResponse, error) { 113 req, _ := s.client.NewRequest(http.MethodPatch, "instance/organization_settings", ¶ms) 114 115 var organizationSettingsResponse OrganizationSettingsResponse 116 _, err := s.client.Do(req, &organizationSettingsResponse) 117 if err != nil { 118 return nil, err 119 } 120 return &organizationSettingsResponse, nil 121 } 122 123 type UpdateHomeURLParams struct { 124 HomeURL string `json:"home_url"` 125 } 126 127 func (s *InstanceService) UpdateHomeURL(params UpdateHomeURLParams) error { 128 req, _ := s.client.NewRequest(http.MethodPost, "instance/change_domain", ¶ms) 129 130 _, err := s.client.Do(req, nil) 131 if err != nil { 132 return err 133 } 134 return nil 135 }