Skip to main content

Lock operations resource

Get single lock

// Returns a LockResponse
val response = sdk.lockOperations().getSingleLock(LOCK_ID)

Get lock audit trail

// Returns a List<LockAuditTrailResponse>
val response = sdk.lockOperations().getLockAuditTrail(LOCK_ID)

Get audit for user

// Returns a List<AuditResponse>
val response = sdk.lockOperations().getAuditForUser(USER_ID)

Get users for lock

// Returns a List<UserLockResponse>
val response = sdk.lockOperations().getUsersForLock(LOCK_ID)

Get locks for user

// Returns a LockUserResponse
val response = sdk.lockOperations().getLocksForUser(LOCK_ID)

Update lock name

// Returns Unit
sdk.lockOperations().updateLockName(
lockId = LOCK_ID,
name = "LOCK_NAME"
)

Update lock favourite

// Returns Unit
sdk.lockOperations().updateLockFavourite(
lockId = LOCK_ID,
favourite = true
)

Update lock setting default name

// Returns Unit
sdk.lockOperations().updateLockSettingDefaultName(
lockId = LOCK_ID,
name = LOCK_NAME
)

Set lock setting permitted addresses

// Returns Unit
sdk.lockOperations().setLockSettingPermittedAddresses(
lockId = LOCK_ID,
permittedAddresses = listOf(PERMITTED_ADDRESS)
)

Update lock setting hidden

// Returns Unit
sdk.lockOperations().updateLockSettingHidden(
lockId = LOCK_ID,
hidden = true
)

Set lock setting time restrictions

val timeRequirement = LockOperations.TimeRequirement.Builder()
.setStart(START)
.setEnd(END)
.setTimezone(TIMEZONE_ID)
.setDays(EnumSet.of(DayOfWeek.MONDAY))
.build()
// Returns Unit
sdk.lockOperations().setLockSettingTimeRestrictions(
lockId = LOCK_ID,
times = listOf(timeRequirements)
)

Update lock setting location restrictions

val locationRequirement = LockOperations.LocationRequirement.Builder()
.setLatitude(LATITUDE)
.setLongitude(LONGITUDE)
.setEnabled(true)
.build()
// Returns Unit
sdk.lockOperations().updateLockSettingLocationRestrictions(
lockId = LOCK_ID,
location = locationRequirement
)

Get a Sentry Interactive user's public key

warning

This function is only available to users with Sentry Interactive issued auth tokens

// Returns a UserPublicKeyResponse
val response = sdk.lockOperations().getUserPublicKey(
userEmail = "USER_EMAIL",
visitor = false
)

Lookup user public key by email

// Returns a UserPublicKeyResponse
val response = sdk.lockOperations().getUserPublicKeyByEmail("USER_EMAIL")

Lookup user public key by telephone

// Returns a UserPublicKeyResponse
val response = sdk.lockOperations().getUserPublicKeyByTelephone("USER_TELEPHONE")

Lookup user public key by local key

// Returns a UserPublicKeyResponse
val response = sdk.lockOperations().getUserPublicKeyByLocalKey("USER_LOCAL_KEY")

Lookup user public key by foreign key

// Returns a UserPublicKeyResponse
val response = sdk.lockOperations().getUserPublicKeyByForeignKey("USER_FOREIGN_KEY")

Lookup user public key by identity

// Returns a UserPublicKeyResponse
val response = sdk.lockOperations().getUserPublicKeyByIdentity("USER_IDENTITY")

Batch lookup user public key by email

// Returns a List<BatchUserPublicKeyResponse>
val response = sdk.lockOperations().getUserPublicKeyByEmails(listOf("USER_EMAIL", "USER_EMAIL"))

Batch lookup user public key by telephone

// Returns a List<BatchUserPublicKeyResponse>
val response = sdk.lockOperations().getUserPublicKeyByTelephones(listOf("USER_TELEPHONE", "USER_TELEPHONE"))

Batch lookup user public key by local key

// Returns a List<BatchUserPublicKeyResponse>
val response = sdk.lockOperations().getUserPublicKeyByLocalKeys(listOf("USER_LOCAL_KEY"))

Batch lookup user public key by foreign key

// Returns a List<BatchUserPublicKeyResponse>
val response = sdk.lockOperations().getUserPublicKeyByForeignKeys(listOf("USER_FOREIGN_KEY", "USER_FOREIGN_KEY"))

Unlock

info

This function can also be used by passing all the necessary parameters to it, such as the user ID, certificate chain, and private key. In the next example, we are using these values from the context and hence we do not need to pass them.

val unlockOperation = LockOperations.UnlockOperation.Builder()
.setBaseOperation(LockOperations.BaseOperation.Builder()
.setLockId(LOCK_ID)
.build())
.build()
// Returns Unit
sdk.lockOperations().unlock(unlockOperation)

Share lock

info

This function can also be used by passing all the necessary parameters to it, such as the user ID, certificate chain, and private key. In the next example, we are using these values from the context and hence we do not need to pass them.

val shareLockOperation = LockOperations.ShareLockOperation.Builder()
.setBaseOperation(LockOperations.BaseOperation.Builder()
.setLockId(LOCK_ID)
.build())
.setShareLock(ShareLock.Builder()
.setTargetUserId(TARGET_USER_ID)
.setTargetUserRole(TARGET_USER_ROLE)
.setTargetUserPublicKey(TARGET_PUBLIC_KEY)
.build())
.build()
// Returns Unit
sdk.lockOperations().shareLock(shareLockOperation)

Batch share lock

info
  • This functionality requires the device to support the batch sharing feature. The function will retrieve the device's capabilities, store them in a cache, and perform the batch operation if supported. Otherwise, it will default to the standard device sharing process.
  • This function can also be used by passing all the necessary parameters to it, such as the user ID, certificate chain, and private key. In the next example, we are using these values from the context and hence we do not need to pass them.
val batchShareLockOperation = LockOperations.BatchShareLockOperation.Builder()
.setBaseOperation(LockOperations.BaseOperation.Builder()
.setLockId(LOCK_ID)
.build())
.setUsers(listOf(ShareLock.Builder()
.setTargetUserId(TARGET_USER_ID)
.setTargetUserRole(TARGET_USER_ROLE)
.setTargetUserPublicKey(TARGET_PUBLIC_KEY)
.build()))
.build()
// Returns Unit
sdk.lockOperations().batchShareLock(batchShareLockOperation)

Revoke access to lock

info

This function can also be used by passing all the necessary parameters to it, such as the user ID, certificate chain, and private key. In the next example, we are using these values from the context and hence we do not need to pass them.

val revokeAccessToLockOperation = LockOperations.RevokeAccessToLockOperation.Builder()
.setBaseOperation(LockOperations.BaseOperation.Builder()
.setLockId(LOCK_ID)
.build())
.setUsers(listOf(USER_ID))
.build()
// Returns Unit
sdk.lockOperations().revokeAccessToLock(revokeAccessToLockOperation)

Update secure setting unlock duration

info

This function can also be used by passing all the necessary parameters to it, such as the user ID, certificate chain, and private key. In the next example, we are using these values from the context and hence we do not need to pass them.

val updateSecureSettingUnlockDuration = LockOperations.UpdateSecureSettingUnlockDuration.Builder()
.setBaseOperation(LockOperations.BaseOperation.Builder()
.setLockId(LOCK_ID)
.build())
.setUnlockDuration(UNLOCK_DURATION)
.build()
// Returns Unit
sdk.lockOperations().updateSecureSettingUnlockDuration(updateSecureSettingUnlockDuration)

Update secure setting unlock between

info

This function can also be used by passing all the necessary parameters to it, such as the user ID, certificate chain, and private key. In the next example, we are using these values from the context and hence we do not need to pass them.

val updateSecureSettingUnlockBetween = LockOperations.UpdateSecureSettingUnlockBetween.Builder()
.setBaseOperation(LockOperations.BaseOperation.Builder()
.setLockId(LOCK_ID)
.build())
.setUnlockBetween(LockOperations.UnlockBetween.Builder()
.setStart(START)
.setEnd(END)
.setTimezone(TIMEZONE)
.setDays(listOf(DayOfWeek.MONDAY))
.build())
.build()
// Returns Unit
sdk.lockOperations().updateSecureSettingUnlockBetween(updateSecureSettingUnlockBetween)

Get pinned locks

// Returns List<LockResponse>
val response = sdk.lockOperations().getPinnedLocks()

Get shareable locks

// Returns a List<ShareableLockResponse>
val response = sdk.lockOperations().getShareableLocks()