github.com/jfrog/jfrog-cli-core@v1.12.1/artifactory/commands/usersmanagement/groupupdate.go (about) 1 package usersmanagement 2 3 import ( 4 "github.com/jfrog/jfrog-cli-core/artifactory/utils" 5 "github.com/jfrog/jfrog-cli-core/utils/config" 6 "github.com/jfrog/jfrog-client-go/artifactory/services" 7 ) 8 9 type GroupUpdateCommand struct { 10 serverDetails *config.ServerDetails 11 name string 12 users []string 13 } 14 15 func NewGroupUpdateCommand() *GroupUpdateCommand { 16 return &GroupUpdateCommand{} 17 } 18 19 func (guc *GroupUpdateCommand) ServerDetails() (*config.ServerDetails, error) { 20 return guc.serverDetails, nil 21 } 22 23 func (guc *GroupUpdateCommand) SetServerDetails(serverDetails *config.ServerDetails) *GroupUpdateCommand { 24 guc.serverDetails = serverDetails 25 return guc 26 } 27 28 func (guc *GroupUpdateCommand) SetName(groupName string) *GroupUpdateCommand { 29 guc.name = groupName 30 return guc 31 } 32 33 func (guc *GroupUpdateCommand) Name() string { 34 return guc.name 35 } 36 37 func (guc *GroupUpdateCommand) SetUsers(users []string) *GroupUpdateCommand { 38 guc.users = users 39 return guc 40 } 41 42 func (guc *GroupUpdateCommand) Users() []string { 43 return guc.users 44 } 45 46 func (guc *GroupUpdateCommand) CommandName() string { 47 return "rt_group_update" 48 } 49 50 func (guc *GroupUpdateCommand) Run() error { 51 servicesManager, err := utils.CreateServiceManager(guc.serverDetails, -1, false) 52 if err != nil { 53 return err 54 } 55 group := new(services.Group) 56 group.Name = guc.Name() 57 group.UsersNames = guc.Users() 58 params := new(services.GroupParams) 59 params.GroupDetails = *group 60 return servicesManager.UpdateGroup(*params) 61 }