当前位置: 首页>>代码示例>>Golang>>正文


Golang service.NewClient函数代码示例

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


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

示例1: opClientServiceDestroy

func opClientServiceDestroy(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
	err := service.NewClient(st).Destroy("non-existent")
	if params.IsCodeNotFound(err) {
		err = nil
	}
	return func() {}, err
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:perm_test.go

示例2: newServiceAPIClient

func (c *upgradeCharmCommand) newServiceAPIClient() (*apiservice.Client, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return apiservice.NewClient(root), nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:upgradecharm.go

示例3: opClientDestroyRelation

func opClientDestroyRelation(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
	err := service.NewClient(st).DestroyRelation("nosuch1", "nosuch2")
	if params.IsCodeNotFound(err) {
		err = nil
	}
	return func() {}, err
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:perm_test.go

示例4: newServiceAPIClient

func (d *serviceDeployer) newServiceAPIClient() (*apiservice.Client, error) {
	root, err := d.api.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return apiservice.NewClient(root), nil
}
开发者ID:makyo,项目名称:juju,代码行数:7,代码来源:deploy.go

示例5: opClientDestroyServiceUnits

func opClientDestroyServiceUnits(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
	err := service.NewClient(st).DestroyUnits("wordpress/99")
	if err != nil && strings.HasPrefix(err.Error(), "no units were destroyed") {
		err = nil
	}
	return func() {}, err
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:perm_test.go

示例6: getAPI

func (c *removeRelationCommand) getAPI() (serviceDestroyRelationAPI, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return apiservice.NewClient(root), nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:removerelation.go

示例7: requestMetricCredentials

func (c *setPlanCommand) requestMetricCredentials() ([]byte, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	jclient := service.NewClient(root)
	envUUID := jclient.ModelUUID()
	charmURL, err := jclient.GetCharmURL(c.Service)
	if err != nil {
		return nil, errors.Trace(err)
	}

	hc, err := c.NewClient()
	if err != nil {
		return nil, errors.Trace(err)
	}
	client, err := newAuthorizationClient(api.HTTPClient(hc))
	if err != nil {
		return nil, errors.Trace(err)
	}
	m, err := client.Authorize(envUUID, charmURL.String(), c.Service, c.Plan, httpbakery.OpenWebBrowser)
	if err != nil {
		return nil, errors.Trace(err)
	}
	ms := macaroon.Slice{m}
	return json.Marshal(ms)
}
开发者ID:perrito666,项目名称:romulus,代码行数:27,代码来源:set_plan.go

示例8: 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 := apiservice.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,
	})
}
开发者ID:exekias,项目名称:juju,代码行数:25,代码来源:get_test.go

示例9: opClientAddServiceUnits

func opClientAddServiceUnits(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
	_, err := service.NewClient(st).AddUnits("nosuch", 1, nil)
	if params.IsCodeNotFound(err) {
		err = nil
	}
	return func() {}, err
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:perm_test.go

示例10: getServiceAPI

func (c *debugHooksCommand) getServiceAPI() (charmRelationsApi, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return service.NewClient(root), nil
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:debughooks.go

示例11: opClientServiceSetCharm

func opClientServiceSetCharm(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
	err := service.NewClient(st).ServiceSetCharm("nosuch", "local:quantal/wordpress", false, false)
	if params.IsCodeNotFound(err) {
		err = nil
	}
	return func() {}, err
}
开发者ID:imoapps,项目名称:juju,代码行数:7,代码来源:perm_test.go

示例12: opClientServiceUnexpose

func opClientServiceUnexpose(c *gc.C, st api.Connection, mst *state.State) (func(), error) {
	err := service.NewClient(st).Unexpose("wordpress")
	if err != nil {
		return func() {}, err
	}
	return func() {}, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:perm_test.go

示例13: getAPI

func (c *removeServiceCommand) getAPI() (ServiceRemoveAPI, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return apiservice.NewClient(root), nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:7,代码来源:removeservice.go

示例14: 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.Service = svc.Name()
		expect.Charm = ch.Meta().Name
		client := apiservice.NewClient(s.APIState)
		got, err := client.Get(svc.Name())
		c.Assert(err, jc.ErrorIsNil)
		c.Assert(*got, gc.DeepEquals, expect)
	}
}
开发者ID:exekias,项目名称:juju,代码行数:26,代码来源:get_test.go

示例15: getAPI

func (c *exposeCommand) getAPI() (serviceExposeAPI, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return service.NewClient(root), nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:7,代码来源:expose.go


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