Search in sources :

Example 1 with AccountResponse

use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.

the class UpdateAccountCmd method execute.

@Override
public void execute() {
    Account result = _accountService.updateAccount(this);
    if (result != null) {
        AccountResponse response = _responseGenerator.createAccountResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account");
    }
}
Also used : Account(com.cloud.user.Account) ServerApiException(com.cloud.api.ServerApiException) AccountResponse(com.cloud.api.response.AccountResponse)

Example 2 with AccountResponse

use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.

the class EnableAccountCmd method execute.

@Override
public void execute() {
    Account result = _accountService.enableAccount(getAccountName(), getDomainId(), getId());
    if (result != null) {
        AccountResponse response = _responseGenerator.createAccountResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable account");
    }
}
Also used : Account(com.cloud.user.Account) ServerApiException(com.cloud.api.ServerApiException) AccountResponse(com.cloud.api.response.AccountResponse)

Example 3 with AccountResponse

use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.

the class ListAccountsCmd method execute.

@Override
public void execute() {
    List<? extends Account> accounts = _accountService.searchForAccounts(this);
    ListResponse<AccountResponse> response = new ListResponse<AccountResponse>();
    List<AccountResponse> accountResponses = new ArrayList<AccountResponse>();
    for (Account account : accounts) {
        AccountResponse acctResponse = _responseGenerator.createAccountResponse(account);
        acctResponse.setObjectName("account");
        accountResponses.add(acctResponse);
    }
    response.setResponses(accountResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : Account(com.cloud.user.Account) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) AccountResponse(com.cloud.api.response.AccountResponse)

Example 4 with AccountResponse

use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.

the class CreateAccountCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId());
    UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), getDomainId(), getNetworkDomain(), getDetails());
    if (userAccount != null) {
        AccountResponse response = _responseGenerator.createUserAccountResponse(userAccount);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a user account");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) AccountResponse(com.cloud.api.response.AccountResponse) UserAccount(com.cloud.user.UserAccount)

Example 5 with AccountResponse

use of com.cloud.api.response.AccountResponse in project CloudStack-archive by CloudStack-extras.

the class DisableAccountCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
    UserContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId());
    Account result = null;
    if (lockRequested)
        result = _accountService.lockAccount(getAccountName(), getDomainId(), getId());
    else
        result = _accountService.disableAccount(getAccountName(), getDomainId(), getId());
    if (result != null) {
        AccountResponse response = _responseGenerator.createAccountResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account");
    }
}
Also used : Account(com.cloud.user.Account) ServerApiException(com.cloud.api.ServerApiException) AccountResponse(com.cloud.api.response.AccountResponse)

Aggregations

AccountResponse (com.cloud.api.response.AccountResponse)6 ServerApiException (com.cloud.api.ServerApiException)5 Account (com.cloud.user.Account)5 ListResponse (com.cloud.api.response.ListResponse)1 UserAccount (com.cloud.user.UserAccount)1 ArrayList (java.util.ArrayList)1