/**
 *  Copyright 2012 Rackspace
 *
 *  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 com.rackspacecloud.client.service_registry.clients;

import com.google.gson.reflect.TypeToken;
import com.rackspacecloud.client.service_registry.ClientResponse;
import com.rackspacecloud.client.service_registry.containers.ConfigurationValuesContainer;
import com.rackspacecloud.client.service_registry.containers.ServicesContainer;
import com.rackspacecloud.client.service_registry.objects.ConfigurationValue;
import com.rackspacecloud.client.service_registry.objects.Service;
import org.apache.http.NameValuePair;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.message.BasicNameValuePair;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ConfigurationClient extends BaseClient {
    public ConfigurationClient(AuthClient authClient) {
        super(authClient);
    }

    public List<ConfigurationValue> list(Map<String, String> options) throws Exception {
        Type type = new TypeToken<ConfigurationValuesContainer>() {}.getType();
        List<NameValuePair> params = new ArrayList<NameValuePair>();

        ClientResponse response = this.performRequest("/configuration", params, new HttpGet(), true, type);

        ConfigurationValuesContainer container = (ConfigurationValuesContainer)response.getBody();
        return container.getValues();
    }

    public ConfigurationValue get(String id) throws Exception {
        ClientResponse response = this.performRequest("/configuration/" + id, null, new HttpGet(), true, ConfigurationValue.class);

        return (ConfigurationValue)response.getBody();
    }

    public ConfigurationClient set(String id, String value) throws Exception {
        ConfigurationValue cv = new ConfigurationValue(null, value);
        this.performRequestWithPayload("/configuration/"+ id, null, new HttpPut(), cv, false, null);
        return this;
    }
}

@@ -1646,148 +1646,673 @@
     
-Type type = new TypeToken%3CConfigurationValuesContainer%3E() %7B%7D.getType();%0A        List%3CNameValuePair%3E params = new ArrayList%3CNameValuePair%3E();
+return list(options, null);%0A    %7D%0A%0A    public List%3CConfigurationValue%3E list(Map%3CString, String%3E options, String namespace) throws Exception %7B%0A        String url = %22/configuration%22;%0A%0A        Type type = new TypeToken%3CConfigurationValuesContainer%3E() %7B%7D.getType();%0A        List%3CNameValuePair%3E params = new ArrayList%3CNameValuePair%3E();%0A%0A        if (namespace != null) %7B%0A            // Make sure leading and trailing forward slashes are present%0A            if (namespace.indexOf(%22/%22) != 0)  %7B%0A                url += %22/%22 + namespace;%0A            %7D%0A%0A            if (namespace.lastIndexOf(%22/%22) != namespace.length() - 1) %7B%0A                url += %22/%22;%0A            %7D%0A        %7D
 %0A%0A  
@@ -2363,32 +2363,19 @@
 Request(
-%22/configuration%22
+url
 , params

Allow user to pass "namespace" argument to ConfigurationClient.list method and add overloaded method which doesn't take namespace argument.