Class CatalogClient

java.lang.Object
org.kiwiproject.consul.CatalogClient

public class CatalogClient extends Object
HTTP Client for /v1/catalog/ endpoints.
  • Field Details

    • http

      protected final Http http
  • Method Details

    • getDatacenters

      public List<String> getDatacenters()
      Retrieves all datacenters.

      GET /v1/catalog/datacenters

      Returns:
      A list of datacenter names.
    • getDatacenters

      public List<String> getDatacenters(QueryOptions queryOptions)
      Get the list of datacenters with query options
      Parameters:
      queryOptions - the query options to use
      Returns:
      a list of the datacenters
    • getNodes

      public ConsulResponse<List<Node>> getNodes()
      Retrieves all nodes.

      GET /v1/catalog/nodes

      Returns:
      A ConsulResponse containing a list of Node objects.
    • getNodes

      public ConsulResponse<List<Node>> getNodes(QueryOptions queryOptions)
      Retrieves all nodes for a given datacenter with QueryOptions.

      GET /v1/catalog/nodes?dc={datacenter}

      Parameters:
      queryOptions - The Query Options to use.
      Returns:
      A ConsulResponse containing a list of Node objects.
    • getNodes

      public void getNodes(QueryOptions queryOptions, ConsulResponseCallback<List<Node>> callback)
      Asynchronously retrieves the nodes for a given datacenter with QueryOptions.

      GET /v1/catalog/nodes?dc={datacenter}

      Parameters:
      queryOptions - The Query Options to use.
      callback - Callback implemented by callee to handle results, which is a list of Node objects.
    • getServices

      public ConsulResponse<Map<String,List<String>>> getServices()
      Retrieves all services for a given datacenter.

      GET /v1/catalog/services?dc={datacenter}

      Returns:
      A ConsulResponse containing a map of service name to a list of tags.
    • getServices

      public void getServices(ConsulResponseCallback<Map<String,List<String>>> callback)
      Asynchronously retrieves the services for a given datacenter.

      GET /v1/catalog/services?dc={datacenter}

      Parameters:
      callback - Callback implemented by callee to handle results; the callback is provided a map of service name to a list of tags.
    • getServices

      public ConsulResponse<Map<String,List<String>>> getServices(QueryOptions queryOptions)
      Retrieves all services for a given datacenter.

      GET /v1/catalog/services?dc={datacenter}

      Parameters:
      queryOptions - The Query Options to use.
      Returns:
      A ConsulResponse containing a map of service name to a list of tags.
    • getServices

      public void getServices(QueryOptions queryOptions, ConsulResponseCallback<Map<String,List<String>>> callback)
      Asynchronously retrieves the services for a given datacenter.

      GET /v1/catalog/services?dc={datacenter}

      Parameters:
      queryOptions - The Query Options to use.
      callback - Callback implemented by callee to handle results, containing a map of service name to a list of tags
    • getService

      public ConsulResponse<List<CatalogService>> getService(String service)
      Retrieves the single service.

      GET /v1/catalog/service/{service}

      Parameters:
      service - the name of the service to get
      Returns:
      A ConsulResponse containing CatalogService objects.
    • getService

      public ConsulResponse<List<CatalogService>> getService(String service, QueryOptions queryOptions)
      Retrieves a single service for a given datacenter with QueryOptions.

      GET /v1/catalog/service/{service}?dc={datacenter}

      Parameters:
      service - the name of the service to get
      queryOptions - The Query Options to use.
      Returns:
      A ConsulResponse containing CatalogService objects.
    • getService

      public void getService(String service, QueryOptions queryOptions, ConsulResponseCallback<List<CatalogService>> callback)
      Asynchronously retrieves the single service for a given datacenter with QueryOptions.

      GET /v1/catalog/service/{service}?dc={datacenter}

      Parameters:
      service - the name of the service to get
      queryOptions - The Query Options to use.
      callback - Callback implemented by callee to handle results, containing a list of CatalogService objects
    • getNode

      public ConsulResponse<CatalogNode> getNode(String node)
      Retrieves a single node.

      GET /v1/catalog/node/{node}

      Parameters:
      node - the name of the node to get
      Returns:
      A list of matching CatalogService objects.
    • getNode

      public ConsulResponse<CatalogNode> getNode(String node, QueryOptions queryOptions)
      Retrieves a single node for a given datacenter with QueryOptions.

      GET /v1/catalog/node/{node}?dc={datacenter}

      Parameters:
      node - the name of the node to get
      queryOptions - The Query Options to use.
      Returns:
      A list of matching CatalogService objects.
    • getNode

      public void getNode(String node, QueryOptions queryOptions, ConsulResponseCallback<CatalogNode> callback)
      Asynchronously retrieves the single node for a given datacenter with QueryOptions.

      GET /v1/catalog/node/{node}?dc={datacenter}

      Parameters:
      node - the name of the node to get
      queryOptions - The Query Options to use.
      callback - Callback implemented by callee to handle results.
    • register

      public void register(CatalogRegistration registration)
      Registers a service or node.

      PUT /v1/catalog/register

      Parameters:
      registration - A CatalogRegistration
    • register

      public void register(CatalogRegistration registration, QueryOptions options)
      Registers a service or node.

      PUT /v1/catalog/register

      Parameters:
      registration - A CatalogRegistration
      options - The Query Options to use.
    • deregister

      public void deregister(CatalogDeregistration deregistration)
      De-registers a service or node.

      PUT /v1/catalog/deregister

      Parameters:
      deregistration - A CatalogDeregistration
    • deregister

      public void deregister(CatalogDeregistration deregistration, QueryOptions options)
      De-registers a service or node.

      PUT /v1/catalog/deregister

      Parameters:
      deregistration - A CatalogDeregistration
      options - The Query Options to use.
    • getNetworkTimeoutConfig

      public Consul.NetworkTimeoutConfig getNetworkTimeoutConfig()
    • getConfig

      public ClientConfig getConfig()
    • getEventHandler

      public ClientEventHandler getEventHandler()