// NewPermission returns a permission with provided arguments.
322817
func NewPermission(a Action, rt ResourceType, orgID ID) (*Permission, error) {
	p := &Permission{
		Action: a,
		Resource: Resource{
			Type:  rt,
			OrgID: &orgID,
		},
	}

	return p, p.Valid()
}
304725
func MemberPermissions(orgID ID) []Permission {
	ps := []Permission{}
	for _, r := range AllResourceTypes {
		if r == OrgsResourceType {
			ps = append(ps, Permission{Action: ReadAction, Resource: Resource{Type: r, ID: &orgID}})
			continue
		}
		ps = append(ps, Permission{Action: ReadAction, Resource: Resource{Type: r, OrgID: &orgID}})
	}

	return ps
}
1218394
func (c *Channel) RequestPermission() {
	packet := MumbleProto.PermissionQuery{
		ChannelId: &c.ID,
	}
	c.client.Conn.WriteProto(&packet)
}
299794
func (p *ProjectCollaboratorOptions) GetPermission() string {
	if p == nil || p.Permission == nil {
		return ""
	}
	return *p.Permission
}
75533
func (s *UserSetting) SetPermission(v string) *UserSetting {
	s.Permission = &v
	return s
}
858413
func NewLinkPermission(Action *LinkAction, Allow bool) *LinkPermission {
	s := new(LinkPermission)
	s.Action = Action
	s.Allow = Allow
	return s
}
1341438
func NewUserPermission(fields []*querypb.Field, values []sqltypes.Value) *tabletmanagerdatapb.UserPermission {
	up := &tabletmanagerdatapb.UserPermission{
		Privileges: make(map[string]string),
	}
	for i, field := range fields {
		switch strings.ToLower(field.Name) {
		case "host":
			up.Host = values[i].ToString()
		case "user":
			up.User = values[i].ToString()
		case "password":
			up.PasswordChecksum = crc64.Checksum(values[i].ToBytes(), hashTable)
		case "password_last_changed":
			// we skip this one, as the value may be
			// different on master and slaves.
		default:
			up.Privileges[field.Name] = values[i].ToString()
		}
	}
	return up
}
8715
func (s *Device) SetPermissions(v []*string) *Device {
	s.Permissions = v
	return s
}
430089
func (l *License) GetPermissions() []string {
	if l == nil || l.Permissions == nil {
		return nil
	}
	return *l.Permissions
}
556452
func (m *MockLambdaAPI) AddPermission(arg0 *lambda.AddPermissionInput) (*lambda.AddPermissionOutput, error) {
	ret := m.ctrl.Call(m, "AddPermission", arg0)
	ret0, _ := ret[0].(*lambda.AddPermissionOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
393024
func (r *RepositoryPermissionLevel) GetPermission() string {
	if r == nil || r.Permission == nil {
		return ""
	}
	return *r.Permission
}
753071
func (e *Enforcer) DeletePermissionForUser(user string, permission ...string) bool {
	params := make([]interface{}, 0, len(permission)+1)

	params = append(params, user)
	for _, perm := range permission {
		params = append(params, perm)
	}

	return e.RemovePolicy(params...)
}
710781
func OrgAdminPermissions(orgID ID) []Permission {
	ps := []Permission{}
	for _, r := range OrgResources {
		for _, a := range actions {
			ps = append(ps, Permission{ID: &orgID, Action: a, Resource: r})
		}
	}

	return ps
}
357291
func NewUserInfoWithPermissionLevel(User *sharing.UserInfo, PermissionLevel *PaperDocPermissionLevel) *UserInfoWithPermissionLevel {
	s := new(UserInfoWithPermissionLevel)
	s.User = User
	s.PermissionLevel = PermissionLevel
	return s
}
805754
func NewPermissions(state *UserState) *Permissions {
	// default permissions
	return &Permissions{state,
		[]string{"/admin"},         // admin path prefixes
		[]string{"/repo", "/data"}, // user path prefixes
		[]string{"/", "/login", "/register", "/favicon.ico", "/style", "/img", "/js",
			"/favicon.ico", "/robots.txt", "/sitemap_index.xml"}, // public
		true,
		PermissionDenied}
}
895346
func NewRekeyPermissionError(
	dir *tlfhandle.Handle, username kbname.NormalizedUsername) error {
	dirname := dir.GetCanonicalPath()
	return RekeyPermissionError{username, dirname}
}
1152018
func (o *Options) CheckPermissions() error {
	// get the directory the file exists in
	path, err := o.getPath()
	if err != nil {
		return err
	}

	fileDir := filepath.Dir(path)
	fileName := filepath.Base(path)

	// attempt to open a file in the file's directory
	newPath := filepath.Join(fileDir, fmt.Sprintf(".%s.new", fileName))
	fp, err := openFile(newPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, o.TargetMode)
	if err != nil {
		return err
	}
	fp.Close()

	_ = os.Remove(newPath)
	return nil
}