Search in sources :

Example 1 with VpnUsersResponse

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);
}
Also used : Account(com.cloud.user.Account) VpnUser(com.cloud.network.VpnUser) ServerApiException(com.cloud.api.ServerApiException) Domain(com.cloud.domain.Domain) VpnUsersResponse(com.cloud.api.response.VpnUsersResponse)

Example 2 with VpnUsersResponse

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;
}
Also used : VpnUsersResponse(com.cloud.api.response.VpnUsersResponse)

Example 3 with VpnUsersResponse

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);
}
Also used : VpnUser(com.cloud.network.VpnUser) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) VpnUsersResponse(com.cloud.api.response.VpnUsersResponse)

Example 4 with VpnUsersResponse

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);
}
Also used : Account(com.cloud.user.Account) VpnUser(com.cloud.network.VpnUser) ServerApiException(com.cloud.api.ServerApiException) VpnUsersResponse(com.cloud.api.response.VpnUsersResponse)

Example 5 with VpnUsersResponse

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);
}
Also used : VpnUser(com.cloud.network.VpnUser) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) VpnUsersResponse(com.cloud.api.response.VpnUsersResponse)

Aggregations

VpnUsersResponse (com.cloud.api.response.VpnUsersResponse)5 VpnUser (com.cloud.network.VpnUser)4 ServerApiException (com.cloud.api.ServerApiException)2 ListResponse (com.cloud.api.response.ListResponse)2 Account (com.cloud.user.Account)2 ArrayList (java.util.ArrayList)2 Domain (com.cloud.domain.Domain)1 List (java.util.List)1