Class MockBillingController
java.lang.Object
com.yahoo.vespa.hosted.controller.api.integration.billing.MockBillingController
- All Implemented Interfaces:
BillingController
- Author:
- olaa
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddLineItem(com.yahoo.config.provision.TenantName tenant, String description, BigDecimal amount, Optional<Bill.Id> billId, String agent) Add a line item to the given billcreateBillForPeriod(com.yahoo.config.provision.TenantName tenant, LocalDate startDate, LocalDate endDate, String agent) 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.createClientToken(String tenant, String userId) Get the auth token needed to talk to payment servicescreateUncommittedBill(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.createUncommittedBills(LocalDate until) Run {createUncommittedBill} for all tenants with unbilled usebooleandeleteInstrument(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 itemsgetBills()Get all bills from the systemgetBillsForTenant(com.yahoo.config.provision.TenantName tenant) Get all bills for the given tenantgetCollectionMethod(com.yahoo.config.provision.TenantName tenant) Get the bill collection method for the given tenantgetDefaultInstrument(com.yahoo.config.provision.TenantName tenant) Get the payment instrument for the given tenantgetPlan(com.yahoo.config.provision.TenantName tenant) Get the plan ID for the given tenant.getPlanDisplayName(PlanId planId) The display name of the given plangetQuota(com.yahoo.config.provision.TenantName tenant) The quota for the given tenant.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 billlistInstruments(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 tenantsetCollectionMethod(com.yahoo.config.provision.TenantName tenant, CollectionMethod method) Set the bill collection method for the given tenantsetPlan(com.yahoo.config.provision.TenantName tenant, PlanId planId, boolean hasDeployments, boolean isAccountant) Set the plan for the current tenant.voidsetTenants(List<com.yahoo.config.provision.TenantName> tenants) List<com.yahoo.config.provision.TenantName>tenantsWithPlan(List<com.yahoo.config.provision.TenantName> tenants, PlanId planId) Return the list of tenants with the given plan.booleantenantsWithPlanUnderLimit(Plan plan, int limit) Test if the number of tenants with the given plan is under the given limitvoidupdateBillStatus(Bill.Id billId, String agent, String status) Change the status of the given billMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.yahoo.vespa.hosted.controller.api.integration.billing.BillingController
updateCache
-
Constructor Details
-
MockBillingController
-
-
Method Details
-
getPlan
Description copied from interface:BillingControllerGet 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.- Specified by:
getPlanin interfaceBillingController
-
tenantsWithPlan
public List<com.yahoo.config.provision.TenantName> tenantsWithPlan(List<com.yahoo.config.provision.TenantName> tenants, PlanId planId) Description copied from interface:BillingControllerReturn the list of tenants with the given plan.- Specified by:
tenantsWithPlanin interfaceBillingController- Parameters:
tenants- All existing tenants in the systemplanId- The ID of the plan to filter existing tenants on.- Returns:
- The tenants that have the given plan.
-
getPlanDisplayName
Description copied from interface:BillingControllerThe display name of the given plan- Specified by:
getPlanDisplayNamein interfaceBillingController
-
getQuota
Description copied from interface:BillingControllerThe quota for the given tenant. This method will return default quota for tenants that do not exist.- Specified by:
getQuotain interfaceBillingController
-
setPlan
public PlanResult setPlan(com.yahoo.config.provision.TenantName tenant, PlanId planId, boolean hasDeployments, boolean isAccountant) Description copied from interface:BillingControllerSet the plan for the current tenant. Checks some pre-conditions to see if the tenant is eligible for the given plan.- Specified by:
setPlanin interfaceBillingController- Parameters:
tenant- The name of the tenant.planId- The ID of the plan to change to.hasDeployments- Does the tenant have active deployments.isAccountant- Is it the hosted accountant that is doing the operation- Returns:
- String containing error message if something went wrong. Empty otherwise
-
createBillForPeriod
public Bill.Id createBillForPeriod(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent) Description copied from interface:BillingControllerCreate a bill of unbilled use for the given tenant in the given time period.- Specified by:
createBillForPeriodin interfaceBillingController- 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.
-
createBillForPeriod
public Bill.Id createBillForPeriod(com.yahoo.config.provision.TenantName tenant, LocalDate startDate, LocalDate endDate, String agent) - Specified by:
createBillForPeriodin interfaceBillingController
-
createUncommittedBill
Description copied from interface:BillingControllerCreate 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.- Specified by:
createUncommittedBillin interfaceBillingController- 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
Description copied from interface:BillingControllerRun {createUncommittedBill} for all tenants with unbilled use- Specified by:
createUncommittedBillsin interfaceBillingController
-
getUnusedLineItems
Description copied from interface:BillingControllerGet line items that have been manually added to a tenant, but is not yet part of a bill- Specified by:
getUnusedLineItemsin interfaceBillingController
-
getDefaultInstrument
public Optional<PaymentInstrument> getDefaultInstrument(com.yahoo.config.provision.TenantName tenant) Description copied from interface:BillingControllerGet the payment instrument for the given tenant- Specified by:
getDefaultInstrumentin interfaceBillingController
-
createClientToken
Description copied from interface:BillingControllerGet the auth token needed to talk to payment services- Specified by:
createClientTokenin interfaceBillingController
-
deleteInstrument
public boolean deleteInstrument(com.yahoo.config.provision.TenantName tenant, String userId, String instrumentId) Description copied from interface:BillingControllerDelete a payment instrument from the list of the tenant's instruments- Specified by:
deleteInstrumentin interfaceBillingController
-
updateBillStatus
Description copied from interface:BillingControllerChange the status of the given bill- Specified by:
updateBillStatusin interfaceBillingController
-
addLineItem
public void addLineItem(com.yahoo.config.provision.TenantName tenant, String description, BigDecimal amount, Optional<Bill.Id> billId, String agent) Description copied from interface:BillingControllerAdd a line item to the given bill- Specified by:
addLineItemin interfaceBillingController
-
deleteLineItem
Description copied from interface:BillingControllerDelete a line item - only available for unused line items- Specified by:
deleteLineItemin interfaceBillingController
-
setActivePaymentInstrument
Description copied from interface:BillingControllerSet the given payment instrument as the active instrument for the tenant- Specified by:
setActivePaymentInstrumentin interfaceBillingController
-
listInstruments
Description copied from interface:BillingControllerList the payment instruments from the tenant- Specified by:
listInstrumentsin interfaceBillingController
-
getBillsForTenant
Description copied from interface:BillingControllerGet all bills for the given tenant- Specified by:
getBillsForTenantin interfaceBillingController
-
getBills
Description copied from interface:BillingControllerGet all bills from the system- Specified by:
getBillsin interfaceBillingController
-
getCollectionMethod
Description copied from interface:BillingControllerGet the bill collection method for the given tenant- Specified by:
getCollectionMethodin interfaceBillingController
-
setCollectionMethod
public CollectionResult setCollectionMethod(com.yahoo.config.provision.TenantName tenant, CollectionMethod method) Description copied from interface:BillingControllerSet the bill collection method for the given tenant- Specified by:
setCollectionMethodin interfaceBillingController
-
tenantsWithPlanUnderLimit
Description copied from interface:BillingControllerTest if the number of tenants with the given plan is under the given limit- Specified by:
tenantsWithPlanUnderLimitin interfaceBillingController
-
setTenants
-
addBill
-