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

@@ -27,7 +27,7 @@ type roleAssignmentData struct {
// AssignRole assigns the provided member ID to the given role ID.
func (c *client) AssignRole(ctx context.Context, roleID gidx.PrefixedID, memberID gidx.PrefixedID) error {
path := fmt.Sprintf("/api/v1/roles/%s/assignments", roleID.String())
path := fmt.Sprintf(permsPathRoleAssignmentsFormat, roleID.String())
body, err := encodeJSON(RoleAssign{
SubjectID: memberID.String(),
@@ -51,7 +51,7 @@ func (c *client) AssignRole(ctx context.Context, roleID gidx.PrefixedID, memberI
// UnassignRole removes the provided member ID from the given role ID.
func (c *client) UnassignRole(ctx context.Context, roleID gidx.PrefixedID, memberID gidx.PrefixedID) error {
path := fmt.Sprintf("/api/v1/roles/%s/assignments", roleID.String())
path := fmt.Sprintf(permsPathRoleAssignmentsFormat, roleID.String())
body, err := encodeJSON(RoleAssign{
SubjectID: memberID.String(),
@@ -75,7 +75,7 @@ func (c *client) UnassignRole(ctx context.Context, roleID gidx.PrefixedID, membe
// ListRoleAssignments lists all assignments for the given role.
func (c *client) ListRoleAssignments(ctx context.Context, roleID gidx.PrefixedID) ([]gidx.PrefixedID, error) {
path := fmt.Sprintf("/api/v1/roles/%s/assignments", roleID.String())
path := fmt.Sprintf(permsPathRoleAssignmentsFormat, roleID.String())
var response roleAssignmentData