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


Golang params.ModifyEnvironUsers类代码示例

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


在下文中一共展示了ModifyEnvironUsers类的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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。