當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。