func (resource ServiceInstancesSummaries) ToModels() (instances []models.ServiceInstance) { for _, instanceSummary := range resource.ServiceInstances { applicationNames := resource.findApplicationNamesForInstance(instanceSummary.Name) planSummary := instanceSummary.ServicePlan servicePlan := models.ServicePlanFields{} servicePlan.Name = planSummary.Name servicePlan.GUID = planSummary.GUID offeringSummary := planSummary.ServiceOffering serviceOffering := models.ServiceOfferingFields{} serviceOffering.Label = offeringSummary.Label serviceOffering.Provider = offeringSummary.Provider serviceOffering.Version = offeringSummary.Version instance := models.ServiceInstance{} instance.Name = instanceSummary.Name instance.LastOperation.Type = instanceSummary.LastOperation.Type instance.LastOperation.State = instanceSummary.LastOperation.State instance.LastOperation.Description = instanceSummary.LastOperation.Description instance.ApplicationNames = applicationNames instance.ServicePlan = servicePlan instance.ServiceOffering = serviceOffering instances = append(instances, instance) } return }
} plan2 := models.ServicePlanFields{ Guid: "spark-guid-2", Name: "spark-2", } offering := models.ServiceOfferingFields{Label: "cleardb"} serviceInstance := models.ServiceInstance{} serviceInstance.Name = "my-service-1" serviceInstance.LastOperation.Type = "create" serviceInstance.LastOperation.State = "in progress" serviceInstance.LastOperation.Description = "fake state description" serviceInstance.ServicePlan = plan serviceInstance.ApplicationNames = []string{"cli1", "cli2"} serviceInstance.ServiceOffering = offering serviceInstance2 := models.ServiceInstance{} serviceInstance2.Name = "my-service-2" serviceInstance2.LastOperation.Type = "create" serviceInstance2.LastOperation.State = "" serviceInstance2.LastOperation.Description = "fake state description" serviceInstance2.ServicePlan = plan2 serviceInstance2.ApplicationNames = []string{"cli1"} serviceInstance2.ServiceOffering = offering userProvidedServiceInstance := models.ServiceInstance{} userProvidedServiceInstance.Name = "my-service-provided-by-user" serviceInstances := []models.ServiceInstance{serviceInstance, serviceInstance2, userProvidedServiceInstance}