Add cws availability check.
Этот коммит содержится в:
@@ -52,6 +52,9 @@ func (api *API) InitCloud() {
|
|||||||
|
|
||||||
// POST /api/v4/cloud/webhook
|
// POST /api/v4/cloud/webhook
|
||||||
api.BaseRoutes.Cloud.Handle("/webhook", api.CloudAPIKeyRequired(handleCWSWebhook)).Methods("POST")
|
api.BaseRoutes.Cloud.Handle("/webhook", api.CloudAPIKeyRequired(handleCWSWebhook)).Methods("POST")
|
||||||
|
|
||||||
|
// GET /api/v4/cloud/cws-health-check
|
||||||
|
api.BaseRoutes.Cloud.Handle("/check-cws-connection", api.APIHandler(handleCheckCWSConnection)).Methods("GET")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -746,3 +749,12 @@ func handleCWSWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
ReturnStatusOK(w)
|
ReturnStatusOK(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleCheckCWSConnection(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
if err := c.App.Cloud().CheckCWSConnection(); err != nil {
|
||||||
|
c.Err = model.NewAppError("Api4.handleCWSHealthCheck", "api.server.cws.health_check.app_error", nil, "CWS Server is not available.", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnStatusOK(w)
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,4 +45,6 @@ type CloudInterface interface {
|
|||||||
|
|
||||||
CreateOrUpdateSubscriptionHistoryEvent(userID string, userCount int) (*model.SubscriptionHistory, error)
|
CreateOrUpdateSubscriptionHistoryEvent(userID string, userCount int) (*model.SubscriptionHistory, error)
|
||||||
HandleLicenseChange() error
|
HandleLicenseChange() error
|
||||||
|
|
||||||
|
CheckCWSConnection() error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,20 @@ func (_m *CloudInterface) ChangeSubscription(userID string, subscriptionID strin
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckCWSConnection provides a mock function with given fields:
|
||||||
|
func (_m *CloudInterface) CheckCWSConnection() error {
|
||||||
|
ret := _m.Called()
|
||||||
|
|
||||||
|
var r0 error
|
||||||
|
if rf, ok := ret.Get(0).(func() error); ok {
|
||||||
|
r0 = rf()
|
||||||
|
} else {
|
||||||
|
r0 = ret.Error(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0
|
||||||
|
}
|
||||||
|
|
||||||
// ConfirmCustomerPayment provides a mock function with given fields: userID, confirmRequest
|
// ConfirmCustomerPayment provides a mock function with given fields: userID, confirmRequest
|
||||||
func (_m *CloudInterface) ConfirmCustomerPayment(userID string, confirmRequest *model.ConfirmPaymentMethodRequest) error {
|
func (_m *CloudInterface) ConfirmCustomerPayment(userID string, confirmRequest *model.ConfirmPaymentMethodRequest) error {
|
||||||
ret := _m.Called(userID, confirmRequest)
|
ret := _m.Called(userID, confirmRequest)
|
||||||
|
|||||||
@@ -2575,6 +2575,10 @@
|
|||||||
"id": "api.scheme.patch_scheme.license.error",
|
"id": "api.scheme.patch_scheme.license.error",
|
||||||
"translation": "Your license does not support update permissions schemes"
|
"translation": "Your license does not support update permissions schemes"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.server.cws.health_check.app_error",
|
||||||
|
"translation": "CWS Server is not available."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.server.hosted_signup_unavailable.error",
|
"id": "api.server.hosted_signup_unavailable.error",
|
||||||
"translation": "Portal unavailable for self-hosted signup."
|
"translation": "Portal unavailable for self-hosted signup."
|
||||||
|
|||||||
@@ -8700,6 +8700,17 @@ func (c *Client4) AddUserToGroupSyncables(userID string) (*Response, error) {
|
|||||||
return BuildResponse(r), nil
|
return BuildResponse(r), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client4) CheckCWSConnection() (*Response, error) {
|
||||||
|
r, err := c.DoAPIGet(c.cloudRoute()+"/healthz", "")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return BuildResponse(r), err
|
||||||
|
}
|
||||||
|
defer closeBody(r)
|
||||||
|
|
||||||
|
return BuildResponse(r), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Worktemplates sections
|
// Worktemplates sections
|
||||||
|
|
||||||
func (c *Client4) worktemplatesRoute() string {
|
func (c *Client4) worktemplatesRoute() string {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user