Skip to content

Commit

Permalink
Merge branch 'main' into groupqos
Browse files Browse the repository at this point in the history
  • Loading branch information
tenstad authored Jan 31, 2025
2 parents 188fea5 + 764e393 commit 1387c81
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions internal/sdk/cloudian/qos.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"strconv"
)

const DefaultRegion = ""

// QualityOfService configures data limits for a Group or User.
type QualityOfService struct {
// Warning is the soft limit that triggers a warning.
Expand Down Expand Up @@ -104,12 +106,16 @@ func (qos *QualityOfService) queryParams(params map[string]string) error {
// Default user-level QoS for the whole region (GroupID="*", UserID="ALL")
// Group-level QoS for a specific group (GroupID="<groupId>", UserID="*")
// Default group-level QoS for the whole region (GroupID="ALL", UserID="*")
func (client Client) SetQOS(ctx context.Context, user User, qos QualityOfService) error {
func (client Client) SetQOS(ctx context.Context, user User, region string, qos QualityOfService) error {
params := make(map[string]string)
if err := qos.queryParams(params); err != nil {
return err
}

if region != DefaultRegion {
params["region"] = region
}

resp, err := client.newRequest(ctx).
SetQueryParam("userId", user.UserID).
SetQueryParam("groupId", user.GroupID).
Expand All @@ -129,10 +135,16 @@ func (client Client) SetQOS(ctx context.Context, user User, qos QualityOfService

// SetQOS gets QualityOfService limits for a Group or User, depending on the value of GroupID and UserID.
// See SetQOS for details.
func (client Client) GetQOS(ctx context.Context, user User) (*QualityOfService, error) {
func (client Client) GetQOS(ctx context.Context, user User, region string) (*QualityOfService, error) {
params := make(map[string]string)
if region != DefaultRegion {
params["region"] = region
}

resp, err := client.newRequest(ctx).
SetQueryParam("userId", user.UserID).
SetQueryParam("groupId", user.GroupID).
SetQueryParams(params).
Get("/qos/limits")
if err != nil {
return nil, err
Expand Down

0 comments on commit 1387c81

Please sign in to comment.