budget

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: AGPL-3.0 Imports: 1 Imported by: 14

Documentation

Overview

The budget package contains definitions of wireformats used by the budget service clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

type Budget struct {
	Owner    string `json:"owner"`
	Limit    string `json:"limit"`
	Consumed string `json:"consumed"`
	Usage    string `json:"usage"`
	Model    string `json:"model"`
}

Budget represents the amount the user has allocated to a model.

func (Budget) SortableKey

func (a Budget) SortableKey() string

SortableKey returns a key by which allocations can be sorted.

type CreateBudgetRequest

type CreateBudgetRequest struct {
	Model  string `json:"model"`
	Limit  string `json:"limit"`
	Wallet string `json:"-"`
}

CreateBudgetRequest defines a request to create an budget in the specified wallet.

func (CreateBudgetRequest) Body

func (r CreateBudgetRequest) Body() interface{}

Body returns the request body.

func (CreateBudgetRequest) ContentType

func (CreateBudgetRequest) ContentType() string

ContentType return the content-type header to be set for the request.

func (CreateBudgetRequest) Method

func (CreateBudgetRequest) Method() string

Method returns the method for the request.

func (CreateBudgetRequest) URL

func (r CreateBudgetRequest) URL(apiRoot string) string

URL returns the URL for the request.

type CreateWalletRequest

type CreateWalletRequest struct {
	Wallet string `json:"wallet"`
	Limit  string `json:"limit"`
}

CreateWalletRequest is used in the requests to the budget service for creating the specified wallet.

func (CreateWalletRequest) Body

func (c CreateWalletRequest) Body() interface{}

Body returns the body of the request.

func (CreateWalletRequest) ContentType

func (CreateWalletRequest) ContentType() string

ContentType return the content-type header to be set for the request.

func (CreateWalletRequest) Method

func (CreateWalletRequest) Method() string

Method returns the http method used for this request.

func (CreateWalletRequest) URL

func (CreateWalletRequest) URL(apiRoot string) string

URL returns the URL of the request.

type DeleteBudgetRequest

type DeleteBudgetRequest struct {
	Model string `json:"-"`
}

DeleteBudgetRequest defines a request that removes a budget associated with a model.

func (DeleteBudgetRequest) Method

func (DeleteBudgetRequest) Method() string

Method returns the method for the request.

func (DeleteBudgetRequest) URL

func (r DeleteBudgetRequest) URL(apiRoot string) string

URL returns the URL for the request.

type GetWalletRequest

type GetWalletRequest struct {
	Wallet string
}

GetWalletRequest defines a request that retrieves a specific wallet.

func (GetWalletRequest) Method

func (GetWalletRequest) Method() string

Method returns the method for the request.

func (GetWalletRequest) URL

func (r GetWalletRequest) URL(apiRoot string) string

URL returns the URL for the request.

type ListWalletsRequest

type ListWalletsRequest struct{}

ListWalletsRequest defines a request to the budgets service to list a user's wallets.

func (ListWalletsRequest) Method

func (ListWalletsRequest) Method() string

Method returns the method of the request.

func (ListWalletsRequest) URL

func (ListWalletsRequest) URL(apiRoot string) string

URL returns the URL of the request.

type ListWalletsResponse

type ListWalletsResponse struct {
	Wallets WalletSummaries `json:"wallets, omitempty"`
	Total   WalletTotals    `json:"total, omitempty"`
	Credit  string          `json:"credit, omitempty"`
}

ListWalletsResponse is returned by the ListBdugets API call.

type SetWalletRequest

type SetWalletRequest struct {
	Wallet string `json:"-"`
	Limit  string `json:"limit"`
}

SetWalletRequest defines a request that updates the limit of a wallet.

func (SetWalletRequest) Body

func (r SetWalletRequest) Body() interface{}

Body returns the request body.

func (SetWalletRequest) ContentType

func (SetWalletRequest) ContentType() string

ContentType return the content-type header to be set for the request.

func (SetWalletRequest) Method

func (SetWalletRequest) Method() string

Method returns the method of the request.

func (SetWalletRequest) URL

func (r SetWalletRequest) URL(apiRoot string) string

URL returns the URL for the request.

type SortedBudgets

type SortedBudgets []Budget

SortedBudgets have additional methods that allow for sorting budgets.

func (SortedBudgets) Len

func (a SortedBudgets) Len() int

Len is part of the sort.Interface implementation.

func (SortedBudgets) Less

func (a SortedBudgets) Less(i, j int) bool

Less is part of the sort.Interface implementation.

func (SortedBudgets) Swap

func (a SortedBudgets) Swap(i, j int)

Swap is part of the sort.Interface implementation.

type UpdateBudgetRequest

type UpdateBudgetRequest struct {
	Model  string `json:"-"`
	Limit  string `json:"limit,omitempty"`
	Wallet string `json:"wallet,omitempty"`
}

UpdateBudgetRequest defines a request to update a budget associated with a model.

func (UpdateBudgetRequest) Body

func (r UpdateBudgetRequest) Body() interface{}

Body returns the request body.

func (UpdateBudgetRequest) ContentType

func (UpdateBudgetRequest) ContentType() string

ContentType return the content-type header to be set for the request.

func (UpdateBudgetRequest) Method

func (UpdateBudgetRequest) Method() string

Method returns the method for the request.

func (UpdateBudgetRequest) URL

func (r UpdateBudgetRequest) URL(apiRoot string) string

URL returns the URL for the request.

type WalletSummaries

type WalletSummaries []WalletSummary

WalletSummaries is an alphabetically sorted list of wallet summaries.

func (WalletSummaries) Len

func (b WalletSummaries) Len() int

Implement sort.Interface.

func (WalletSummaries) Less

func (b WalletSummaries) Less(i, j int) bool

func (WalletSummaries) Swap

func (b WalletSummaries) Swap(i, j int)

type WalletSummary

type WalletSummary struct {
	Owner       string `json:"owner"`
	Wallet      string `json:"wallet"`
	Limit       string `json:"limit"`
	Budgeted    string `json:"budgeted"`
	Unallocated string `json:"unallocated"`
	Available   string `json:"available"`
	Consumed    string `json:"consumed"`
	Default     bool   `json:"default,omitempty"`
}

WalletSummary represents the summary information for a single wallet in the ListWalletsResponse structure.

type WalletTotals

type WalletTotals struct {
	Limit       string `json:"limit, omitempty"`
	Budgeted    string `json:"budgeted"`
	Available   string `json:"available"`
	Unallocated string `json:"unallocated"`
	Usage       string `json:"usage"`
	Consumed    string `json:"consumed"`
}

type WalletWithBudgets

type WalletWithBudgets struct {
	Limit   string       `json:"limit, omitempty"`
	Total   WalletTotals `json:"total"`
	Budgets []Budget     `json:"budgets, omitempty"`
}

WalletWithBudgets represents the current state of the wallet and its budgets.

Jump to

Keyboard shortcuts

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