// Retrieves the specified security group from the AWS API, or returns nil if not found
349296
func (c *Cloud) findSecurityGroup(securityGroupID string) (*ec2.SecurityGroup, error) {
	describeSecurityGroupsRequest := &ec2.DescribeSecurityGroupsInput{
		GroupIds: []*string{&securityGroupID},
	}
	// We don't apply our tag filters because we are retrieving by ID

	groups, err := c.ec2.DescribeSecurityGroups(describeSecurityGroupsRequest)
	if err != nil {
		glog.Warningf("Error retrieving security group: %q", err)
		return nil, err
	}

	if len(groups) == 0 {
		return nil, nil
	}
	if len(groups) != 1 {
		// This should not be possible - ids should be unique
		return nil, fmt.Errorf("multiple security groups found with same id %q", securityGroupID)
	}
	group := groups[0]
	return group, nil
}
157551
func (t *Template) GetAllAWSRedshiftClusterSecurityGroupResources() map[string]*resources.AWSRedshiftClusterSecurityGroup {
	results := map[string]*resources.AWSRedshiftClusterSecurityGroup{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSRedshiftClusterSecurityGroup:
			results[name] = resource
		}
	}
	return results
}
984902
func (t *Template) GetAWSElastiCacheSecurityGroupWithName(name string) (*resources.AWSElastiCacheSecurityGroup, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSElastiCacheSecurityGroup:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSElastiCacheSecurityGroup not found", name)
}
646092
func (c *Client) GetGroups() (groups []common.Group, err error) {
	return c.protocol.GetGroups()
}
1014412
func (c *Client) AuthorizeSecurityGroupEgress(p *AuthorizeSecurityGroupEgressParameter) (*SecurityGroupEgress, error) {
	obj, err := c.Request("authorizeSecurityGroupEgress", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*SecurityGroupEgress), err
}
1372697
func (t *Template) GetAllAWSRDSDBSecurityGroupResources() map[string]*resources.AWSRDSDBSecurityGroup {
	results := map[string]*resources.AWSRDSDBSecurityGroup{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSRDSDBSecurityGroup:
			results[name] = resource
		}
	}
	return results
}
92074
func (client *Client) DescribeSecurityGroups(args *DescribeSecurityGroupsArgs) (securityGroupItems []SecurityGroupItemType, pagination *common.PaginationResult, err error) {
	response, err := client.DescribeSecurityGroupsWithRaw(args)
	if err != nil {
		return nil, nil, err
	}

	return response.SecurityGroups.SecurityGroup, &response.PaginationResult, nil
}
713598
func (c *Client) GetFirewallGroup(id string) (FirewallGroup, error) {
	groups, err := c.GetFirewallGroups()
	if err != nil {
		return FirewallGroup{}, err
	}

	for _, g := range groups {
		if g.ID == id {
			return g, nil
		}
	}
	return FirewallGroup{}, fmt.Errorf("Firewall group with ID %v not found", id)
}
590554
func (e *environ) groupInfoByName(ctx context.ProviderCallContext, groupName string) (ec2.SecurityGroupInfo, error) {
	resp, err := e.securityGroupsByNameOrID(groupName)
	if err != nil {
		return ec2.SecurityGroupInfo{}, maybeConvertCredentialError(err, ctx)
	}

	if len(resp.Groups) != 1 {
		return ec2.SecurityGroupInfo{}, errors.NewNotFound(fmt.Errorf(
			"expected one security group named %q, got %v",
			groupName, resp.Groups,
		), "")
	}
	return resp.Groups[0], nil
}
261535
func (c *Client) AuthorizeSecurityGroupIngress(p *AuthorizeSecurityGroupIngressParameter) (*SecurityGroupIngress, error) {
	obj, err := c.Request("authorizeSecurityGroupIngress", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*SecurityGroupIngress), err
}
370017
func (cs *StreamManager) LockProtectedGroup(g *Group) {
	cs.LockProtectedEntries(g.Entries)
	cs.LockProtectedGroups(g.Groups)
}
580797
func (client *Client) GetSpaceSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) {
	return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceSecurityGroupsRequest, filters)
}
727884
func (s *SecurityGroupService) GetSecurityGroupID(keyword string, opts ...OptionFunc) (string, int, error) {
	p := &ListSecurityGroupsParams{}
	p.p = make(map[string]interface{})

	p.p["keyword"] = keyword

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListSecurityGroups(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
	}

	if l.Count == 1 {
		return l.SecurityGroups[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.SecurityGroups {
			if v.Name == keyword {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
}
957935
func (cs *StreamManager) UnlockProtectedGroup(g *Group) {
	cs.UnlockProtectedEntries(g.Entries)
	cs.UnlockProtectedGroups(g.Groups)
}
739039
func resourceAwsDbSecurityGroupAuthorizeRule(ingress interface{}, dbSecurityGroupName string, conn *rds.RDS) error {
	ing := ingress.(map[string]interface{})

	opts := rds.AuthorizeDBSecurityGroupIngressInput{
		DBSecurityGroupName: aws.String(dbSecurityGroupName),
	}

	if attr, ok := ing["cidr"]; ok && attr != "" {
		opts.CIDRIP = aws.String(attr.(string))
	}

	if attr, ok := ing["security_group_name"]; ok && attr != "" {
		opts.EC2SecurityGroupName = aws.String(attr.(string))
	}

	if attr, ok := ing["security_group_id"]; ok && attr != "" {
		opts.EC2SecurityGroupId = aws.String(attr.(string))
	}

	if attr, ok := ing["security_group_owner_id"]; ok && attr != "" {
		opts.EC2SecurityGroupOwnerId = aws.String(attr.(string))
	}

	log.Printf("[DEBUG] Authorize ingress rule configuration: %#v", opts)

	_, err := conn.AuthorizeDBSecurityGroupIngress(&opts)

	if err != nil {
		return fmt.Errorf("Error authorizing security group ingress: %s", err)
	}

	return nil
}
370491
func GetGroupsInfo(groupIDs, fields string) (*Groups, error) {
	data, err := httpclient.GetData(APIURL + "/method/groups.getById?group_ids=" + groupIDs + "&fields=" + fields + "&access_token=" + accessToken + "&v=" + APIVersion)
	if err != nil {
		return nil, err
	}

	var groups Groups
	if err := json.Unmarshal(data, &groups); err != nil {
		return nil, err
	}
	return &groups, nil
}
1150795
func (r Network_Storage_Backup_Evault) GetPermissionsGroups() (resp []datatypes.Network_Storage_Group, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Storage_Backup_Evault", "getPermissionsGroups", nil, &r.Options, &resp)
	return
}