Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/main/java/com/ecwid/consul/ConsulException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
*/
public class ConsulException extends RuntimeException {

public ConsulException() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. I request that this be reverted.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No-arg constructor is recovered but I think removing it is more normative.
if not declared parameter-construct java has a no-arg constructor built in it

}

public ConsulException(Throwable cause) {
super(cause);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ecwid/consul/ConsulRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

public interface ConsulRequest {

public List<UrlParameters> asUrlParameters();
List<UrlParameters> asUrlParameters();

}
2 changes: 1 addition & 1 deletion src/main/java/com/ecwid/consul/UrlParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
*/
public interface UrlParameters {

public List<String> toUrlParameters();
List<String> toUrlParameters();

}
4 changes: 2 additions & 2 deletions src/main/java/com/ecwid/consul/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static String generateUrl(String baseUrl, List<UrlParameters> params) {
return baseUrl;
}

List<String> allParams = new ArrayList<String>();
List<String> allParams = new ArrayList<>();
for (UrlParameters item : params) {
if (item != null) {
allParams.addAll(item.toUrlParameters());
Expand All @@ -65,7 +65,7 @@ public static Map<String, String> createTokenMap(String token) {
}

public static String toSecondsString(long waitTime) {
return String.valueOf(waitTime) + "s";
return waitTime + "s";
}

public static String assembleAgentAddress(String host, int port, String path) {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/ecwid/consul/transport/HttpTransport.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.ecwid.consul.transport;

import java.util.Map;

/**
* @author Vasily Vasilkov (vgv@ecwid.com)
*/
public interface HttpTransport {

public HttpResponse makeGetRequest(HttpRequest request);
HttpResponse makeGetRequest(HttpRequest request);

public HttpResponse makePutRequest(HttpRequest request);
HttpResponse makePutRequest(HttpRequest request);

public HttpResponse makeDeleteRequest(HttpRequest request);
HttpResponse makeDeleteRequest(HttpRequest request);

}
32 changes: 16 additions & 16 deletions src/main/java/com/ecwid/consul/v1/ConsulRawClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public HttpResponse makeGetRequest(String endpoint, List<UrlParameters> urlParam
url = Utils.generateUrl(url, urlParams);

HttpRequest request = HttpRequest.Builder.newBuilder()
.setUrl(url)
.build();
.setUrl(url)
.build();

return httpTransport.makeGetRequest(request);
}
Expand All @@ -144,9 +144,9 @@ public HttpResponse makeGetRequest(Request request) {
url = Utils.generateUrl(url, request.getUrlParameters());

HttpRequest httpRequest = HttpRequest.Builder.newBuilder()
.setUrl(url)
.addHeaders(Utils.createTokenMap(request.getToken()))
.build();
.setUrl(url)
.addHeaders(Utils.createTokenMap(request.getToken()))
.build();

return httpTransport.makeGetRequest(httpRequest);
}
Expand All @@ -156,23 +156,23 @@ public HttpResponse makePutRequest(String endpoint, String content, UrlParameter
url = Utils.generateUrl(url, urlParams);

HttpRequest request = HttpRequest.Builder.newBuilder()
.setUrl(url)
.setContent(content)
.build();
.setUrl(url)
.setContent(content)
.build();

return httpTransport.makePutRequest(request);
}

public HttpResponse makePutRequest(Request request) {
//, String endpoint, byte[] binaryContent, UrlParameters... urlParams
// String endpoint, byte[] binaryContent, UrlParameters... urlParams
String url = prepareUrl(agentAddress + request.getEndpoint());
url = Utils.generateUrl(url, request.getUrlParameters());

HttpRequest httpRequest = HttpRequest.Builder.newBuilder()
.setUrl(url)
.setBinaryContent(request.getBinaryContent())
.addHeaders(Utils.createTokenMap(request.getToken()))
.build();
.setUrl(url)
.setBinaryContent(request.getBinaryContent())
.addHeaders(Utils.createTokenMap(request.getToken()))
.build();

return httpTransport.makePutRequest(httpRequest);
}
Expand All @@ -182,9 +182,9 @@ public HttpResponse makeDeleteRequest(Request request) {
url = Utils.generateUrl(url, request.getUrlParameters());

HttpRequest httpRequest = HttpRequest.Builder.newBuilder()
.setUrl(url)
.addHeaders(Utils.createTokenMap(request.getToken()))
.build();
.setUrl(url)
.addHeaders(Utils.createTokenMap(request.getToken()))
.build();

return httpTransport.makeDeleteRequest(httpRequest);
}
Expand Down
58 changes: 29 additions & 29 deletions src/main/java/com/ecwid/consul/v1/agent/AgentClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,61 @@
*/
public interface AgentClient {

public Response<Map<String, Check>> getAgentChecks();
Response<Map<String, Check>> getAgentChecks();

public Response<Map<String, Service>> getAgentServices();
Response<Map<String, Service>> getAgentServices();

public Response<List<Member>> getAgentMembers();
Response<List<Member>> getAgentMembers();

public Response<Self> getAgentSelf();
Response<Self> getAgentSelf();

public Response<Self> getAgentSelf(String token);
Response<Self> getAgentSelf(String token);

public Response<Void> agentSetMaintenance(boolean maintenanceEnabled);
Response<Void> agentSetMaintenance(boolean maintenanceEnabled);

public Response<Void> agentSetMaintenance(boolean maintenanceEnabled, String reason);
Response<Void> agentSetMaintenance(boolean maintenanceEnabled, String reason);

public Response<Void> agentJoin(String address, boolean wan);
Response<Void> agentJoin(String address, boolean wan);

public Response<Void> agentForceLeave(String node);
Response<Void> agentForceLeave(String node);

public Response<Void> agentCheckRegister(NewCheck newCheck);
Response<Void> agentCheckRegister(NewCheck newCheck);

public Response<Void> agentCheckRegister(NewCheck newCheck, String token);
Response<Void> agentCheckRegister(NewCheck newCheck, String token);

public Response<Void> agentCheckDeregister(String checkId);
Response<Void> agentCheckDeregister(String checkId);

public Response<Void> agentCheckDeregister(String checkId, String token);
Response<Void> agentCheckDeregister(String checkId, String token);

public Response<Void> agentCheckPass(String checkId);
Response<Void> agentCheckPass(String checkId);

public Response<Void> agentCheckPass(String checkId, String note);
Response<Void> agentCheckPass(String checkId, String note);

public Response<Void> agentCheckPass(String checkId, String note, String token);
Response<Void> agentCheckPass(String checkId, String note, String token);

public Response<Void> agentCheckWarn(String checkId);
Response<Void> agentCheckWarn(String checkId);

public Response<Void> agentCheckWarn(String checkId, String note);
Response<Void> agentCheckWarn(String checkId, String note);

public Response<Void> agentCheckWarn(String checkId, String note, String token);
Response<Void> agentCheckWarn(String checkId, String note, String token);

public Response<Void> agentCheckFail(String checkId);
Response<Void> agentCheckFail(String checkId);

public Response<Void> agentCheckFail(String checkId, String note);
Response<Void> agentCheckFail(String checkId, String note);

public Response<Void> agentCheckFail(String checkId, String note, String token);
Response<Void> agentCheckFail(String checkId, String note, String token);

public Response<Void> agentServiceRegister(NewService newService);
Response<Void> agentServiceRegister(NewService newService);

public Response<Void> agentServiceRegister(NewService newService, String token);
Response<Void> agentServiceRegister(NewService newService, String token);

public Response<Void> agentServiceDeregister(String serviceId);
Response<Void> agentServiceDeregister(String serviceId);

public Response<Void> agentServiceDeregister(String serviceId, String token);
Response<Void> agentServiceDeregister(String serviceId, String token);

public Response<Void> agentServiceSetMaintenance(String serviceId, boolean maintenanceEnabled);
Response<Void> agentServiceSetMaintenance(String serviceId, boolean maintenanceEnabled);

public Response<Void> agentServiceSetMaintenance(String serviceId, boolean maintenanceEnabled, String reason);
Response<Void> agentServiceSetMaintenance(String serviceId, boolean maintenanceEnabled, String reason);

public Response<Void> agentReload();
Response<Void> agentReload();
}
34 changes: 17 additions & 17 deletions src/main/java/com/ecwid/consul/v1/catalog/CatalogClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,81 +15,81 @@
*/
public interface CatalogClient {

public Response<Void> catalogRegister(CatalogRegistration catalogRegistration);
Response<Void> catalogRegister(CatalogRegistration catalogRegistration);

public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token);
Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token);

// -------------------------------------------------------------------------------

public Response<Void> catalogDeregister(CatalogDeregistration catalogDeregistration);
Response<Void> catalogDeregister(CatalogDeregistration catalogDeregistration);

public Response<Void> catalogDeregister(CatalogDeregistration catalogDeregistration, String token);
Response<Void> catalogDeregister(CatalogDeregistration catalogDeregistration, String token);

// -------------------------------------------------------------------------------

public Response<List<String>> getCatalogDatacenters();
Response<List<String>> getCatalogDatacenters();

// -------------------------------------------------------------------------------

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #getCatalogNodes(CatalogNodesRequest catalogNodesRequest)}
*/
@Deprecated
public Response<List<Node>> getCatalogNodes(QueryParams queryParams);
Response<List<Node>> getCatalogNodes(QueryParams queryParams);

public Response<List<Node>> getCatalogNodes(CatalogNodesRequest catalogNodesRequest);
Response<List<Node>> getCatalogNodes(CatalogNodesRequest catalogNodesRequest);

// -------------------------------------------------------------------------------

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #getCatalogServices(CatalogServicesRequest catalogServicesRequest)}
*/
@Deprecated
public Response<Map<String, List<String>>> getCatalogServices(QueryParams queryParams);
Response<Map<String, List<String>>> getCatalogServices(QueryParams queryParams);

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #getCatalogServices(CatalogServicesRequest catalogServicesRequest)}
*/
@Deprecated
public Response<Map<String, List<String>>> getCatalogServices(QueryParams queryParams, String token);
Response<Map<String, List<String>>> getCatalogServices(QueryParams queryParams, String token);

public Response<Map<String, List<String>>> getCatalogServices(CatalogServicesRequest catalogServicesRequest);
Response<Map<String, List<String>>> getCatalogServices(CatalogServicesRequest catalogServicesRequest);

// -------------------------------------------------------------------------------

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #getCatalogService(String serviceName, CatalogServiceRequest catalogServiceRequest)}
*/
@Deprecated
public Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, QueryParams queryParams);
Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, QueryParams queryParams);

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #getCatalogService(String serviceName, CatalogServiceRequest catalogServiceRequest)}
*/
@Deprecated
public Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, String tag, QueryParams queryParams);
Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, String tag, QueryParams queryParams);

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #getCatalogService(String serviceName, CatalogServiceRequest catalogServiceRequest)}
*/
@Deprecated
public Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, QueryParams queryParams, String token);
Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, QueryParams queryParams, String token);

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #getCatalogService(String serviceName, CatalogServiceRequest catalogServiceRequest)}
*/
@Deprecated
public Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, String tag, QueryParams queryParams, String token);
Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, String tag, QueryParams queryParams, String token);

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #getCatalogService(String serviceName, CatalogServiceRequest catalogServiceRequest)}
*/
@Deprecated
public Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, String[] tags, QueryParams queryParams, String token);
Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, String[] tags, QueryParams queryParams, String token);

public Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, CatalogServiceRequest catalogServiceRequest);
Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, CatalogServiceRequest catalogServiceRequest);

// -------------------------------------------------------------------------------

public Response<CatalogNode> getCatalogNode(String nodeName, QueryParams queryParams);
Response<CatalogNode> getCatalogNode(String nodeName, QueryParams queryParams);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/
public interface CoordinateClient {

public Response<List<Datacenter>> getDatacenters();
Response<List<Datacenter>> getDatacenters();

public Response<List<Node>> getNodes(QueryParams queryParams);
Response<List<Node>> getNodes(QueryParams queryParams);

}
8 changes: 4 additions & 4 deletions src/main/java/com/ecwid/consul/v1/event/EventClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
*/
public interface EventClient {

public Response<Event> eventFire(String event, String payload, EventParams eventParams, QueryParams queryParams);
Response<Event> eventFire(String event, String payload, EventParams eventParams, QueryParams queryParams);

// -------------------------------------------------------------------------------

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #eventList(EventListRequest eventListRequest)}
*/
@Deprecated
public Response<List<Event>> eventList(QueryParams queryParams);
Response<List<Event>> eventList(QueryParams queryParams);

/**
* @deprecated This method will be removed in consul-api 2.0. Use {@link #eventList(EventListRequest eventListRequest)}
*/
@Deprecated
public Response<List<Event>> eventList(String event, QueryParams queryParams);
Response<List<Event>> eventList(String event, QueryParams queryParams);

public Response<List<Event>> eventList(EventListRequest eventListRequest);
Response<List<Event>> eventList(EventListRequest eventListRequest);

}
Loading