add variable and method comments
This commit is contained in:
@@ -8,20 +8,24 @@ import (
|
||||
"go.infratographer.com/x/gidx"
|
||||
)
|
||||
|
||||
// RoleAssign is the role assignment request body.
|
||||
type RoleAssign struct {
|
||||
SubjectID string `json:"subject_id"`
|
||||
}
|
||||
|
||||
// RoleAssignResponse is the response from a role assignment.
|
||||
type RoleAssignResponse struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
// roleAssignmentData is the response from listing a role assignment
|
||||
type roleAssignmentData struct {
|
||||
Data []struct {
|
||||
SubjectID string `json:"subject_id"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
// 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())
|
||||
|
||||
@@ -45,6 +49,7 @@ func (c *Client) AssignRole(ctx context.Context, roleID gidx.PrefixedID, memberI
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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())
|
||||
|
||||
@@ -68,6 +73,7 @@ func (c *Client) UnassignRole(ctx context.Context, roleID gidx.PrefixedID, membe
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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())
|
||||
|
||||
@@ -91,6 +97,7 @@ func (c *Client) ListRoleAssignments(ctx context.Context, roleID gidx.PrefixedID
|
||||
return assignments, nil
|
||||
}
|
||||
|
||||
// RoleHasAssignment gets the assignments for the given role and check for the provided member id.
|
||||
func (c *Client) RoleHasAssignment(ctx context.Context, roleID gidx.PrefixedID, memberID gidx.PrefixedID) (bool, error) {
|
||||
assignments, err := c.ListRoleAssignments(ctx, roleID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user