Skip to content
Snippets Groups Projects
Commit ca6285ed authored by Konstantinos Georgilakis's avatar Konstantinos Georgilakis
Browse files

add WebhookEventType to Webhook body

parent 43a052e7
No related branches found
No related tags found
1 merge request!276add WebhookEventType to Webhook body
Pipeline #95505 passed
......@@ -7,6 +7,7 @@ import net.geant.nmaas.orchestration.api.model.AppDeploymentView;
import net.geant.nmaas.orchestration.entities.AppDeployment;
import net.geant.nmaas.orchestration.exceptions.InvalidDeploymentIdException;
import net.geant.nmaas.orchestration.exceptions.WebServiceCommunicationException;
import net.geant.nmaas.portal.api.domain.AppDeploymentWebhookDto;
import net.geant.nmaas.portal.api.domain.WebhookEventDto;
import net.geant.nmaas.portal.api.exceptions.MissingElementException;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
......@@ -47,7 +48,7 @@ public class AppDeploymentJob extends WebhookJob {
}
AppDeployment appDeployment = appDeploymentRepositoryManager.load(Identifier.newInstance(deploymentIdStr));
callWebhook(webhook, modelMapper.map(appDeployment, AppDeploymentView.class));
callWebhook(webhook, new AppDeploymentWebhookDto(modelMapper.map(appDeployment, AppDeploymentView.class), WebhookEventType.APPLICATION_DEPLOYMENT));
} catch (GeneralSecurityException e) {
log.error("Failed to decrypt webhook with id {}", webhookId);
throw new JobExecutionException("Failed webhook decryption");
......
......@@ -42,7 +42,7 @@ public class DomainActionJob extends WebhookJob {
return;
}
callWebhook(webhook, new DomainActionDto(domain, action));
callWebhook(webhook, new DomainActionDto(domain, action, WebhookEventType.DOMAIN_ACTION));
} catch (GeneralSecurityException e) {
log.error("Failed to decrypt webhook with id {}", webhookId);
throw new JobExecutionException("Failed webhook decryption");
......
......@@ -40,7 +40,7 @@ public class DomainGroupJob extends WebhookJob {
log.warn("Webhook's event type with id {} has been updated. DomainGroupJob is abandoned", webhookId);
return;
}
DomainGroupWebhookDto view = new DomainGroupWebhookDto(domainGroup, action);
DomainGroupWebhookDto view = new DomainGroupWebhookDto(domainGroup, action, WebhookEventType.DOMAIN_GROUP_ACTION);
callWebhook(webhook, view);
} catch (GeneralSecurityException e) {
log.error("Failed to decrypt webhook with id {}", webhookId);
......
......@@ -56,7 +56,7 @@ public class UserDomainAssignmentJob extends WebhookJob {
Domain domain = domainService.findDomain(domainId).orElseThrow(() -> new MissingElementException(String.format("Domain with id: %d cannot be found", domainId)));
User user = userService.findById(userId).orElseThrow(() -> new MissingElementException(String.format("User with id: %d cannot be found", userId)));
UserDomainAssignmentWebhookDto dto = new UserDomainAssignmentWebhookDto(modelMapper.map(user, UserView.class), modelMapper.map(domain, DomainView.class), role, action);
UserDomainAssignmentWebhookDto dto = new UserDomainAssignmentWebhookDto(modelMapper.map(user, UserView.class), modelMapper.map(domain, DomainView.class), role, action, WebhookEventType.USER_ASSIGNMENT);
callWebhook(webhook, dto);
} catch (GeneralSecurityException e) {
log.error("Failed to decrypt webhook with id {}", webhookId);
......
package net.geant.nmaas.portal.api.domain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.geant.nmaas.orchestration.api.model.AppDeploymentView;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
@AllArgsConstructor
@Getter
@Setter
public class AppDeploymentWebhookDto {
private AppDeploymentView appDeployment;
private WebhookEventType webhookEventType;
}
......@@ -3,6 +3,7 @@ package net.geant.nmaas.portal.api.domain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
@AllArgsConstructor
@Getter
......@@ -11,4 +12,5 @@ public class DomainActionDto {
private DomainView domainView;
private String action;
private WebhookEventType webhookEventType;
}
......@@ -3,6 +3,7 @@ package net.geant.nmaas.portal.api.domain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
@AllArgsConstructor
@Getter
......@@ -11,5 +12,6 @@ public class DomainGroupWebhookDto {
private DomainGroupView domainGroup;
private String action;
private WebhookEventType webhookEventType;
}
......@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.geant.nmaas.portal.persistent.entity.Role;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
@AllArgsConstructor
@Getter
......@@ -14,4 +15,5 @@ public class UserDomainAssignmentWebhookDto {
private DomainView domain;
private Role role;
private String action;
private WebhookEventType webhookEventType;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment