* When service setting flag is on, self hosted workspaces can initiate process for self-serve sign up
* Add hosted_customer api.
Этот коммит содержится в:
Nathaniel Allred
2022-11-29 13:32:08 -06:00
коммит произвёл GitHub
родитель 2455de99ff
Коммит 4f3f6e6496
12 изменённых файлов: 249 добавлений и 1 удалений

Просмотреть файл

@@ -326,6 +326,10 @@ func (c *Client4) cloudRoute() string {
return "/cloud"
}
func (c *Client4) hostedCustomerRoute() string {
return "/hosted_customer"
}
func (c *Client4) testEmailRoute() string {
return "/email/test"
}
@@ -8220,6 +8224,23 @@ func (c *Client4) UpdateCloudCustomerAddress(address *Address) (*CloudCustomer,
return customer, BuildResponse(r), nil
}
func (c *Client4) BootstrapSelfHostedSignup(req BootstrapSelfHostedSignupRequest) (*BootstrapSelfHostedSignupResponse, *Response, error) {
reqBytes, err := json.Marshal(req)
if err != nil {
return nil, nil, NewAppError("BootstrapSelfHostedSignup", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
r, err := c.DoAPIPostBytes(c.hostedCustomerRoute()+"/bootstrap", reqBytes)
if err != nil {
return nil, BuildResponse(r), err
}
defer closeBody(r)
var res *BootstrapSelfHostedSignupResponse
json.NewDecoder(r.Body).Decode(&res)
return res, BuildResponse(r), nil
}
func (c *Client4) ListImports() ([]string, *Response, error) {
r, err := c.DoAPIGet(c.importsRoute(), "")
if err != nil {

Просмотреть файл

@@ -274,6 +274,19 @@ type ProductLimits struct {
Teams *TeamsLimits `json:"teams,omitempty"`
}
type BootstrapSelfHostedSignupRequest struct {
Email string `json:"email"`
}
type BootstrapSelfHostedSignupResponse struct {
Progress string `json:"progress"`
}
type BootstrapSelfHostedSignupResponseInternal struct {
Progress string `json:"progress"`
License string `json:"license"`
}
func (p *Product) IsYearly() bool {
return p.RecurringInterval == RecurringIntervalYearly
}

Просмотреть файл

@@ -383,6 +383,7 @@ type ServiceSettings struct {
CollapsedThreads *string `access:"experimental_features"`
ManagedResourcePaths *string `access:"environment_web_server,write_restrictable,cloud_restrictable"`
EnableCustomGroups *bool `access:"site_users_and_teams"`
SelfHostedFirstTimePurchase *bool `access:"write_restrictable,cloud_restrictable"`
AllowSyncedDrafts *bool `access:"site_posts"`
}
@@ -852,6 +853,10 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
if s.AllowSyncedDrafts == nil {
s.AllowSyncedDrafts = NewBool(true)
}
if s.SelfHostedFirstTimePurchase == nil {
s.SelfHostedFirstTimePurchase = NewBool(false)
}
}
type ClusterSettings struct {

Просмотреть файл

@@ -56,6 +56,7 @@ type License struct {
SkuShortName string `json:"sku_short_name"`
IsTrial bool `json:"is_trial"`
IsGovSku bool `json:"is_gov_sku"`
SignupJWT *string `json:"signup_jwt"`
}
type Customer struct {

Просмотреть файл

@@ -158,6 +158,11 @@ func TestIsCloud(t *testing.T) {
l1.Features = nil
assert.False(t, l1.IsCloud())
t.Run("false if license is nil", func(t *testing.T) {
var license *License
assert.False(t, license.IsCloud())
})
}
func TestLicenseRecordIsValid(t *testing.T) {