當前位置: 首頁>>代碼示例>>Golang>>正文


Golang perigee.Get函數代碼示例

本文整理匯總了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
}
開發者ID:WIZARD-CXY,項目名稱:golang-devops-stuff,代碼行數:28,代碼來源:keypairs.go

示例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
}
開發者ID:ericcapricorn,項目名稱:kubernetes,代碼行數:27,代碼來源:servers.go

示例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
}
開發者ID:ericcapricorn,項目名稱:kubernetes,代碼行數:32,代碼來源:servers.go

示例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
}
開發者ID:jyidiego,項目名稱:gorax,代碼行數:13,代碼來源:region.go

示例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
}
開發者ID:jyidiego,項目名稱:gorax,代碼行數:15,代碼來源:region.go

示例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
}
開發者ID:jyidiego,項目名稱:gorax,代碼行數:15,代碼來源:region.go

示例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
}
開發者ID:ericcapricorn,項目名稱:kubernetes,代碼行數:14,代碼來源:servers.go

示例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
}
開發者ID:jyidiego,項目名稱:gorax,代碼行數:14,代碼來源:region.go

示例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
}
開發者ID:rafbgarcia,項目名稱:gophercloud,代碼行數:15,代碼來源:servers.go

示例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
}
開發者ID:haklop,項目名稱:gophercloud-extensions,代碼行數:14,代碼來源:network.go

示例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
}
開發者ID:haklop,項目名稱:gophercloud-extensions,代碼行數:14,代碼來源:network.go

示例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
}
開發者ID:haklop,項目名稱:gophercloud-extensions,代碼行數:14,代碼來源:network.go

示例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
}
開發者ID:haklop,項目名稱:gophercloud-extensions,代碼行數:14,代碼來源:network.go

示例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
}
開發者ID:haklop,項目名稱:gophercloud-extensions,代碼行數:14,代碼來源:network.go

示例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
}
開發者ID:haklop,項目名稱:gophercloud-extensions,代碼行數:14,代碼來源:network.go


注:本文中的github.com/racker/perigee.Get函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。