| /** |
| * |
| * 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.rimuhosting.miro; |
| |
| import static com.google.common.base.Preconditions.checkNotNull; |
| import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPERTY_RIMUHOSTING_APIKEY; |
| import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPERTY_RIMUHOSTING_ENDPOINT; |
| |
| import java.net.URI; |
| import java.util.Properties; |
| |
| import org.jclouds.PropertiesBuilder; |
| |
| /** |
| * Builds properties used in RimuHosting Clients |
| * |
| * @author Adrian Cole |
| */ |
| public class RimuHostingPropertiesBuilder extends PropertiesBuilder { |
| @Override |
| protected Properties defaultProperties() { |
| Properties properties = super.defaultProperties(); |
| properties.setProperty(PROPERTY_RIMUHOSTING_ENDPOINT, "https://rimuhosting.com/r"); |
| return properties; |
| } |
| |
| public RimuHostingPropertiesBuilder(Properties properties) { |
| super(properties); |
| } |
| |
| public RimuHostingPropertiesBuilder(String secret) { |
| super(); |
| withCredentials(secret); |
| } |
| |
| public RimuHostingPropertiesBuilder withCredentials(String secret) { |
| properties.setProperty(PROPERTY_RIMUHOSTING_APIKEY, checkNotNull(secret, "password")); |
| return this; |
| } |
| |
| @Override |
| public RimuHostingPropertiesBuilder withEndpoint(URI endpoint) { |
| properties.setProperty(PROPERTY_RIMUHOSTING_ENDPOINT, checkNotNull(endpoint, "endpoint") |
| .toString()); |
| return this; |
| } |
| |
| @Override |
| public PropertiesBuilder withCredentials(String account, String key) { |
| return withCredentials(account != null ? account : key); |
| } |
| } |