Search in sources :

Example 1 with UrlDto

use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.

the class SwitchStoreService method getSwitch.

/**
 * Gets the switch with params.
 *
 * @return the switch with params
 */
public InventorySwitch getSwitch(String switchId) {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.SWITCH_STORE, Url.GET_SWITCH);
        Map<String, String> params = new HashMap<String, String>();
        params.put(RequestParams.SWITCH_ID.getName(), switchId);
        urlDto.setParams(params);
        AuthConfigDto authDto = authService.getAuth(StoreType.SWITCH_STORE);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        return authService.getResponse(urlDto, authDto, InventorySwitch.class);
    } catch (Exception e) {
        LOGGER.error("Error occurred while retriving switches. Switch Id: " + switchId, e);
        throw new StoreIntegrationException(e);
    }
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) HashMap(java.util.HashMap) IAuthService(org.openkilda.integration.auth.service.IAuthService) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) AuthConfigDto(org.openkilda.store.model.AuthConfigDto)

Example 2 with UrlDto

use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.

the class SwitchStoreService method getSwitchPort.

/**
 * Gets the switch port.
 *
 * @param switchId the switch id
 * @return the switch port
 */
public List<Port> getSwitchPort(final String switchId) {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.SWITCH_STORE, Url.GET_SWITCH_PORTS);
        AuthConfigDto authDto = authService.getAuth(StoreType.SWITCH_STORE);
        Map<String, String> params = new HashMap<String, String>();
        params.put(RequestParams.SWITCH_ID.getName(), switchId);
        urlDto.setParams(params);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        return authService.getResponseList(urlDto, authDto, Port.class);
    } catch (Exception e) {
        LOGGER.error("Error occurred while retriving switch ports. Switch Id: " + switchId, e);
        throw new StoreIntegrationException(e);
    }
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) HashMap(java.util.HashMap) IAuthService(org.openkilda.integration.auth.service.IAuthService) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) AuthConfigDto(org.openkilda.store.model.AuthConfigDto)

Example 3 with UrlDto

use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.

the class SwitchStoreService method getSwitches.

/**
 * Gets the switches with params.
 *
 * @return the switches with params
 */
public List<InventorySwitch> getSwitches() {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.SWITCH_STORE, Url.GET_ALL_SWITCHES);
        AuthConfigDto authDto = authService.getAuth(StoreType.SWITCH_STORE);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        return authService.getResponseList(urlDto, authDto, InventorySwitch.class);
    } catch (Exception e) {
        LOGGER.error("Error occurred while retriving switches", e);
        throw new StoreIntegrationException(e);
    }
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) IAuthService(org.openkilda.integration.auth.service.IAuthService) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) AuthConfigDto(org.openkilda.store.model.AuthConfigDto)

Example 4 with UrlDto

use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.

the class FlowStoreService method getContracts.

/**
 * Gets the all contracts.
 *
 * @param linkId
 *            the link id
 * @return the all contracts
 */
public List<Contract> getContracts(final String linkId) {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.LINK_STORE, Url.GET_CONTRACT);
        Map<String, String> params = new HashMap<String, String>();
        params.put(RequestParams.LINK_ID.getName(), linkId);
        urlDto.setParams(params);
        AuthConfigDto authDto = authService.getAuth(StoreType.LINK_STORE);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        return authService.getResponseList(urlDto, authDto, Contract.class);
    } catch (Exception e) {
        LOGGER.error("Error occurred while retriving contracts by link id: " + linkId, e);
        throw new StoreIntegrationException(e);
    }
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) HashMap(java.util.HashMap) IAuthService(org.openkilda.integration.auth.service.IAuthService) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) AuthConfigDto(org.openkilda.store.model.AuthConfigDto)

Example 5 with UrlDto

use of org.openkilda.store.model.UrlDto in project open-kilda by telstra.

the class FlowStoreService method deleteContract.

/**
 * Delete contract.
 *
 * @param linkId
 *            the link id
 * @param contractId
 *            the contract id
 */
public void deleteContract(final String linkId, final String contractId) {
    try {
        UrlDto urlDto = storeService.getUrl(StoreType.LINK_STORE, Url.DELETE_CONTRACT);
        Map<String, String> params = new HashMap<String, String>();
        params.put(RequestParams.LINK_ID.getName(), linkId);
        params.put(RequestParams.CONTRACT_ID.getName(), contractId);
        urlDto.setParams(params);
        AuthConfigDto authDto = authService.getAuth(StoreType.LINK_STORE);
        IAuthService authService = IAuthService.getService(authDto.getAuthType());
        authService.getResponse(urlDto, authDto, null);
    } catch (Exception e) {
        LOGGER.error("Error occurred while deleting contract: " + contractId, e);
        throw new StoreIntegrationException(e);
    }
}
Also used : UrlDto(org.openkilda.store.model.UrlDto) HashMap(java.util.HashMap) IAuthService(org.openkilda.integration.auth.service.IAuthService) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) StoreIntegrationException(org.openkilda.integration.exception.StoreIntegrationException) AuthConfigDto(org.openkilda.store.model.AuthConfigDto)

Aggregations

UrlDto (org.openkilda.store.model.UrlDto)17 HashMap (java.util.HashMap)11 IAuthService (org.openkilda.integration.auth.service.IAuthService)9 StoreIntegrationException (org.openkilda.integration.exception.StoreIntegrationException)9 AuthConfigDto (org.openkilda.store.model.AuthConfigDto)9 Transactional (org.springframework.transaction.annotation.Transactional)5 LinkStoreRequestUrlsEntity (org.openkilda.store.linkstore.dao.entity.LinkStoreRequestUrlsEntity)3 SwitchStoreRequestUrlsEntity (org.openkilda.store.switchstore.dao.entity.SwitchStoreRequestUrlsEntity)3 ArrayList (java.util.ArrayList)2 OauthConfigEntity (org.openkilda.store.auth.dao.entity.OauthConfigEntity)2 RequestValidationException (org.usermanagement.exception.RequestValidationException)2 LinkStoreConfigDto (org.openkilda.store.model.LinkStoreConfigDto)1 SwitchStoreConfigDto (org.openkilda.store.model.SwitchStoreConfigDto)1