use of com.cloud.api.response.VpnUsersResponse in project cosmic by MissionCriticalCloud.
the class AddVpnUserCmd method execute.
@Override
public void execute() {
final VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
final Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
}
final VpnUsersResponse vpnResponse = new VpnUsersResponse();
vpnResponse.setId(vpnUser.getUuid());
vpnResponse.setUserName(vpnUser.getUsername());
vpnResponse.setAccountName(account.getAccountName());
final 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);
}
use of com.cloud.api.response.VpnUsersResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createVpnUserResponse.
@Override
public VpnUsersResponse createVpnUserResponse(final VpnUser vpnUser) {
final 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 com.cloud.api.response.VpnUsersResponse in project CloudStack-archive by CloudStack-extras.
the class ListVpnUsersCmd method execute.
@Override
public void execute() {
List<? extends VpnUser> vpnUsers = _ravService.searchForVpnUsers(this);
ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
for (VpnUser vpnUser : vpnUsers) {
vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
}
response.setResponses(vpnResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.VpnUsersResponse in project CloudStack-archive by CloudStack-extras.
the class AddVpnUserCmd method execute.
@Override
public void execute() {
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
if (!_ravService.applyVpnUsers(vpnUser.getAccountId())) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
}
VpnUsersResponse vpnResponse = new VpnUsersResponse();
vpnResponse.setId(vpnUser.getId());
vpnResponse.setUserName(vpnUser.getUsername());
vpnResponse.setAccountName(account.getAccountName());
vpnResponse.setDomainId(account.getDomainId());
vpnResponse.setDomainName(_entityMgr.findById(Domain.class, account.getDomainId()).getName());
vpnResponse.setResponseName(getCommandName());
vpnResponse.setObjectName("vpnuser");
this.setResponseObject(vpnResponse);
}
use of com.cloud.api.response.VpnUsersResponse in project cosmic by MissionCriticalCloud.
the class ListVpnUsersCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends VpnUser>, Integer> vpnUsers = _ravService.searchForVpnUsers(this);
final ListResponse<VpnUsersResponse> response = new ListResponse<>();
final List<VpnUsersResponse> vpnResponses = new ArrayList<>();
for (final VpnUser vpnUser : vpnUsers.first()) {
vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
}
response.setResponses(vpnResponses, vpnUsers.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
Aggregations