LogoLogo
ProductsCommunityGitHubShare Feedback
Storage Kit
Storage Kit
  • WHAT IS THE STORAGE KIT?
    • Introduction
    • Architecture
      • System Architecture
      • Functional Architecture
        • L1 | Data Encryption
        • L2 | Data Sharing, Versioning & Search
        • L3 | HL Server-Side Functions
      • Dependencies
  • Getting started
    • Quick Start
    • CLI | Command Line Interface
    • REST APIs
      • Server
      • Client
      • Service
    • Dependency (JVM)
    • Configurations
    • Build
      • Docker Build
      • Local Build
  • Concepts
    • Basic Concepts
      • Sessions
      • Client Set-up
      • Client Document Upload
      • Service Access
    • Advanced Concepts
      • Searchable Symmetric Encryption (SEE)
      • ZCap-LD (Authorization)
        • (Theory) Authorization Capabilities
        • ZCaps - Caveats Extension
  • Usage / Examples
    • Client CLI Examples
    • Client code examples
    • Simple service example
  • Community
    • Discord
    • Twitter
    • Newsletter
    • GitHub Discussions
  • DEVELOPER RELATIONS
    • Contribute
    • Roadmap
    • Share Feedback
    • Contact
  • Product Editions
    • Open Source | Always Free
    • Enterprise | Self-Managed
    • Cloud Platform | Managed
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Usage / Examples

Client code examples

Applicable to all following examples

val clientService = ClientService()

Setup master key (initial run)

val masterKey = "123456".toByteArray()

clientService.createMasterKey(masterKey)

Session setup

val masterKey = "123456".toByteArray()

clientService.unlockWithMasterKey(masterKey)
clientService.setupSessionService()

Create a session

val newSession = clientService.sessionService.createSession("sess01")

clientService.sessionService.selectSession(newSession.sessionId)

clientService.setup()

Create EDV

val providerUrl = "http://localhost:7000"

val result = clientService.edvService.createEdv(providerUrl)

println("Created EDV ${res.edvId} at $providerUrl")

Create document

clientService.documentService.create("documentId123", "the content".toByteArray())

Update document

clientService.documentService.update("documentId123", "new content".toByteArray())

Load document

val result = clientService.documentService.load(edvId, documentId).toString()  // or .toBytes()

Delete document

clientService.documentService.delete("documentId123")

Search document

val results = clientService.documentService.search(edvId, "keyword")
results.forEach { println(it) }

Get all documents in EDV

val results = clientService.indexService.getDocuments(edvId)
results.forEach { println(it) }

Retrieve tree of EDV

val results = clientService.indexService.getTree()
results.forEach { println(it) }

Enable notification channel

clientService.edvService.notificationsConnect(edvId) { event ->
    println("Received notification from EDV $edvId: " +
    "Document ${event.documentId} was ${event.operation.name}" +
    " by ${event.invoker}.")
}

Diconnect notification channels

clientService.edvService.notificationsDisconnect()

Export session

val jwe = sessionService.export(sessionService.sessionId)
println("Session export (it's encrypted with the masterkey): $jwe")
PreviousClient CLI ExamplesNextSimple service example

Last updated 28 days ago

Was this helpful?