Search in sources :

Example 1 with SSHKeyPairResponse

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

the class ListSSHKeyPairsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    Pair<List<? extends SSHKeyPair>, Integer> resultList = _mgr.listSSHKeyPairs(this);
    List<SSHKeyPairResponse> responses = new ArrayList<SSHKeyPairResponse>();
    for (SSHKeyPair result : resultList.first()) {
        SSHKeyPairResponse r = _responseGenerator.createSSHKeyPairResponse(result, false);
        r.setObjectName("sshkeypair");
        responses.add(r);
    }
    ListResponse<SSHKeyPairResponse> response = new ListResponse<SSHKeyPairResponse>();
    response.setResponses(responses, resultList.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : SSHKeyPairResponse(org.apache.cloudstack.api.response.SSHKeyPairResponse) SSHKeyPair(com.cloud.user.SSHKeyPair) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with SSHKeyPairResponse

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

the class RegisterSSHKeyPairCmd method execute.

@Override
public void execute() {
    SSHKeyPair result = _mgr.registerSSHKeyPair(this);
    SSHKeyPairResponse response = _responseGenerator.createSSHKeyPairResponse(result, false);
    response.setResponseName(getCommandName());
    response.setObjectName("keypair");
    setResponseObject(response);
}
Also used : SSHKeyPairResponse(org.apache.cloudstack.api.response.SSHKeyPairResponse) SSHKeyPair(com.cloud.user.SSHKeyPair)

Example 3 with SSHKeyPairResponse

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

the class ApiResponseHelper method createSSHKeyPairResponse.

@Override
public SSHKeyPairResponse createSSHKeyPairResponse(SSHKeyPair sshkeyPair, boolean privatekey) {
    SSHKeyPairResponse response = new SSHKeyPairResponse(sshkeyPair.getName(), sshkeyPair.getFingerprint());
    if (privatekey) {
        response = new CreateSSHKeyPairResponse(sshkeyPair.getName(), sshkeyPair.getFingerprint(), sshkeyPair.getPrivateKey());
    }
    Account account = ApiDBUtils.findAccountById(sshkeyPair.getAccountId());
    response.setAccountName(account.getAccountName());
    Domain domain = ApiDBUtils.findDomainById(sshkeyPair.getDomainId());
    response.setDomainId(domain.getUuid());
    response.setDomainName(domain.getName());
    return response;
}
Also used : CreateSSHKeyPairResponse(org.apache.cloudstack.api.response.CreateSSHKeyPairResponse) SSHKeyPairResponse(org.apache.cloudstack.api.response.SSHKeyPairResponse) ProjectAccount(com.cloud.projects.ProjectAccount) UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) CreateSSHKeyPairResponse(org.apache.cloudstack.api.response.CreateSSHKeyPairResponse) Domain(com.cloud.domain.Domain)

Aggregations

SSHKeyPairResponse (org.apache.cloudstack.api.response.SSHKeyPairResponse)3 SSHKeyPair (com.cloud.user.SSHKeyPair)2 Domain (com.cloud.domain.Domain)1 ProjectAccount (com.cloud.projects.ProjectAccount)1 Account (com.cloud.user.Account)1 UserAccount (com.cloud.user.UserAccount)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CreateSSHKeyPairResponse (org.apache.cloudstack.api.response.CreateSSHKeyPairResponse)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1