Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: go var names #116

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions internal/sdk/cloudian/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ func NewClient(baseURL string, authHeader string, opts ...func(*Client)) *Client
}

// List all users of a group.
func (client Client) ListUsers(ctx context.Context, groupId string, offsetUserId *string) ([]User, error) {
func (client Client) ListUsers(ctx context.Context, groupID string, userID *string) ([]User, error) {
params := map[string]string{
"groupId": groupId,
"groupId": groupID,
"userType": "all",
"userStatus": "all",
"limit": strconv.Itoa(ListLimit),
}
if offsetUserId != nil {
params["offset"] = *offsetUserId
if userID != nil {
params["offset"] = *userID
}

var users []User
Expand All @@ -157,7 +157,7 @@ func (client Client) ListUsers(ctx context.Context, groupId string, offsetUserId
// Paginated API endpoint where limit+1 elements indicates more pages
if len(users) > ListLimit {
// Fetch remaining users starting from the user after the limit
moreUsers, err := client.ListUsers(ctx, groupId, &users[ListLimit].UserID)
moreUsers, err := client.ListUsers(ctx, groupID, &users[ListLimit].UserID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -290,8 +290,8 @@ func (client Client) DeleteUserCredentials(ctx context.Context, accessKey string
}

// Delete a group and all its members.
func (client Client) DeleteGroupRecursive(ctx context.Context, groupId string) error {
users, err := client.ListUsers(ctx, groupId, nil)
func (client Client) DeleteGroupRecursive(ctx context.Context, groupID string) error {
users, err := client.ListUsers(ctx, groupID, nil)
if err != nil {
return fmt.Errorf("error listing users: %w", err)
}
Expand All @@ -302,13 +302,13 @@ func (client Client) DeleteGroupRecursive(ctx context.Context, groupId string) e
}
}

return client.DeleteGroup(ctx, groupId)
return client.DeleteGroup(ctx, groupID)
}

// Deletes a group if it is without members.
func (client Client) DeleteGroup(ctx context.Context, groupId string) error {
func (client Client) DeleteGroup(ctx context.Context, groupID string) error {
resp, err := client.newRequest(ctx).
SetQueryParams(map[string]string{"groupId": groupId}).
SetQueryParams(map[string]string{"groupId": groupID}).
Delete("/group")
if err != nil {
return err
Expand Down Expand Up @@ -358,10 +358,10 @@ func (client Client) UpdateGroup(ctx context.Context, group Group) error {

// Get a group. Returns an error even in the case of a group not found.
// This error can then be checked against ErrNotFound: errors.Is(err, ErrNotFound)
func (client Client) GetGroup(ctx context.Context, groupId string) (*Group, error) {
func (client Client) GetGroup(ctx context.Context, groupID string) (*Group, error) {
var group groupInternal
resp, err := client.newRequest(ctx).
SetQueryParams(map[string]string{"groupId": groupId}).
SetQueryParams(map[string]string{"groupId": groupID}).
SetResult(&group).
Get("/group")
if err != nil {
Expand Down
Loading