Tabnine Logo
com.ecwid.consul
Code IndexAdd Tabnine to your IDE (free)

How to use com.ecwid.consul

Best Java code snippets using com.ecwid.consul (Showing top 20 results out of 315)

origin: Ecwid/consul-api

public RawResponse makeDeleteRequest(String endpoint, UrlParameters... urlParams) {
  String url = prepareUrl(agentAddress + endpoint);
  url = Utils.generateUrl(url, urlParams);
  return httpTransport.makeDeleteRequest(url);
}
origin: Ecwid/consul-api

public RawResponse makePutRequest(String endpoint, String content, UrlParameters... urlParams) {
  String url = prepareUrl(agentAddress + endpoint);
  url = Utils.generateUrl(url, urlParams);
  return httpTransport.makePutRequest(url, content);
}
origin: Ecwid/consul-api

public RawResponse makeGetRequest(String endpoint, List<UrlParameters> urlParams) {
  String url = prepareUrl(agentAddress + endpoint);
  url = Utils.generateUrl(url, urlParams);
  return httpTransport.makeGetRequest(url);
}
origin: Ecwid/consul-api

@Test
public void testGenerateUrl_Encoded() throws Exception {
  UrlParameters first = new SingleUrlParameters("key", "value value");
  UrlParameters second = new SingleUrlParameters("key2");
  UrlParameters third = new SingleUrlParameters("key3", "value!value");
  assertEquals("/some-url?key=value+value&key2&key3=value%21value", Utils.generateUrl("/some-url", first, second, third));
}
origin: Ecwid/consul-api

  @Test
  public void testToUrlParameters() throws Exception {
    UrlParameters parameters = new SingleUrlParameters("key");
    assertEquals(Collections.singletonList("key"), parameters.toUrlParameters());

    parameters = new SingleUrlParameters("key", "value");
    assertEquals(Collections.singletonList("key=value"), parameters.toUrlParameters());

    parameters = new SingleUrlParameters("key", "value value");
    assertEquals(Collections.singletonList("key=value+value"), parameters.toUrlParameters());
  }
}
origin: Ecwid/consul-api

private void checkUnsignedLongRange(long start, long end) throws Exception {
  for (long l = start; l < end; l++) {
    String str = Utils.toUnsignedString(l);
    long l2 = Utils.parseUnsignedLong(str);
    assertEquals(l, l2);
    if (l >= 0) {
      assertEquals(Long.toString(l), str);
      assertEquals(l, l2);
    }
  }
}
origin: com.ecwid.consul/consul-api

private String prepareUrl(String url) {
  if (url.contains(" ")) {
    // temp hack for old clients who did manual encoding and just use %20
    return Utils.encodeUrl(url);
  } else {
    return url;
  }
}
origin: com.ecwid.consul/consul-api

ConsulRawClient(HttpTransport httpTransport, String agentHost, int agentPort, String path) {
  this.httpTransport = httpTransport;
  // check that agentHost has scheme or not
  String agentHostLowercase = agentHost.toLowerCase();
  if (!agentHostLowercase.startsWith("https://") && !agentHostLowercase.startsWith("http://")) {
    // no scheme in host, use default 'http'
    agentHost = "http://" + agentHost;
  }
  this.agentAddress = Utils.assembleAgentAddress(agentHost, agentPort, path);
}
origin: com.ecwid.consul/consul-api

public static String generateUrl(String baseUrl, UrlParameters... params) {
  return generateUrl(baseUrl, Arrays.asList(params));
}
origin: com.ecwid.consul/consul-api

private Long parseUnsignedLong(Header header) {
  if (header == null) {
    return null;
  }
  String value = header.getValue();
  if (value == null) {
    return null;
  }
  try {
    return Utils.parseUnsignedLong(value);
  } catch (Exception e) {
    return null;
  }
}
origin: Ecwid/consul-api

  @Override
  public List<String> toUrlParameters() {
    if (value != null) {
      return Collections.singletonList(key + "=" + Utils.encodeValue(value));
    } else {
      return Collections.singletonList(key);
    }
  }
}
origin: Ecwid/consul-api

@Test
public void testUnsignedLongParsing() throws Exception {
  checkUnsignedLongRange(-100, 100);
  checkUnsignedLongRange(Long.MIN_VALUE, Long.MIN_VALUE + 100);
  checkUnsignedLongRange(Long.MAX_VALUE - 100, Long.MAX_VALUE);
}
origin: com.ecwid.consul/consul-api

public RawResponse makePutRequest(String endpoint, byte[] content, UrlParameters... urlParams) {
  String url = prepareUrl(agentAddress + endpoint);
  url = Utils.generateUrl(url, urlParams);
  return httpTransport.makePutRequest(url, content);
}
origin: Ecwid/consul-api

@Test
public void testGenerateUrl_Parametrized() throws Exception {
  UrlParameters first = new SingleUrlParameters("key", "value");
  UrlParameters second = new SingleUrlParameters("key2");
  assertEquals("/some-url?key=value&key2", Utils.generateUrl("/some-url", first, second));
}
origin: Ecwid/consul-api

private String prepareUrl(String url) {
  if (url.contains(" ")) {
    // temp hack for old clients who did manual encoding and just use %20
    return Utils.encodeUrl(url);
  } else {
    return url;
  }
}
origin: Ecwid/consul-api

ConsulRawClient(HttpTransport httpTransport, String agentHost, int agentPort, String path) {
  this.httpTransport = httpTransport;
  // check that agentHost has scheme or not
  String agentHostLowercase = agentHost.toLowerCase();
  if (!agentHostLowercase.startsWith("https://") && !agentHostLowercase.startsWith("http://")) {
    // no scheme in host, use default 'http'
    agentHost = "http://" + agentHost;
  }
  this.agentAddress = Utils.assembleAgentAddress(agentHost, agentPort, path);
}
origin: Ecwid/consul-api

public static String generateUrl(String baseUrl, UrlParameters... params) {
  return generateUrl(baseUrl, Arrays.asList(params));
}
origin: Ecwid/consul-api

private Long parseUnsignedLong(Header header) {
  if (header == null) {
    return null;
  }
  String value = header.getValue();
  if (value == null) {
    return null;
  }
  try {
    return Utils.parseUnsignedLong(value);
  } catch (Exception e) {
    return null;
  }
}
origin: com.ecwid.consul/consul-api

  @Override
  public List<String> toUrlParameters() {
    if (value != null) {
      return Collections.singletonList(key + "=" + Utils.encodeValue(value));
    } else {
      return Collections.singletonList(key);
    }
  }
}
origin: Ecwid/consul-api

@Test
public void testEncodeUrl() throws Exception {
  String uri = "http://example.com/path with spaces";
  String expected = "http://example.com/path%20with%20spaces";
  assertEquals(expected, Utils.encodeUrl(uri));
}
com.ecwid.consul

Most used classes

  • ConsulClient
    Full consul-api client with all supported methods. If you like to use more specific clients, please
  • Response
  • QueryParams
  • NewService
  • GetValue
  • HealthService,
  • NewService$Check,
  • TLSConfig,
  • Check,
  • PutParams,
  • NewSession,
  • SingleUrlParameters,
  • UrlParameters,
  • Utils,
  • ConsistencyMode,
  • ConsulRawClient$Builder,
  • ConsulRawClient,
  • OperationException,
  • QueryParams$Builder
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now