router

package
v1.0.0-beta.96 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 33 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

	// deps
	FeatureConnector            productcatalog.FeatureConnector
	EntitlementConnector        entitlement.Connector
	EntitlementBalanceConnector meteredentitlement.Connector
	GrantConnector              credit.GrantConnector

	// FIXME: implement generic module management, loading, etc...
	EntitlementsEnabled bool
}

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) CreateEntitlement

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

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 api.SubjectIdOrKey, entitlementId api.EntitlementId)

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

func (*Router) CreateMeter

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

func (*Router) CreatePortalToken

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

CreatePortalToken creates a new portal token.

func (*Router) DeleteEntitlement

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

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

func (*Router) DeleteFeature

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

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

func (*Router) DeleteMeter

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

func (*Router) DeleteSubject

func (a *Router) DeleteSubject(w http.ResponseWriter, r *http.Request, idOrKey string)

func (*Router) GetEntitlement

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

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

func (*Router) GetEntitlementHistory

func (a *Router) GetEntitlementHistory(w http.ResponseWriter, r *http.Request, subjectIdOrKey api.SubjectIdOrKey, entitlementId api.EntitlementId, 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 api.SubjectIdOrKey, entitlementIdOrFeatureKey api.EntitlementIdOrFeatureKey, 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 api.FeatureId)

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

func (*Router) GetMeter

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

func (*Router) GetSubject

func (a *Router) GetSubject(w http.ResponseWriter, r *http.Request, idOrKey string)

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) ListEntitlementGrants

func (a *Router) ListEntitlementGrants(w http.ResponseWriter, r *http.Request, subjectIdOrKey api.SubjectIdOrKey, entitlementId api.EntitlementId, params api.ListEntitlementGrantsParams)

List grants for an entitlement (GET /api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/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) 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) 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) ListSubjects

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

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) ResetEntitlementUsage

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

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

func (*Router) UpsertSubject

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

func (*Router) VoidGrant

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

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

Jump to

Keyboard shortcuts

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