當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ModifyEnvironUsers.Changes方法代碼示例

本文整理匯總了Golang中github.com/juju/juju/apiserver/params.ModifyEnvironUsers.Changes方法的典型用法代碼示例。如果您正苦於以下問題:Golang ModifyEnvironUsers.Changes方法的具體用法?Golang ModifyEnvironUsers.Changes怎麽用?Golang ModifyEnvironUsers.Changes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/juju/juju/apiserver/params.ModifyEnvironUsers的用法示例。


在下文中一共展示了ModifyEnvironUsers.Changes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ShareEnvironment

// ShareEnvironment allows the given users access to the environment.
func (c *Client) ShareEnvironment(users ...names.UserTag) error {
	var args params.ModifyEnvironUsers
	for _, user := range users {
		if &user != nil {
			args.Changes = append(args.Changes, params.ModifyEnvironUser{
				UserTag: user.String(),
				Action:  params.AddEnvUser,
			})
		}
	}

	var result params.ErrorResults
	err := c.facade.FacadeCall("ShareEnvironment", args, &result)
	if err != nil {
		return errors.Trace(err)
	}

	for i, r := range result.Results {
		if r.Error != nil && r.Error.Code == params.CodeAlreadyExists {
			logger.Warningf("environment is already shared with %s", users[i].Canonical())
			result.Results[i].Error = nil
		}
	}
	return result.Combine()
}
開發者ID:imoapps,項目名稱:juju,代碼行數:26,代碼來源:client.go

示例2: UnshareEnvironment

// UnshareEnvironment removes access to the environment for the given users.
func (c *Client) UnshareEnvironment(users ...names.UserTag) error {
	var args params.ModifyEnvironUsers
	for _, user := range users {
		if &user != nil {
			args.Changes = append(args.Changes, params.ModifyEnvironUser{
				UserTag: user.String(),
				Action:  params.RemoveEnvUser,
			})
		}
	}

	var result params.ErrorResults
	err := c.facade.FacadeCall("ShareEnvironment", args, &result)
	if err != nil {
		return errors.Trace(err)
	}

	for i, r := range result.Results {
		if r.Error != nil && r.Error.Code == params.CodeNotFound {
			logger.Warningf("environment was not previously shared with user %s", users[i].Username())
			result.Results[i].Error = nil
		}
	}
	return result.Combine()
}
開發者ID:Pankov404,項目名稱:juju,代碼行數:26,代碼來源:client.go

示例3: UnshareEnvironment

// UnshareEnvironment removes access to the environment for the given users.
func (c *Client) UnshareEnvironment(users []names.UserTag) (result params.ErrorResults, err error) {
	var args params.ModifyEnvironUsers
	for _, user := range users {
		if &user != nil {
			args.Changes = append(args.Changes, params.ModifyEnvironUser{
				UserTag: user.String(),
				Action:  params.RemoveEnvUser,
			})
		}
	}

	err = c.facade.FacadeCall("ShareEnvironment", args, &result)
	return result, err
}
開發者ID:zhouqt,項目名稱:juju,代碼行數:15,代碼來源:client.go


注:本文中的github.com/juju/juju/apiserver/params.ModifyEnvironUsers.Changes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。