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

Golang block.NewClient函数代码示例

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

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



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

示例1: getBlockAPI

// getBlockAPI returns a block api for listing blocks.
func getBlockAPI(c *envcmd.EnvCommandBase) (block.BlockListAPI, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, err
	}
	return apiblock.NewClient(root), nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:8,代码来源:bootstrap.go


示例2: getBlockAPI

// getBlockAPI returns a block api for block manipulation.
func getBlockAPI(c newAPIRoot) (*apiblock.Client, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, err
	}
	return apiblock.NewClient(root), nil
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:protection.go


示例3: TestSwitchBlockOff

func (s *blockMockSuite) TestSwitchBlockOff(c *gc.C) {
	called := false
	blockType := state.DestroyBlock.String()

	apiCaller := basetesting.APICallerFunc(
		func(objType string,
			version int,
			id, request string,
			a, response interface{},
		) error {
			called = true
			c.Check(objType, gc.Equals, "Block")
			c.Check(id, gc.Equals, "")
			c.Check(request, gc.Equals, "SwitchBlockOff")

			args, ok := a.(params.BlockSwitchParams)
			c.Assert(ok, jc.IsTrue)
			// message is never sent, so this argument should
			// always be empty string.
			c.Assert(args.Message, gc.DeepEquals, "")
			c.Assert(args.Type, gc.DeepEquals, blockType)

			_, ok = response.(*params.ErrorResult)
			c.Assert(ok, jc.IsTrue)

			return nil
		})
	blockClient := block.NewClient(apiCaller)
	err := blockClient.SwitchBlockOff(blockType)
	c.Assert(called, jc.IsTrue)
	c.Assert(err, gc.IsNil)
}
开发者ID:howbazaar,项目名称:juju,代码行数:32,代码来源:client_test.go


示例4: getBlockAPI

// getBlockAPI returns a block api for listing blocks.
func getBlockAPI(c *modelcmd.ModelCommandBase) (listBlocksAPI, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return block.NewClient(root), nil
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:controller.go


示例5: TestSwitchBlockOn

func (s *blockMockSuite) TestSwitchBlockOn(c *gc.C) {
	called := false
	blockType := state.DestroyBlock.String()
	msg := "for test switch block on"

	apiCaller := basetesting.APICallerFunc(
		func(objType string,
			version int,
			id, request string,
			a, response interface{},
		) error {
			called = true
			c.Check(objType, gc.Equals, "Block")
			c.Check(id, gc.Equals, "")
			c.Check(request, gc.Equals, "SwitchBlockOn")

			args, ok := a.(params.BlockSwitchParams)
			c.Assert(ok, jc.IsTrue)
			c.Assert(args.Message, gc.DeepEquals, msg)
			c.Assert(args.Type, gc.DeepEquals, blockType)

			_, ok = response.(*params.ErrorResult)
			c.Assert(ok, jc.IsTrue)

			return nil
		})
	blockClient := block.NewClient(apiCaller)
	err := blockClient.SwitchBlockOn(blockType, msg)
	c.Assert(called, jc.IsTrue)
	c.Assert(err, gc.IsNil)
}
开发者ID:howbazaar,项目名称:juju,代码行数:31,代码来源:client_test.go


示例6: SetUpTest

func (s *blockSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	s.blockClient = block.NewClient(s.APIState)
	c.Assert(s.blockClient, gc.NotNil)
	s.AddCleanup(func(*gc.C) {
		s.blockClient.ClientFacade.Close()
	})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:8,代码来源:block_test.go


示例7: SetUpTest

func (s *blockSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)

	conn, err := juju.NewAPIState(s.AdminUserTag(c), s.Environ, api.DialOpts{})
	c.Assert(err, jc.ErrorIsNil)
	s.AddCleanup(func(*gc.C) { conn.Close() })

	s.ctx = &mockContext{
		agentConfig: &mockAgentConfig{dataDir: s.DataDir()},
		apiState:    conn,
		state:       s.State,
	}
	s.blockClient = block.NewClient(conn)
}
开发者ID:Pankov404,项目名称:juju,代码行数:14,代码来源:block_test.go


示例8: TestSwitchBlockOnError

func (s *blockMockSuite) TestSwitchBlockOnError(c *gc.C) {
	called := false
	errmsg := "test error"
	apiCaller := basetesting.APICallerFunc(
		func(objType string,
			version int,
			id, request string,
			a, response interface{},
		) error {
			called = true
			result, ok := response.(*params.ErrorResult)
			c.Assert(ok, jc.IsTrue)
			result.Error = common.ServerError(errors.New(errmsg))

			return nil
		})
	blockClient := block.NewClient(apiCaller)
	err := blockClient.SwitchBlockOn("", "")
	c.Assert(called, jc.IsTrue)
	c.Assert(errors.Cause(err), gc.ErrorMatches, errmsg)
}
开发者ID:howbazaar,项目名称:juju,代码行数:21,代码来源:client_test.go


示例9: TestList

func (s *blockMockSuite) TestList(c *gc.C) {
	var called bool
	one := params.BlockResult{
		Result: params.Block{
			Id:      "-42",
			Type:    state.DestroyBlock.String(),
			Message: "for test switch on",
			Tag:     "some valid tag, right?",
		},
	}
	errmsg := "another test error"
	two := params.BlockResult{
		Error: common.ServerError(errors.New(errmsg)),
	}
	apiCaller := basetesting.APICallerFunc(
		func(
			objType string,
			version int,
			id, request string,
			a, response interface{}) error {
			called = true
			c.Check(objType, gc.Equals, "Block")
			c.Check(id, gc.Equals, "")
			c.Check(request, gc.Equals, "List")
			c.Assert(a, gc.IsNil)

			result := response.(*params.BlockResults)
			result.Results = []params.BlockResult{one, two}
			return nil
		})
	blockClient := block.NewClient(apiCaller)
	found, err := blockClient.List()
	c.Assert(called, jc.IsTrue)
	c.Assert(errors.Cause(err), gc.ErrorMatches, errmsg)
	c.Assert(found, gc.HasLen, 1)
}
开发者ID:howbazaar,项目名称:juju,代码行数:36,代码来源:client_test.go


示例10: NewBlockHelper

// NewBlockHelper creates a block switch used in testing
// to manage desired juju blocks.
func NewBlockHelper(st api.Connection) BlockHelper {
	return BlockHelper{
		blockClient: block.NewClient(st),
	}
}
开发者ID:kakamessi99,项目名称:juju,代码行数:7,代码来源:util_test.go


示例11: NewBlockHelper

// NewBlockHelper creates a block switch used in testing
// to manage desired juju blocks.
func NewBlockHelper(st *api.State) BlockHelper {
	return BlockHelper{
		blockClient: block.NewClient(st),
	}
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:7,代码来源:util_test.go


示例12: NewBlockHelper

// NewBlockHelper creates a block switch used in testing
// to manage desired juju blocks.
func NewBlockHelper(st api.Connection) BlockHelper {
	return BlockHelper{
		ApiState: st,
		client:   block.NewClient(st),
	}
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:block.go


示例13: SetUpTest

func (s *blockSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	s.blockClient = block.NewClient(s.APIState)
	c.Assert(s.blockClient, gc.NotNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:5,代码来源:block_test.go


示例14: NewBlockHelper

// NewBlockHelper creates a block switch used in testing
// to manage desired juju blocks.
func NewBlockHelper(st *api.State) BlockHelper {
	return BlockHelper{
		ApiState: st,
		client:   block.NewClient(st),
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:8,代码来源:block.go


示例15: NewCmdBlockHelper

// NewCmdBlockHelper creates a block switch used in testing
// to manage desired juju blocks.
func NewCmdBlockHelper(api base.APICallCloser) CmdBlockHelper {
	return CmdBlockHelper{
		blockClient: block.NewClient(api),
	}
}
开发者ID:kat-co,项目名称:juju,代码行数:7,代码来源:cmdblockhelper.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang common.Life函数代码示例发布时间:2022-05-23
下一篇:
Golang testing.CheckingAPICaller函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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