router

package
v1.0.0-beta.189 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2025 License: Apache-2.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	NamespaceManager    *namespace.Manager
	StreamingConnector  streaming.Connector
	IngestHandler       http.Handler
	Meters              meter.Repository
	PortalCORSEnabled   bool
	PortalTokenStrategy *authenticator.PortalTokenStrategy
	ErrorHandler        errorsx.Handler
	Logger              *slog.Logger

	// deps
	App                         app.Service
	AppStripe                   appstripe.Service
	Customer                    customer.Service
	Billing                     billing.Service
	Plan                        plan.Service
	SubscriptionService         subscription.Service
	SubscriptionWorkflowService subscription.WorkflowService
	PlanSubscriptionService     plansubscription.PlanSubscriptionService
	DebugConnector              debug.DebugConnector
	FeatureConnector            feature.FeatureConnector
	EntitlementConnector        entitlement.Connector
	EntitlementBalanceConnector meteredentitlement.Connector
	GrantConnector              credit.GrantConnector
	GrantRepo                   grant.Repo
	Notification                notification.Service

	// FIXME: implement generic module management, loading, etc...
	BillingEnabled        bool
	ProductCatalogEnabled bool
	AppsEnabled           bool
}

func (Config) Validate

func (c Config) Validate() error

type IngestHandler

type IngestHandler interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request, namespace string)
}

type QueryMeterResponse

type QueryMeterResponse struct {
	WindowSize *models.WindowSize     `json:"windowSize,omitempty"`
	From       *time.Time             `json:"from,omitempty"`
	To         *time.Time             `json:"to,omitempty"`
	Data       []models.MeterQueryRow `json:"data"`
}

QueryMeterResponse is returned by the QueryMeter endpoint.

func (QueryMeterResponse) Render

Render implements the chi renderer interface.

func (QueryMeterResponse) RenderCSV

func (resp QueryMeterResponse) RenderCSV(w http.ResponseWriter, r *http.Request, _groupByKeys []string, meterIDOrSlug string)

RenderCSV renders the response as CSV.

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(config Config) (*Router, error)

func (*Router) AdvanceInvoiceAction

func (a *Router) AdvanceInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string)

Advance the invoice's state to the next status (POST /api/v1/billing/invoices/{invoiceId}/advance)

func (*Router) AppStripeWebhook

func (a *Router) AppStripeWebhook(w http.ResponseWriter, r *http.Request, appID string)

Handle app stripe webhook (POST /api/v1/apps/{appId}/stripe/webhook)

func (*Router) ApproveInvoiceAction

func (a *Router) ApproveInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string)

Send the invoice to the customer (POST /api/v1/billing/invoices/{invoiceId}/approve)

func (*Router) ArchivePlan

func (a *Router) ArchivePlan(w http.ResponseWriter, r *http.Request, planId string)

Archive plan version (POST /api/v1/plans/{planId}/archive)

func (*Router) CancelSubscription

func (a *Router) CancelSubscription(w http.ResponseWriter, r *http.Request, subscriptionId string)

(POST /api/v1/subscriptions/{subscriptionId}/cancel)

func (*Router) ChangeSubscription

func (a *Router) ChangeSubscription(w http.ResponseWriter, r *http.Request, subscriptionId string)

func (*Router) CreateBillingProfile

func (a *Router) CreateBillingProfile(w http.ResponseWriter, r *http.Request)

Create a new billing profile (POST /api/v1/billing/profile)

func (*Router) CreateCustomer

func (a *Router) CreateCustomer(w http.ResponseWriter, r *http.Request)

Create a customer (POST /api/v1/customer/customers)

func (*Router) CreateEntitlement

func (a *Router) CreateEntitlement(w http.ResponseWriter, r *http.Request, subjectIdOrKey string)

Create entitlement (POST /api/v1/subjects/{subjectIdOrKey}/entitlements)

func (*Router) CreateFeature

func (a *Router) CreateFeature(w http.ResponseWriter, r *http.Request)

Create feature (POST /api/v1/features)

func (*Router) CreateGrant

func (a *Router) CreateGrant(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, entitlementIdOrFeatureKey string)

Create grant (POST /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/grants)

func (*Router) CreateNotificationChannel

func (a *Router) CreateNotificationChannel(w http.ResponseWriter, r *http.Request)

Create a notification channel (POST /api/v1/notification/channels)

func (*Router) CreateNotificationRule

func (a *Router) CreateNotificationRule(w http.ResponseWriter, r *http.Request)

Create a notification rule (POST /api/v1/notification/rules)

func (*Router) CreatePendingInvoiceLine

func (a *Router) CreatePendingInvoiceLine(w http.ResponseWriter, r *http.Request)

Create a new line item (POST /api/v1/billing/invoices/lines)

func (*Router) CreatePlan

func (a *Router) CreatePlan(w http.ResponseWriter, r *http.Request)

Create a plan (POST /api/v1/plans)

func (*Router) CreatePortalToken

func (a *Router) CreatePortalToken(w http.ResponseWriter, r *http.Request)

CreatePortalToken creates a new portal token.

func (*Router) CreateStripeCheckoutSession

func (a *Router) CreateStripeCheckoutSession(w http.ResponseWriter, r *http.Request)

Handle create app stripe checkout session (POST /api/v1/stripe/checkout/sessions)

func (*Router) CreateSubscription

func (a *Router) CreateSubscription(w http.ResponseWriter, r *http.Request)

(POST /api/v1/subscriptions)

func (*Router) DeleteBillingProfile

func (a *Router) DeleteBillingProfile(w http.ResponseWriter, r *http.Request, id string)

Archive a billing profile (DELETE /api/v1/billing/profile/{id})

func (*Router) DeleteBillingProfileCustomerOverride

func (a *Router) DeleteBillingProfileCustomerOverride(w http.ResponseWriter, r *http.Request, customerId string)

Delete a customer override (DELETE /api/v1/billing/customer/{customerId})

func (*Router) DeleteCustomer

func (a *Router) DeleteCustomer(w http.ResponseWriter, r *http.Request, customerID string)

Delete a customer (DELETE /api/v1/customer/customers/{customerId})

func (*Router) DeleteCustomerAppData

func (a *Router) DeleteCustomerAppData(w http.ResponseWriter, r *http.Request, customerID string, appID string)

Delete customer app data (DELETE /api/v1/customer/customers/{customerId}/apps/{appId})

func (*Router) DeleteEntitlement

func (a *Router) DeleteEntitlement(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, entitlementId string)

Delete entitlement (DELETE /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId})

func (*Router) DeleteFeature

func (a *Router) DeleteFeature(w http.ResponseWriter, r *http.Request, featureId string)

Delete feature (DELETE /api/v1/features/{featureId})

func (*Router) DeleteInvoice

func (a *Router) DeleteInvoice(w http.ResponseWriter, r *http.Request, invoiceId string)

Delete an invoice (DELETE /api/v1/billing/invoices/{customerId}/invoices/{invoiceId})

func (*Router) DeleteNotificationChannel

func (a *Router) DeleteNotificationChannel(w http.ResponseWriter, r *http.Request, channelID string)

Delete a notification channel (DELETE /api/v1/notification/channels/{channelId})

func (*Router) DeleteNotificationRule

func (a *Router) DeleteNotificationRule(w http.ResponseWriter, r *http.Request, ruleID string)

Delete a notification rule (DELETE /api/v1/notification/rules/{ruleId})

func (*Router) DeletePlan

func (a *Router) DeletePlan(w http.ResponseWriter, r *http.Request, planId string)

Delete plan (DELETE /api/v1/plans/{planId})

func (*Router) EditSubscription

func (a *Router) EditSubscription(w http.ResponseWriter, r *http.Request, subscriptionId string)

(PATCH /api/v1/subscriptions/{subscriptionId})

func (*Router) GetApp

func (a *Router) GetApp(w http.ResponseWriter, r *http.Request, appID string)

Handle to get app by id (GET /api/v1/apps/{appId})

func (*Router) GetBillingProfile

func (a *Router) GetBillingProfile(w http.ResponseWriter, r *http.Request, id string, params api.GetBillingProfileParams)

Get a billing profile by ID (GET /api/v1/billing/profile/{id})

func (*Router) GetBillingProfileCustomerOverride

func (a *Router) GetBillingProfileCustomerOverride(w http.ResponseWriter, r *http.Request, customerId string)

Get a customer override (GET /api/v1/billing/customer/{customerId})

func (*Router) GetCustomer

func (a *Router) GetCustomer(w http.ResponseWriter, r *http.Request, customerID string)

Get customer (GET /api/v1/customer/customers/{customerId})

func (*Router) GetCustomerEntitlementValue

func (a *Router) GetCustomerEntitlementValue(w http.ResponseWriter, r *http.Request, customerId string, featureKey string, params api.GetCustomerEntitlementValueParams)

Get entitlement value (GET /api/v1/customers/{customerId}/entitlements/{featureKey}/value)

func (*Router) GetDebugMetrics

func (a *Router) GetDebugMetrics(w http.ResponseWriter, r *http.Request)

Get debug metrics (GET /api/v1/debug/metrics)

func (*Router) GetEntitlement

func (a *Router) GetEntitlement(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, entitlementId string)

Get entitlement (GET /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId})

func (*Router) GetEntitlementById

func (a *Router) GetEntitlementById(w http.ResponseWriter, r *http.Request, entitlementId string)

Get an entitlement (GET /api/v1/entitlements/{entitlementId})

func (*Router) GetEntitlementHistory

func (a *Router) GetEntitlementHistory(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, entitlementId string, params api.GetEntitlementHistoryParams)

Get the balance history of a specific entitlement. (GET /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/history)

func (*Router) GetEntitlementValue

func (a *Router) GetEntitlementValue(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, entitlementIdOrFeatureKey string, params api.GetEntitlementValueParams)

Get the value of a specific entitlement. (GET /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/value)

func (*Router) GetFeature

func (a *Router) GetFeature(w http.ResponseWriter, r *http.Request, featureId string)

Get feature (GET /api/v1/features/{featureId})

func (*Router) GetInvoice

func (a *Router) GetInvoice(w http.ResponseWriter, r *http.Request, invoiceId string, params api.GetInvoiceParams)

Get an invoice (GET /api/v1/billing/invoices/{invoiceId})

func (*Router) GetMarketplaceListing

func (a *Router) GetMarketplaceListing(w http.ResponseWriter, r *http.Request, appType api.AppType)

Get a marketplace listing (GET /api/v1/marketplace/listings/{appType})

func (*Router) GetMeter

func (a *Router) GetMeter(w http.ResponseWriter, r *http.Request, meterIdOrSlug string)

func (*Router) GetNotificationChannel

func (a *Router) GetNotificationChannel(w http.ResponseWriter, r *http.Request, channelID string)

Get notification channel (GET /api/v1/notification/channels/{channelId})

func (*Router) GetNotificationEvent

func (a *Router) GetNotificationEvent(w http.ResponseWriter, r *http.Request, eventID string)

Get notification event (GET /api/v1/notification/events/{eventId})

func (*Router) GetNotificationRule

func (a *Router) GetNotificationRule(w http.ResponseWriter, r *http.Request, ruleID string)

Get notification rule (GET /api/v1/notification/rules/{ruleId})

func (*Router) GetPlan

func (a *Router) GetPlan(w http.ResponseWriter, r *http.Request, planIdOrKey string, params api.GetPlanParams)

Get plan (GET /api/v1/plans/{planId})

func (*Router) GetSubscription

func (a *Router) GetSubscription(w http.ResponseWriter, r *http.Request, subscriptionId string, params api.GetSubscriptionParams)

(GET /api/v1/subscriptions/{subscriptionId})

func (*Router) IngestEvents

func (a *Router) IngestEvents(w http.ResponseWriter, r *http.Request)

func (*Router) InvalidatePortalTokens

func (a *Router) InvalidatePortalTokens(w http.ResponseWriter, r *http.Request)

func (*Router) InvoicePendingLinesAction

func (a *Router) InvoicePendingLinesAction(w http.ResponseWriter, r *http.Request)

Invoice a customer based on the pending line items (POST /api/v1/billing/invoices/{customerId}/invoice)

func (*Router) ListApps

func (a *Router) ListApps(w http.ResponseWriter, r *http.Request, params api.ListAppsParams)

Handle to list apps (GET /api/v1/apps)

func (*Router) ListBillingProfileCustomerOverrides

func (a *Router) ListBillingProfileCustomerOverrides(w http.ResponseWriter, r *http.Request, params api.ListBillingProfileCustomerOverridesParams)

List customer overrides (GET /api/v1/billing/customer)

func (*Router) ListBillingProfiles

func (a *Router) ListBillingProfiles(w http.ResponseWriter, r *http.Request, params api.ListBillingProfilesParams)

(GET /api/v1/billing/profile)

func (*Router) ListCurrencies

func (a *Router) ListCurrencies(w http.ResponseWriter, r *http.Request)

List supported currencies (GET /api/v1/info/currencies)

func (*Router) ListCustomerAppData

func (a *Router) ListCustomerAppData(w http.ResponseWriter, r *http.Request, customerID string, params api.ListCustomerAppDataParams)

List customer apps (GET /api/v1/customer/customers/{customerId}/apps)

func (*Router) ListCustomers

func (a *Router) ListCustomers(w http.ResponseWriter, r *http.Request, params api.ListCustomersParams)

List customers (GET /api/v1/customer/customers)

func (*Router) ListEntitlementGrants

func (a *Router) ListEntitlementGrants(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, entitlementIdOrFeatureKey string, params api.ListEntitlementGrantsParams)

List grants for an entitlement (GET /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants)

func (*Router) ListEntitlements

func (a *Router) ListEntitlements(w http.ResponseWriter, r *http.Request, params api.ListEntitlementsParams)

List entitlements (GET /api/v1/entitlements)

func (*Router) ListEvents

func (a *Router) ListEvents(w http.ResponseWriter, r *http.Request, params api.ListEventsParams)

func (*Router) ListFeatures

func (a *Router) ListFeatures(w http.ResponseWriter, r *http.Request, params api.ListFeaturesParams)

List features (GET /api/v1/features)

func (*Router) ListGrants

func (a *Router) ListGrants(w http.ResponseWriter, r *http.Request, params api.ListGrantsParams)

List grants (GET /api/v1/grants)

func (*Router) ListInvoices

func (a *Router) ListInvoices(w http.ResponseWriter, r *http.Request, params api.ListInvoicesParams)

List invoices (GET /api/v1/billing/invoices)

func (*Router) ListMarketplaceListings

func (a *Router) ListMarketplaceListings(w http.ResponseWriter, r *http.Request, params api.ListMarketplaceListingsParams)

List marketplace listings (GET /api/v1/marketplace/listings)

func (*Router) ListMeterSubjects

func (a *Router) ListMeterSubjects(w http.ResponseWriter, r *http.Request, meterIDOrSlug string)

ListMeterSubjects lists the subjects of a meter.

func (*Router) ListMeters

func (a *Router) ListMeters(w http.ResponseWriter, r *http.Request)

func (*Router) ListNotificationChannels

func (a *Router) ListNotificationChannels(w http.ResponseWriter, r *http.Request, params api.ListNotificationChannelsParams)

List notification channels (GET /api/v1/notification/channels)

func (*Router) ListNotificationEvents

func (a *Router) ListNotificationEvents(w http.ResponseWriter, r *http.Request, params api.ListNotificationEventsParams)

List notification evens (GET /api/v1/notification/events)

func (*Router) ListNotificationRules

func (a *Router) ListNotificationRules(w http.ResponseWriter, r *http.Request, params api.ListNotificationRulesParams)

List notification rules (GET /api/v1/notification/rules)

func (*Router) ListPlans

func (a *Router) ListPlans(w http.ResponseWriter, r *http.Request, params api.ListPlansParams)

List plans (GET /api/v1/plans)

func (*Router) ListPortalTokens

func (a *Router) ListPortalTokens(w http.ResponseWriter, r *http.Request, params api.ListPortalTokensParams)

func (*Router) ListSubjectEntitlements

func (a *Router) ListSubjectEntitlements(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, params api.ListSubjectEntitlementsParams)

List entitlements (GET /api/v1/subjects/{subjectIdOrKey}/entitlements)

func (*Router) MarketplaceAppAPIKeyInstall

func (a *Router) MarketplaceAppAPIKeyInstall(w http.ResponseWriter, r *http.Request, appType api.AppType)

Install a marketplace app by API key (POST /api/v1/marketplace/install/apikey)

func (*Router) MarketplaceOAuth2InstallAuthorize

func (a *Router) MarketplaceOAuth2InstallAuthorize(w http.ResponseWriter, r *http.Request, appType api.AppType, params api.MarketplaceOAuth2InstallAuthorizeParams)

Authorize the installation of a marketplace app by OAuth2 (// (GET /api/v1/marketplace/install/oauth2/authorize))

func (*Router) MarketplaceOAuth2InstallGetURL

func (a *Router) MarketplaceOAuth2InstallGetURL(w http.ResponseWriter, r *http.Request, appType api.AppType)

Get the URL to install a marketplace app by OAuth2 (GET /api/v1/marketplace/install/oauth2)

func (*Router) MigrateSubscription

func (a *Router) MigrateSubscription(w http.ResponseWriter, r *http.Request, subscriptionId string)

(POST /api/v1/subscriptions/{subscriptionId}/migrate)

func (*Router) NextPlan

func (a *Router) NextPlan(w http.ResponseWriter, r *http.Request, planIdOrKey string)

New draft plan (POST /api/v1/plans/{planIdOrKey}/next)

func (*Router) OverrideEntitlement

func (a *Router) OverrideEntitlement(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, entitlementIdOrFeatureKey string)

Override an entitlement (PUT /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/override)

func (*Router) PublishPlan

func (a *Router) PublishPlan(w http.ResponseWriter, r *http.Request, planId string)

Publish plan (POST /api/v1/plans/{planId}/publish)

func (*Router) QueryMeter

func (a *Router) QueryMeter(w http.ResponseWriter, r *http.Request, meterIDOrSlug string, params api.QueryMeterParams)

QueryMeter queries the values stored for a meter.

func (*Router) QueryMeterWithMeter

func (a *Router) QueryMeterWithMeter(ctx context.Context, w http.ResponseWriter, r *http.Request, logger *slog.Logger, meter models.Meter, params api.QueryMeterParams)

QueryMeter queries the values stored for a meter.

func (*Router) QueryPortalMeter

func (a *Router) QueryPortalMeter(w http.ResponseWriter, r *http.Request, meterSlug string, params api.QueryPortalMeterParams)

func (*Router) RecalculateInvoiceTaxAction

func (a *Router) RecalculateInvoiceTaxAction(w http.ResponseWriter, r *http.Request, invoiceId string)

Recalculate an invoice's tax amounts (POST /api/v1/billing/invoices/{invoiceId}/tax/recalculate)

func (*Router) ReceiveSvixOperationalEvent

func (a *Router) ReceiveSvixOperationalEvent(w http.ResponseWriter, r *http.Request)

Receive Svix operational events (POST /api/v1/notification/webhook/svix)

func (*Router) ResetEntitlementUsage

func (a *Router) ResetEntitlementUsage(w http.ResponseWriter, r *http.Request, subjectIdOrKey string, entitlementId string)

Reset entitlement (POST /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/reset)

func (*Router) RetryInvoiceAction

func (a *Router) RetryInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string)

Retry a failed synchronization step of the invoice (POST /api/v1/billing/invoices/{invoiceId}/retry)

func (*Router) SimulateInvoice

func (a *Router) SimulateInvoice(w http.ResponseWriter, r *http.Request, customerId string)

Simulate an invoice for a customer (POST /api/v1/billing/customers/{customerId}/invoices/simulate)

func (*Router) TestNotificationRule

func (a *Router) TestNotificationRule(w http.ResponseWriter, r *http.Request, ruleID string)

Test notification rule (POST /api/v1/notification/rules/{ruleId}/test)

func (*Router) UninstallApp

func (a *Router) UninstallApp(w http.ResponseWriter, r *http.Request, appID string)

Uninstall an app by id (DELETE /api/v1/apps/{id})

func (*Router) UnscheduleCancelation

func (a *Router) UnscheduleCancelation(w http.ResponseWriter, r *http.Request, subscriptionId string)

(POST /api/v1/subscriptions/{subscriptionId}/unschedule-cancelation)

func (*Router) UpdateApp

func (a *Router) UpdateApp(w http.ResponseWriter, r *http.Request, appID string)

Handle to update an app (PUT /api/v1/apps/{appId})

func (*Router) UpdateBillingProfile

func (a *Router) UpdateBillingProfile(w http.ResponseWriter, r *http.Request, id string)

Update a billing profile (PUT /api/v1/billing/profile/{id})

func (*Router) UpdateCustomer

func (a *Router) UpdateCustomer(w http.ResponseWriter, r *http.Request, customerID string)

Update customer (PUT /api/v1/customer/customers/{customerId})

func (*Router) UpdateInvoice

func (a *Router) UpdateInvoice(w http.ResponseWriter, r *http.Request, invoiceId string)

Update an invoice (PUT /api/v1/billing/invoices/{invoiceId})

func (*Router) UpdateNotificationChannel

func (a *Router) UpdateNotificationChannel(w http.ResponseWriter, r *http.Request, channelID string)

Update notification channel (PUT /api/v1/notification/channels/{channelId})

func (*Router) UpdateNotificationRule

func (a *Router) UpdateNotificationRule(w http.ResponseWriter, r *http.Request, ruleID string)

Update a notification rule (PUT /api/v1/notification/rules/{ruleId})

func (*Router) UpdatePlan

func (a *Router) UpdatePlan(w http.ResponseWriter, r *http.Request, planId string)

Update a plan (PUT /api/v1/plans/{planId})

func (*Router) UpdateStripeAPIKey

func (a *Router) UpdateStripeAPIKey(w http.ResponseWriter, r *http.Request, appID string)

Handle update stripe api key (POST /api/v1/apps/{id}/stripe/api-key)

func (*Router) UpsertBillingProfileCustomerOverride

func (a *Router) UpsertBillingProfileCustomerOverride(w http.ResponseWriter, r *http.Request, customerId string)

Create/update a customer override (POST /api/v1/billing/customer/{customerId})

func (*Router) UpsertCustomerAppData

func (a *Router) UpsertCustomerAppData(w http.ResponseWriter, r *http.Request, customerID string)

Upsert customer app data (PUT /api/v1/customer/customers/{customerId}/apps/{appId})

func (*Router) VoidGrant

func (a *Router) VoidGrant(w http.ResponseWriter, r *http.Request, grantId string)

Delete a grant (DELETE /api/v1/grants/{grantId})

func (*Router) VoidInvoiceAction

func (a *Router) VoidInvoiceAction(w http.ResponseWriter, r *http.Request, invoiceId string)

Void an invoice (POST /api/v1/billing/invoices/{invoiceId}/void)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL