本文整理汇总了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;未经允许,请勿转载。 |
请发表评论