Example usage for org.springframework.web.util UriComponentsBuilder pathSegment

List of usage examples for org.springframework.web.util UriComponentsBuilder pathSegment

Introduction

In this page you can find the example usage for org.springframework.web.util UriComponentsBuilder pathSegment.

Prototype

@Override
public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalArgumentException 

Source Link

Document

Append path segments to the existing path.

Usage

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically deletes a key-value pair in etcd.
 * /*from w w  w  . ja v  a  2 s .  co m*/
 * @param key
 *            the key
 * @param prevValue
 *            the previous value of the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndDelete(final String key, String prevValue) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("prevValue", prevValue);

    return execute(builder, HttpMethod.DELETE, null, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Sets the value of the node with the given key in etcd. Any previously
 * existing key-value pair is returned as prevNode in the etcd response.
 * /*from   w ww  .  j  a  v a 2  s  . c  o  m*/
 * @param key
 *            the node's key
 * @param value
 *            the node's value
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse put(final String key, final String value) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Creates a new node with the given key-value pair under the node with the
 * given key.//from   w ww  .  j  av  a2 s.c  om
 * 
 * @param key
 *            the directory node's key
 * @param value
 *            the value of the created node
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse create(final String key, final String value) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.POST, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Creates a directory node in etcd.//from   w  w w . j  av a 2s .com
 * 
 * @param key
 *            the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse putDir(final String key) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("dir", "true");

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Sets the value of the node with the given key in etcd.
 * // ww w . ja  va 2 s. c  o  m
 * @param key
 *            the node's key
 * @param value
 *            the node's value
 * @param ttl
 *            the node's time-to-live or <code>-1</code> to unset existing
 *            ttl
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse put(String key, String value, int ttl) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("ttl", ttl == -1 ? "" : ttl);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically updates a key-value pair in etcd.
 * /*  w  ww  .j a  va2  s.com*/
 * @param key
 *            the key
 * @param value
 *            the value
 * @param prevIndex
 *            the modified index of the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndSwap(String key, String value, int prevIndex) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("prevIndex", prevIndex);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically updates a key-value pair in etcd.
 * /* w  w  w. java  2  s. co  m*/
 * @param key
 *            the key
 * @param value
 *            the value
 * @param prevValue
 *            the previous value of the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndSwap(String key, String value, String prevValue) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("prevValue", prevValue);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Creates a directory node in etcd.//  ww  w  .j a v a  2 s  . c  o m
 * 
 * @param key
 *            the key
 * @param ttl
 *            the time-to-live
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse putDir(String key, int ttl) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("dir", "true");
    payload.set("ttl", ttl == -1 ? "" : String.valueOf(ttl));

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically creates or updates a key-value pair in etcd.
 * /* w w  w.ja v  a 2 s. co m*/
 * @param key
 *            the key
 * @param value
 *            the value
 * @param prevExist
 *            <code>true</code> if the existing node should be updated,
 *            <code>false</code> of the node should be created
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndSwap(final String key, final String value, boolean prevExist)
        throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("prevExist", prevExist);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically updates a key-value pair in etcd.
 * //from w  ww.ja va  2 s  . c o m
 * @param key
 *            the key
 * @param value
 *            the value
 * @param ttl
 *            the time-to-live
 * @param prevIndex
 *            the modified index of the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndSwap(String key, String value, int ttl, int prevIndex) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("ttl", ttl == -1 ? "" : ttl);
    builder.queryParam("prevIndex", prevIndex);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}