// newPermSetForGroup returns a set of all the permissions in the
// given slice of IPPerms. It ignores the name and owner
// id in source groups, and any entry with no source ips will
// be granted for the given group only.
555835
func newPermSetForGroup(ps []ec2.IPPerm, group ec2.SecurityGroup) permSet {
	m := make(permSet)
	for _, p := range ps {
		k := permKey{
			protocol: p.Protocol,
			fromPort: p.FromPort,
			toPort:   p.ToPort,
		}
		if len(p.SourceIPs) > 0 {
			for _, ip := range p.SourceIPs {
				k.ipAddr = ip
				m[k] = true
			}
		} else {
			k.groupId = group.Id
			m[k] = true
		}
	}
	return m
}
1268682
func (s IPPermissionSet) Ungroup() IPPermissionSet {
	l := []*ec2.IpPermission{}
	for _, p := range s.List() {
		if len(p.IpRanges) <= 1 {
			l = append(l, p)
			continue
		}
		for _, ipRange := range p.IpRanges {
			c := &ec2.IpPermission{}
			*c = *p
			c.IpRanges = []*ec2.IpRange{ipRange}
			l = append(l, c)
		}
	}

	l2 := []*ec2.IpPermission{}
	for _, p := range l {
		if len(p.UserIdGroupPairs) <= 1 {
			l2 = append(l2, p)
			continue
		}
		for _, u := range p.UserIdGroupPairs {
			c := &ec2.IpPermission{}
			*c = *p
			c.UserIdGroupPairs = []*ec2.UserIdGroupPair{u}
			l2 = append(l, c)
		}
	}

	l3 := []*ec2.IpPermission{}
	for _, p := range l2 {
		if len(p.PrefixListIds) <= 1 {
			l3 = append(l3, p)
			continue
		}
		for _, v := range p.PrefixListIds {
			c := &ec2.IpPermission{}
			*c = *p
			c.PrefixListIds = []*ec2.PrefixListId{v}
			l3 = append(l3, c)
		}
	}

	return NewIPPermissionSet(l3...)
}
1228686
func NewPaperEnabledUsersGroupAdditionType(Description string) *PaperEnabledUsersGroupAdditionType {
	s := new(PaperEnabledUsersGroupAdditionType)
	s.Description = Description
	return s
}
1212112
func (s *CreateBillingGroupInput) SetBillingGroupProperties(v *BillingGroupProperties) *CreateBillingGroupInput {
	s.BillingGroupProperties = v
	return s
}
575304
func NewPermissionAtID(id ID, a Action, r Resource) (*Permission, error) {
	p := &Permission{
		Action:   a,
		Resource: r,
		ID:       &id,
	}

	return p, p.Valid()
}
1014513
func (entry *Entry) SetPermset(pset *Permset) error {
	rv, _ := C.acl_set_permset(entry.e, pset.p)
	if rv < 0 {
		return fmt.Errorf("unable to set permset on entry")
	}
	return nil
}
43399
func (s *UpdateEnvironmentMembershipInput) SetPermissions(v string) *UpdateEnvironmentMembershipInput {
	s.Permissions = &v
	return s
}
595537
func (s *CreateParameterGroupOutput) SetParameterGroup(v *ParameterGroup) *CreateParameterGroupOutput {
	s.ParameterGroup = v
	return s
}
620842
func (c *Crowd) CreateGroup(name string, description string) (status bool) {

	url := c.url + "rest/usermanagement/1/group"

	c.Client.Jar = c.cookies

	values := map[string]string{"name": name, "type": "GROUP", "description": description, "active": "true"}
	jsonStr, _ := json.Marshal(values)

	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
	if err != nil {
		panic(err)
	}
	req.SetBasicAuth(c.user, c.passwd)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Accept", "application/json")

	resp, err := c.Client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	switch resp.StatusCode {
	case 201:
		status = true
	default:
		fmt.Printf("request failed: %s\n", resp.Status)
	}

	return status

}
188478
func NewGroupMod() *GroupMod {
	g := new(GroupMod)
	g.Header = NewOfp13Header()
	g.Header.Type = Type_GroupMod

	g.Command = OFPGC_ADD
	g.Type = OFPGT_ALL
	g.GroupId = 0
	g.Buckets = make([]Bucket, 0)
	return g
}
985320
func (s *EnvironmentMember) SetPermissions(v string) *EnvironmentMember {
	s.Permissions = &v
	return s
}
249154
func newGroup(name string, cacheBytes int64, getter Getter, peers PeerPicker) *Group {
	if getter == nil {
		panic("nil Getter")
	}
	mu.Lock()
	defer mu.Unlock()
	initPeerServerOnce.Do(callInitPeerServer)
	if _, dup := groups[name]; dup {
		panic("duplicate registration of group " + name)
	}
	g := &Group{
		name:       name,
		getter:     getter,
		peers:      peers,
		cacheBytes: cacheBytes,
		loadGroup:  &singleflight.Group{},
	}
	if fn := newGroupHook; fn != nil {
		fn(g)
	}
	groups[name] = g
	return g
}
978320
func (i *goIpsetProvider) NewIpset(name string, hasht string, p *ipset.Params) (Ipset, error) {
	return ipset.New(name, hasht, p)
}
256241
func (s *LocalVolumeResourceData) SetGroupOwnerSetting(v *GroupOwnerSetting) *LocalVolumeResourceData {
	s.GroupOwnerSetting = v
	return s
}
507799
func (ctx *RoleBindingRestrictionContext) groupsForUser(subject rbac.Subject) ([]*userapi.Group, error) {
	if subject.Kind != rbac.UserKind {
		return []*userapi.Group{}, fmt.Errorf("not a user: %q", subject.Name)
	}

	return ctx.groupCache.GroupsFor(subject.Name)
}
832720
func (pset *Permset) ClearPerms() error {
	rv, _ := C.acl_clear_perms(pset.p)
	if rv < 0 {
		return fmt.Errorf("unable to clear perms")
	}
	return nil
}
229018
func (sd *SecurityDescriptor) SetGroup(sid *SID) {
	if off := sd.setSid(sid); off != 0 {
		sd.ptr.GroupOffset = int32(off)
		sd.ptr.Control &^= seGroupDefaulted
	}
}