github.com/arunkumar7540/cli@v6.45.0+incompatible/actor/v2action/composite/update_service_instance.go (about)

     1  package composite
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/actor/v2action"
     5  )
     6  
     7  //go:generate counterfeiter . GetServiceInstanceActor
     8  
     9  type GetServiceInstanceActor interface {
    10  	GetServiceInstanceByNameAndSpace(name string, spaceGUID string) (v2action.ServiceInstance, v2action.Warnings, error)
    11  }
    12  
    13  //go:generate counterfeiter . GetServicePlanActor
    14  
    15  type GetServicePlanActor interface {
    16  	GetServicePlan(servicePlanGUID string) (v2action.ServicePlan, v2action.Warnings, error)
    17  }
    18  
    19  //go:generate counterfeiter . UpdateServiceInstanceMaintenanceInfoActor
    20  
    21  type UpdateServiceInstanceMaintenanceInfoActor interface {
    22  	UpdateServiceInstanceMaintenanceInfo(serviceInsrtanceGUID string, maintenanceInfo v2action.MaintenanceInfo) (v2action.Warnings, error)
    23  }
    24  
    25  type UpdateServiceInstanceCompositeActor struct {
    26  	GetServiceInstanceActor                   GetServiceInstanceActor
    27  	GetServicePlanActor                       GetServicePlanActor
    28  	UpdateServiceInstanceMaintenanceInfoActor UpdateServiceInstanceMaintenanceInfoActor
    29  }
    30  
    31  // UpgradeServiceInstance requests update on the service instance with the `maintenance_info` available on the plan
    32  func (c UpdateServiceInstanceCompositeActor) UpgradeServiceInstance(serviceInstanceGUID, servicePlanGUID string) (v2action.Warnings, error) {
    33  	servicePlan, warnings, err := c.GetServicePlanActor.GetServicePlan(servicePlanGUID)
    34  	if err != nil {
    35  		return warnings, err
    36  	}
    37  	updateWarnings, err := c.UpdateServiceInstanceMaintenanceInfoActor.UpdateServiceInstanceMaintenanceInfo(
    38  		serviceInstanceGUID,
    39  		v2action.MaintenanceInfo(servicePlan.MaintenanceInfo),
    40  	)
    41  	return append(warnings, updateWarnings...), err
    42  }
    43  
    44  // GetServiceInstanceByNameAndSpace gets the service instance by name and space guid provided
    45  func (c UpdateServiceInstanceCompositeActor) GetServiceInstanceByNameAndSpace(name string, spaceGUID string) (v2action.ServiceInstance, v2action.Warnings, error) {
    46  	return c.GetServiceInstanceActor.GetServiceInstanceByNameAndSpace(name, spaceGUID)
    47  }