Search in sources :

Example 1 with AccountResponse

use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.

the class UpdateAccountCmd method execute.

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

Example 2 with AccountResponse

use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.

the class CreateAccountCmd method execute.

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

Example 3 with AccountResponse

use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.

the class MarkDefaultZoneForAccountCmd method execute.

@Override
public void execute() {
    Account result = _configService.markDefaultZone(getAccountName(), getDomainId(), getDefaultZoneId());
    if (result != null) {
        AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to mark the account with the default zone");
    }
}
Also used : Account(com.cloud.user.Account) ServerApiException(org.apache.cloudstack.api.ServerApiException) AccountResponse(org.apache.cloudstack.api.response.AccountResponse)

Example 4 with AccountResponse

use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.

the class QueryManagerImpl method searchForAccounts.

@Override
public ListResponse<AccountResponse> searchForAccounts(ListAccountsCmd cmd) {
    Pair<List<AccountJoinVO>, Integer> result = searchForAccountsInternal(cmd);
    ListResponse<AccountResponse> response = new ListResponse<AccountResponse>();
    ResponseView respView = ResponseView.Restricted;
    if (cmd instanceof ListAccountsCmdByAdmin) {
        respView = ResponseView.Full;
    }
    List<AccountResponse> accountResponses = ViewResponseHelper.createAccountResponse(respView, result.first().toArray(new AccountJoinVO[result.first().size()]));
    response.setResponses(accountResponses, result.second());
    return response;
}
Also used : ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) ProjectAccountResponse(org.apache.cloudstack.api.response.ProjectAccountResponse) AccountResponse(org.apache.cloudstack.api.response.AccountResponse) ListAccountsCmdByAdmin(org.apache.cloudstack.api.command.admin.account.ListAccountsCmdByAdmin) ProjectAccountJoinVO(com.cloud.api.query.vo.ProjectAccountJoinVO) UserAccountJoinVO(com.cloud.api.query.vo.UserAccountJoinVO) AccountJoinVO(com.cloud.api.query.vo.AccountJoinVO)

Example 5 with AccountResponse

use of org.apache.cloudstack.api.response.AccountResponse in project cloudstack by apache.

the class DisableAccountCmd method execute.

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

Aggregations

AccountResponse (org.apache.cloudstack.api.response.AccountResponse)9 ServerApiException (org.apache.cloudstack.api.ServerApiException)6 Account (com.cloud.user.Account)4 UserAccountJoinVO (com.cloud.api.query.vo.UserAccountJoinVO)2 UserAccount (com.cloud.user.UserAccount)2 ProjectAccountResponse (org.apache.cloudstack.api.response.ProjectAccountResponse)2 AccountJoinVO (com.cloud.api.query.vo.AccountJoinVO)1 ProjectAccountJoinVO (com.cloud.api.query.vo.ProjectAccountJoinVO)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Role (org.apache.cloudstack.acl.Role)1 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)1 ListAccountsCmdByAdmin (org.apache.cloudstack.api.command.admin.account.ListAccountsCmdByAdmin)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 UserResponse (org.apache.cloudstack.api.response.UserResponse)1 CallContext (org.apache.cloudstack.context.CallContext)1 LdapUser (org.apache.cloudstack.ldap.LdapUser)1 NoLdapUserMatchingQueryException (org.apache.cloudstack.ldap.NoLdapUserMatchingQueryException)1