Search in sources :

Example 1 with BotDetectionAlertSubscriptionListDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionAlertSubscriptionListDTO in project carbon-apimgt by wso2.

the class AlertSubscriptionsApiServiceImpl method getBotDetectionAlertSubscriptions.

/**
 * Retrieve a list of bot detection alert subscriptions
 *
 * @param messageContext CXF Message Context
 * @return list of bot detection alert subscriptions
 * @throws APIManagementException if an error occurs when retrieving bot detection alert subscriptions
 */
@Override
public Response getBotDetectionAlertSubscriptions(MessageContext messageContext) throws APIManagementException {
    APIAdmin apiAdmin = new APIAdminImpl();
    List<BotDetectionData> botDetectionDataList = apiAdmin.getBotDetectionAlertSubscriptions();
    BotDetectionAlertSubscriptionListDTO listDTO = BotDetectionMappingUtil.fromAlertSubscriptionListToListDTO(botDetectionDataList);
    return Response.ok().entity(listDTO).build();
}
Also used : APIAdmin(org.wso2.carbon.apimgt.api.APIAdmin) BotDetectionData(org.wso2.carbon.apimgt.api.model.botDataAPI.BotDetectionData) APIAdminImpl(org.wso2.carbon.apimgt.impl.APIAdminImpl) BotDetectionAlertSubscriptionListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionAlertSubscriptionListDTO)

Example 2 with BotDetectionAlertSubscriptionListDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionAlertSubscriptionListDTO in project carbon-apimgt by wso2.

the class BotDetectionMappingUtil method fromAlertSubscriptionListToListDTO.

/**
 * Converts a list of Bot Detection Alert Subscription model objects into a list DTO
 *
 * @param alertSubscriptionList list of Bot Detection Alert Subscriptions
 * @return A List DTO of converted Bot Detection Alert Subscriptions
 */
public static BotDetectionAlertSubscriptionListDTO fromAlertSubscriptionListToListDTO(List<BotDetectionData> alertSubscriptionList) {
    BotDetectionAlertSubscriptionListDTO listDTO = new BotDetectionAlertSubscriptionListDTO();
    List<BotDetectionAlertSubscriptionDTO> alertSubscriptionDTOs = new ArrayList<>();
    for (BotDetectionData alertSubscription : alertSubscriptionList) {
        alertSubscriptionDTOs.add(fromAlertSubscriptionToDTO(alertSubscription));
    }
    listDTO.setList(alertSubscriptionDTOs);
    listDTO.setCount(alertSubscriptionDTOs.size());
    return listDTO;
}
Also used : ArrayList(java.util.ArrayList) BotDetectionData(org.wso2.carbon.apimgt.api.model.botDataAPI.BotDetectionData) BotDetectionAlertSubscriptionListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionAlertSubscriptionListDTO) BotDetectionAlertSubscriptionDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionAlertSubscriptionDTO)

Aggregations

BotDetectionData (org.wso2.carbon.apimgt.api.model.botDataAPI.BotDetectionData)2 BotDetectionAlertSubscriptionListDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionAlertSubscriptionListDTO)2 ArrayList (java.util.ArrayList)1 APIAdmin (org.wso2.carbon.apimgt.api.APIAdmin)1 APIAdminImpl (org.wso2.carbon.apimgt.impl.APIAdminImpl)1 BotDetectionAlertSubscriptionDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionAlertSubscriptionDTO)1