Example usage for org.springframework.util MultiValueMap set

List of usage examples for org.springframework.util MultiValueMap set

Introduction

In this page you can find the example usage for org.springframework.util MultiValueMap set.

Prototype

void set(K key, @Nullable V value);

Source Link

Document

Set the given single value under the given key.

Usage

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 w w .  j a  va 2s.c  o m
 * 
 * @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  ww w. jav a  2s. c  o m
 * 
 * @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.
 * //from  ww w. j a va 2s  . co  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  v a 2 s . c om
 * @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.
 * /*  www . j a v  a  2 s .com*/
 * @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.//from   w  w  w .  j  ava  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  .j  a v a 2  s .com*/
 * @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.
 * /*ww  w  .j  a v a  2s.  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);
}

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

/**
 * Atomically updates a key-value pair in etcd.
 * // ww w .j  a  v  a2s  .c o m
 * @param key
 *            the key
 * @param value
 *            the value
 * @param ttl
 *            the time-to-live
 * @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, int ttl, String prevValue) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("ttl", ttl == -1 ? "" : ttl);
    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

/**
 * Atomically creates or updates a key-value pair in etcd.
 * /*ww  w.j a v  a 2  s .c om*/
 * @param key
 *            the key
 * @param value
 *            the value
 * @param ttl
 *            the time-to-live
 * @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, int ttl, boolean prevExist)
        throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("ttl", ttl == -1 ? "" : ttl);
    builder.queryParam("prevExist", prevExist);

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

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