github.com/Thanhphan1147/cloudfoundry-cli@v7.1.0+incompatible/actor/v7action/router_group.go (about) 1 package v7action 2 3 import ( 4 "code.cloudfoundry.org/cli/actor/actionerror" 5 "code.cloudfoundry.org/cli/api/router" 6 "code.cloudfoundry.org/cli/api/router/routererror" 7 ) 8 9 type RouterGroup router.RouterGroup 10 11 func (actor Actor) GetRouterGroups() ([]RouterGroup, error) { 12 var routerGroups []RouterGroup 13 14 apiRouterGroups, err := actor.RoutingClient.GetRouterGroups() 15 if err != nil { 16 return nil, err 17 } 18 19 for _, group := range apiRouterGroups { 20 routerGroups = append(routerGroups, RouterGroup(group)) 21 } 22 23 return routerGroups, err 24 } 25 26 func (actor Actor) GetRouterGroupByName(name string) (RouterGroup, error) { 27 apiRouterGroup, err := actor.RoutingClient.GetRouterGroupByName(name) 28 if err != nil { 29 if _, ok := err.(routererror.ResourceNotFoundError); ok { 30 return RouterGroup{}, actionerror.RouterGroupNotFoundError{Name: name} 31 } 32 33 return RouterGroup{}, err 34 } 35 36 return RouterGroup(apiRouterGroup), nil 37 }