Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import com.stytch.java.b2b.models.organizations.ConnectedAppsRequestOptions
import com.stytch.java.b2b.models.organizations.ConnectedAppsResponse
import com.stytch.java.b2b.models.organizations.CreateRequest
import com.stytch.java.b2b.models.organizations.CreateResponse
import com.stytch.java.b2b.models.organizations.DeleteExternalIdRequest
import com.stytch.java.b2b.models.organizations.DeleteExternalIdRequestOptions
import com.stytch.java.b2b.models.organizations.DeleteExternalIdResponse
import com.stytch.java.b2b.models.organizations.DeleteRequest
import com.stytch.java.b2b.models.organizations.DeleteRequestOptions
import com.stytch.java.b2b.models.organizations.DeleteResponse
Expand Down Expand Up @@ -270,6 +273,22 @@ public interface Organizations {
data: GetConnectedAppRequest,
methodOptions: GetConnectedAppRequestOptions? = null,
): CompletableFuture<StytchResult<GetConnectedAppResponse>>

public suspend fun deleteExternalId(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions? = null,
): StytchResult<DeleteExternalIdResponse>

public fun deleteExternalId(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions? = null,
callback: (StytchResult<DeleteExternalIdResponse>) -> Unit,
)

public fun deleteExternalIdCompletable(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions? = null,
): CompletableFuture<StytchResult<DeleteExternalIdResponse>>
}

internal class OrganizationsImpl(
Expand Down Expand Up @@ -514,4 +533,36 @@ internal class OrganizationsImpl(
.async {
getConnectedApp(data, methodOptions)
}.asCompletableFuture()

override suspend fun deleteExternalId(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions?,
): StytchResult<DeleteExternalIdResponse> =
withContext(Dispatchers.IO) {
var headers = emptyMap<String, String>()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}

httpClient.delete("/v1/b2b/organizations/${data.organizationId}/external_id", headers)
}

override fun deleteExternalId(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions?,
callback: (StytchResult<DeleteExternalIdResponse>) -> Unit,
) {
coroutineScope.launch {
callback(deleteExternalId(data, methodOptions))
}
}

override fun deleteExternalIdCompletable(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions?,
): CompletableFuture<StytchResult<DeleteExternalIdResponse>> =
coroutineScope
.async {
deleteExternalId(data, methodOptions)
}.asCompletableFuture()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import com.stytch.java.b2b.models.organizationsmembers.CreateRequest
import com.stytch.java.b2b.models.organizationsmembers.CreateRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.CreateResponse
import com.stytch.java.b2b.models.organizationsmembers.DangerouslyGetRequest
import com.stytch.java.b2b.models.organizationsmembers.DeleteExternalIdRequest
import com.stytch.java.b2b.models.organizationsmembers.DeleteExternalIdRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.DeleteExternalIdResponse
import com.stytch.java.b2b.models.organizationsmembers.DeleteMFAPhoneNumberRequest
import com.stytch.java.b2b.models.organizationsmembers.DeleteMFAPhoneNumberRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.DeleteMFAPhoneNumberResponse
Expand Down Expand Up @@ -566,6 +569,22 @@ public interface Members {
methodOptions: GetConnectedAppsRequestOptions? = null,
): CompletableFuture<StytchResult<GetConnectedAppsResponse>>

public suspend fun deleteExternalId(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions? = null,
): StytchResult<DeleteExternalIdResponse>

public fun deleteExternalId(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions? = null,
callback: (StytchResult<DeleteExternalIdResponse>) -> Unit,
)

public fun deleteExternalIdCompletable(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions? = null,
): CompletableFuture<StytchResult<DeleteExternalIdResponse>>

/**
* Creates a Member. An `organization_id` and `email_address` are required.
*/
Expand Down Expand Up @@ -1000,6 +1019,38 @@ internal class MembersImpl(
getConnectedApps(data, methodOptions)
}.asCompletableFuture()

override suspend fun deleteExternalId(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions?,
): StytchResult<DeleteExternalIdResponse> =
withContext(Dispatchers.IO) {
var headers = emptyMap<String, String>()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}

httpClient.delete("/v1/b2b/organizations/${data.organizationId}/members/${data.memberId}/external_id", headers)
}

override fun deleteExternalId(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions?,
callback: (StytchResult<DeleteExternalIdResponse>) -> Unit,
) {
coroutineScope.launch {
callback(deleteExternalId(data, methodOptions))
}
}

override fun deleteExternalIdCompletable(
data: DeleteExternalIdRequest,
methodOptions: DeleteExternalIdRequestOptions?,
): CompletableFuture<StytchResult<DeleteExternalIdResponse>> =
coroutineScope
.async {
deleteExternalId(data, methodOptions)
}.asCompletableFuture()

override suspend fun create(
data: CreateRequest,
methodOptions: CreateRequestOptions?,
Expand Down
6 changes: 6 additions & 0 deletions stytch/src/main/kotlin/com/stytch/java/b2b/api/rbac/RBAC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ package com.stytch.java.b2b.api.rbac
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.stytch.java.b2b.api.rbacorganizations.Organizations
import com.stytch.java.b2b.api.rbacorganizations.OrganizationsImpl
import com.stytch.java.b2b.models.rbac.PolicyRequest
import com.stytch.java.b2b.models.rbac.PolicyResponse
import com.stytch.java.common.InstantAdapter
Expand All @@ -23,6 +25,8 @@ import kotlinx.coroutines.withContext
import java.util.concurrent.CompletableFuture

public interface RBAC {
public val organizations: Organizations

/**
* Get the active RBAC Policy for your current Stytch Project. An RBAC Policy is the canonical document that stores all
* defined Resources and Roles within your RBAC permissioning model.
Expand Down Expand Up @@ -87,6 +91,8 @@ internal class RBACImpl(
) : RBAC {
private val moshi = Moshi.Builder().add(InstantAdapter()).build()

override val organizations: Organizations = OrganizationsImpl(httpClient, coroutineScope)

override suspend fun policy(data: PolicyRequest): StytchResult<PolicyResponse> =
withContext(Dispatchers.IO) {
var headers = emptyMap<String, String>()
Expand Down
Loading
Loading