本文整理汇总了Golang中github.com/racker/perigee.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ListKeyPairs
// See the CloudImagesProvider interface for details.
func (gsp *genericServersProvider) ListKeyPairs() ([]KeyPair, error) {
type KeyPairs struct {
KeyPairs []struct {
KeyPair KeyPair `json:"keypair"`
} `json:"keypairs"`
}
var kp KeyPairs
err := gsp.context.WithReauth(gsp.access, func() error {
url := gsp.endpoint + "/os-keypairs"
return perigee.Get(url, perigee.Options{
CustomClient: gsp.context.httpClient,
Results: &kp,
MoreHeaders: map[string]string{
"X-Auth-Token": gsp.access.AuthToken(),
},
})
})
// Flatten out the list of keypairs
var keypairs []KeyPair
for _, k := range kp.KeyPairs {
keypairs = append(keypairs, k.KeyPair)
}
return keypairs, err
}
示例2: ServerById
// See the CloudServersProvider interface for details.
func (gsp *genericServersProvider) ServerById(id string) (*Server, error) {
var s *Server
err := gsp.context.WithReauth(gsp.access, func() error {
url := gsp.endpoint + "/servers/" + id
return perigee.Get(url, perigee.Options{
Results: &struct{ Server **Server }{&s},
MoreHeaders: map[string]string{
"X-Auth-Token": gsp.access.AuthToken(),
},
OkCodes: []int{200},
})
})
// Compatibility with v0.0.x -- we "map" our public and private
// addresses into a legacy structure field for the benefit of
// earlier software.
if err != nil {
return s, err
}
err = mapstructure.Decode(s.RawAddresses, &s.Addresses)
return s, err
}
示例3: ListServers
// See the CloudServersProvider interface for details.
func (gcp *genericServersProvider) ListServers() ([]Server, error) {
var ss []Server
err := gcp.context.WithReauth(gcp.access, func() error {
url := gcp.endpoint + "/servers/detail"
return perigee.Get(url, perigee.Options{
CustomClient: gcp.context.httpClient,
Results: &struct{ Servers *[]Server }{&ss},
MoreHeaders: map[string]string{
"X-Auth-Token": gcp.access.AuthToken(),
},
})
})
// Compatibility with v0.0.x -- we "map" our public and private
// addresses into a legacy structure field for the benefit of
// earlier software.
if err != nil {
return ss, err
}
for _, s := range ss {
err = mapstructure.Decode(s.RawAddresses, &s.Addresses)
if err != nil {
return ss, err
}
}
return ss, err
}
示例4: Images
// Images method provides a complete list of images hosted at the region.
func (r *raxRegion) Images() ([]Image, error) {
var is []Image
url, _ := r.EndpointByName("images")
err := perigee.Get(url, perigee.Options{
CustomClient: r.httpClient,
Results: &struct{ Images *[]Image }{&is},
MoreHeaders: map[string]string{
"X-Auth-Token": r.token,
},
})
return is, err
}
示例5: Servers
// Servers method provides a complete list of servers hosted by the user
// at a given region.
func (r *raxRegion) Servers() ([]Server, error) {
var ss []Server
url, _ := r.EndpointByName("servers/detail")
err := perigee.Get(url, perigee.Options{
CustomClient: r.httpClient,
Results: &struct{ Servers *[]Server }{&ss},
MoreHeaders: map[string]string{
"X-Auth-Token": r.token,
},
})
return ss, err
}
示例6: ServerInfoById
// ServerInfoById provides the complete server information record
// given you know its unique ID.
func (r *raxRegion) ServerInfoById(id string) (*Server, error) {
var s *Server
baseUrl, err := r.EndpointByName("servers")
serverUrl := fmt.Sprintf("%s/%s", baseUrl, id)
err = perigee.Get(serverUrl, perigee.Options{
Results: &struct{ Server **Server }{&s},
MoreHeaders: map[string]string{
"X-Auth-Token": r.token,
},
})
return s, err
}
示例7: GetSGRule
// See the CloudServersProvider interface for details.
func (gsp *genericServersProvider) GetSGRule(id string) (*SGRule, error) {
var sgr *SGRule
err := gsp.context.WithReauth(gsp.access, func() error {
ep := fmt.Sprintf("%s/os-security-group-default-rules/%s", gsp.endpoint, id)
return perigee.Get(ep, perigee.Options{
MoreHeaders: map[string]string{
"X-Auth-Token": gsp.access.AuthToken(),
},
Results: &struct{ Security_group_default_rule **SGRule }{&sgr},
})
})
return sgr, err
}
示例8: Flavors
// Flavors method provides a complete list of machine configurations (called flavors) available at the region.
func (r *raxRegion) Flavors() ([]Flavor, error) {
var fs []Flavor
url, _ := r.EndpointByName("flavors")
err := perigee.Get(url, perigee.Options{
CustomClient: r.httpClient,
Results: &struct{ Flavors *[]Flavor }{&fs},
MoreHeaders: map[string]string{
"X-Auth-Token": r.token,
},
})
return fs, err
}
示例9: ServerById
// See the CloudServersProvider interface for details.
func (gsp *genericServersProvider) ServerById(id string) (*Server, error) {
var s *Server
err := gsp.context.WithReauth(gsp.access, func() error {
url := gsp.endpoint + "/servers/" + id
return perigee.Get(url, perigee.Options{
Results: &struct{ Server **Server }{&s},
MoreHeaders: map[string]string{
"X-Auth-Token": gsp.access.AuthToken(),
},
})
})
return s, err
}
示例10: GetFirewall
func (gnp *genericNetworksProvider) GetFirewall(firewallId string) (*Firewall, error) {
var firewall *Firewall
ep := gnp.endpoint + "/v2.0/fw/firewalls/" + firewallId
err := perigee.Get(ep, perigee.Options{
Results: &struct{ Firewall **Firewall }{&firewall},
MoreHeaders: map[string]string{
"X-Auth-Token": gnp.access.AuthToken(),
},
OkCodes: []int{200},
})
return firewall, err
}
示例11: GetVip
func (gnp *genericNetworksProvider) GetVip(vipId string) (*Vip, error) {
var vip *Vip
ep := gnp.endpoint + "/v2.0/lb/vips/" + vipId
err := perigee.Get(ep, perigee.Options{
Results: &struct{ Vip **Vip }{&vip},
MoreHeaders: map[string]string{
"X-Auth-Token": gnp.access.AuthToken(),
},
OkCodes: []int{200},
})
return vip, err
}
示例12: GetNetwork
func (gnp *genericNetworksProvider) GetNetwork(id string) (*Network, error) {
var n *Network
ep := gnp.endpoint + "/v2.0/networks/" + id
err := perigee.Get(ep, perigee.Options{
Results: &struct{ Network **Network }{&n},
MoreHeaders: map[string]string{
"X-Auth-Token": gnp.access.AuthToken(),
},
OkCodes: []int{200},
})
return n, err
}
示例13: GetMember
func (gnp *genericNetworksProvider) GetMember(memberId string) (*Member, error) {
var member *Member
ep := gnp.endpoint + "/v2.0/lb/members/" + memberId
err := perigee.Get(ep, perigee.Options{
Results: &struct{ Member **Member }{&member},
MoreHeaders: map[string]string{
"X-Auth-Token": gnp.access.AuthToken(),
},
OkCodes: []int{200},
})
return member, err
}
示例14: GetPool
func (gnp *genericNetworksProvider) GetPool(poolId string) (*Pool, error) {
var pool *Pool
ep := gnp.endpoint + "/v2.0/lb/pools/" + poolId
err := perigee.Get(ep, perigee.Options{
Results: &struct{ Pool **Pool }{&pool},
MoreHeaders: map[string]string{
"X-Auth-Token": gnp.access.AuthToken(),
},
OkCodes: []int{200},
})
return pool, err
}
示例15: GetSecurityGroup
func (gnp *genericNetworksProvider) GetSecurityGroup(id string) (*SecurityGroup, error) {
var s *SecurityGroup
ep := gnp.endpoint + "/v2.0/security-groups/" + id
err := perigee.Get(ep, perigee.Options{
Results: &struct{ SecurityGroup **SecurityGroup }{&s},
MoreHeaders: map[string]string{
"X-Auth-Token": gnp.access.AuthToken(),
},
OkCodes: []int{200},
})
return s, err
}