Add support for 6.0.23

This commit is contained in:
Paul Tyng
2020-10-19 11:13:51 -04:00
parent 020dad41e7
commit abc676f62b
84 changed files with 2131 additions and 252 deletions

View File

@@ -49,12 +49,18 @@ type Client struct {
loginPath string
csrf string
version string
}
func (c *Client) CSRFToken() string {
return c.csrf
}
func (c *Client) Version() string {
return c.version
}
func (c *Client) SetBaseURL(base string) error {
var err error
c.baseURL, err = url.Parse(base)
@@ -128,6 +134,18 @@ func (c *Client) Login(ctx context.Context, user, pass string) error {
return fmt.Errorf("unable to determine API URL style: %w", err)
}
var status struct {
Meta struct {
ServerVersion string `json:"server_version"`
UUID string `json:"uuid"`
} `json:"meta"`
}
err = c.do(ctx, "GET", "/status", nil, &status)
if err != nil {
return err
}
c.version = status.Meta.ServerVersion
err = c.do(ctx, "POST", c.loginPath, &struct {
Username string `json:"username"`
Password string `json:"password"`