本文整理匯總了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()
}
示例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()
}
示例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
}