// NewFolderPermission returns a new FolderPermission instance
172707
func NewFolderPermission(Action *FolderAction, Allow bool) *FolderPermission {
	s := new(FolderPermission)
	s.Action = Action
	s.Allow = Allow
	return s
}
898088
func (s *RoleService) NewDeleteRolePermissionParams(id string) *DeleteRolePermissionParams {
	p := &DeleteRolePermissionParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	return p
}
850170
func (e *Enforcer) AddPermissionForUser(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.AddPolicy(params...)
}
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
}
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
}
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()
}
327993
func NewMissionCount(COUNT uint16, TARGET_SYSTEM uint8, TARGET_COMPONENT uint8) *MissionCount {
	m := MissionCount{}
	m.COUNT = COUNT
	m.TARGET_SYSTEM = TARGET_SYSTEM
	m.TARGET_COMPONENT = TARGET_COMPONENT
	return &m
}
149841
func (c *Files) CreateFolder(in *CreateFolderInput) (out *CreateFolderOutput, err error) {
	body, err := c.call("/files/create_folder", in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}
369544
func New(name string) *Folder {
	f := newFolder(name)
	f.Root = true
	return f
}
670905
func OrgMemberPermissions(orgID ID) []Permission {
	ps := []Permission{}
	for _, r := range OrgResources {
		ps = append(ps, Permission{ID: &orgID, Action: ReadAction, Resource: r})
	}

	return ps
}
958156
func NewMissionRequestList(TARGET_SYSTEM uint8, TARGET_COMPONENT uint8) *MissionRequestList {
	m := MissionRequestList{}
	m.TARGET_SYSTEM = TARGET_SYSTEM
	m.TARGET_COMPONENT = TARGET_COMPONENT
	return &m
}
135742
func NewMountFolderArg(SharedFolderId string) *MountFolderArg {
	s := new(MountFolderArg)
	s.SharedFolderId = SharedFolderId
	return s
}
427551
func NewFolderSharingInfo(ReadOnly bool) *FolderSharingInfo {
	s := new(FolderSharingInfo)
	s.ReadOnly = ReadOnly
	s.TraverseOnly = false
	s.NoAccess = false
	return s
}
1257539
func NewUnmountFolderArg(SharedFolderId string) *UnmountFolderArg {
	s := new(UnmountFolderArg)
	s.SharedFolderId = SharedFolderId
	return s
}
15005
func NewGlobalPermission(a Action, rt ResourceType) (*Permission, error) {
	p := &Permission{
		Action: a,
		Resource: Resource{
			Type: rt,
		},
	}
	return p, p.Valid()
}
1094109
func NewUpdateFolderPolicyArg(SharedFolderId string) *UpdateFolderPolicyArg {
	s := new(UpdateFolderPolicyArg)
	s.SharedFolderId = SharedFolderId
	return s
}
1206986
func (f *File) SetPermission(permission *roles.Permission) (err error) {
	jsonVal, err := json.Marshal(permission)
	if err == nil {
		err = ioutil.WriteFile(f.metaFilePath(), jsonVal, 0644)
	}
	return err
}