feat: added bootstrap to CLI

This commit is contained in:
Sheen Capadngan
2025-03-18 02:27:42 +08:00
parent 2d1d6f5ce8
commit 64569ab44b
6 changed files with 149 additions and 14 deletions

View File

@@ -600,3 +600,23 @@ func CallGatewayHeartBeatV1(httpClient *resty.Client) error {
return nil
}
func CallBootstrapInstance(httpClient *resty.Client, request BootstrapInstanceRequest) (*BootstrapInstanceResponse, error) {
var resBody BootstrapInstanceResponse
response, err := httpClient.
R().
SetResult(&resBody).
SetHeader("User-Agent", USER_AGENT).
SetBody(request).
Post(fmt.Sprintf("%v/v1/admin/bootstrap", request.Domain))
if err != nil {
return nil, fmt.Errorf("CallBootstrapInstance: Unable to complete api request [err=%w]", err)
}
if response.IsError() {
return nil, fmt.Errorf("CallBootstrapInstance: Unsuccessful response [%v %v] [status-code=%v] [response=%v]", response.Request.Method, response.Request.URL, response.StatusCode(), response.String())
}
return &resBody, nil
}

View File

@@ -654,3 +654,27 @@ type ExchangeRelayCertResponseV1 struct {
Certificate string `json:"certificate"`
CertificateChain string `json:"certificateChain"`
}
type BootstrapInstanceRequest struct {
Email string `json:"email"`
Password string `json:"password"`
Organization string `json:"organization"`
Domain string `json:"domain"`
}
type BootstrapInstanceResponseOrganization struct {
ID string `json:"id"`
Name string `json:"name"`
}
type BootstrapInstanceResponseIdentity struct {
ID string `json:"id"`
Name string `json:"name"`
Credentials interface{} `json:"credentials"`
}
type BootstrapInstanceResponse struct {
Message string `json:"message"`
Organization BootstrapInstanceResponseOrganization `json:"organization"`
Identity BootstrapInstanceResponseIdentity `json:"identity"`
}