github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/resources/routes.go (about) 1 package resources 2 3 import "code.cloudfoundry.org/cli/cf/models" 4 5 type RouteResource struct { 6 Resource 7 Entity RouteEntity 8 } 9 10 type RouteEntity struct { 11 Host string `json:"host"` 12 Domain DomainResource `json:"domain"` 13 Path string `json:"path"` 14 Port int `json:"port"` 15 Space SpaceResource `json:"space"` 16 Apps []ApplicationResource `json:"apps"` 17 ServiceInstance ServiceInstanceResource `json:"service_instance"` 18 } 19 20 func (resource RouteResource) ToFields() (fields models.Route) { 21 fields.GUID = resource.Metadata.GUID 22 fields.Host = resource.Entity.Host 23 return 24 } 25 26 func (resource RouteResource) ToModel() (route models.Route) { 27 route.Host = resource.Entity.Host 28 route.Path = resource.Entity.Path 29 route.Port = resource.Entity.Port 30 route.GUID = resource.Metadata.GUID 31 route.Domain = resource.Entity.Domain.ToFields() 32 route.Space = resource.Entity.Space.ToFields() 33 route.ServiceInstance = resource.Entity.ServiceInstance.ToFields() 34 for _, appResource := range resource.Entity.Apps { 35 route.Apps = append(route.Apps, appResource.ToFields()) 36 } 37 return 38 }