diff --git a/magefile.go b/magefile.go index fd4fe088f87..625adb3aaa6 100644 --- a/magefile.go +++ b/magefile.go @@ -3065,12 +3065,12 @@ func authESS(ctx context.Context) error { // Attempt to use API key to check if it's valid for authSuccess := false; !authSuccess; { client := ess.NewClient(ess.Config{ApiKey: essAPIKey}) - u, err := client.GetUser(ctx, ess.GetUserRequest{}) + u, err := client.GetAccount(ctx, ess.GetAccountRequest{}) if err != nil { return fmt.Errorf("unable to successfully connect to ESS API: %w", err) } - if u.User.UserID != 0 { + if u.ID != "" { // We have a user. It indicates that the API key works. All set! authSuccess = true continue @@ -3079,7 +3079,7 @@ func authESS(ctx context.Context) error { fmt.Fprintln(os.Stderr, "❌ ESS authentication unsuccessful. Retrying...") prompt := fmt.Sprintf("Please provide a ESS API key for %s. To get your API key, "+ - "visit %s/deployment-features/keys:", client.BaseURL(), strings.TrimRight(client.BaseURL(), "/api/v1")) + "visit %s/account/keys:", client.BaseURL(), strings.TrimRight(client.BaseURL(), "/api/v1")) essAPIKey, err = stringPrompt(prompt) if err != nil { return fmt.Errorf("unable to read ESS API key from prompt: %w", err) diff --git a/pkg/testing/ess/users.go b/pkg/testing/ess/users.go index 3b04888ddd0..b9803b3b527 100644 --- a/pkg/testing/ess/users.go +++ b/pkg/testing/ess/users.go @@ -10,25 +10,23 @@ import ( "fmt" ) -type GetUserRequest struct { +type GetAccountRequest struct { // For future use } -type GetUserResponse struct { - User struct { - UserID int `json:"user_id"` - } `json:"user"` +type GetAccountResponse struct { + ID string `json:"id"` } -// GetUser returns information about the authenticated user -func (c *Client) GetUser(ctx context.Context, req GetUserRequest) (*GetUserResponse, error) { - resp, err := c.doGet(ctx, "users") +// GetAccount returns information about the authenticated user +func (c *Client) GetAccount(ctx context.Context, req GetAccountRequest) (*GetAccountResponse, error) { + resp, err := c.doGet(ctx, "account") if err != nil { return nil, fmt.Errorf("error calling get user API: %w", err) } defer resp.Body.Close() - var respBody GetUserResponse + var respBody GetAccountResponse if err := json.NewDecoder(resp.Body).Decode(&respBody); err != nil { return nil, fmt.Errorf("error parsing get user response: %w", err) }