Skip to content

Commit

Permalink
PLT-1470: Added support for get role with name. (#138)
Browse files Browse the repository at this point in the history
* PLT-1470: Added support for get team with name.
  • Loading branch information
SivaanandM authored Nov 6, 2024
1 parent 9d183cf commit 76d563f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions client/team.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package client

import (
"errors"

clientv1 "github.com/spectrocloud/palette-sdk-go/api/client/v1"
"github.com/spectrocloud/palette-sdk-go/api/models"
)
Expand Down Expand Up @@ -42,6 +44,25 @@ func (h *V1Client) GetTeam(uid string) (*models.V1Team, error) {
return resp.Payload, nil
}

// GetTeamWithName retrieves an existing team by Team name.
func (h *V1Client) GetTeamWithName(teamName string) (*models.V1Team, error) {
// ACL scoped to tenant only
nameFilter := "metadata.name=" + teamName
params := clientv1.NewV1TeamsListParams().WithFilters(&nameFilter)
resp, err := h.Client.V1TeamsList(params)
if err != nil {
return nil, err
}
if resp.Payload.Items != nil {
if len(resp.Payload.Items) == 1 {
return resp.Payload.Items[0], nil
}
return nil, errors.New("More than one team found name: " + teamName)
}
return nil, errors.New("Team not found for name: " + teamName)

}

// DeleteTeam deletes an existing team by UID.
func (h *V1Client) DeleteTeam(uid string) error {
// ACL scoped to tenant only
Expand Down

0 comments on commit 76d563f

Please sign in to comment.