mirror of https://github.com/apache/jclouds.git
Implemented updateAccount global admin API
This commit is contained in:
parent
d2eb9866c5
commit
a5fd2f7a05
|
@ -22,6 +22,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||
import org.jclouds.cloudstack.options.CreateAccountOptions;
|
||||
import org.jclouds.cloudstack.options.UpdateAccountOptions;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.QueryParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
|
@ -60,6 +61,17 @@ public interface GlobalAccountAsyncClient extends DomainAccountAsyncClient {
|
|||
@QueryParam("firstname") String firstName, @QueryParam("lastname") String lastName,
|
||||
@QueryParam("password") String hashedPassword, CreateAccountOptions... options);
|
||||
|
||||
/**
|
||||
* @see GlobalAccountClient#updateAccount
|
||||
*/
|
||||
@GET
|
||||
@QueryParams(keys = "command", values = "updateAccount")
|
||||
@SelectJson("account")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Account> updateAccount(@QueryParam("account") String accountName,
|
||||
@QueryParam("domainid") long domainId, @QueryParam("newname") String newName, UpdateAccountOptions... options);
|
||||
|
||||
/**
|
||||
* @see GlobalAccountClient#deleteAccount
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.options.CreateAccountOptions;
|
||||
import org.jclouds.cloudstack.options.UpdateAccountOptions;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
|
||||
/**
|
||||
|
@ -54,6 +55,17 @@ public interface GlobalAccountClient extends DomainAccountClient {
|
|||
Account createAccount(String userName, Account.Type accountType, String email,
|
||||
String firstName, String lastName, String hashedPassword, CreateAccountOptions... options);
|
||||
|
||||
/**
|
||||
* Update an existing account
|
||||
*
|
||||
* @param accountName the current account name
|
||||
* @param domainId the ID of the domain were the account exists
|
||||
* @param newName new name for the account
|
||||
* @param options optional arguments
|
||||
* @return
|
||||
*/
|
||||
Account updateAccount(String accountName, long domainId, String newName, UpdateAccountOptions... options);
|
||||
|
||||
/**
|
||||
* Delete an account with the specified ID
|
||||
*
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
/**
|
||||
* Optional arguments for updating an Account
|
||||
*
|
||||
* @see <a
|
||||
* href="http://download.cloud.com/releases/2.2.0/api_2.2.12/global_admin/updateAccount.html"
|
||||
* />
|
||||
* @author Andrei Savu
|
||||
*/
|
||||
public class UpdateAccountOptions extends BaseHttpRequestOptions {
|
||||
|
||||
public static final UpdateAccountOptions NONE = new UpdateAccountOptions();
|
||||
|
||||
/**
|
||||
* @param networkDomain
|
||||
* network domain for the account's networks
|
||||
*/
|
||||
public UpdateAccountOptions networkDomain(String networkDomain) {
|
||||
this.queryParameters.replaceValues("networkdomain", ImmutableSet.<String>of(networkDomain));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see UpdateAccountOptions#networkDomain
|
||||
*/
|
||||
public static UpdateAccountOptions networkDomain(String networkDomain) {
|
||||
UpdateAccountOptions options = new UpdateAccountOptions();
|
||||
return options.networkDomain(networkDomain);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -45,6 +44,12 @@ public class GlobalAccountClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
assertEquals(account.getName(), prefix + "-account");
|
||||
assertEquals(account.getType(), Account.Type.USER);
|
||||
|
||||
Account updated = globalAdminClient.getAccountClient().updateAccount(
|
||||
account.getName(), account.getDomainId(), prefix + "-account-2");
|
||||
|
||||
assertNotNull(updated);
|
||||
assertEquals(updated.getName(), prefix + "-account-2");
|
||||
|
||||
} finally {
|
||||
if (account != null) {
|
||||
globalAdminClient.getAccountClient().deleteAccount(account.getId());
|
||||
|
|
Loading…
Reference in New Issue