blob: b0d36cc963150006a08b41ead20675eb983c8213 [file] [log] [blame]
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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 org.jclouds.rackspace;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_ENDPOINT;
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_KEY;
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_USER;
import java.net.URI;
import java.util.Properties;
import org.jclouds.PropertiesBuilder;
/**
* Builds properties used in Rackspace Connections
*
* @author Adrian Cole
*/
public class RackspacePropertiesBuilder extends PropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_RACKSPACE_ENDPOINT, "https://api.mosso.com");
return properties;
}
public RackspacePropertiesBuilder(Properties properties) {
super(properties);
}
public RackspacePropertiesBuilder(String id, String secret) {
super();
withCredentials(id, secret);
}
public RackspacePropertiesBuilder withCredentials(String id, String secret) {
properties.setProperty(PROPERTY_RACKSPACE_USER, checkNotNull(id, "user"));
properties.setProperty(PROPERTY_RACKSPACE_KEY, checkNotNull(secret, "key"));
return this;
}
public RackspacePropertiesBuilder withEndpoint(URI endpoint) {
properties.setProperty(PROPERTY_RACKSPACE_ENDPOINT,
checkNotNull(endpoint, "endpoint").toString());
return this;
}
}