-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CreateWarrantOptions and DeleteWarrantOptions
- Loading branch information
1 parent
4f489bd
commit 0bcb0ab
Showing
6 changed files
with
199 additions
and
2 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/kotlin/com/workos/fga/builders/CreateWarrantOptionsBuilder.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,48 @@ | ||
package com.workos.fga.builders | ||
|
||
import com.workos.fga.models.Subject | ||
import com.workos.fga.types.CreateWarrantOptions | ||
|
||
/** | ||
* Builder for options when performing a warrant create. | ||
* | ||
* @param resourceType The type of the resource. Must be one of your system's existing resource types. | ||
* @param resourceId The unique ID of the resource. | ||
* @param relation The relation for this resource to subject association. The relation must be valid per the resource type definition. | ||
* @param subject (see [Subject]) The resource with the specified `relation` to the resource provided by resourceType and resourceId. | ||
* @param policy A boolean expression that must evaluate to true for this warrant to apply. The expression can reference variables provided in the context attribute of access check requests. | ||
*/ | ||
class CreateWarrantOptionsBuilder @JvmOverloads constructor( | ||
private var resourceType: String, | ||
private var resourceId: String, | ||
private var relation: String, | ||
private var subject: Subject, | ||
private var policy: String? = null, | ||
) { | ||
fun resourceType(value: String) = apply { resourceType = value } | ||
|
||
fun resourceId(value: String) = apply { resourceId = value } | ||
|
||
fun relation(value: String) = apply { relation = value } | ||
|
||
fun subject(value: Subject) = apply { subject = value } | ||
|
||
fun policy(value: String) = apply { policy = value } | ||
|
||
fun build(): CreateWarrantOptions { | ||
return CreateWarrantOptions( | ||
resourceType = this.resourceType, | ||
resourceId = this.resourceId, | ||
relation = this.relation, | ||
subject = this.subject, | ||
policy = this.policy, | ||
) | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun create(resourceType: String, resourceId: String, relation: String, subject: Subject): CreateWarrantOptionsBuilder { | ||
return CreateWarrantOptionsBuilder(resourceType, resourceId, relation, subject) | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/kotlin/com/workos/fga/builders/DeleteWarrantOptionsBuilder.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,48 @@ | ||
package com.workos.fga.builders | ||
|
||
import com.workos.fga.models.Subject | ||
import com.workos.fga.types.DeleteWarrantOptions | ||
|
||
/** | ||
* Builder for options when performing a warrant delete. | ||
* | ||
* @param resourceType The type of the resource. Must be one of your system's existing resource types. | ||
* @param resourceId The unique ID of the resource. | ||
* @param relation The relation for this resource to subject association. The relation must be valid per the resource type definition. | ||
* @param subject (see [Subject]) The resource with the specified `relation` to the resource provided by resourceType and resourceId. | ||
* @param policy A boolean expression that must evaluate to true for this warrant to apply. The expression can reference variables provided in the context attribute of access check requests. | ||
*/ | ||
class DeleteWarrantOptionsBuilder @JvmOverloads constructor( | ||
private var resourceType: String, | ||
private var resourceId: String, | ||
private var relation: String, | ||
private var subject: Subject, | ||
private var policy: String? = null, | ||
) { | ||
fun resourceType(value: String) = apply { resourceType = value } | ||
|
||
fun resourceId(value: String) = apply { resourceId = value } | ||
|
||
fun relation(value: String) = apply { relation = value } | ||
|
||
fun subject(value: Subject) = apply { subject = value } | ||
|
||
fun policy(value: String) = apply { policy = value } | ||
|
||
fun build(): DeleteWarrantOptions { | ||
return DeleteWarrantOptions( | ||
resourceType = this.resourceType, | ||
resourceId = this.resourceId, | ||
relation = this.relation, | ||
subject = this.subject, | ||
policy = this.policy, | ||
) | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun create(resourceType: String, resourceId: String, relation: String, subject: Subject): DeleteWarrantOptionsBuilder { | ||
return DeleteWarrantOptionsBuilder(resourceType, resourceId, relation, subject) | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/com/workos/fga/types/CreateWarrantOptions.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,38 @@ | ||
package com.workos.fga.types | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.workos.fga.models.Subject | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
class CreateWarrantOptions @JvmOverloads constructor( | ||
/** | ||
* The type of the resource. | ||
*/ | ||
@JsonProperty("resource_type") | ||
resourceType: String, | ||
|
||
/** | ||
* The unique ID of the resource. | ||
*/ | ||
@JsonProperty("resource_id") | ||
resourceId: String, | ||
|
||
/** | ||
* The relation for this resource to subject association. The relation must be valid per the resource type definition. | ||
*/ | ||
@JsonProperty("relation") | ||
relation: String, | ||
|
||
/** | ||
* The resource with the specified `relation` to the resource provided by resourceType and resourceId. | ||
*/ | ||
@JsonProperty("subject") | ||
subject: Subject, | ||
|
||
/** | ||
* A boolean expression that must evaluate to true for this warrant to apply. The expression can reference variables provided in the context attribute of access check requests. | ||
*/ | ||
@JsonProperty("policy") | ||
policy: String? = null, | ||
) : WriteWarrantOptions("create", resourceType, resourceId, relation, subject, policy) |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/com/workos/fga/types/DeleteWarrantOptions.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,38 @@ | ||
package com.workos.fga.types | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.workos.fga.models.Subject | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
class DeleteWarrantOptions @JvmOverloads constructor( | ||
/** | ||
* The type of the resource. | ||
*/ | ||
@JsonProperty("resource_type") | ||
resourceType: String, | ||
|
||
/** | ||
* The unique ID of the resource. | ||
*/ | ||
@JsonProperty("resource_id") | ||
resourceId: String, | ||
|
||
/** | ||
* The relation for this resource to subject association. The relation must be valid per the resource type definition. | ||
*/ | ||
@JsonProperty("relation") | ||
relation: String, | ||
|
||
/** | ||
* The resource with the specified `relation` to the resource provided by resourceType and resourceId. | ||
*/ | ||
@JsonProperty("subject") | ||
subject: Subject, | ||
|
||
/** | ||
* A boolean expression that must evaluate to true for this warrant to apply. The expression can reference variables provided in the context attribute of access check requests. | ||
*/ | ||
@JsonProperty("policy") | ||
policy: String? = null, | ||
) : WriteWarrantOptions("delete", resourceType, resourceId, relation, subject, policy) |
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