com.synedge.oss.client.origin.JerseyOriginClient.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of synedge-java-client Show documentation
Show all versions of synedge-java-client Show documentation
This client allows you to easily connect to the Synedge API with any language running on the JDK
The newest version!
package com.synedge.oss.client.origin
import com.synedge.oss.client.OriginClient
import com.synedge.oss.client.SynedgeClient
import com.synedge.oss.client.authentication.AuthenticatedClient
import groovy.transform.PackageScope
class JerseyOriginClient extends AuthenticatedClient implements OriginClient {
@PackageScope
JerseyOriginClient(String username, String password, String endpoint = SynedgeClient.DEFAULT_ENDPOINT) {
super(username, password, endpoint)
}
@Override
Collection getOrigins(String customerId) {
def responseJson = signAndGet(client.target(endpoint).path(customerId).path('origins').request())
responseJson.collect { it -> createOrigin(it)}
}
@Override
Origin getOrigin(String customerId, String originId) {
def responseJson = signAndGet(client.target(endpoint).path(customerId).path('origins').path(originId).request())
createOrigin(responseJson)
}
private Origin createOrigin(def originJson) {
Host primaryHost = new Host(originJson.primaryHost.hostname, originJson.primaryHost.port, originJson.primaryHost.path)
Host secondaryHost = null
if (originJson.secondaryHost != null) {
secondaryHost = new Host(originJson.secondaryHost.hostname, originJson.secondaryHost.port, originJson.secondaryHost.path)
}
new Origin(originJson.id, originJson.name, primaryHost, secondaryHost);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy