All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.nikore.consul.v1.ConsulClient Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2015 Matt Christiansen ([email protected])
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.nikore.consul.v1;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.core.JsonProcessingException;
import net.nikore.consul.v1.acl.AclClient;
import net.nikore.consul.v1.acl.AclConsulClient;
import net.nikore.consul.v1.acl.model.Acl;
import net.nikore.consul.v1.acl.model.NewAcl;
import net.nikore.consul.v1.acl.model.UpdateAcl;
import net.nikore.consul.v1.agent.AgentClient;
import net.nikore.consul.v1.agent.AgentConsulClient;
import net.nikore.consul.v1.agent.model.Member;
import net.nikore.consul.v1.agent.model.NewCheck;
import net.nikore.consul.v1.agent.model.NewService;
import net.nikore.consul.v1.agent.model.Self;
import net.nikore.consul.v1.agent.model.Service;
import net.nikore.consul.v1.catalog.CatalogClient;
import net.nikore.consul.v1.catalog.CatalogConsulClient;
import net.nikore.consul.v1.catalog.model.CatalogDeregistration;
import net.nikore.consul.v1.catalog.model.CatalogNode;
import net.nikore.consul.v1.catalog.model.CatalogRegistration;
import net.nikore.consul.v1.catalog.model.CatalogService;
import net.nikore.consul.v1.catalog.model.Node;
import net.nikore.consul.v1.event.EventClient;
import net.nikore.consul.v1.event.EventConsulClient;
import net.nikore.consul.v1.event.model.Event;
import net.nikore.consul.v1.event.model.EventParams;
import net.nikore.consul.v1.health.HealthClient;
import net.nikore.consul.v1.health.HealthConsulClient;
import net.nikore.consul.v1.health.model.HealthService;
import net.nikore.consul.v1.kv.KeyValueClient;
import net.nikore.consul.v1.kv.KeyValueConsulClient;
import net.nikore.consul.v1.kv.model.GetBinaryValue;
import net.nikore.consul.v1.kv.model.GetValue;
import net.nikore.consul.v1.health.model.Check;
import net.nikore.consul.v1.kv.model.PutParams;
import net.nikore.consul.v1.session.SessionClient;
import net.nikore.consul.v1.session.SessionConsulClient;
import net.nikore.consul.v1.session.model.NewSession;
import net.nikore.consul.v1.session.model.Session;
import net.nikore.consul.v1.status.StatusClient;
import net.nikore.consul.v1.status.StatusConsulClient;

public final class ConsulClient implements AclClient, AgentClient, CatalogClient, EventClient, HealthClient, KeyValueClient, SessionClient, StatusClient {

  private final AclClient aclClient;
  private final AgentClient agentClient;
  private final CatalogClient catalogClient;
  private final EventClient eventClient;
  private final HealthClient healthClient;
  private final KeyValueClient keyValueClient;
  private final SessionClient sessionClient;
  private final StatusClient statusClient;

  public ConsulClient(ConsulRawClient rawClient) {
    aclClient = new AclConsulClient(rawClient);
    agentClient = new AgentConsulClient(rawClient);
    catalogClient = new CatalogConsulClient(rawClient);
    eventClient = new EventConsulClient(rawClient);
    healthClient = new HealthConsulClient(rawClient);
    keyValueClient = new KeyValueConsulClient(rawClient);
    sessionClient = new SessionConsulClient(rawClient);
    statusClient = new StatusConsulClient(rawClient);
  }

  public ConsulClient() {
    this(new ConsulRawClient());
  }

  public ConsulClient(String agentHost) {
    this(new ConsulRawClient(agentHost));
  }

  public ConsulClient(String agentHost, int agentPort) {
    this(new ConsulRawClient(agentHost, agentPort));
  }

  @Override
  public Response aclCreate(NewAcl newAcl, String token) throws IOException {
    return aclClient.aclCreate(newAcl, token);
  }

  @Override
  public Response aclUpdate(UpdateAcl updateAcl, String token) throws JsonProcessingException {
    return aclClient.aclUpdate(updateAcl, token);
  }

  @Override
  public Response aclDestroy(String aclId, String token) {
    return aclClient.aclDestroy(aclId, token);
  }

  @Override
  public Response getAcl(String id) throws IOException {
    return aclClient.getAcl(id);
  }

  @Override
  public Response aclClone(String aclId, String token) throws IOException {
    return aclClient.aclClone(aclId, token);
  }

  @Override
  public Response> getAclList(String token) throws IOException {
    return aclClient.getAclList(token);
  }

  @Override
  public Response> getAgentChecks() throws IOException {
    return agentClient.getAgentChecks();
  }

  @Override
  public Response> getAgentServices() throws IOException {
    return agentClient.getAgentServices();
  }

  @Override
  public Response> getAgentMembers() throws IOException {
    return agentClient.getAgentMembers();
  }

  @Override
  public Response getAgentSelf() throws IOException {
    return agentClient.getAgentSelf();
  }

  @Override
  public Response agentJoin(String address, boolean wan) {
    return agentClient.agentJoin(address, wan);
  }

  @Override
  public Response agentForceLeave(String node) {
    return agentClient.agentForceLeave(node);
  }

  @Override
  public Response agentCheckRegister(NewCheck newCheck) throws JsonProcessingException {
    return agentClient.agentCheckRegister(newCheck);
  }

  @Override
  public Response agentCheckDeregister(String checkId) {
    return agentClient.agentCheckDeregister(checkId);
  }

  @Override
  public Response agentCheckPass(String checkId) {
    return agentClient.agentCheckPass(checkId);
  }

  @Override
  public Response agentCheckPass(String checkId, String note) {
    return agentClient.agentCheckPass(checkId, note);
  }

  @Override
  public Response agentCheckWarn(String checkId) {
    return agentClient.agentCheckWarn(checkId);
  }

  @Override
  public Response agentCheckWarn(String checkId, String note) {
    return agentClient.agentCheckWarn(checkId, note);
  }

  @Override
  public Response agentCheckFail(String checkId) {
    return agentClient.agentCheckFail(checkId);
  }

  @Override
  public Response agentCheckFail(String checkId, String note) {
    return agentClient.agentCheckFail(checkId, note);
  }

  @Override
  public Response agentServiceRegister(NewService newService) throws JsonProcessingException {
    return agentClient.agentServiceRegister(newService);
  }

  @Override
  public Response agentServiceDeregister(String serviceId) {
    return agentClient.agentServiceDeregister(serviceId);
  }

  @Override
  public Response catalogRegister(CatalogRegistration catalogRegistration) throws JsonProcessingException {
    return catalogClient.catalogRegister(catalogRegistration);
  }

  @Override
  public Response catalogDeregister(CatalogDeregistration catalogDeregistration, CatalogDeregistration... catalogDeregistrations) throws JsonProcessingException {
    return catalogClient.catalogDeregister(catalogDeregistration, catalogDeregistrations);
  }

  @Override
  public Response> getCatalogDatacenters() throws IOException {
    return catalogClient.getCatalogDatacenters();
  }

  @Override
  public Response> getCatalogNodes(QueryParams queryParams) throws IOException {
    return catalogClient.getCatalogNodes(queryParams);
  }

  @Override
  public Response>> getCatalogServices(QueryParams queryParams) throws IOException {
    return catalogClient.getCatalogServices(queryParams);
  }

  @Override
  public Response> getCatalogService(String serviceName, QueryParams queryParams) throws IOException {
    return catalogClient.getCatalogService(serviceName, queryParams);
  }

  @Override
  public Response> getCatalogService(String serviceName, String tag, QueryParams queryParams) throws IOException {
    return catalogClient.getCatalogService(serviceName, tag, queryParams);
  }

  @Override
  public Response getCatalogNode(String nodeName, QueryParams queryParams) throws IOException {
    return catalogClient.getCatalogNode(nodeName, queryParams);
  }

  @Override
  public Response eventFire(String event, String payload, EventParams eventParams, QueryParams queryParams) throws IOException {
    return eventClient.eventFire(event, payload, eventParams, queryParams);
  }

  @Override
  public Response> eventList(QueryParams queryParams) throws IOException {
    return eventClient.eventList(queryParams);
  }

  @Override
  public Response> eventList(String event, QueryParams queryParams) throws IOException {
    return eventClient.eventList(event, queryParams);
  }

  @Override
  public Response> getHealthChecksForNode(String nodeName, QueryParams queryParams) throws IOException {
    return healthClient.getHealthChecksForNode(nodeName, queryParams);
  }

  @Override
  public Response> getHealthChecksForService(String serviceName, QueryParams queryParams) throws IOException {
    return healthClient.getHealthChecksForService(serviceName, queryParams);
  }

  @Override
  public Response> getHealthServices(String serviceName, boolean onlyPassing, QueryParams queryParams) throws IOException {
    return healthClient.getHealthServices(serviceName, onlyPassing, queryParams);
  }

  @Override
  public Response> getHealthServices(String serviceName, String tag, boolean onlyPassing, QueryParams queryParams) throws IOException {
    return healthClient.getHealthServices(serviceName, tag, onlyPassing, queryParams);
  }

  @Override
  public Response> getHealthChecksState(QueryParams queryParams) throws IOException {
    return healthClient.getHealthChecksState(queryParams);
  }

  @Override
  public Response> getHealthChecksState(Check.CheckStatus checkStatus, QueryParams queryParams) throws IOException {
    return healthClient.getHealthChecksState(checkStatus, queryParams);
  }

  @Override
  public Response getKVValue(String key) throws IOException {
    return keyValueClient.getKVValue(key, null);
  }

  @Override
  public Response getKVValue(String key, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVValue(key, queryParams);
  }

  @Override
  public Response getKVValue(String key, String token, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVValue(key, token, queryParams);
  }

  @Override
  public Response getKVBinaryValue(String key, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVBinaryValue(key, queryParams);
  }

  @Override
  public Response getKVBinaryValue(String key, String token, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVBinaryValue(key, token, queryParams);
  }

  @Override
  public Response> getKVValues(String keyPrefix, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVValues(keyPrefix, queryParams);
  }

  @Override
  public Response> getKVValues(String keyPrefix, String token, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVValues(keyPrefix, token, queryParams);
  }

  @Override
  public Response> getKVBinaryValues(String keyPrefix, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVBinaryValues(keyPrefix, queryParams);
  }

  @Override
  public Response> getKVBinaryValues(String keyPrefix, String token, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVBinaryValues(keyPrefix, token, queryParams);
  }

  @Override
  public Response> getKVKeysOnly(String keyPrefix, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVKeysOnly(keyPrefix, queryParams);
  }

  @Override
  public Response> getKVKeysOnly(String keyPrefix, String separator, String token, QueryParams queryParams) throws IOException {
    return keyValueClient.getKVKeysOnly(keyPrefix, separator, token, queryParams);
  }

  @Override
  public Response setKVValue(String key, String value) throws IOException {
    return keyValueClient.setKVValue(key, value);
  }

  @Override
  public Response setKVValue(String key, String value, PutParams putParams) throws IOException {
    return keyValueClient.setKVValue(key, value, putParams);
  }

  @Override
  public Response setKVValue(String key, String value, String token, PutParams putParams) throws IOException {
    return keyValueClient.setKVValue(key, value, token, putParams);
  }

  @Override
  public Response setKVBinaryValue(String key, byte[] value) throws IOException {
    return keyValueClient.setKVBinaryValue(key, value);
  }

  @Override
  public Response setKVBinaryValue(String key, byte[] value, PutParams putParams) throws IOException {
    return keyValueClient.setKVBinaryValue(key, value, putParams);
  }

  @Override
  public Response setKVBinaryValue(String key, byte[] value, String token, PutParams putParams) throws IOException {
    return keyValueClient.setKVBinaryValue(key, value, token, putParams);
  }

  @Override
  public Response deleteKVValue(String key) {
    return keyValueClient.deleteKVValue(key);
  }

  @Override
  public Response deleteKVValue(String key, String token) {
    return keyValueClient.deleteKVValue(key, token);
  }

  @Override
  public Response deleteKVValues(String key) {
    return keyValueClient.deleteKVValues(key);
  }

  @Override
  public Response deleteKVValues(String key, String token) {
    return keyValueClient.deleteKVValues(key, token);
  }

  @Override
  public Response sessionCreate(NewSession newSession, QueryParams queryParams) throws IOException {
    return sessionClient.sessionCreate(newSession, queryParams);
  }

  @Override
  public Response sessionDestroy(String session, QueryParams queryParams) {
    return sessionClient.sessionDestroy(session, queryParams);
  }

  @Override
  public Response getSessionInfo(String session, QueryParams queryParams) throws IOException {
    return sessionClient.getSessionInfo(session, queryParams);
  }

  @Override
  public Response> getSessionNode(String node, QueryParams queryParams) throws IOException {
    return sessionClient.getSessionNode(node, queryParams);
  }

  @Override
  public Response> getSessionList(QueryParams queryParams) throws IOException {
    return sessionClient.getSessionList(queryParams);
  }

  @Override
  public Response getStatusLeader() throws IOException {
    return statusClient.getStatusLeader();
  }

  @Override
  public Response> getStatusPeers() throws IOException {
    return statusClient.getStatusPeers();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy