github.com/sleungcy-sap/cli@v7.1.0+incompatible/command/v7/disable_service_access_command.go (about) 1 package v7 2 3 import ( 4 "code.cloudfoundry.org/cli/command/flag" 5 ) 6 7 type DisableServiceAccessCommand struct { 8 BaseCommand 9 10 RequiredArgs flag.Service `positional-args:"yes"` 11 ServiceBroker string `short:"b" description:"Disable access to a service offering from a particular service broker. Required when service offering name is ambiguous"` 12 Organization string `short:"o" description:"Disable access for a specified organization"` 13 ServicePlan string `short:"p" description:"Disable access to a specified service plan"` 14 usage interface{} `usage:"CF_NAME disable-service-access SERVICE [-b BROKER] [-p PLAN] [-o ORG]"` 15 relatedCommands interface{} `related_commands:"enable-service-access, marketplace, service-access, service-brokers"` 16 } 17 18 func (cmd DisableServiceAccessCommand) Execute(args []string) error { 19 if err := cmd.SharedActor.CheckTarget(false, false); err != nil { 20 return err 21 } 22 23 if err := cmd.displayMessage(); err != nil { 24 return err 25 } 26 27 skipped, warnings, err := cmd.Actor.DisableServiceAccess(cmd.RequiredArgs.ServiceOffering, cmd.ServiceBroker, cmd.Organization, cmd.ServicePlan) 28 cmd.UI.DisplayWarnings(warnings) 29 if err != nil { 30 return err 31 } 32 33 displaySkippedPlans(cmd.UI, "none", skipped) 34 35 cmd.UI.DisplayOK() 36 37 return nil 38 } 39 40 func (cmd DisableServiceAccessCommand) displayMessage() error { 41 user, err := cmd.Config.CurrentUser() 42 if err != nil { 43 return err 44 } 45 46 setServiceAccessMessage{ 47 Operation: "Disabling", 48 ServiceOffering: cmd.RequiredArgs.ServiceOffering, 49 ServicePlan: cmd.ServicePlan, 50 Organization: cmd.Organization, 51 ServiceBroker: cmd.ServiceBroker, 52 User: user.Name, 53 }.displayMessage(cmd.UI) 54 55 return nil 56 }