github.com/1and1/oneandone-cloudserver-sdk-go@v1.4.1/pricing.go (about)

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