• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang perigee.Post函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/racker/perigee.Post函数的典型用法代码示例。如果您正苦于以下问题:Golang Post函数的具体用法?Golang Post怎么用?Golang Post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: papersPlease

// papersPlease contains the common logic between authentication and re-authentication.
// The name, obviously a joke on the process of authentication, was chosen because
// of how many other entities exist in the program containing the word Auth or Authorization.
// I didn't need another one.
func (c *Context) papersPlease(p Provider, options AuthOptions) (*Access, error) {
	var access *Access

	if (options.Username == "") || (options.Password == "") {
		return nil, ErrCredentials
	}

	err := perigee.Post(p.AuthEndpoint, perigee.Options{
		CustomClient: c.httpClient,
		ReqBody: &AuthContainer{
			Auth: Auth{
				PasswordCredentials: PasswordCredentials{
					Username: options.Username,
					Password: options.Password,
				},
				TenantId:   options.TenantId,
				TenantName: options.TenantName,
			},
		},
		Results: &struct {
			Access **Access `json:"access"`
		}{
			&access,
		},
	})
	if err == nil {
		access.options = options
		access.provider = p
		access.context = c
	}
	return access, err
}
开发者ID:huxoll,项目名称:gophercloud,代码行数:36,代码来源:authenticate.go


示例2: CreateFloatingIp

func (gsp *genericServersProvider) CreateFloatingIp(pool string) (FloatingIp, error) {
	fip := new(FloatingIp)

	err := gsp.context.WithReauth(gsp.access, func() error {
		url := gsp.endpoint + "/os-floating-ips"
		return perigee.Post(url, perigee.Options{
			CustomClient: gsp.context.httpClient,
			ReqBody: map[string]string{
				"pool": pool,
			},
			Results: &struct {
				FloatingIp **FloatingIp `json:"floating_ip"`
			}{&fip},
			MoreHeaders: map[string]string{
				"X-Auth-Token": gsp.access.AuthToken(),
			},
		})
	})

	if fip.Ip == "" {
		return *fip, errors.New("Error creating floating IP")
	}

	return *fip, err
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:25,代码来源:floating_ips.go


示例3: Authenticate

// Authenticate attempts to verify this Identity object's credentials.
func (id *identity) Authenticate() error {
	creds := &AuthContainer{
		Auth: Auth{
			PasswordCredentials: PasswordCredentials{
				Username: id.username,
				Password: id.password,
			},
		},
	}

	err := perigee.Post(id.AuthEndpoint(), perigee.Options{
		CustomClient: id.httpClient,
		ReqBody:      creds,
		Results:      &id.access,
	})
	if err != nil {
		return err
	}

	id.isAuthenticated = true
	id.token = id.access.Access.Token.Id
	id.expires = id.access.Access.Token.Expires
	id.tenantId = id.access.Access.Token.Tenant.Id
	id.tenantName = id.access.Access.Token.Tenant.Name
	return nil
}
开发者ID:racker,项目名称:gorax,代码行数:27,代码来源:identity.go


示例4: RevertResizeServer

// RevertResizeServer will reject a server's resized configuration, thus
// rolling back to the original server.
func (r *raxRegion) RevertResizeServer(id string) error {
	baseUrl, err := r.EndpointByName("servers")
	serverUrl := fmt.Sprintf("%s/%s/action", baseUrl, id)
	err = perigee.Post(serverUrl, perigee.Options{
		ReqBody: &struct {
			RevertResize *int `json:"revertResize"`
		}{nil},
		OkCodes: []int{204},
		MoreHeaders: map[string]string{
			"X-Auth-Token": r.token,
		},
	})
	return err
}
开发者ID:jyidiego,项目名称:gorax,代码行数:16,代码来源:region.go


示例5: UnrescueServer

// See the CloudServersProvider interface for details
func (gsp *genericServersProvider) UnrescueServer(id string) error {
	return gsp.context.WithReauth(gsp.access, func() error {
		url := fmt.Sprintf("%s/servers/%s/action", gsp.endpoint, id)
		return perigee.Post(url, perigee.Options{
			ReqBody: &struct {
				Unrescue *int `json:"unrescue"`
			}{nil},
			MoreHeaders: map[string]string{
				"X-Auth-Token": gsp.access.AuthToken(),
			},
			OkCodes: []int{202},
		})
	})
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:15,代码来源:servers.go


示例6: AssociateFloatingIp

func (gsp *genericServersProvider) AssociateFloatingIp(serverId string, ip FloatingIp) error {
	return gsp.context.WithReauth(gsp.access, func() error {
		ep := fmt.Sprintf("%s/servers/%s/action", gsp.endpoint, serverId)
		return perigee.Post(ep, perigee.Options{
			CustomClient: gsp.context.httpClient,
			ReqBody: map[string](map[string]string){
				"addFloatingIp": map[string]string{"address": ip.Ip},
			},
			MoreHeaders: map[string]string{
				"X-Auth-Token": gsp.access.AuthToken(),
			},
			OkCodes: []int{202},
		})
	})
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:15,代码来源:floating_ips.go


示例7: CreateDefaultSGRule

// See the CloudServersProvider interface for details.
func (gsp *genericServersProvider) CreateDefaultSGRule(r SGRule) (*SGRule, error) {
	var sgr *SGRule
	err := gsp.context.WithReauth(gsp.access, func() error {
		ep := fmt.Sprintf("%s/os-security-group-default-rules", gsp.endpoint)
		return perigee.Post(ep, perigee.Options{
			MoreHeaders: map[string]string{
				"X-Auth-Token": gsp.access.AuthToken(),
			},
			Results: &struct{ Security_group_default_rule **SGRule }{&sgr},
			ReqBody: struct {
				Security_group_default_rule SGRule `json:"security_group_default_rule"`
			}{r},
		})
	})
	return sgr, err
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:17,代码来源:servers.go


示例8: AssociateMonitor

func (gnp *genericNetworksProvider) AssociateMonitor(monitorId string, poolId string) error {
	monitor := Monitor{Id: monitorId}

	ep := gnp.endpoint + "/v2.0/lb/pools/" + poolId + "/health_monitors"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			Monitor *Monitor `json:"health_monitor"`
		}{&monitor},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:16,代码来源:network.go


示例9: CreateSubnet

func (gnp *genericNetworksProvider) CreateSubnet(ns NewSubnet) (*Subnet, error) {
	var s *Subnet

	ep := gnp.endpoint + "/v2.0/subnets"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			NewSubnet *NewSubnet `json:"subnet"`
		}{&ns},
		Results: &struct{ Subnet **Subnet }{&s},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return s, err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:17,代码来源:network.go


示例10: CreateVip

func (gnp *genericNetworksProvider) CreateVip(newVip NewVip) (*Vip, error) {
	var vip *Vip

	ep := gnp.endpoint + "/v2.0/lb/vips"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			NewVip *NewVip `json:"vip"`
		}{&newVip},
		Results: &struct{ Vip **Vip }{&vip},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return vip, err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:17,代码来源:network.go


示例11: CreateMember

func (gnp *genericNetworksProvider) CreateMember(newMember NewMember) (*Member, error) {
	var member *Member

	ep := gnp.endpoint + "/v2.0/lb/members"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			NewMember *NewMember `json:"member"`
		}{&newMember},
		Results: &struct{ Member **Member }{&member},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return member, err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:17,代码来源:network.go


示例12: CreatePool

func (gnp *genericNetworksProvider) CreatePool(newPool NewPool) (*Pool, error) {
	var pool *Pool

	ep := gnp.endpoint + "/v2.0/lb/pools"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			NewPool *NewPool `json:"pool"`
		}{&newPool},
		Results: &struct{ Pool **Pool }{&pool},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return pool, err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:17,代码来源:network.go


示例13: CreateNetwork

func (gnp *genericNetworksProvider) CreateNetwork(nn NewNetwork) (*Network, error) {
	var n *Network

	ep := gnp.endpoint + "/v2.0/networks"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			NewNetwork *NewNetwork `json:"network"`
		}{&nn},
		Results: &struct{ Network **Network }{&n},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return n, err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:17,代码来源:network.go


示例14: CreateSecurityGroupRule

func (gnp *genericNetworksProvider) CreateSecurityGroupRule(nsgr SecurityGroupRule) (*SecurityGroupRule, error) {
	var sgr *SecurityGroupRule

	ep := gnp.endpoint + "/v2.0/security-group-rules"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			SecurityGroupRule *SecurityGroupRule `json:"security_group_rule"`
		}{&nsgr},
		Results: &struct{ SecurityGroupRule **SecurityGroupRule }{&sgr},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return sgr, err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:17,代码来源:network.go


示例15: CreateKeyPair

func (gsp *genericServersProvider) CreateKeyPair(nkp NewKeyPair) (KeyPair, error) {
	var kp KeyPair

	err := gsp.context.WithReauth(gsp.access, func() error {
		url := gsp.endpoint + "/os-keypairs"
		return perigee.Post(url, perigee.Options{
			ReqBody: &struct {
				KeyPair *NewKeyPair `json:"keypair"`
			}{&nkp},
			CustomClient: gsp.context.httpClient,
			Results:      &struct{ KeyPair *KeyPair }{&kp},
			MoreHeaders: map[string]string{
				"X-Auth-Token": gsp.access.AuthToken(),
			},
		})
	})
	return kp, err
}
开发者ID:WIZARD-CXY,项目名称:golang-devops-stuff,代码行数:18,代码来源:keypairs.go


示例16: RebuildServer

// RebuildServer removes all data on the server and replaces it with the specified image
// on the specified flavor.
func (r *raxRegion) RebuildServer(id string, ns NewServer) (*Server, error) {
	var s *Server
	baseUrl, err := r.EndpointByName("servers")
	serverUrl := fmt.Sprintf("%s/%s/action", baseUrl, id)
	err = perigee.Post(serverUrl, perigee.Options{
		ReqBody: &struct {
			Rebuild NewServer `json:"rebuild"`
		}{Rebuild: ns},
		Results: &struct {
			Server **Server `json:"server"`
		}{&s},
		OkCodes: []int{202},
		MoreHeaders: map[string]string{
			"X-Auth-Token": r.token,
		},
	})
	return s, err
}
开发者ID:jyidiego,项目名称:gorax,代码行数:20,代码来源:region.go


示例17: CreateSecurityGroup

func (gnp *genericNetworksProvider) CreateSecurityGroup(nsg NewSecurityGroup) (*SecurityGroup, error) {
	var csg *SecurityGroup
	ep := gnp.endpoint + "/v2.0/security-groups"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			NewSecurityGroup *NewSecurityGroup `json:"security_group"`
		}{&nsg},
		Results: &struct {
			SecurityGroup **SecurityGroup `json:"security_group"`
		}{&csg},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return csg, err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:18,代码来源:network.go


示例18: CreateFirewall

func (gnp *genericNetworksProvider) CreateFirewall(newFirewall NewFirewall) (*Firewall, error) {
	var firewall *Firewall

	ep := gnp.endpoint + "/v2.0/fw/firewalls"
	err := perigee.Post(ep, perigee.Options{
		ReqBody: &struct {
			NewFirewall *NewFirewall `json:"firewall"`
		}{&newFirewall},
		Results: &struct {
			Firewall **Firewall `json:"firewall"`
		}{&firewall},
		MoreHeaders: map[string]string{
			"X-Auth-Token": gnp.access.AuthToken(),
		},
		OkCodes: []int{201},
	})

	return firewall, err
}
开发者ID:haklop,项目名称:gophercloud-extensions,代码行数:19,代码来源:network.go


示例19: ResizeServer

// ResizeServer can be a short-hand for RebuildServer where only the size of the server
// changes.  Note that after the resize operation is requested, you will need to confirm
// the resize has completed for changes to take effect permanently.  Changes will assume
// to be confirmed even without an explicit confirmation after 24 hours from the initial
// request.
func (r *raxRegion) ResizeServer(id, name, flavor, diskConfig string) error {
	baseUrl, err := r.EndpointByName("servers")
	serverUrl := fmt.Sprintf("%s/%s/action", baseUrl, id)
	rr := ResizeRequest{
		Name:       name,
		FlavorRef:  flavor,
		DiskConfig: diskConfig,
	}
	err = perigee.Post(serverUrl, perigee.Options{
		ReqBody: &struct {
			Resize ResizeRequest `json:"resize"`
		}{rr},
		OkCodes: []int{202},
		MoreHeaders: map[string]string{
			"X-Auth-Token": r.token,
		},
	})
	return err
}
开发者ID:jyidiego,项目名称:gorax,代码行数:24,代码来源:region.go


示例20: RebuildServer

// See the CloudServersProvider interface for details.
func (gsp *genericServersProvider) RebuildServer(id string, ns NewServer) (*Server, error) {
	var s *Server

	err := gsp.context.WithReauth(gsp.access, func() error {
		ep := fmt.Sprintf("%s/servers/%s/action", gsp.endpoint, id)
		return perigee.Post(ep, perigee.Options{
			ReqBody: &struct {
				Rebuild *NewServer `json:"rebuild"`
			}{&ns},
			Results: &struct{ Server **Server }{&s},
			MoreHeaders: map[string]string{
				"X-Auth-Token": gsp.access.AuthToken(),
			},
			OkCodes: []int{202},
		})
	})

	return s, err
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:20,代码来源:servers.go



注:本文中的github.com/racker/perigee.Post函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang perigee.Request函数代码示例发布时间:2022-05-28
下一篇:
Golang perigee.Get函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap