File tree Expand file tree Collapse file tree 4 files changed +47
-5
lines changed
src/main/java/com/ecwid/consul/v1 Expand file tree Collapse file tree 4 files changed +47
-5
lines changed Original file line number Diff line number Diff line change @@ -367,6 +367,11 @@ public Response<List<Node>> getCatalogNodes(QueryParams queryParams) {
367
367
return catalogClient .getCatalogNodes (queryParams );
368
368
}
369
369
370
+ @ Override
371
+ public Response <List <Node >> getCatalogNodes (Map <String , String > nodeMeta , QueryParams queryParams ) {
372
+ return catalogClient .getCatalogNodes (nodeMeta , queryParams );
373
+ }
374
+
370
375
@ Override
371
376
public Response <Map <String , List <String >>> getCatalogServices (QueryParams queryParams ) {
372
377
return catalogClient .getCatalogServices (queryParams );
Original file line number Diff line number Diff line change
1
+ package com .ecwid .consul .v1 ;
2
+
3
+ import com .ecwid .consul .UrlParameters ;
4
+
5
+ import java .util .ArrayList ;
6
+ import java .util .List ;
7
+ import java .util .Map ;
8
+
9
+ public class NodeMetaParameters implements UrlParameters {
10
+
11
+ private final Map <String , String > nodeMeta ;
12
+
13
+ public NodeMetaParameters (Map <String , String > nodeMeta ) {
14
+ this .nodeMeta = nodeMeta ;
15
+ }
16
+
17
+ @ Override
18
+ public List <String > toUrlParameters () {
19
+ List <String > params = new ArrayList <>();
20
+
21
+ if (nodeMeta != null ) {
22
+ String key = "node-meta" ;
23
+
24
+ for (Map .Entry <String , String > entry : nodeMeta .entrySet ()) {
25
+ String value = entry .getKey () + ":" + entry .getValue ();
26
+ params .add (key + "=" + value );
27
+ }
28
+ }
29
+
30
+ return params ;
31
+ }
32
+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ public interface CatalogClient {
27
27
28
28
public Response <List <Node >> getCatalogNodes (QueryParams queryParams );
29
29
30
+ public Response <List <Node >> getCatalogNodes (Map <String , String > nodeMeta , QueryParams queryParams );
31
+
30
32
public Response <Map <String , List <String >>> getCatalogServices (QueryParams queryParams );
31
33
32
34
public Response <Map <String , List <String >>> getCatalogServices (QueryParams queryParams , String token );
Original file line number Diff line number Diff line change 8
8
import com .ecwid .consul .json .GsonFactory ;
9
9
import com .ecwid .consul .transport .RawResponse ;
10
10
import com .ecwid .consul .transport .TLSConfig ;
11
- import com .ecwid .consul .v1 .ConsulRawClient ;
12
- import com .ecwid .consul .v1 .OperationException ;
13
- import com .ecwid .consul .v1 .QueryParams ;
14
- import com .ecwid .consul .v1 .Response ;
11
+ import com .ecwid .consul .v1 .*;
15
12
import com .ecwid .consul .v1 .catalog .model .CatalogDeregistration ;
16
13
import com .ecwid .consul .v1 .catalog .model .CatalogNode ;
17
14
import com .ecwid .consul .v1 .catalog .model .CatalogRegistration ;
@@ -104,7 +101,13 @@ public Response<List<String>> getCatalogDatacenters() {
104
101
105
102
@ Override
106
103
public Response <List <Node >> getCatalogNodes (QueryParams queryParams ) {
107
- RawResponse rawResponse = rawClient .makeGetRequest ("/v1/catalog/nodes" , queryParams );
104
+ return getCatalogNodes (null , queryParams );
105
+ }
106
+
107
+ @ Override
108
+ public Response <List <Node >> getCatalogNodes (Map <String , String > nodeMeta , QueryParams queryParams ) {
109
+ UrlParameters nodeMetaParam = new NodeMetaParameters (nodeMeta );
110
+ RawResponse rawResponse = rawClient .makeGetRequest ("/v1/catalog/nodes" , queryParams , nodeMetaParam );
108
111
109
112
if (rawResponse .getStatusCode () == 200 ) {
110
113
List <Node > value = GsonFactory .getGson ().fromJson (rawResponse .getContent (), new TypeToken <List <Node >>() {
You can’t perform that action at this time.
0 commit comments