github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/actor/v7action/marketplace.go (about) 1 package v7action 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 5 ) 6 7 type ServiceOfferingWithPlans ccv3.ServiceOfferingWithPlans 8 9 type MarketplaceFilter struct { 10 SpaceGUID, ServiceOfferingName, ServiceBrokerName string 11 } 12 13 func (actor Actor) Marketplace(filter MarketplaceFilter) ([]ServiceOfferingWithPlans, Warnings, error) { 14 var query []ccv3.Query 15 16 if filter.SpaceGUID != "" { 17 query = append(query, ccv3.Query{ 18 Key: ccv3.SpaceGUIDFilter, 19 Values: []string{filter.SpaceGUID}, 20 }) 21 } 22 23 if filter.ServiceOfferingName != "" { 24 query = append(query, ccv3.Query{ 25 Key: ccv3.ServiceOfferingNamesFilter, 26 Values: []string{filter.ServiceOfferingName}, 27 }) 28 } 29 30 if filter.ServiceBrokerName != "" { 31 query = append(query, ccv3.Query{ 32 Key: ccv3.ServiceBrokerNamesFilter, 33 Values: []string{filter.ServiceBrokerName}, 34 }) 35 } 36 37 serviceOffering, warnings, err := actor.CloudControllerClient.GetServicePlansWithOfferings(query...) 38 if err != nil { 39 return nil, Warnings(warnings), err 40 } 41 42 result := make([]ServiceOfferingWithPlans, len(serviceOffering)) 43 for i := range serviceOffering { 44 result[i] = ServiceOfferingWithPlans(serviceOffering[i]) 45 } 46 47 return result, Warnings(warnings), nil 48 }