Skip to content

Commit

Permalink
Updates in the scenario activity API contract
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoworko committed Sep 23, 2024
1 parent 0ec7862 commit 87d224f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ class ScenarioActivityApiHttpService(
scenarioComment match {
case ScenarioComment.Available(comment, lastModifiedByUserName, lastModifiedAt) =>
Dtos.ScenarioActivityComment(
status = Dtos.ScenarioActivityCommentStatus.Available(comment),
content = Dtos.ScenarioActivityCommentContent.Available(comment),
lastModifiedBy = lastModifiedByUserName.value,
lastModifiedAt = lastModifiedAt,
)
case ScenarioComment.Deleted(deletedByUserName, deletedAt) =>
Dtos.ScenarioActivityComment(
status = Dtos.ScenarioActivityCommentStatus.Deleted,
content = Dtos.ScenarioActivityCommentContent.Deleted,
lastModifiedBy = deletedByUserName.value,
lastModifiedAt = deletedAt,
)
Expand All @@ -241,14 +241,14 @@ class ScenarioActivityApiHttpService(
attachment match {
case ScenarioAttachment.Available(attachmentId, attachmentFilename, lastModifiedByUserName, lastModifiedAt) =>
Dtos.ScenarioActivityAttachment(
status = Dtos.ScenarioActivityAttachmentStatus.Available(attachmentId.value),
file = Dtos.ScenarioActivityAttachmentFile.Available(attachmentId.value),
filename = attachmentFilename.value,
lastModifiedBy = lastModifiedByUserName.value,
lastModifiedAt = lastModifiedAt,
)
case ScenarioAttachment.Deleted(attachmentFilename, deletedByUserName, deletedAt) =>
Dtos.ScenarioActivityAttachment(
status = Dtos.ScenarioActivityAttachmentStatus.Deleted,
file = Dtos.ScenarioActivityAttachmentFile.Deleted,
filename = attachmentFilename.value,
lastModifiedBy = deletedByUserName.value,
lastModifiedAt = deletedAt,
Expand All @@ -259,60 +259,60 @@ class ScenarioActivityApiHttpService(
private def toDto(scenarioActivity: ScenarioActivity): Dtos.ScenarioActivity = {
scenarioActivity match {
case ScenarioActivity.ScenarioCreated(_, scenarioActivityId, user, date, scenarioVersion) =>
Dtos.ScenarioActivity.ScenarioCreated(
Dtos.ScenarioActivity.forScenarioCreated(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value)
)
case ScenarioActivity.ScenarioArchived(_, scenarioActivityId, user, date, scenarioVersion) =>
Dtos.ScenarioActivity.ScenarioArchived(
Dtos.ScenarioActivity.forScenarioArchived(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value)
)
case ScenarioActivity.ScenarioUnarchived(_, scenarioActivityId, user, date, scenarioVersion) =>
Dtos.ScenarioActivity.ScenarioUnarchived(
Dtos.ScenarioActivity.forScenarioUnarchived(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value)
)
case ScenarioActivity.ScenarioDeployed(_, scenarioActivityId, user, date, scenarioVersion, comment) =>
Dtos.ScenarioActivity.ScenarioDeployed(
Dtos.ScenarioActivity.forScenarioDeployed(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value),
comment = toDto(comment),
)
case ScenarioActivity.ScenarioPaused(_, scenarioActivityId, user, date, scenarioVersion, comment) =>
Dtos.ScenarioActivity.ScenarioPaused(
Dtos.ScenarioActivity.forScenarioPaused(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value),
comment = toDto(comment),
)
case ScenarioActivity.ScenarioCanceled(_, scenarioActivityId, user, date, scenarioVersion, comment) =>
Dtos.ScenarioActivity.ScenarioCanceled(
Dtos.ScenarioActivity.forScenarioCanceled(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value),
comment = toDto(comment),
)
case ScenarioActivity.ScenarioModified(_, scenarioActivityId, user, date, scenarioVersion, comment) =>
Dtos.ScenarioActivity.ScenarioModified(
Dtos.ScenarioActivity.forScenarioModified(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value),
comment = toDto(comment),
)
case ScenarioActivity.ScenarioNameChanged(_, id, user, date, version, oldName, newName) =>
Dtos.ScenarioActivity.ScenarioNameChanged(
Dtos.ScenarioActivity.forScenarioNameChanged(
id = id.value,
user = user.name.value,
date = date,
Expand All @@ -321,23 +321,23 @@ class ScenarioActivityApiHttpService(
newName = newName,
)
case ScenarioActivity.CommentAdded(_, scenarioActivityId, user, date, scenarioVersion, comment) =>
Dtos.ScenarioActivity.CommentAdded(
Dtos.ScenarioActivity.forCommentAdded(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value),
comment = toDto(comment),
)
case ScenarioActivity.AttachmentAdded(_, scenarioActivityId, user, date, scenarioVersion, attachment) =>
Dtos.ScenarioActivity.AttachmentAdded(
Dtos.ScenarioActivity.forAttachmentAdded(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value),
attachment = toDto(attachment),
)
case ScenarioActivity.ChangedProcessingMode(_, scenarioActivityId, user, date, scenarioVersion, from, to) =>
Dtos.ScenarioActivity.ChangedProcessingMode(
Dtos.ScenarioActivity.forChangedProcessingMode(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
Expand All @@ -354,7 +354,7 @@ class ScenarioActivityApiHttpService(
sourceEnvironment,
sourceScenarioVersion
) =>
Dtos.ScenarioActivity.IncomingMigration(
Dtos.ScenarioActivity.forIncomingMigration(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
Expand All @@ -371,7 +371,7 @@ class ScenarioActivityApiHttpService(
comment,
destinationEnvironment
) =>
Dtos.ScenarioActivity.OutgoingMigration(
Dtos.ScenarioActivity.forOutgoingMigration(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
Expand All @@ -389,7 +389,7 @@ class ScenarioActivityApiHttpService(
dateFinished,
errorMessage
) =>
Dtos.ScenarioActivity.PerformedSingleExecution(
Dtos.ScenarioActivity.forPerformedSingleExecution(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
Expand All @@ -407,7 +407,7 @@ class ScenarioActivityApiHttpService(
dateFinished,
errorMessage
) =>
Dtos.ScenarioActivity.PerformedScheduledExecution(
Dtos.ScenarioActivity.forPerformedScheduledExecution(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
Expand All @@ -425,7 +425,7 @@ class ScenarioActivityApiHttpService(
changes,
errorMessage
) =>
Dtos.ScenarioActivity.AutomaticUpdate(
Dtos.ScenarioActivity.forAutomaticUpdate(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
Expand All @@ -435,13 +435,14 @@ class ScenarioActivityApiHttpService(
errorMessage = errorMessage,
)
case ScenarioActivity.CustomAction(_, scenarioActivityId, user, date, scenarioVersion, actionName, comment) =>
Dtos.ScenarioActivity.CustomAction(
Dtos.ScenarioActivity.forCustomAction(
id = scenarioActivityId.value,
user = user.name.value,
date = date,
scenarioVersion = scenarioVersion.map(_.value),
actionName = actionName,
comment = toDto(comment),
customIcon = None,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,23 @@ object Dtos {
additionalFields = List.empty,
)

def forScenarioPaused(
id: UUID,
user: String,
date: Instant,
scenarioVersion: Option[Long],
comment: ScenarioActivityComment,
): ScenarioActivity = ScenarioActivity(
id = id,
`type` = ScenarioActivityType.ScenarioPaused,
user = user,
date = date,
scenarioVersion = scenarioVersion,
comment = Some(comment),
attachment = None,
additionalFields = List.empty,
)

def forScenarioCanceled(
id: UUID,
user: String,
Expand Down
12 changes: 6 additions & 6 deletions docs-internal/api/nu-designer-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3105,8 +3105,8 @@ paths:
type: string
examples:
Example:
summary: 'Unable to edit comment with id: {commentId}'
value: 'Unable to delete comment with id: a76d6eba-9b6c-4d97-aaa1-984a23f88019'
summary: 'Unable to edit comment for activity with id: {commentId}'
value: 'Unable to delete comment for activity with id: a76d6eba-9b6c-4d97-aaa1-984a23f88019'
'501':
description: Impersonation is not supported for defined authentication mechanism
content:
Expand Down Expand Up @@ -3195,8 +3195,8 @@ paths:
type: string
examples:
Example:
summary: 'Unable to edit comment with id: {commentId}'
value: 'Unable to delete comment with id: a76d6eba-9b6c-4d97-aaa1-984a23f88019'
summary: 'Unable to edit comment for activity with id: {commentId}'
value: 'Unable to delete comment for activity with id: a76d6eba-9b6c-4d97-aaa1-984a23f88019'
'501':
description: Impersonation is not supported for defined authentication mechanism
content:
Expand Down Expand Up @@ -3374,8 +3374,8 @@ paths:
type: string
examples:
Example:
summary: 'Unable to edit comment with id: {commentId}'
value: 'Unable to delete comment with id: a76d6eba-9b6c-4d97-aaa1-984a23f88019'
summary: 'Unable to edit comment for activity with id: {commentId}'
value: 'Unable to delete comment for activity with id: a76d6eba-9b6c-4d97-aaa1-984a23f88019'
'501':
description: Impersonation is not supported for defined authentication mechanism
content:
Expand Down

0 comments on commit 87d224f

Please sign in to comment.