-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARC-1807: Bump authzed client to 0.8.0
- Loading branch information
1 parent
bf85e5e
commit 8a5cae1
Showing
9 changed files
with
70 additions
and
91 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
9 changes: 3 additions & 6 deletions
9
...nding/src/main/java/com/oviva/spicegen/spicedbbinding/internal/ObjectReferenceMapper.java
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 |
---|---|---|
@@ -1,14 +1,11 @@ | ||
package com.oviva.spicegen.spicedbbinding.internal; | ||
|
||
import com.authzed.api.v1.Core; | ||
import com.authzed.api.v1.ObjectReference; | ||
import com.oviva.spicegen.api.ObjectRef; | ||
|
||
public class ObjectReferenceMapper { | ||
|
||
public Core.ObjectReference map(ObjectRef ref) { | ||
return Core.ObjectReference.newBuilder() | ||
.setObjectType(ref.kind()) | ||
.setObjectId(ref.id()) | ||
.build(); | ||
public ObjectReference map(ObjectRef ref) { | ||
return ObjectReference.newBuilder().setObjectType(ref.kind()).setObjectId(ref.id()).build(); | ||
} | ||
} |
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
9 changes: 5 additions & 4 deletions
9
...ding/src/main/java/com/oviva/spicegen/spicedbbinding/internal/SubjectReferenceMapper.java
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
package com.oviva.spicegen.spicedbbinding.internal; | ||
|
||
import com.authzed.api.v1.Core; | ||
import com.authzed.api.v1.ObjectReference; | ||
import com.authzed.api.v1.SubjectReference; | ||
import com.oviva.spicegen.api.SubjectRef; | ||
|
||
public class SubjectReferenceMapper { | ||
|
||
public Core.SubjectReference map(SubjectRef subjectRef) { | ||
public SubjectReference map(SubjectRef subjectRef) { | ||
var ref = | ||
Core.ObjectReference.newBuilder() | ||
ObjectReference.newBuilder() | ||
.setObjectType(subjectRef.kind()) | ||
.setObjectId(subjectRef.id()) | ||
.build(); | ||
return Core.SubjectReference.newBuilder().setObject(ref).build(); | ||
return SubjectReference.newBuilder().setObject(ref).build(); | ||
} | ||
} |
15 changes: 8 additions & 7 deletions
15
...ng/src/main/java/com/oviva/spicegen/spicedbbinding/internal/UpdateRelationshipMapper.java
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 |
---|---|---|
@@ -1,32 +1,33 @@ | ||
package com.oviva.spicegen.spicedbbinding.internal; | ||
|
||
import com.authzed.api.v1.Core; | ||
import com.authzed.api.v1.Relationship; | ||
import com.authzed.api.v1.RelationshipUpdate; | ||
import com.oviva.spicegen.api.UpdateRelationship; | ||
|
||
public class UpdateRelationshipMapper { | ||
|
||
private final ObjectReferenceMapper objectReferenceMapper = new ObjectReferenceMapper(); | ||
private final SubjectReferenceMapper subjectReferenceMapper = new SubjectReferenceMapper(); | ||
|
||
public Core.RelationshipUpdate map(UpdateRelationship updateRelationship) { | ||
public RelationshipUpdate map(UpdateRelationship updateRelationship) { | ||
|
||
var subjectRef = subjectReferenceMapper.map(updateRelationship.subject()); | ||
var resourceRef = objectReferenceMapper.map(updateRelationship.resource()); | ||
|
||
return Core.RelationshipUpdate.newBuilder() | ||
return RelationshipUpdate.newBuilder() | ||
.setOperation(mapOperation(updateRelationship.operation())) | ||
.setRelationship( | ||
Core.Relationship.newBuilder() | ||
Relationship.newBuilder() | ||
.setRelation(updateRelationship.relation()) | ||
.setSubject(subjectRef) | ||
.setResource(resourceRef)) | ||
.build(); | ||
} | ||
|
||
private Core.RelationshipUpdate.Operation mapOperation(UpdateRelationship.Operation operation) { | ||
private RelationshipUpdate.Operation mapOperation(UpdateRelationship.Operation operation) { | ||
return switch (operation) { | ||
case UPDATE -> Core.RelationshipUpdate.Operation.OPERATION_TOUCH; | ||
case DELETE -> Core.RelationshipUpdate.Operation.OPERATION_DELETE; | ||
case UPDATE -> RelationshipUpdate.Operation.OPERATION_TOUCH; | ||
case DELETE -> RelationshipUpdate.Operation.OPERATION_DELETE; | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.