Fix AP group access on API proxy
This commit is contained in:
@@ -28,7 +28,7 @@ type APGroup struct {
|
|||||||
func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error) {
|
func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error) {
|
||||||
var respBody []APGroup
|
var respBody []APGroup
|
||||||
|
|
||||||
err := c.do(ctx, "GET", fmt.Sprintf("/v2/api/site/%s/apgroups", site), nil, &respBody)
|
err := c.do(ctx, "GET", fmt.Sprintf("%s/site/%s/apgroups", c.apiV2Path, site), nil, &respBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error
|
|||||||
func (c *Client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*APGroup, error) {
|
func (c *Client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*APGroup, error) {
|
||||||
var respBody APGroup
|
var respBody APGroup
|
||||||
|
|
||||||
err := c.do(ctx, "POST", fmt.Sprintf("/v2/api/site/%s/apgroups", site), d, &respBody)
|
err := c.do(ctx, "POST", fmt.Sprintf("%s/site/%s/apgroups", c.apiV2Path, site), d, &respBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
apiPath = "/api"
|
apiPath = "/api"
|
||||||
apiPathNew = "/proxy/network/api"
|
apiV2Path = "/v2/api"
|
||||||
|
|
||||||
|
apiPathNew = "/proxy/network/api"
|
||||||
|
apiV2PathNew = "/proxy/network/v2/api"
|
||||||
|
|
||||||
loginPath = "/api/login"
|
loginPath = "/api/login"
|
||||||
loginPathNew = "/api/auth/login"
|
loginPathNew = "/api/auth/login"
|
||||||
@@ -49,6 +52,7 @@ type Client struct {
|
|||||||
baseURL *url.URL
|
baseURL *url.URL
|
||||||
|
|
||||||
apiPath string
|
apiPath string
|
||||||
|
apiV2Path string
|
||||||
loginPath string
|
loginPath string
|
||||||
statusPath string
|
statusPath string
|
||||||
|
|
||||||
@@ -115,6 +119,7 @@ func (c *Client) setAPIUrlStyle(ctx context.Context) error {
|
|||||||
if resp.StatusCode == http.StatusOK {
|
if resp.StatusCode == http.StatusOK {
|
||||||
// the new API returns a 200 for a / request
|
// the new API returns a 200 for a / request
|
||||||
c.apiPath = apiPathNew
|
c.apiPath = apiPathNew
|
||||||
|
c.apiV2Path = apiV2PathNew
|
||||||
c.loginPath = loginPathNew
|
c.loginPath = loginPathNew
|
||||||
c.statusPath = statusPathNew
|
c.statusPath = statusPathNew
|
||||||
return nil
|
return nil
|
||||||
@@ -122,6 +127,7 @@ func (c *Client) setAPIUrlStyle(ctx context.Context) error {
|
|||||||
|
|
||||||
// The old version returns a "302" (to /manage) for a / request
|
// The old version returns a "302" (to /manage) for a / request
|
||||||
c.apiPath = apiPath
|
c.apiPath = apiPath
|
||||||
|
c.apiV2Path = apiV2Path
|
||||||
c.loginPath = loginPath
|
c.loginPath = loginPath
|
||||||
c.statusPath = statusPath
|
c.statusPath = statusPath
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user