http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/functions/WindowsLoginCredentialsFromEncryptedData.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/functions/WindowsLoginCredentialsFromEncryptedData.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/functions/WindowsLoginCredentialsFromEncryptedData.java new file mode 100644 index 0000000..c26c394 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/functions/WindowsLoginCredentialsFromEncryptedData.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.functions; + +import static com.google.common.base.Charsets.UTF_8; +import static com.google.common.io.BaseEncoding.base64; + +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.spec.KeySpec; +import java.util.regex.Pattern; + +import javax.crypto.Cipher; + +import org.jclouds.cloudstack.domain.EncryptedPasswordAndPrivateKey; +import org.jclouds.crypto.Crypto; +import org.jclouds.crypto.Pems; +import org.jclouds.domain.LoginCredentials; +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Function; +import com.google.common.base.Throwables; +import com.google.inject.Inject; +import com.google.inject.Singleton; + +/** + * Given an encrypted Windows Administrator password and the decryption key, return a LoginCredentials instance. + */ +@Singleton +public class WindowsLoginCredentialsFromEncryptedData implements Function<EncryptedPasswordAndPrivateKey, LoginCredentials> { + + private final Crypto crypto; + + @Inject + public WindowsLoginCredentialsFromEncryptedData(Crypto crypto) { + this.crypto = crypto; + } + + private static final Pattern whitespace = Pattern.compile("\\s"); + + @Override + public LoginCredentials apply(@Nullable EncryptedPasswordAndPrivateKey dataAndKey) { + if (dataAndKey == null) + return null; + try { + KeySpec keySpec = Pems.privateKeySpec(dataAndKey.getPrivateKey()); + KeyFactory kf = crypto.rsaKeyFactory(); + PrivateKey privKey = kf.generatePrivate(keySpec); + + Cipher cipher = crypto.cipher("RSA"); + cipher.init(Cipher.DECRYPT_MODE, privKey); + byte[] cipherText = base64().decode(whitespace.matcher(dataAndKey.getEncryptedPassword()).replaceAll("")); + byte[] plainText = cipher.doFinal(cipherText); + String password = new String(plainText, UTF_8); + + return LoginCredentials.builder() + .user("Administrator") + .password(password) + .noPrivateKey() + .build(); + + } catch (Exception e) { + throw Throwables.propagate(e); + } + } +}
http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/functions/ZoneIdToZone.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/functions/ZoneIdToZone.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/functions/ZoneIdToZone.java new file mode 100644 index 0000000..6e18605 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/functions/ZoneIdToZone.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.cloudstack.CloudStackApi; +import org.jclouds.cloudstack.domain.Zone; +import org.jclouds.cloudstack.features.ZoneApi; + +import com.google.common.cache.CacheLoader; +import com.google.inject.Inject; + +/** + * Defines a cache that allows a zone to be looked up by its ID. + */ +public class ZoneIdToZone extends CacheLoader<String, Zone> { + + private final ZoneApi zoneClient; + + @Inject + public ZoneIdToZone(CloudStackApi client) { + checkNotNull(client, "client"); + this.zoneClient = client.getZoneApi(); + } + + @Override + public Zone load(String zoneId) throws Exception { + checkNotNull(zoneId, "zoneId"); + return zoneClient.getZone(zoneId); + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java new file mode 100644 index 0000000..6c6f886 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.handlers; + +import java.io.IOException; + +import javax.annotation.Resource; +import javax.inject.Singleton; + +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpErrorHandler; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.HttpResponseException; +import org.jclouds.logging.Logger; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.InsufficientResourcesException; +import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.util.Closeables2; +import org.jclouds.util.Strings2; + +import com.google.common.base.Throwables; + +@Singleton +public class CloudStackErrorHandler implements HttpErrorHandler { + @Resource + protected Logger logger = Logger.NULL; + + public void handleError(HttpCommand command, HttpResponse response) { + // it is important to always read fully and close streams + String message = parseMessage(response); + Exception exception = message != null ? new HttpResponseException(command, response, message) + : new HttpResponseException(command, response); + try { + message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), + response.getStatusLine()); + switch (response.getStatusCode()) { + case 400: + exception = new IllegalArgumentException(message, exception); + break; + case 531: + case 401: + exception = new AuthorizationException(message, exception); + break; + case 404: + if (!command.getCurrentRequest().getMethod().equals("DELETE")) { + exception = new ResourceNotFoundException(message, exception); + } + break; + case 405: + exception = new IllegalArgumentException(message, exception); + break; + case 409: + case 431: + if (message.contains("does not exist")) { + exception = new ResourceNotFoundException(message, exception); + } else { + exception = new IllegalStateException(message, exception); + } + break; + case 534: + if (message.contains("Maximum number of resources of type")) { + exception = new InsufficientResourcesException(message, exception); + } + break; + case 537: + exception = new IllegalStateException(message, exception); + break; + } + } finally { + Closeables2.closeQuietly(response.getPayload()); + command.setException(exception); + } + } + + public String parseMessage(HttpResponse response) { + if (response.getPayload() == null) + return null; + try { + return Strings2.toStringAndClose(response.getPayload().openStream()); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + response.getPayload().getInput().close(); + } catch (IOException e) { + Throwables.propagate(e); + } + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/handlers/InvalidateSessionAndRetryOn401AndLogoutOnClose.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/handlers/InvalidateSessionAndRetryOn401AndLogoutOnClose.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/handlers/InvalidateSessionAndRetryOn401AndLogoutOnClose.java new file mode 100644 index 0000000..119e6b5 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/handlers/InvalidateSessionAndRetryOn401AndLogoutOnClose.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.handlers; + +import static org.jclouds.http.HttpUtils.releasePayload; + +import javax.annotation.PreDestroy; + +import org.jclouds.cloudstack.domain.LoginResponse; +import org.jclouds.cloudstack.features.SessionApi; +import org.jclouds.domain.Credentials; +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.handlers.BackoffLimitedRetryHandler; + +import com.google.common.cache.LoadingCache; +import com.google.inject.Inject; +import com.google.inject.Singleton; + +/** + * This will parse and set an appropriate exception on the command object. + */ +@Singleton +public class InvalidateSessionAndRetryOn401AndLogoutOnClose extends BackoffLimitedRetryHandler { + private final LoadingCache<Credentials, LoginResponse> authenticationResponseCache; + private final SessionApi sessionClient; + + @Inject + protected InvalidateSessionAndRetryOn401AndLogoutOnClose(LoadingCache<Credentials, LoginResponse> authenticationResponseCache, + SessionApi sessionClient) { + this.authenticationResponseCache = authenticationResponseCache; + this.sessionClient = sessionClient; + } + + @Override + public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { + try { + switch (response.getStatusCode()) { + case 401: + authenticationResponseCache.invalidateAll(); + return super.shouldRetryRequest(command, response); + } + return false; + + } finally { + releasePayload(response); + } + } + + /** + * it is important that we close any sessions on close to help the server not become overloaded. + */ + @PreDestroy + public void logoutOnClose() { + for (LoginResponse s : authenticationResponseCache.asMap().values()) { + try { + sessionClient.logoutUser(s.getSessionKey()); + } catch (Exception e) { + logger.error(e, "error logging out session %s", s.getSessionKey()); + } + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java new file mode 100644 index 0000000..962b751 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.internal; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.Context; +import org.jclouds.cloudstack.CloudStackApi; +import org.jclouds.cloudstack.CloudStackContext; +import org.jclouds.cloudstack.CloudStackDomainApi; +import org.jclouds.cloudstack.CloudStackGlobalApi; +import org.jclouds.compute.ComputeService; +import org.jclouds.compute.Utils; +import org.jclouds.compute.internal.ComputeServiceContextImpl; +import org.jclouds.location.Provider; +import org.jclouds.rest.ApiContext; + +import com.google.common.reflect.TypeToken; + +@Singleton +public class CloudStackContextImpl extends ComputeServiceContextImpl implements CloudStackContext { + private final CloudStackApi client; + private final ApiContext<CloudStackDomainApi> domainContext; + private final ApiContext<CloudStackGlobalApi> globalContext; + + @Inject + CloudStackContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType, + ComputeService computeService, Utils utils, CloudStackApi client, + ApiContext<CloudStackDomainApi> domainContext, + ApiContext<CloudStackGlobalApi> globalContext) { + super(backend, backendType, computeService, utils); + this.client = client; + this.domainContext = domainContext; + this.globalContext = globalContext; + } + + @Override + public CloudStackApi getApi() { + return client; + } + + @Override + public CloudStackDomainApi getDomainApi() { + return domainContext.getApi(); + } + + @Override + public CloudStackGlobalApi getGlobalApi() { + return globalContext.getApi(); + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/loaders/LoginWithPasswordCredentials.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/loaders/LoginWithPasswordCredentials.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/loaders/LoginWithPasswordCredentials.java new file mode 100644 index 0000000..9d6ca1b --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/loaders/LoginWithPasswordCredentials.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.loaders; + +import static com.google.common.base.Charsets.UTF_8; +import static com.google.common.hash.Hashing.md5; +import static com.google.common.io.BaseEncoding.base16; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.cloudstack.domain.LoginResponse; +import org.jclouds.cloudstack.features.SessionApi; +import org.jclouds.domain.Credentials; + +import com.google.common.cache.CacheLoader; + +@Singleton +public class LoginWithPasswordCredentials extends CacheLoader<Credentials, LoginResponse> { + private final SessionApi client; + + @Inject + public LoginWithPasswordCredentials(SessionApi client) { + this.client = client; + } + + @Override + public LoginResponse load(Credentials input) { + String username = input.identity; + String domain = ""; // empty = ROOT domain + + // domain may be present + if (username.indexOf('/') != -1) { + // username may not end with slash! + domain = username.substring(0, username.lastIndexOf('/')); + username = username.substring(username.lastIndexOf('/') + 1, username.length()); + } + String hashedPassword = base16().lowerCase().encode(md5().hashString(input.credential, UTF_8).asBytes()); + return client.loginUserInDomainWithHashOfPassword(username, domain, hashedPassword); + } + + @Override + public String toString() { + return "loginWithPasswordCredentials()"; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AccountInDomainOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AccountInDomainOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AccountInDomainOptions.java new file mode 100644 index 0000000..9d990da --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AccountInDomainOptions.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; + +/** + * Options for services that apply to accounts in domains + * + * @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" /> + */ +public class AccountInDomainOptions extends BaseHttpRequestOptions { + + public static final AccountInDomainOptions NONE = new AccountInDomainOptions(); + + /** + * + * @param account + * an optional account for the resource + * @param domain + * domain id + */ + public AccountInDomainOptions accountInDomain(String account, String domain) { + this.queryParameters.replaceValues("account", ImmutableSet.of(account)); + this.queryParameters.replaceValues("domainid", ImmutableSet.of(domain + "")); + return this; + } + + /** + * @param domainId + * The domain for the resource + */ + public AccountInDomainOptions domainId(String domainId) { + this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + "")); + return this; + + } + + public static class Builder { + /** + * @see AccountInDomainOptions#accountInDomain + */ + public static AccountInDomainOptions accountInDomain(String account, String domain) { + AccountInDomainOptions options = new AccountInDomainOptions(); + return options.accountInDomain(account, domain); + } + + /** + * @see AccountInDomainOptions#domainId + */ + public static AccountInDomainOptions domainId(String domainId) { + AccountInDomainOptions options = new AccountInDomainOptions(); + return options.domainId(domainId); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddClusterOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddClusterOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddClusterOptions.java new file mode 100644 index 0000000..ff24415 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddClusterOptions.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import org.jclouds.cloudstack.domain.AllocationState; +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; + +/** + * Options to the GlobalHostApi.addHost() API call + */ +public class AddClusterOptions extends BaseHttpRequestOptions { + + public static final AddClusterOptions NONE = new AddClusterOptions(); + + /** + * @param allocationState Allocation state of this Host for allocation of new resources + */ + public AddClusterOptions allocationState(AllocationState allocationState) { + this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString())); + return this; + } + + /** + * @param password the password for the host + */ + public AddClusterOptions password(String password) { + this.queryParameters.replaceValues("password", ImmutableSet.of(password)); + return this; + } + + /** + * @param podId the Pod ID for the host + */ + public AddClusterOptions podId(String podId) { + this.queryParameters.replaceValues("podid", ImmutableSet.of(podId + "")); + return this; + } + + /** + * @param url the URL + */ + public AddClusterOptions url(String url) { + this.queryParameters.replaceValues("url", ImmutableSet.of(url)); + return this; + } + + /** + * @param username the username for the cluster + */ + public AddClusterOptions username(String username) { + this.queryParameters.replaceValues("username", ImmutableSet.of(username)); + return this; + } + + public static class Builder { + + /** + * @param allocationState Allocation state of this Host for allocation of new resources + */ + public static AddClusterOptions allocationState(AllocationState allocationState) { + return new AddClusterOptions().allocationState(allocationState); + } + + /** + * @param password the password for the host + */ + public static AddClusterOptions password(String password) { + return new AddClusterOptions().password(password); + } + + /** + * @param podId the Pod ID for the host + */ + public static AddClusterOptions podId(String podId) { + return new AddClusterOptions().podId(podId); + } + + /** + * @param url the URL + */ + public static AddClusterOptions url(String url) { + return new AddClusterOptions().url(url); + } + + /** + * @param username the username for the cluster + */ + public static AddClusterOptions username(String username) { + return new AddClusterOptions().username(username); + } + + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddHostOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddHostOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddHostOptions.java new file mode 100644 index 0000000..49037ad --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddHostOptions.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import java.util.Set; + +import org.jclouds.cloudstack.domain.AllocationState; +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableSet; + +/** + * Options to the GlobalHostApi.addHost() API call + */ +public class AddHostOptions extends BaseHttpRequestOptions { + + public static final AddHostOptions NONE = new AddHostOptions(); + + /** + * @param allocationState Allocation state of this Host for allocation of new resources + */ + public AddHostOptions allocationState(AllocationState allocationState) { + this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString())); + return this; + } + + /** + * @param clusterId the cluster ID for the host + */ + public AddHostOptions clusterId(String clusterId) { + this.queryParameters.replaceValues("clusterid", ImmutableSet.of(clusterId + "")); + return this; + } + + /** + * @param clusterName the cluster name for the host + */ + public AddHostOptions clusterName(String clusterName) { + this.queryParameters.replaceValues("clustername", ImmutableSet.of(clusterName)); + return this; + } + + /** + * @param hostTags list of tags to be added to the host + */ + public AddHostOptions hostTags(Set<String> hostTags) { + this.queryParameters.replaceValues("hosttags", ImmutableSet.of(Joiner.on(',').join(hostTags))); + return this; + } + + /** + * @param podId the Pod ID for the host + */ + public AddHostOptions podId(String podId) { + this.queryParameters.replaceValues("podid", ImmutableSet.of(podId + "")); + return this; + } + + public static class Builder { + + /** + * @param allocationState Allocation state of this Host for allocation of new resources + */ + public static AddHostOptions allocationState(AllocationState allocationState) { + return new AddHostOptions().allocationState(allocationState); + } + + /** + * @param clusterId the cluster ID for the host + */ + public static AddHostOptions clusterId(String clusterId) { + return new AddHostOptions().clusterId(clusterId); + } + + /** + * @param clusterName the cluster name for the host + */ + public static AddHostOptions clusterName(String clusterName) { + return new AddHostOptions().clusterName(clusterName); + } + + /** + * @param hostTags list of tags to be added to the host + */ + public static AddHostOptions hostTags(Set<String> hostTags) { + return new AddHostOptions().hostTags(hostTags); + } + + /** + * @param podId the Pod ID for the host + */ + public static AddHostOptions podId(String podId) { + return new AddHostOptions().podId(podId); + } + + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddSecondaryStorageOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddSecondaryStorageOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddSecondaryStorageOptions.java new file mode 100644 index 0000000..4e5b718 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AddSecondaryStorageOptions.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; + +/** + * Options for the GlobalHostApi.addSecondaryStorage() API call + */ +public class AddSecondaryStorageOptions extends BaseHttpRequestOptions { + + public static final AddSecondaryStorageOptions NONE = new AddSecondaryStorageOptions(); + + /** + * @param zoneId + * the ID of the zone + */ + public AddSecondaryStorageOptions zoneId(String zoneId) { + this.queryParameters.replaceValues("zoneid", ImmutableSet.of(zoneId + "")); + return this; + } + + public static class Builder { + + /** + * @param zoneId + * the ID of the zone + */ + public static AddSecondaryStorageOptions zoneId(String zoneId) { + return new AddSecondaryStorageOptions().zoneId(zoneId); + } + + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AssignVirtualMachineOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AssignVirtualMachineOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AssignVirtualMachineOptions.java new file mode 100644 index 0000000..26c5e64 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AssignVirtualMachineOptions.java @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import com.google.common.base.Function; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; + +/** + * Options used to control what disk offerings are returned + * + * @see <a href= + * "http://download.cloud.com/releases/3.0.3/api_3.0.3/root_admin/assignVirtualMachine.html" + * /> + */ +public class AssignVirtualMachineOptions extends AccountInDomainOptions { + + public static final AssignVirtualMachineOptions NONE = new AssignVirtualMachineOptions(); + + /** + * @param networkId + * network id used by virtual machine + */ + public AssignVirtualMachineOptions networkId(String networkId) { + this.queryParameters.replaceValues("networkids", ImmutableSet.of(networkId + "")); + return this; + } + + /** + * @param networkIds + * network ids used by virtual machine + */ + public AssignVirtualMachineOptions networkIds(Iterable<String> networkIds) { + this.queryParameters.replaceValues("networkids", ImmutableSet.of(Joiner.on(',').join(networkIds))); + return this; + } + + public Iterable<String> getNetworkIds() { + if (queryParameters.get("networkids").size() == 1) { + return Iterables.transform( + Splitter.on(",").split(Iterables.getOnlyElement(queryParameters.get("networkids"))), + new Function<String, String>() { + + @Override + public String apply(String arg0) { + return arg0; + } + + }); + } else { + return ImmutableSet.<String> of(); + } + } + + /** + * @param securityGroupId + * security group applied to the virtual machine. Should be passed + * only when vm is created from a zone with Basic Network support + */ + public AssignVirtualMachineOptions securityGroupId(String securityGroupId) { + this.queryParameters.replaceValues("securitygroupids", ImmutableSet.of(securityGroupId + "")); + return this; + } + + /** + * @param securityGroupIds + * security groups applied to the virtual machine. Should be passed + * only when vm is created from a zone with Basic Network support + */ + public AssignVirtualMachineOptions securityGroupIds(Iterable<String> securityGroupIds) { + this.queryParameters.replaceValues("securitygroupids", ImmutableSet.of(Joiner.on(',').join(securityGroupIds))); + return this; + } + + public static class Builder { + /** + * @see AssignVirtualMachineOptions#networkId + */ + public static AssignVirtualMachineOptions networkId(String id) { + AssignVirtualMachineOptions options = new AssignVirtualMachineOptions(); + return options.networkId(id); + } + + /** + * @see AssignVirtualMachineOptions#networkIds + */ + public static AssignVirtualMachineOptions networkIds(Iterable<String> networkIds) { + AssignVirtualMachineOptions options = new AssignVirtualMachineOptions(); + return options.networkIds(networkIds); + } + + /** + * @see AssignVirtualMachineOptions#securityGroupId + */ + public static AssignVirtualMachineOptions securityGroupId(String id) { + AssignVirtualMachineOptions options = new AssignVirtualMachineOptions(); + return options.securityGroupId(id); + } + + /** + * @see AssignVirtualMachineOptions#securityGroupIds + */ + public static AssignVirtualMachineOptions securityGroupIds(Iterable<String> securityGroupIds) { + AssignVirtualMachineOptions options = new AssignVirtualMachineOptions(); + return options.securityGroupIds(securityGroupIds); + } + + /** + * @see AssignVirtualMachineOptions#accountInDomain + */ + public static AssignVirtualMachineOptions accountInDomain(String account, String domain) { + AssignVirtualMachineOptions options = new AssignVirtualMachineOptions(); + return options.accountInDomain(account, domain); + } + + /** + * @see AssignVirtualMachineOptions#domainId + */ + public static AssignVirtualMachineOptions domainId(String domainId) { + AssignVirtualMachineOptions options = new AssignVirtualMachineOptions(); + return options.domainId(domainId); + } + } + + /** + * {@inheritDoc} + */ + @Override + public AssignVirtualMachineOptions accountInDomain(String account, String domain) { + return AssignVirtualMachineOptions.class.cast(super.accountInDomain(account, domain)); + } + + /** + * {@inheritDoc} + */ + @Override + public AssignVirtualMachineOptions domainId(String domainId) { + return AssignVirtualMachineOptions.class.cast(super.domainId(domainId)); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AssociateIPAddressOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AssociateIPAddressOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AssociateIPAddressOptions.java new file mode 100644 index 0000000..a4d507c --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/AssociateIPAddressOptions.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import com.google.common.collect.ImmutableSet; + +/** + * Options used to acquire and associate a public IP to an account. + * + * @see <a href= + * "http://download.cloud.com/releases/2.2.0/api/user/associateIpAddress.html" + * /> + */ +public class AssociateIPAddressOptions extends AccountInDomainOptions { + + public static final AssociateIPAddressOptions NONE = new AssociateIPAddressOptions(); + + /** + * @param networkId + * The network this ip address should be associated to. + */ + public AssociateIPAddressOptions networkId(String networkId) { + this.queryParameters.replaceValues("networkid", ImmutableSet.of(networkId + "")); + return this; + + } + + /** + * @param projectId + * Project for the IP + */ + public AssociateIPAddressOptions projectId(String projectId) { + this.queryParameters.replaceValues("projectid", ImmutableSet.of(projectId + "")); + return this; + } + + public static class Builder { + + /** + * @see AssociateIPAddressOptions#networkId + */ + public static AssociateIPAddressOptions networkId(String networkId) { + AssociateIPAddressOptions options = new AssociateIPAddressOptions(); + return options.networkId(networkId); + } + + /** + * @see AssociateIPAddressOptions#accountInDomain + */ + public static AssociateIPAddressOptions accountInDomain(String account, String domain) { + AssociateIPAddressOptions options = new AssociateIPAddressOptions(); + return options.accountInDomain(account, domain); + } + + /** + * @see AssociateIPAddressOptions#domainId + */ + public static AssociateIPAddressOptions domainId(String domainId) { + AssociateIPAddressOptions options = new AssociateIPAddressOptions(); + return options.domainId(domainId); + } + + /** + * @see AssociateIPAddressOptions#projectId(String) + */ + public static AssociateIPAddressOptions projectId(String projectId) { + AssociateIPAddressOptions options = new AssociateIPAddressOptions(); + return options.projectId(projectId); + } + } + + /** + * {@inheritDoc} + */ + @Override + public AssociateIPAddressOptions accountInDomain(String account, String domain) { + return AssociateIPAddressOptions.class.cast(super.accountInDomain(account, domain)); + } + + /** + * {@inheritDoc} + */ + @Override + public AssociateIPAddressOptions domainId(String domainId) { + return AssociateIPAddressOptions.class.cast(super.domainId(domainId)); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateAccountOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateAccountOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateAccountOptions.java new file mode 100644 index 0000000..b82e9ff --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateAccountOptions.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; + +/** + * Optional fields for account creation + * + * @see <a + * href="http://download.cloud.com/releases/2.2.0/api_2.2.12/global_admin/createAccount.html" + * /> + */ +public class CreateAccountOptions extends BaseHttpRequestOptions { + + public static final CreateAccountOptions NONE = new CreateAccountOptions(); + + /** + * @param networkDomain network domain + */ + public CreateAccountOptions networkDomain(String networkDomain) { + this.queryParameters.replaceValues("networkdomain", ImmutableSet.of(networkDomain)); + return this; + } + + /** + * @param account an optional account for the resource + */ + public CreateAccountOptions account(String account) { + this.queryParameters.replaceValues("account", ImmutableSet.of(account)); + return this; + } + + /** + * @param domainId The domain for the resource + */ + public CreateAccountOptions domainId(String domainId) { + this.queryParameters.replaceValues("domainid", ImmutableSet.of(domainId + "")); + return this; + + } + + public static class Builder { + + /** + * @see CreateAccountOptions#networkDomain + */ + public static CreateAccountOptions networkDomain(String networkDomain) { + CreateAccountOptions options = new CreateAccountOptions(); + return options.networkDomain(networkDomain); + } + + /** + * @see CreateAccountOptions#account + */ + public static CreateAccountOptions account(String account) { + CreateAccountOptions options = new CreateAccountOptions(); + return options.account(account); + } + + /** + * @see CreateAccountOptions#domainId + */ + public static CreateAccountOptions domainId(String domainId) { + CreateAccountOptions options = new CreateAccountOptions(); + return options.domainId(domainId); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateDiskOfferingOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateDiskOfferingOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateDiskOfferingOptions.java new file mode 100644 index 0000000..18c17c9 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateDiskOfferingOptions.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import java.util.Set; + +import com.google.common.collect.ImmutableSet; + +/** + * Options to control how disk offerings are created + * + * @see <a + * href="http://download.cloud.com/releases/2.2.0/api_2.2.12/global_admin/createDiskOffering.html" + * /> + */ +public class CreateDiskOfferingOptions extends AccountInDomainOptions { + + public static final CreateDiskOfferingOptions NONE = new CreateDiskOfferingOptions(); + + /** + * @param customized + * whether disk offering is custom or not + */ + public CreateDiskOfferingOptions customized(boolean customized) { + this.queryParameters.replaceValues("customized", ImmutableSet.<String>of(customized + "")); + return this; + } + + /** + * @param diskSizeInGB + * size of the disk offering in GB + */ + public CreateDiskOfferingOptions diskSizeInGB(int diskSizeInGB) { + this.queryParameters.replaceValues("disksize", ImmutableSet.<String>of(diskSizeInGB + "")); + return this; + } + + /** + * @param tags + * the tags for this service offering + */ + public CreateDiskOfferingOptions tags(Set<String> tags) { + this.queryParameters.replaceValues("tags", ImmutableSet.copyOf(tags)); + return this; + } + + public static class Builder { + + /** + * @see CreateDiskOfferingOptions#customized + */ + public static CreateDiskOfferingOptions customized(boolean customized) { + CreateDiskOfferingOptions options = new CreateDiskOfferingOptions(); + return options.customized(customized); + } + + /** + * @see CreateDiskOfferingOptions#diskSizeInGB + */ + public static CreateDiskOfferingOptions diskSizeInGB(int diskSizeInGB) { + CreateDiskOfferingOptions options = new CreateDiskOfferingOptions(); + return options.diskSizeInGB(diskSizeInGB); + } + + /** + * @see CreateDiskOfferingOptions#tags + */ + public static CreateDiskOfferingOptions tags(Set<String> tags) { + CreateDiskOfferingOptions options = new CreateDiskOfferingOptions(); + return options.tags(tags); + } + + /** + * @see CreateDiskOfferingOptions#accountInDomain + */ + public static CreateDiskOfferingOptions accountInDomain(String account, String domain) { + CreateDiskOfferingOptions options = new CreateDiskOfferingOptions(); + return options.accountInDomain(account, domain); + } + + /** + * @see CreateDiskOfferingOptions#domainId + */ + public static CreateDiskOfferingOptions domainId(String domainId) { + CreateDiskOfferingOptions options = new CreateDiskOfferingOptions(); + return options.domainId(domainId); + } + } + + /** + * {@inheritDoc} + */ + @Override + public CreateDiskOfferingOptions accountInDomain(String account, String domain) { + return CreateDiskOfferingOptions.class.cast(super.accountInDomain(account, domain)); + } + + /** + * {@inheritDoc} + */ + @Override + public CreateDiskOfferingOptions domainId(String domainId) { + return CreateDiskOfferingOptions.class.cast(super.domainId(domainId)); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateDomainOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateDomainOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateDomainOptions.java new file mode 100644 index 0000000..17c65bb --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateDomainOptions.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; + +/** + * Options used to control how a domain is created + * + * @see <a href= + * "http://download.cloud.com/releases/2.2.0/api_2.2.12/global_admin/createDomain.html" + * /> + */ +public class CreateDomainOptions extends BaseHttpRequestOptions { + + public static final CreateDomainOptions NONE = new CreateDomainOptions(); + + /** + * @param networkDomain + * network domain for networks in the domain + */ + public CreateDomainOptions networkDomain(String networkDomain) { + this.queryParameters.replaceValues("networkdomain", ImmutableSet.of(networkDomain)); + return this; + } + + /** + * @param parentDomainId + * the ID of the parent domain + */ + public CreateDomainOptions parentDomainId(String parentDomainId) { + this.queryParameters.replaceValues("parentdomainid", ImmutableSet.of(parentDomainId + "")); + return this; + } + + public static class Builder { + + /** + * @see CreateDomainOptions#networkDomain + */ + public static CreateDomainOptions networkDomain(String networkDomain) { + CreateDomainOptions options = new CreateDomainOptions(); + return options.networkDomain(networkDomain); + } + + /** + * @see CreateDomainOptions#parentDomainId + */ + public static CreateDomainOptions parentDomainId(String parentDomainId) { + CreateDomainOptions options = new CreateDomainOptions(); + return options.parentDomainId(parentDomainId); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateFirewallRuleOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateFirewallRuleOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateFirewallRuleOptions.java new file mode 100644 index 0000000..5804be6 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateFirewallRuleOptions.java @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import java.util.Set; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableSet; + +/** + * Options used to control how a firewall rule is created + * + * @see <a href= + * "http://download.cloud.com/releases/2.2.0/api_2.2.12/global_admin/createFirewallRule.html" + * /> + */ +public class CreateFirewallRuleOptions extends BaseHttpRequestOptions { + + public static final CreateFirewallRuleOptions NONE = new CreateFirewallRuleOptions(); + + /** + * @param CIDRs + * the list of CIDRs to forward traffic from + */ + public CreateFirewallRuleOptions CIDRs(Set<String> CIDRs) { + this.queryParameters.replaceValues("cidrlist", ImmutableSet.of(Joiner.on(",").join(CIDRs))); + return this; + } + + /** + * @param startPort + * the starting port of firewall rule + */ + public CreateFirewallRuleOptions startPort(int startPort) { + this.queryParameters.replaceValues("startport", ImmutableSet.of(startPort + "")); + return this; + } + + /** + * @param endPort + * the ending port of firewall rule + */ + public CreateFirewallRuleOptions endPort(int endPort) { + this.queryParameters.replaceValues("endport", ImmutableSet.of(endPort + "")); + return this; + } + + /** + * @param icmpCode + * error code for this icmp message + */ + public CreateFirewallRuleOptions icmpCode(String icmpCode) { + this.queryParameters.replaceValues("icmpcode", ImmutableSet.of(icmpCode)); + return this; + } + + /** + * @param icmpType + * type of the icmp message being sent + */ + public CreateFirewallRuleOptions icmpType(String icmpType) { + this.queryParameters.replaceValues("icmptype", ImmutableSet.of(icmpType)); + return this; + } + + public static class Builder { + + /** + * @see CreateFirewallRuleOptions#CIDRs + */ + public static CreateFirewallRuleOptions CIDRs(Set<String> CIDRs) { + CreateFirewallRuleOptions options = new CreateFirewallRuleOptions(); + return options.CIDRs(CIDRs); + } + + /** + * @see CreateFirewallRuleOptions#startPort + */ + public static CreateFirewallRuleOptions startPort(int startPort) { + CreateFirewallRuleOptions options = new CreateFirewallRuleOptions(); + return options.startPort(startPort); + } + + /** + * @see CreateFirewallRuleOptions#endPort + */ + public static CreateFirewallRuleOptions endPort(int endPort) { + CreateFirewallRuleOptions options = new CreateFirewallRuleOptions(); + return options.endPort(endPort); + } + + /** + * @see CreateFirewallRuleOptions#icmpCode + */ + public static CreateFirewallRuleOptions icmpCode(String icmpCode) { + CreateFirewallRuleOptions options = new CreateFirewallRuleOptions(); + return options.icmpCode(icmpCode); + } + + /** + * @see CreateFirewallRuleOptions#icmpType + */ + public static CreateFirewallRuleOptions icmpType(String icmpType) { + CreateFirewallRuleOptions options = new CreateFirewallRuleOptions(); + return options.icmpType(icmpType); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateIPForwardingRuleOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateIPForwardingRuleOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateIPForwardingRuleOptions.java new file mode 100644 index 0000000..4229efa --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateIPForwardingRuleOptions.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; + +/** + * Options used to create an ip forwarding rule + * + * @see <a href= + * "http://download.cloud.com/releases/2.2.0/api/user/createIpForwardingRule.html" + * /> + */ +public class CreateIPForwardingRuleOptions extends BaseHttpRequestOptions { + + public static final CreateIPForwardingRuleOptions NONE = new CreateIPForwardingRuleOptions(); + + /** + * @param endPort + * the end port for the rule + */ + public CreateIPForwardingRuleOptions endPort(int endPort) { + this.queryParameters.replaceValues("endport", ImmutableSet.of(endPort + "")); + return this; + + } + + public static class Builder { + + /** + * @see CreatePortForwardingRuleOptions#endPort + */ + public static CreateIPForwardingRuleOptions endPort(int endPort) { + CreateIPForwardingRuleOptions options = new CreateIPForwardingRuleOptions(); + return options.endPort(endPort); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateLoadBalancerRuleOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateLoadBalancerRuleOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateLoadBalancerRuleOptions.java new file mode 100644 index 0000000..1f826a0 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateLoadBalancerRuleOptions.java @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import java.util.Set; + +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableSet; + +/** + * Options used to control what load balancer rules are returned + * + * @see <a href= + * "http://download.cloud.com/releases/2.2.0/api_2.2.12/user/createLoadBalancerRule.html" + * /> + */ +public class CreateLoadBalancerRuleOptions extends AccountInDomainOptions { + + public static final CreateLoadBalancerRuleOptions NONE = new CreateLoadBalancerRuleOptions(); + + /** + * @param allowedSourceCIRDs the cidr list to forward traffic from + */ + public CreateLoadBalancerRuleOptions allowedSourceCIDRs(Set<String> allowedSourceCIRDs) { + this.queryParameters.replaceValues("cidrlist", + ImmutableSet.of(Joiner.on(",").join(allowedSourceCIRDs))); + return this; + } + + /** + * @param description the description of the load balancer rule + */ + public CreateLoadBalancerRuleOptions description(String description) { + this.queryParameters.replaceValues("description", ImmutableSet.of(description)); + return this; + } + + /** + * @param openFirewall if true, firewall rule for source/end pubic port is automatically + * created; if false - firewall rule has to be created explicitly. Has value true by default + */ + public CreateLoadBalancerRuleOptions openFirewall(boolean openFirewall) { + this.queryParameters.replaceValues("openfirewall", ImmutableSet.of(openFirewall + "")); + return this; + } + + /** + * @param zoneId the availability zone ID + */ + public CreateLoadBalancerRuleOptions zoneId(String zoneId) { + this.queryParameters.replaceValues("zoneid", ImmutableSet.of(zoneId + "")); + return this; + } + + public static class Builder { + + /** + * @see CreateLoadBalancerRuleOptions#allowedSourceCIDRs + */ + public static CreateLoadBalancerRuleOptions allowedSourceCIDRs(Set<String> allowedSourceCIDRs) { + CreateLoadBalancerRuleOptions options = new CreateLoadBalancerRuleOptions(); + return options.allowedSourceCIDRs(allowedSourceCIDRs); + } + + /** + * @see CreateLoadBalancerRuleOptions#description + */ + public static CreateLoadBalancerRuleOptions description(String description) { + CreateLoadBalancerRuleOptions options = new CreateLoadBalancerRuleOptions(); + return options.description(description); + } + + /** + * @see CreateLoadBalancerRuleOptions#openFirewall + */ + public static CreateLoadBalancerRuleOptions openFirewall(boolean openFirewall) { + CreateLoadBalancerRuleOptions options = new CreateLoadBalancerRuleOptions(); + return options.openFirewall(openFirewall); + } + + /** + * @see CreateLoadBalancerRuleOptions#zoneId + */ + public static CreateLoadBalancerRuleOptions zoneId(String zoneId) { + CreateLoadBalancerRuleOptions options = new CreateLoadBalancerRuleOptions(); + return options.zoneId(zoneId); + } + + /** + * @see CreateLoadBalancerRuleOptions#accountInDomain + */ + public static CreateLoadBalancerRuleOptions accountInDomain(String account, String domain) { + CreateLoadBalancerRuleOptions options = new CreateLoadBalancerRuleOptions(); + return options.accountInDomain(account, domain); + } + + /** + * @see CreateLoadBalancerRuleOptions#domainId + */ + public static CreateLoadBalancerRuleOptions domainId(String id) { + CreateLoadBalancerRuleOptions options = new CreateLoadBalancerRuleOptions(); + return options.domainId(id); + } + } + + /** + * {@inheritDoc} + */ + @Override + public CreateLoadBalancerRuleOptions accountInDomain(String account, String domain) { + return CreateLoadBalancerRuleOptions.class.cast(super.accountInDomain(account, domain)); + } + + /** + * {@inheritDoc} + */ + @Override + public CreateLoadBalancerRuleOptions domainId(String domainId) { + return CreateLoadBalancerRuleOptions.class.cast(super.domainId(domainId)); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateNetworkOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateNetworkOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateNetworkOptions.java new file mode 100644 index 0000000..2b75825 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreateNetworkOptions.java @@ -0,0 +1,236 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import com.google.common.collect.ImmutableSet; + +/** + * Optional fields for network creation + * + * @see <a + * href="http://download.cloud.com/releases/2.2.0/api_2.2.12/user/createNetwork.html" + * /> + */ +public class CreateNetworkOptions extends AccountInDomainOptions { + + public static final CreateNetworkOptions NONE = new CreateNetworkOptions(); + + /** + * @param isDefault + * true if network is default, false otherwise + */ + public CreateNetworkOptions isDefault(boolean isDefault) { + this.queryParameters.replaceValues("isdefault", ImmutableSet.of(isDefault + "")); + return this; + } + + /** + * @param isShared + * true if network is shared across accounts in the Zone + */ + public CreateNetworkOptions isShared(boolean isShared) { + this.queryParameters.replaceValues("isshared", ImmutableSet.of(isShared + "")); + return this; + } + + /** + * @param startIP + * the beginning IP address in the VLAN IP range + */ + public CreateNetworkOptions startIP(String startIP) { + this.queryParameters.replaceValues("startip", ImmutableSet.of(startIP)); + return this; + } + + /** + * @param endIP + * the ending IP address in the network IP range. If not specified, will be defaulted to startIP + */ + public CreateNetworkOptions endIP(String endIP) { + this.queryParameters.replaceValues("endip", ImmutableSet.of(endIP)); + return this; + } + + /** + * @param gateway + * the gateway of the VLAN IP range + */ + public CreateNetworkOptions gateway(String gateway) { + this.queryParameters.replaceValues("gateway", ImmutableSet.of(gateway)); + return this; + } + + /** + * @param netmask + * the netmask of the VLAN IP range + */ + public CreateNetworkOptions netmask(String netmask) { + this.queryParameters.replaceValues("netmask", ImmutableSet.of(netmask)); + return this; + } + + /** + * @param networkDomain + * network domain + */ + public CreateNetworkOptions networkDomain(String networkDomain) { + this.queryParameters.replaceValues("networkdomain", ImmutableSet.of(networkDomain)); + return this; + } + + /** + * @param vlan + * the ID or VID of the VLAN. Default is an "untagged" VLAN. + */ + public CreateNetworkOptions vlan(String vlan) { + this.queryParameters.replaceValues("vlan", ImmutableSet.of(vlan)); + return this; + } + + /** + * @param projectId + * the project this network will be in. + */ + public CreateNetworkOptions projectId(String projectId) { + this.queryParameters.replaceValues("projectid", ImmutableSet.of(projectId + "")); + return this; + } + + public static class Builder { + /** + * @see CreateNetworkOptions#isDefault + */ + public static CreateNetworkOptions isDefault(boolean isDefault) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.isDefault(isDefault); + } + + /** + * @see CreateNetworkOptions#isShared + */ + public static CreateNetworkOptions isShared(boolean isShared) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.isShared(isShared); + } + + /** + * @see CreateNetworkOptions#startIP(String) + */ + public static CreateNetworkOptions startIP(String startIP) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.startIP(startIP); + } + + /** + * @see CreateNetworkOptions#endIP(String) + */ + public static CreateNetworkOptions endIP(String endIP) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.endIP(endIP); + } + + /** + * @see CreateNetworkOptions#gateway(String) + */ + public static CreateNetworkOptions gateway(String gateway) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.gateway(gateway); + } + + /** + * @see CreateNetworkOptions#netmask(String) + */ + public static CreateNetworkOptions netmask(String netmask) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.netmask(netmask); + } + + /** + * @see CreateNetworkOptions#networkDomain(String) + */ + public static CreateNetworkOptions networkDomain(String networkDomain) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.networkDomain(networkDomain); + } + + /** + * @see CreateNetworkOptions#vlan(String) + */ + public static CreateNetworkOptions vlan(String vlan) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.vlan(vlan); + } + + /** + * @see CreateNetworkOptions#accountInDomain + */ + public static CreateNetworkOptions accountInDomain(String account, String domain) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.accountInDomain(account, domain); + } + + /** + * @see CreateNetworkOptions#domainId + */ + public static CreateNetworkOptions domainId(String domainId) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.domainId(domainId); + } + + /** + * @see CreateNetworkOptions#projectId(String) + */ + public static CreateNetworkOptions projectId(String projectId) { + CreateNetworkOptions options = new CreateNetworkOptions(); + return options.projectId(projectId); + } + } + + /** + * Specify the account that will own the network. This can be run by a privileged user to be + * able to set advanced network properties, such as the VLAN tag, and then to immediately pass + * ownership of the network to an unprivileged user. + * + * Note that the unprivileged user will be able to delete the network later, since they are it's owner. + * + * @param account + * account name + * @param domain + * domain ID + */ + @Override + public CreateNetworkOptions accountInDomain(String account, String domain) { + return CreateNetworkOptions.class.cast(super.accountInDomain(account, domain)); + } + + /** + * Specify the domain that will own the network. Any user in the domain can then use this + * network. + * + * CloudStack requires that when using this option, you also specify isShared(true). + * + * Changes or deletions to this network must be done by a domain admin in the same domain, or a + * global admin. + * + * @param domainId + * domain ID + */ + @Override + public CreateNetworkOptions domainId(String domainId) { + return CreateNetworkOptions.class.cast(super.domainId(domainId)); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreatePodOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreatePodOptions.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreatePodOptions.java new file mode 100644 index 0000000..712271d --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/options/CreatePodOptions.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.cloudstack.options; + +import org.jclouds.cloudstack.domain.AllocationState; +import org.jclouds.http.options.BaseHttpRequestOptions; + +import com.google.common.collect.ImmutableSet; + +/** + * Options to the GlobalPodApi.createPod API call. + */ +public class CreatePodOptions extends BaseHttpRequestOptions { + + public static final CreatePodOptions NONE = new CreatePodOptions(); + + public static class Builder { + + public static CreatePodOptions allocationState(AllocationState allocationState) { + return new CreatePodOptions().allocationState(allocationState); + } + + } + + public CreatePodOptions allocationState(AllocationState allocationState) { + this.queryParameters.replaceValues("allocationstate", ImmutableSet.of(allocationState.toString())); + return this; + } + +}
