define endpoints as constants

This commit is contained in:
Mike Mason
2023-07-21 18:44:48 +00:00
parent 1bd86d3ec9
commit b421163ae2
4 changed files with 18 additions and 10 deletions

View File

@@ -35,7 +35,7 @@ type ResourceRole struct {
// CreateRole creates a role on the given resource id with the provided actions.
func (c *client) CreateRole(ctx context.Context, resourceID gidx.PrefixedID, actions []string) (gidx.PrefixedID, error) {
path := fmt.Sprintf("/api/v1/resources/%s/roles", resourceID.String())
path := fmt.Sprintf(permsPathResourceRolesFormat, resourceID.String())
body, err := encodeJSON(ResourceRoleCreate{
Actions: actions,
@@ -77,7 +77,7 @@ func (c *client) DeleteRole(ctx context.Context, roleID gidx.PrefixedID) error {
// ListResourceRoles fetches all roles assigned to the provided resource.
func (c *client) ListResourceRoles(ctx context.Context, resourceID gidx.PrefixedID) (ResourceRoles, error) {
path := fmt.Sprintf("/api/v1/resources/%s/roles", resourceID.String())
path := fmt.Sprintf(permsPathResourceRolesFormat, resourceID.String())
var response struct {
Data ResourceRoles `json:"data"`