Skip to content

feat(cost-centers): migrate from BillingService to EnterpriseService.CostCenter API #77

@vmvarela

Description

@vmvarela

Description

go-github v84 exposes a new, richer Cost Centers API under EnterpriseService (file: enterprise_billing_cost_centers.go), separate from and more capable than the BillingService methods currently used in the cost-centers branch.

The new API supports individual GetCostCenter lookups, explicit AddResources/RemoveResources operations, and a ListCostCenterOptions filter — all missing from the current implementation.

go-github v84 API (EnterpriseService)

func (s *EnterpriseService) ListCostCenters(ctx context.Context, enterprise string, opts *ListCostCenterOptions) (*CostCenters, *Response, error)
func (s *EnterpriseService) GetCostCenter(ctx context.Context, enterprise, costCenterID string) (*CostCenter, *Response, error)
func (s *EnterpriseService) CreateCostCenter(ctx context.Context, enterprise string, costCenter CostCenterRequest) (*CostCenter, *Response, error)
func (s *EnterpriseService) UpdateCostCenter(ctx context.Context, enterprise, costCenterID string, costCenter CostCenterRequest) (*CostCenter, *Response, error)
func (s *EnterpriseService) DeleteCostCenter(ctx context.Context, enterprise, costCenterID string) (*DeleteCostCenterResponse, *Response, error)
func (s *EnterpriseService) AddResourcesToCostCenter(ctx context.Context, enterprise, costCenterID string, resources CostCenterResourceRequest) (*AddResourcesToCostCenterResponse, *Response, error)
func (s *EnterpriseService) RemoveResourcesFromCostCenter(ctx context.Context, enterprise, costCenterID string, resources CostCenterResourceRequest) (*RemoveResourcesFromCostCenterResponse, *Response, error)

Current State

The cost-centers branch uses client.Billing.GetCostCenters / CreateCostCenter / UpdateCostCenterResources / DeleteCostCenter (BillingService). These lack individual GetCostCenter and have a different resource mutation model.

Acceptance Criteria

  • Evaluate whether to migrate existing resource_github_enterprise_cost_center.go to the new EnterpriseService methods or keep both paths
  • Use EnterpriseService.GetCostCenter in Read (instead of scanning list)
  • Use EnterpriseService.AddResourcesToCostCenter / RemoveResourcesFromCostCenter for reconciliation in Update
  • Use ListCostCenterOptions (state filter) in the data source
  • Update util_enterprise_cost_center.go accordingly
  • All acceptance tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    cost-centersRelated to the cost-centers feature branchpriority:highMust be in the next sprintsize:mMedium — 4 to 8 hourstype:featureNew functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions