本文整理汇总了Golang中github.com/juju/juju/api/application.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: opClientDestroyRelation
func opClientDestroyRelation(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
err := application.NewClient(st).DestroyRelation("nosuch1", "nosuch2")
if params.IsCodeNotFound(err) {
err = nil
}
return func() {}, err
}
示例2: getAPI
func (c *removeRelationCommand) getAPI() (serviceDestroyRelationAPI, error) {
root, err := c.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
return application.NewClient(root), nil
}
示例3: TestGetMaxResolutionInt
func (s *getSuite) TestGetMaxResolutionInt(c *gc.C) {
// See the bug http://pad.lv/1217742
// Get ends up pushing a map[string]interface{} which containts
// an int64 through a JSON Marshal & Unmarshal which ends up changing
// the int64 into a float64. We will fix it if we find it is actually a
// problem.
const nonFloatInt = (int64(1) << 54) + 1
const asFloat = float64(nonFloatInt)
c.Assert(int64(asFloat), gc.Not(gc.Equals), nonFloatInt)
c.Assert(int64(asFloat)+1, gc.Equals, nonFloatInt)
ch := s.AddTestingCharm(c, "dummy")
svc := s.AddTestingService(c, "test-service", ch)
err := svc.UpdateConfigSettings(map[string]interface{}{"skill-level": nonFloatInt})
c.Assert(err, jc.ErrorIsNil)
client := apiapplication.NewClient(s.APIState)
got, err := client.Get(svc.Name())
c.Assert(err, jc.ErrorIsNil)
c.Assert(got.Config["skill-level"], jc.DeepEquals, map[string]interface{}{
"description": "A number indicating skill.",
"type": "int",
"value": asFloat,
})
}
示例4: getServiceAPI
func (c *debugHooksCommand) getServiceAPI() (charmRelationsApi, error) {
root, err := c.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
return application.NewClient(root), nil
}
示例5: opClientAddServiceUnits
func opClientAddServiceUnits(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
_, err := application.NewClient(st).AddUnits("nosuch", 1, nil)
if params.IsCodeNotFound(err) {
err = nil
}
return func() {}, err
}
示例6: opClientServiceUnexpose
func opClientServiceUnexpose(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
err := application.NewClient(st).Unexpose("wordpress")
if err != nil {
return func() {}, err
}
return func() {}, nil
}
示例7: opClientServiceDestroy
func opClientServiceDestroy(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
err := application.NewClient(st).Destroy("non-existent")
if params.IsCodeNotFound(err) {
err = nil
}
return func() {}, err
}
示例8: TestServiceGet
func (s *getSuite) TestServiceGet(c *gc.C) {
for i, t := range getTests {
c.Logf("test %d. %s", i, t.about)
ch := s.AddTestingCharm(c, t.charm)
svc := s.AddTestingService(c, fmt.Sprintf("test%d", i), ch)
var constraintsv constraints.Value
if t.constraints != "" {
constraintsv = constraints.MustParse(t.constraints)
err := svc.SetConstraints(constraintsv)
c.Assert(err, jc.ErrorIsNil)
}
if t.config != nil {
err := svc.UpdateConfigSettings(t.config)
c.Assert(err, jc.ErrorIsNil)
}
expect := t.expect
expect.Constraints = constraintsv
expect.Application = svc.Name()
expect.Charm = ch.Meta().Name
client := apiapplication.NewClient(s.APIState)
got, err := client.Get(svc.Name())
c.Assert(err, jc.ErrorIsNil)
c.Assert(*got, gc.DeepEquals, expect)
}
}
示例9: opClientDestroyServiceUnits
func opClientDestroyServiceUnits(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
err := application.NewClient(st).DestroyUnits("wordpress/99")
if err != nil && strings.HasPrefix(err.Error(), "no units were destroyed") {
err = nil
}
return func() {}, err
}
示例10: getAPI
func (c *exposeCommand) getAPI() (serviceExposeAPI, error) {
root, err := c.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
return application.NewClient(root), nil
}
示例11: NewDeployCommandWithDefaultAPI
func NewDeployCommandWithDefaultAPI(steps []DeployStep) cmd.Command {
deployCmd := &DeployCommand{Steps: steps}
cmd := modelcmd.Wrap(deployCmd)
deployCmd.NewAPIRoot = func() (DeployAPI, error) {
apiRoot, err := deployCmd.ModelCommandBase.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
bakeryClient, err := deployCmd.BakeryClient()
if err != nil {
return nil, errors.Trace(err)
}
cstoreClient := newCharmStoreClient(bakeryClient).WithChannel(deployCmd.Channel)
adapter := &deployAPIAdapter{
Connection: apiRoot,
apiClient: &apiClient{Client: apiRoot.Client()},
charmsClient: &charmsClient{Client: apicharms.NewClient(apiRoot)},
applicationClient: &applicationClient{Client: application.NewClient(apiRoot)},
modelConfigClient: &modelConfigClient{Client: modelconfig.NewClient(apiRoot)},
charmstoreClient: &charmstoreClient{Client: cstoreClient},
annotationsClient: &annotationsClient{Client: annotations.NewClient(apiRoot)},
charmRepoClient: &charmRepoClient{CharmStore: charmrepo.NewCharmStoreFromClient(cstoreClient)},
}
return adapter, nil
}
return cmd
}
示例12: resetBlogTitle
func resetBlogTitle(c *gc.C, st api.Connection) func() {
return func() {
err := application.NewClient(st).Set("wordpress", map[string]string{
"blog-title": "",
})
c.Assert(err, jc.ErrorIsNil)
}
}
示例13: opClientSetServiceConstraints
func opClientSetServiceConstraints(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
nullConstraints := constraints.Value{}
err := application.NewClient(st).SetConstraints("wordpress", nullConstraints)
if err != nil {
return func() {}, err
}
return func() {}, nil
}
示例14: opClientServiceSet
func opClientServiceSet(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
err := application.NewClient(st).Set("wordpress", map[string]string{
"blog-title": "foo",
})
if err != nil {
return func() {}, err
}
return resetBlogTitle(c, st), nil
}
示例15: getAPI
func (c *serviceConstraintsCommand) getAPI() (serviceConstraintsAPI, error) {
if c.api != nil {
return c.api, nil
}
root, err := c.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
return application.NewClient(root), nil
}