-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpricing.go
40 lines (33 loc) · 1.09 KB
/
pricing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package oneandone
import "net/http"
type Pricing struct {
Currency string `json:"currency,omitempty"`
Plan *pricingPlan `json:"pricing_plans,omitempty"`
}
type pricingPlan struct {
Image *pricingItem `json:"image,omitempty"`
PublicIPs []pricingItem `json:"public_ips,omitempty"`
Servers *serverPricing `json:"servers,omitempty"`
SharedStorage *pricingItem `json:"shared_storage,omitempty"`
SoftwareLicenses []pricingItem `json:"software_licences,omitempty"`
}
type serverPricing struct {
FixedServers []pricingItem `json:"fixed_servers,omitempty"`
FlexServers []pricingItem `json:"flexible_server,omitempty"`
}
type pricingItem struct {
Name string `json:"name,omitempty"`
GrossPrice float64 `json:"price_gross"`
NetPrice float64 `json:"price_net"`
Unit string `json:"unit,omitempty"`
}
// GET /pricing
func (api *API) GetPricing() (*Pricing, error) {
result := new(Pricing)
url := createUrl(api, pricingPathSegment)
err := api.Client.Get(url, &result, http.StatusOK)
if err != nil {
return nil, err
}
return result, nil
}