44 "context"
55 "fmt"
66
7+ "github.com/conductorone/baton-sdk/pkg/connectorbuilder"
78 rs "github.com/conductorone/baton-sdk/pkg/types/resource"
89 "github.com/conductorone/baton-workato/pkg/connector/client"
910 "github.com/conductorone/baton-workato/pkg/connector/workato"
@@ -17,6 +18,8 @@ const (
1718 assignedEntitlement = "assigned"
1819)
1920
21+ var _ connectorbuilder.ResourceSyncerV2 = (* privilegeBuilder )(nil )
22+
2023type privilegeBuilder struct {
2124 client * client.WorkatoClient
2225 cache * collaboratorCache
@@ -26,8 +29,7 @@ func (o *privilegeBuilder) ResourceType(ctx context.Context) *v2.ResourceType {
2629 return privilegeResourceType
2730}
2831
29- // List returns all the users from the database as resource objects.
30- // Users include a UserTrait because they are the 'shape' of a standard user.
32+ // List returns all the privileges.
3133func (o * privilegeBuilder ) List (ctx context.Context , _ * v2.ResourceId , _ rs.SyncOpAttrs ) ([]* v2.Resource , * rs.SyncOpResults , error ) {
3234 l := ctxzap .Extract (ctx )
3335 l .Debug ("Listing privileges" )
@@ -47,7 +49,7 @@ func (o *privilegeBuilder) List(ctx context.Context, _ *v2.ResourceId, _ rs.Sync
4749 return rv , nil , nil
4850}
4951
50- // Entitlements always returns an empty slice for users .
52+ // Entitlements returns an entitlement for the privilege to be assigned to a collaborator .
5153func (o * privilegeBuilder ) Entitlements (_ context.Context , resource * v2.Resource , _ rs.SyncOpAttrs ) ([]* v2.Entitlement , * rs.SyncOpResults , error ) {
5254 var rv []* v2.Entitlement
5355 assigmentOptions := []entitlement.EntitlementOption {
@@ -60,12 +62,12 @@ func (o *privilegeBuilder) Entitlements(_ context.Context, resource *v2.Resource
6062 return rv , nil , nil
6163}
6264
63- // Grants always returns an empty slice for users since they don't have any entitlements .
64- func (o * privilegeBuilder ) Grants (ctx context.Context , resource * v2.Resource , attr rs.SyncOpAttrs ) ([]* v2.Grant , * rs.SyncOpResults , error ) {
65+ // Grants returns an empty slice. Grants for privileges are emitted when listing collaborator grants .
66+ func (o * privilegeBuilder ) Grants (_ context.Context , _ * v2.Resource , _ rs.SyncOpAttrs ) ([]* v2.Grant , * rs.SyncOpResults , error ) {
6567 return nil , nil , nil
6668}
6769
68- func newPrivilegeBuilder (client * client.WorkatoClient , env workato. Environment ) * privilegeBuilder {
70+ func newPrivilegeBuilder (client * client.WorkatoClient ) * privilegeBuilder {
6971 return & privilegeBuilder {
7072 client : client ,
7173 cache : newCollaboratorCache (client ),
0 commit comments