github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/actor/v2action/application_instance.go (about) 1 package v2action 2 3 import ( 4 "code.cloudfoundry.org/cli/actor/actionerror" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" 6 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2" 7 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2/constant" 8 ) 9 10 type ApplicationInstanceState constant.ApplicationInstanceState 11 12 type ApplicationInstance ccv2.ApplicationInstance 13 14 func (instance ApplicationInstance) Crashed() bool { 15 return instance.State == constant.ApplicationInstanceCrashed 16 } 17 18 func (instance ApplicationInstance) Flapping() bool { 19 return instance.State == constant.ApplicationInstanceFlapping 20 } 21 22 func (instance ApplicationInstance) Running() bool { 23 return instance.State == constant.ApplicationInstanceRunning 24 } 25 26 func (actor Actor) GetApplicationInstancesByApplication(guid string) (map[int]ApplicationInstance, Warnings, error) { 27 ccAppInstances, warnings, err := actor.CloudControllerClient.GetApplicationApplicationInstances(guid) 28 29 switch err.(type) { 30 case ccerror.ResourceNotFoundError, ccerror.NotStagedError, ccerror.InstancesError: 31 return nil, Warnings(warnings), actionerror.ApplicationInstancesNotFoundError{ApplicationGUID: guid} 32 } 33 34 appInstances := map[int]ApplicationInstance{} 35 36 for id, applicationInstance := range ccAppInstances { 37 appInstances[id] = ApplicationInstance(applicationInstance) 38 } 39 40 return appInstances, Warnings(warnings), err 41 }