Documentation ¶
Index ¶
- func AddonGenericName(name string) string
- func GetOVHEndpoints() []string
- func IntervalToDuration(interval int, unit string) string
- func IsForbiddenError(err error) bool
- func IsNotAvailableError(err error) bool
- type Logger
- type MultiService
- type Service
- func (s *Service) AddEcoItem(cartID, planCode string, quantity int, ...) (*kimsufiorder.EcoItemResponse, error)
- func (s *Service) AssignCart(cartID string) error
- func (s *Service) CheckoutCart(cartID string, autoPay bool) (*kimsufiorder.CheckoutResponse, error)
- func (s *Service) ConfigureEcoItemOptions(cartID string, itemID int, options kimsufiorder.EcoItemOptions, ...) (kimsufiorder.Options, error)
- func (s *Service) ConfigureItem(cartID string, itemID int, ...) ([]kimsufiorder.ItemConfigurationResponse, error)
- func (s *Service) CreateCart(ovhSubsidiary string, expire time.Time) (*kimsufiorder.CartResponse, error)
- func (s *Service) GenerateItemAutoConfigurations(itemConfigurationOptions []kimsufiorder.ItemConfiguration) kimsufiorder.ItemConfigurationRequests
- func (s *Service) GetAvailabilities(datacenters []string, planCode string, options map[string]string) (*kimsufiavailability.Availabilities, error)
- func (s *Service) GetEcoInfo(cartID, planCode string) (kimsufiorder.EcoItemInfos, error)
- func (s *Service) GetEcoOptions(cartID string, planCode string) ([]kimsufiorder.EcoItemOption, error)
- func (s *Service) GetItemRequiredConfiguration(cartID string, itemID int) ([]kimsufiorder.ItemConfiguration, error)
- func (s *Service) ListServers(ovhSubsidiary string) (*kimsuficatalog.Catalog, error)
- func (s *Service) TestAuth() error
- func (s *Service) WithAuth(appKey, appSecret, consumerKey string) (*Service, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddonGenericName ¶
AddonGenericName returns the generic name of an addon. It strips out the last part of the name after the last dash. e.g. ram-64g-ecc-2400-24sk50 -> ram-64g-ecc-2400
func GetOVHEndpoints ¶
func GetOVHEndpoints() []string
GetOVHEndpoints returns a list of OVH endpoints. It keeps only the ones starting with "ovh-".
func IntervalToDuration ¶
IntervalToDuration converts an interval and a unit to a duration string. examples: - 1 year -> P1Y - 2 years -> P2Y - 1 month -> P1M - 2 months -> P2M - 12 months -> P1Y - 0 days -> P0D - 1 day -> P1D - 2 days -> P2D - 31 days -> P31D
func IsForbiddenError ¶
IsForbiddenError checks if the error is an ovh.APIError with http.StatusForbidden code.
func IsNotAvailableError ¶
IsNotAvailableError checks if the error is an ovh.APIError which contains an availability error message.
Types ¶
type Logger ¶
Logger is a wrapper around logrus.Logger. It is used to log requests and responses.
func NewRequestLogger ¶
NewRequestLogger creates a new Logger for requests. If l is nil, a no-op logger is used.
func (*Logger) LogRequest ¶
LogRequest logs the HTTP request. Format: request: method url proto header
func (*Logger) LogResponse ¶
LogResponse logs the HTTP response. Format: response: status proto header
type MultiService ¶
MultiService is a map of OVH endpoints to Services.
func NewMultiService ¶
func NewMultiService(l *logrus.Logger, c *cache.Cache) (MultiService, error)
NewMultiService creates a new MultiService with a Service for each OVH endpoint.
func (MultiService) Endpoint ¶
func (m MultiService) Endpoint(endpoint string) *Service
Endpoint returns the Service for the given endpoint.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a wrapper around ovh.Client with optional caching and logging.
func NewService ¶
NewService creates a new Service for the given endpoint. logger is optional, if nil a no-op logger will be used. c is optional, if nil no caching will be used.
func (*Service) AddEcoItem ¶
func (s *Service) AddEcoItem(cartID, planCode string, quantity int, priceConfig kimsufiorder.EcoItemPriceConfig) (*kimsufiorder.EcoItemResponse, error)
AddEcoItem adds an OVH eco item to the cart with the given planCode, quantity and duration, mode from priceConfig.
func (*Service) AssignCart ¶
AssignCart assigns the cart to the user's account.
func (*Service) CheckoutCart ¶
func (s *Service) CheckoutCart(cartID string, autoPay bool) (*kimsufiorder.CheckoutResponse, error)
CheckoutCart checks out the cart to place the order. If autoPay is true, the order will be paid automatically using the preferred payment method.
func (*Service) ConfigureEcoItemOptions ¶
func (s *Service) ConfigureEcoItemOptions(cartID string, itemID int, options kimsufiorder.EcoItemOptions, userOptions kimsufiorder.Options, priceConfig kimsufiorder.EcoItemPriceConfig) (kimsufiorder.Options, error)
ConfigureEcoItemOptions configures the item options in the cart. It finds the cheapest mandatory options and merges them into the user options.
func (*Service) ConfigureItem ¶
func (s *Service) ConfigureItem(cartID string, itemID int, configurations []kimsufiorder.ItemConfigurationRequest) ([]kimsufiorder.ItemConfigurationResponse, error)
ConfigureItem configures an item in the cart with the given configurations.
func (*Service) CreateCart ¶
func (s *Service) CreateCart(ovhSubsidiary string, expire time.Time) (*kimsufiorder.CartResponse, error)
CreateCart creates a new cart which will expire at the given time.
func (*Service) GenerateItemAutoConfigurations ¶
func (s *Service) GenerateItemAutoConfigurations(itemConfigurationOptions []kimsufiorder.ItemConfiguration) kimsufiorder.ItemConfigurationRequests
GenerateItemAutoConfigurations generates configurations for an item.. It returns every required configuration with only one allowed value.
func (*Service) GetAvailabilities ¶
func (s *Service) GetAvailabilities(datacenters []string, planCode string, options map[string]string) (*kimsufiavailability.Availabilities, error)
GetAvailabilities returns servers availabilities. datacenters is a list of datacenters to filter on. planCode is the plan code to filter on. options is a map of additional query parameters. see https://eu.api.ovh.com/console/?section=%2Fdedicated%2Fserver&branch=v1#get-/dedicated/server/datacenter/availabilities
func (*Service) GetEcoInfo ¶
func (s *Service) GetEcoInfo(cartID, planCode string) (kimsufiorder.EcoItemInfos, error)
GetEcoInfo returns information about an eco item in the cart.
func (*Service) GetEcoOptions ¶
func (s *Service) GetEcoOptions(cartID string, planCode string) ([]kimsufiorder.EcoItemOption, error)
GetEcoOptions returns the options for an eco item in the cart.
func (*Service) GetItemRequiredConfiguration ¶
func (s *Service) GetItemRequiredConfiguration(cartID string, itemID int) ([]kimsufiorder.ItemConfiguration, error)
GetItemRequiredConfiguration returns the required configuration options for an item in the cart.
func (*Service) ListServers ¶
func (s *Service) ListServers(ovhSubsidiary string) (*kimsuficatalog.Catalog, error)
ListServers returns the catalog for the given OVH subsidiary. ovhSubsidiary is the country code to filter on, given in a two-letter format. see https://eu.api.ovh.com/console/?section=%2Forder&branch=v1#get-/order/catalog/public/eco