github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/command/v7/update_space_quota_command.go (about) 1 package v7 2 3 import ( 4 "code.cloudfoundry.org/cli/actor/v7action" 5 "code.cloudfoundry.org/cli/command/flag" 6 "code.cloudfoundry.org/cli/command/translatableerror" 7 ) 8 9 type UpdateSpaceQuotaCommand struct { 10 BaseCommand 11 12 RequiredArgs flag.SpaceQuota `positional-args:"Yes"` 13 NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. -1 represents an unlimited amount."` 14 PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans."` 15 NoPaidServicePlans bool `long:"disallow-paid-service-plans" description:"Disallow provisioning instances of paid service plans."` 16 PerProcessMemory flag.MegabytesWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` 17 TotalMemory flag.MegabytesWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` 18 NewName string `short:"n" description:"New name"` 19 TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount."` 20 TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount."` 21 TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount."` 22 TotalLogVolume flag.BytesWithUnlimited `short:"l" description:"Total log volume per second all processes can have, in bytes (e.g. 128B, 4K, 1M). -1 represents an unlimited amount."` 23 24 usage interface{} `usage:"CF_NAME update-space-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS] [-l LOG_VOLUME]"` 25 relatedCommands interface{} `related_commands:"space, space-quota, space-quotas"` 26 } 27 28 func (cmd UpdateSpaceQuotaCommand) Execute(args []string) error { 29 if cmd.PaidServicePlans && cmd.NoPaidServicePlans { 30 return translatableerror.ArgumentCombinationError{ 31 Args: []string{"--allow-paid-service-plans", "--disallow-paid-service-plans"}, 32 } 33 } 34 35 err := cmd.SharedActor.CheckTarget(true, false) 36 if err != nil { 37 return err 38 } 39 40 user, err := cmd.Actor.GetCurrentUser() 41 if err != nil { 42 return err 43 } 44 45 oldQuotaName := cmd.RequiredArgs.SpaceQuota 46 orgGUID := cmd.Config.TargetedOrganization().GUID 47 48 cmd.UI.DisplayTextWithFlavor("Updating space quota {{.QuotaName}} for org {{.OrgName}} as {{.User}}...", 49 map[string]interface{}{ 50 "QuotaName": oldQuotaName, 51 "OrgName": cmd.Config.TargetedOrganizationName(), 52 "User": user.Name, 53 }) 54 55 var paidServicesAllowed *bool 56 if cmd.PaidServicePlans || cmd.NoPaidServicePlans { 57 paidServicesAllowed = &cmd.PaidServicePlans 58 } 59 60 updatedQuotaLimits := v7action.QuotaLimits{ 61 TotalMemoryInMB: convertMegabytesFlagToNullInt(cmd.TotalMemory), 62 PerProcessMemoryInMB: convertMegabytesFlagToNullInt(cmd.PerProcessMemory), 63 TotalInstances: convertIntegerLimitFlagToNullInt(cmd.NumAppInstances), 64 PaidServicesAllowed: paidServicesAllowed, 65 TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances), 66 TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes), 67 TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts), 68 TotalLogVolume: convertBytesFlagToNullInt(cmd.TotalLogVolume), 69 } 70 71 warnings, err := cmd.Actor.UpdateSpaceQuota(oldQuotaName, orgGUID, cmd.NewName, updatedQuotaLimits) 72 cmd.UI.DisplayWarnings(warnings) 73 if err != nil { 74 return err 75 } 76 77 cmd.UI.DisplayOK() 78 79 return nil 80 }