// NewPermission returns a permission with provided arguments.
6119
func NewPermission(a Action, r Resource) (*Permission, error) {
	p := &Permission{
		Action:   a,
		Resource: r,
	}

	return p, p.Valid()
}
831396
func (o *NSGateway) CreatePermission(child *Permission) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
501639
func PermissionAllowed(perm Permission, ps []Permission) bool {
	for _, p := range ps {
		if p.Matches(perm) {
			return true
		}
	}
	return false
}
585507
func (s *CreateRoleInput) SetPermissionsBoundary(v string) *CreateRoleInput {
	s.PermissionsBoundary = &v
	return s
}
948055
func (st *State) UserPermission(subject names.UserTag, target names.Tag) (permission.Access, error) {
	if err := st.userMayHaveAccess(subject); err != nil {
		return "", errors.Trace(err)
	}

	switch target.Kind() {
	case names.ModelTagKind, names.ControllerTagKind:
		access, err := st.UserAccess(subject, target)
		if err != nil {
			return "", errors.Trace(err)
		}
		return access.Access, nil
	case names.ApplicationOfferTagKind:
		offerUUID, err := applicationOfferUUID(st, target.Id())
		if err != nil {
			return "", errors.Trace(err)
		}
		return st.GetOfferAccess(offerUUID, subject)
	case names.CloudTagKind:
		return st.GetCloudAccess(target.Id(), subject)
	default:
		return "", errors.NotValidf("%q as a target", target.Kind())
	}
}
971154
func (meta Meta) HasPermission(mode roles.PermissionMode, context *qor.Context) bool {
	if meta.Permission == nil {
		return true
	}
	var roles = []interface{}{}
	for _, role := range context.Roles {
		roles = append(roles, role)
	}
	return meta.Permission.HasPermission(mode, roles...)
}
1197431
func NewRestrictUsersAdmission() (admission.Interface, error) {
	return &restrictUsersAdmission{
		Handler: admission.NewHandler(admission.Create, admission.Update),
	}, nil
}
480689
func New2() (*Permissions, error) {
	userstate, err := NewUserStateSimple2()
	if err != nil {
		return nil, err
	}
	return NewPermissions(userstate), nil
}
270937
func (s *DescribeEnvironmentMembershipsInput) SetPermissions(v []*string) *DescribeEnvironmentMembershipsInput {
	s.Permissions = v
	return s
}
299794
func (p *ProjectCollaboratorOptions) GetPermission() string {
	if p == nil || p.Permission == nil {
		return ""
	}
	return *p.Permission
}
858413
func NewLinkPermission(Action *LinkAction, Allow bool) *LinkPermission {
	s := new(LinkPermission)
	s.Action = Action
	s.Allow = Allow
	return s
}
1244332
func (e *SyncedEnforcer) DeletePermission(permission ...string) bool {
	e.m.Lock()
	defer e.m.Unlock()
	return e.Enforcer.DeletePermission(permission...)
}
590339
func NewPerClientGrant(prompt GrantHandler, defaultMethod oauthapi.GrantHandlerType) GrantHandler {
	return &perClientGrant{
		auto:          NewAutoGrant(),
		prompt:        prompt,
		deny:          NewEmptyGrant(),
		defaultMethod: defaultMethod,
	}
}
1299954
func (s *CreateUserInput) SetPermissionsBoundary(v string) *CreateUserInput {
	s.PermissionsBoundary = &v
	return s
}
282113
func NewLinkPermissions(CanRevoke bool) *LinkPermissions {
	s := new(LinkPermissions)
	s.CanRevoke = CanRevoke
	return s
}
753894
func (c *Client) ListPermissions() (rec []PermissionInfo, err error) {
	req, err := newGETRequest(c, "permissions/")
	if err != nil {
		return []PermissionInfo{}, err
	}

	if err = executeAndParseRequest(c, req, &rec); err != nil {
		return []PermissionInfo{}, err
	}

	return rec, nil
}
895346
func NewRekeyPermissionError(
	dir *tlfhandle.Handle, username kbname.NormalizedUsername) error {
	dirname := dir.GetCanonicalPath()
	return RekeyPermissionError{username, dirname}
}