-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: minor event log fixes * chore: event-log rest-api + pagination
- Loading branch information
1 parent
edef4c3
commit 3a5a63d
Showing
8 changed files
with
190 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,4 +69,5 @@ fun Application.module() { | |
accounts() | ||
nfts() | ||
issuers() | ||
eventLogs() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
waltid-web-wallet/src/main/kotlin/id/walt/webwallet/service/events/EventLogFilter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package id.walt.webwallet.service.events | ||
|
||
data class EventLogFilter( | ||
val limit: Int = 0, | ||
val event: String? = null, | ||
val action: String? = null, | ||
val tenant: String? = null, | ||
val startingAfter: String? = null, | ||
val sortBy: String?=null, | ||
val sortOrder: String?=null, | ||
) |
19 changes: 19 additions & 0 deletions
19
...d-web-wallet/src/main/kotlin/id/walt/webwallet/service/events/EventLogFilterDataResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package id.walt.webwallet.service.events | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
sealed class EventLogFilterResult | ||
|
||
@Serializable | ||
data class EventLogFilterDataResult( | ||
val items: List<Event>, | ||
val count: Int, | ||
val currentStartingAfter: String? = null, | ||
val nextStartingAfter: String? = null, | ||
) : EventLogFilterResult() | ||
|
||
@Serializable | ||
data class EventLogFilterErrorResult( | ||
val reason: String, | ||
val message: String? = null, | ||
) : EventLogFilterResult() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
waltid-web-wallet/src/main/kotlin/id/walt/webwallet/web/controllers/EventLogController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package id.walt.webwallet.web.controllers | ||
|
||
import id.walt.web.controllers.getWalletService | ||
import id.walt.webwallet.service.events.EventLogFilter | ||
import id.walt.webwallet.service.events.EventLogFilterResult | ||
import io.github.smiley4.ktorswaggerui.dsl.get | ||
import io.github.smiley4.ktorswaggerui.dsl.route | ||
import io.ktor.http.* | ||
import io.ktor.server.application.* | ||
import io.ktor.server.response.* | ||
import org.jetbrains.exposed.sql.transactions.transaction | ||
|
||
fun Application.eventLogs() = walletRoute { | ||
route("eventlog", { | ||
tags = listOf("Event Log") | ||
}) { | ||
get({ | ||
summary = "Retrieve event logs for currently signed in account wallet" | ||
request { | ||
queryParameter<String>("limit") { | ||
description = "Page size" | ||
example = "10" | ||
required = false | ||
} | ||
queryParameter<String>("event") { | ||
description = "Event type" | ||
example = "Account" | ||
required = false | ||
} | ||
queryParameter<String>("action") { | ||
description = "Action type" | ||
example = "Login" | ||
required = false | ||
} | ||
queryParameter<String>("tenant") { | ||
description = "Tenant" | ||
example = "global" | ||
required = false | ||
} | ||
queryParameter<String>("startingAfter") { | ||
description = "Starting after page" | ||
example = "<hash>" | ||
required = false | ||
} | ||
queryParameter<String>("sortBy") { | ||
description = "The property to sort by" | ||
example = "tenant" | ||
required = false | ||
} | ||
queryParameter<String>("sortOrder") { | ||
description = "The sort order [ASC|DESC]" | ||
example = "ASC" | ||
required = false | ||
} | ||
} | ||
response { | ||
HttpStatusCode.OK to { | ||
body<EventLogFilterResult> { | ||
description = "The event log result" | ||
} | ||
} | ||
} | ||
}) { | ||
val wallet = getWalletService() | ||
val limit = call.request.queryParameters["limit"]?.toIntOrNull() ?: 0 | ||
val event = call.request.queryParameters["event"] | ||
val action = call.request.queryParameters["action"] | ||
val tenant = call.request.queryParameters["tenant"] | ||
val startingAfter = call.request.queryParameters["startingAfter"] | ||
val sortBy = call.request.queryParameters["sortBy"] | ||
val sortOrder = call.request.queryParameters["sortOrder"] | ||
context.respond(transaction { | ||
wallet.filterEventLog( | ||
EventLogFilter( | ||
limit = limit, | ||
event = event, | ||
action = action, | ||
tenant = tenant, | ||
startingAfter = startingAfter, | ||
sortBy = sortBy, | ||
sortOrder = sortOrder, | ||
) | ||
) | ||
}) | ||
} | ||
} | ||
} |