feat: add billing accounts sync as entitlements - #35
Conversation
Add support for syncing Coupa Billing Accounts as Entitlements in ConductorOne with full Grant/Revoke provisioning capability. New files: - pkg/connector/billing_accounts.go: ResourceSyncer implementation with List, Entitlements, Grants, Grant, and Revoke methods - pkg/connector/client/billing_accounts.go: SetUserAccounts REST client Modified files: - client/models.go: Account, AccountsQueryResponse, and related structs - client/query.go: GraphQL queries for accounts listing and grants - client/path.go: REST API path for account assignment - client/auth.go: Added core.accounting.read/write OAuth scopes - resource_types.go: billingAccountResourceType definition - connector.go: Registered billingAccountBuilder in ResourceSyncers - baton_capabilities.json: billing_account with SYNC + PROVISION Note: The exact GraphQL field names for billing account queries need validation against a live Coupa instance. The implementation follows the established patterns for roles and groups. Fixes: CXH-1353
|
Claude finished @c1-dev-bot[bot]'s task in 1m 42s —— View job PR Review: feat: add billing accounts sync as entitlements
Overall AssessmentThis is a well-structured PR that closely follows the established patterns from the roles and groups builders. The implementation is consistent and easy to follow. There are a few issues to address, ranging from a potential data model mismatch to minor improvements. Issues1. Singular vs Plural:
|
laurenleach
left a comment
There was a problem hiding this comment.
we should document the required scopes on the resource type capabilities (like https://github.com/ConductorOne/baton-slack-enterprise/blob/main/pkg/connector/resource_types.go#L25-L34)
Summary
Changes
New Files
pkg/connector/billing_accounts.go—billingAccountBuilderimplementing theResourceSyncerinterface with all five methods (List, Entitlements, Grants, Grant, Revoke)pkg/connector/client/billing_accounts.go—SetUserAccountsREST client method for assigning/removing billing accounts viaPUT /api/users/{id}Modified Files
pkg/connector/client/models.go— AddedAccount,AccountsQueryResponse,AccountGrantsQueryResponse,UserAccounts,UserAccountsResponse, andUserAccountsPutResponsestructspkg/connector/client/query.go— Added GraphQL query templates:getAccountsQuery,getAccountGrantListQuery,getUserAccountsQueryand their corresponding functionspkg/connector/client/path.go— AddedsetAccountPathfor REST billing account assignmentpkg/connector/client/auth.go— Addedcore.accounting.readandcore.accounting.writeOAuth scopespkg/connector/resource_types.go— AddedbillingAccountResourceTypedefinitionpkg/connector/connector.go— RegisterednewBillingAccountBuilderinResourceSyncers(), updated connector descriptionbaton_capabilities.json— Addedbilling_accountresource type withCAPABILITY_SYNCandCAPABILITY_PROVISIONImportant Notes
The exact GraphQL field names for billing account queries need validation against a live Coupa instance:
accountsresource name in GraphQLaccount[id]filter for querying users by billing accountaccountfield on the user object for current assignmentsaccount) in the PUT request bodyThe implementation uses the same two-step revoke pattern (clear all, then re-set) used by roles and groups, as Coupa may have the same API constraint.
Test plan
GrantAlreadyExistsGrantAlreadyRevokedFixes: CXH-1353
Automated PR Notice
This PR was automatically created by c1-dev-bot as a potential implementation.
This code requires: