Interface BillingController
-
- All Known Implementing Classes:
MockBillingController
public interface BillingControllerA service that controls creation of bills based on the resource usage of a tenant, controls the quota for a tenant, and controls the plan the tenant is on.- Author:
- ogronnesby, olaa
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddLineItem(com.yahoo.config.provision.TenantName tenant, String description, BigDecimal amount, String agent)Add a line item to the given billBill.IdcreateBillForPeriod(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent)Create a bill of unbilled use for the given tenant in the given time period.StringcreateClientToken(String tenant, String userId)Get the auth token needed to talk to payment servicesBillcreateUncommittedBill(com.yahoo.config.provision.TenantName tenant, LocalDate until)Create an unpersisted bill of unbilled use for the given tenant from the end of last bill until the given date.Map<com.yahoo.config.provision.TenantName,Bill>createUncommittedBills(LocalDate until)Run {createUncommittedBill} for all tenants with unbilled usevoiddeleteBillingInfo(com.yahoo.config.provision.TenantName tenant, Set<User> users, boolean isPrivileged)Delete billing contact information from the tenantbooleandeleteInstrument(com.yahoo.config.provision.TenantName tenant, String userId, String instrumentId)Delete a payment instrument from the list of the tenant's instrumentsvoiddeleteLineItem(String lineItemId)Delete a line item - only available for unused line itemsList<Bill>getBills()Get all bills from the systemList<Bill>getBillsForTenant(com.yahoo.config.provision.TenantName tenant)Get all bills for the given tenantdefault CollectionMethodgetCollectionMethod(com.yahoo.config.provision.TenantName tenant)Get the bill collection method for the given tenantOptional<PaymentInstrument>getDefaultInstrument(com.yahoo.config.provision.TenantName tenant)Get the payment instrument for the given tenantPlanIdgetPlan(com.yahoo.config.provision.TenantName tenant)Get the plan ID for the given tenant.StringgetPlanDisplayName(PlanId planId)The display name of the given planQuotagetQuota(com.yahoo.config.provision.TenantName tenant)The quota for the given tenant.List<Bill.LineItem>getUnusedLineItems(com.yahoo.config.provision.TenantName tenant)Get line items that have been manually added to a tenant, but is not yet part of a billInstrumentListlistInstruments(com.yahoo.config.provision.TenantName tenant, String userId)List the payment instruments from the tenantbooleansetActivePaymentInstrument(InstrumentOwner paymentInstrument)Set the given payment instrument as the active instrument for the tenantdefault CollectionResultsetCollectionMethod(com.yahoo.config.provision.TenantName tenant, CollectionMethod method)Set the bill collection method for the given tenantPlanResultsetPlan(com.yahoo.config.provision.TenantName tenant, PlanId planId, boolean hasDeployments)Set the plan for the current tenant.List<com.yahoo.config.provision.TenantName>tenantsWithPlan(List<com.yahoo.config.provision.TenantName> existing, PlanId planId)Return the list of tenants with the given plan.voidupdateBillStatus(Bill.Id billId, String agent, String status)Change the status of the given bill
-
-
-
Method Detail
-
getPlan
PlanId getPlan(com.yahoo.config.provision.TenantName tenant)
Get the plan ID for the given tenant. This method will not fail if the tenant does not exist, it will return the default plan for that tenant instead.
-
tenantsWithPlan
List<com.yahoo.config.provision.TenantName> tenantsWithPlan(List<com.yahoo.config.provision.TenantName> existing, PlanId planId)
Return the list of tenants with the given plan.- Parameters:
existing- All existing tenants in the systemplanId- The ID of the plan to filter existing tenants on.- Returns:
- The tenants that have the given plan.
-
getQuota
Quota getQuota(com.yahoo.config.provision.TenantName tenant)
The quota for the given tenant. This method will return default quota for tenants that do not exist.
-
setPlan
PlanResult setPlan(com.yahoo.config.provision.TenantName tenant, PlanId planId, boolean hasDeployments)
Set the plan for the current tenant. Checks some pre-conditions to see if the tenant is eligible for the given plan.- Parameters:
tenant- The name of the tenant.planId- The ID of the plan to change to.hasDeployments- Does the tenant have active deployments.- Returns:
- String containing error message if something went wrong. Empty otherwise
-
createBillForPeriod
Bill.Id createBillForPeriod(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent)
Create a bill of unbilled use for the given tenant in the given time period.- Parameters:
tenant- The name of the tenant.startTime- The start of the billing periodendTime- The end of the billing periodagent- The agent that creates the bill- Returns:
- The ID of the new bill.
-
createUncommittedBill
Bill createUncommittedBill(com.yahoo.config.provision.TenantName tenant, LocalDate until)
Create an unpersisted bill of unbilled use for the given tenant from the end of last bill until the given date. This is used to show "unbilled use" in the Console.- Parameters:
tenant- The name of the tenant.until- The end date of the unbilled use period.- Returns:
- A bill with the resource use and cost.
-
createUncommittedBills
Map<com.yahoo.config.provision.TenantName,Bill> createUncommittedBills(LocalDate until)
Run {createUncommittedBill} for all tenants with unbilled use
-
getUnusedLineItems
List<Bill.LineItem> getUnusedLineItems(com.yahoo.config.provision.TenantName tenant)
Get line items that have been manually added to a tenant, but is not yet part of a bill
-
getDefaultInstrument
Optional<PaymentInstrument> getDefaultInstrument(com.yahoo.config.provision.TenantName tenant)
Get the payment instrument for the given tenant
-
createClientToken
String createClientToken(String tenant, String userId)
Get the auth token needed to talk to payment services
-
deleteInstrument
boolean deleteInstrument(com.yahoo.config.provision.TenantName tenant, String userId, String instrumentId)Delete a payment instrument from the list of the tenant's instruments
-
updateBillStatus
void updateBillStatus(Bill.Id billId, String agent, String status)
Change the status of the given bill
-
addLineItem
void addLineItem(com.yahoo.config.provision.TenantName tenant, String description, BigDecimal amount, String agent)Add a line item to the given bill
-
deleteLineItem
void deleteLineItem(String lineItemId)
Delete a line item - only available for unused line items
-
setActivePaymentInstrument
boolean setActivePaymentInstrument(InstrumentOwner paymentInstrument)
Set the given payment instrument as the active instrument for the tenant
-
listInstruments
InstrumentList listInstruments(com.yahoo.config.provision.TenantName tenant, String userId)
List the payment instruments from the tenant
-
getBillsForTenant
List<Bill> getBillsForTenant(com.yahoo.config.provision.TenantName tenant)
Get all bills for the given tenant
-
deleteBillingInfo
void deleteBillingInfo(com.yahoo.config.provision.TenantName tenant, Set<User> users, boolean isPrivileged)Delete billing contact information from the tenant
-
getCollectionMethod
default CollectionMethod getCollectionMethod(com.yahoo.config.provision.TenantName tenant)
Get the bill collection method for the given tenant
-
setCollectionMethod
default CollectionResult setCollectionMethod(com.yahoo.config.provision.TenantName tenant, CollectionMethod method)
Set the bill collection method for the given tenant
-
-