billing: add account membership API (invite members)#123
Merged
Conversation
Add ListMembers/AddMember/RemoveMember to the Billing interface plus their request/response types, so a billing account owner can invite other people to help manage the account. Two member roles alongside the implicit owner: - admin: full co-manager (view + pay invoices, edit tax details, manage members, bill projects to the account); cannot delete the account. - accountant: view invoices/receipts, view the usage report, and pay only. BillingItem gains a Role field carrying the caller's effective role (owner|admin|accountant). AddMember validates a real email (govalidator.IsEmail rejects allUsers/allAuthenticatedUsers — no public principals) + a valid role, and canonicalizes the email lower-case so a mixed-case invite can't lock out the invitee. New errors: ErrBillingForbidden, ErrBillingMemberNotFound, ErrBillingMemberIsOwner. billing.* stays non-delegatable. Also documents on the Project interface that project.create/update require the caller to be owner/admin of the target billing account.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets a billing account owner invite other people to help manage the account — e.g. a company accountant who needs to view invoices/receipts and pay them, without sharing the owner's login.
Adds three methods to the
Billinginterface plus their request/response types and Go client implementations:billing.listMembers— list a billing account's invited members (owner/admin only).billing.addMember— invite a user or change an existing member's role (owner/admin only; upsert).billing.removeMember— remove an invited member (owner/admin only).Roles
Two member roles alongside the implicit owner (the
billing_accounts.ownercolumn, never a member row):billing.update)billing.delete)Notes
BillingItemgains aRolefield carrying the caller's effective role (owner|admin|accountant) so a client can gate management UI without a second lookup.AddMember.Valid()usesgovalidator.IsEmail, which also rejectsallUsers/allAuthenticatedUsers— billing is money, so members must be real, addressable identities (no public principals).billing.*remains non-delegatable (unchangedrole.gobranch): billing is authorized by ownership/membership, not project IAM.ErrBillingForbidden,ErrBillingMemberNotFound,ErrBillingMemberIsOwner.This is the contract-only PR; the apiserver enforcement, console portal UI, docs, MCP and CLI changes land in follow-up PRs that pin to this once merged.
Test
go build ./... && go vet ./...clean.