com.swisscom.cloud.sb.broker.cfextensions.endpoint.EndpointLookup.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of broker Show documentation
Show all versions of broker Show documentation
Swisscom's Open Service Broker API implementation
package com.swisscom.cloud.sb.broker.cfextensions.endpoint
import com.swisscom.cloud.sb.broker.model.ServiceInstance
import com.swisscom.cloud.sb.broker.util.servicedetail.ServiceDetailType
import com.swisscom.cloud.sb.broker.util.servicedetail.ServiceDetailsHelper
import com.swisscom.cloud.sb.model.endpoint.Endpoint
import groovy.transform.CompileStatic
import org.springframework.stereotype.Component
@Component
@CompileStatic
class EndpointLookup {
public static final Collection DEFAULT_PROTOCOLS = Collections.unmodifiableCollection(["tcp"])
Collection findEndpoints(ServiceInstance serviceInstance, EndpointConfig config) {
def result = new LinkedList()
def portsForServiceInstance = ServiceDetailsHelper.from(serviceInstance).findAllWithServiceDetailType(ServiceDetailType.PORT)
if (config.protocols.size() == 0){
config.protocols.addAll(DEFAULT_PROTOCOLS)
}
config.protocols.each { String protocol ->
config.ipRanges.each { String ipRange ->
portsForServiceInstance.each { String port ->
result.add(new Endpoint(protocol: protocol, ports: port, destination: ipRange))
}
}
}
return result
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy