use of org.apache.cloudstack.api.response.VpnUsersResponse in project cloudstack by apache.
the class ListVpnUsersCmd method execute.
@Override
public void execute() {
Pair<List<? extends VpnUser>, Integer> vpnUsers = _ravService.searchForVpnUsers(this);
ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
for (VpnUser vpnUser : vpnUsers.first()) {
vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
}
response.setResponses(vpnResponses, vpnUsers.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.VpnUsersResponse in project cloudstack by apache.
the class ApiResponseHelper method createVpnUserResponse.
@Override
public VpnUsersResponse createVpnUserResponse(VpnUser vpnUser) {
VpnUsersResponse vpnResponse = new VpnUsersResponse();
vpnResponse.setId(vpnUser.getUuid());
vpnResponse.setUserName(vpnUser.getUsername());
vpnResponse.setState(vpnUser.getState().toString());
populateOwner(vpnResponse, vpnUser);
vpnResponse.setObjectName("vpnuser");
return vpnResponse;
}
use of org.apache.cloudstack.api.response.VpnUsersResponse in project cloudstack by apache.
the class AddVpnUserCmd method execute.
@Override
public void execute() {
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
try {
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
}
} catch (Exception ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user due to resource unavailable");
}
VpnUsersResponse vpnResponse = new VpnUsersResponse();
vpnResponse.setId(vpnUser.getUuid());
vpnResponse.setUserName(vpnUser.getUsername());
vpnResponse.setAccountName(account.getAccountName());
Domain domain = _entityMgr.findById(Domain.class, account.getDomainId());
if (domain != null) {
vpnResponse.setDomainId(domain.getUuid());
vpnResponse.setDomainName(domain.getName());
}
vpnResponse.setResponseName(getCommandName());
vpnResponse.setObjectName("vpnuser");
setResponseObject(vpnResponse);
}
Aggregations