List security group rules associated with a security group.

        :param int group_id: The security group to list rules for
558344
def list_securitygroup_rules(self, group_id):
        
        return self.security_group.getRules(id=group_id, iter=True)
97636
def update_instance_security_group(self, instance_id,
                                       new_security_group_ids):
        """"""
        ports = port_list(self.request, device_id=instance_id)
        for p in ports:
            params = {'security_groups': new_security_group_ids}
            port_update(self.request, p.id, **params)
717837
def group(self, groupId):
        
        url = "%s/%s" % (self.root, groupId)
        return Group(url=url,
                     securityHandler=self._securityHandler,
                     proxy_url=self._proxy_url,
                     proxy_port=self._proxy_port,
                     initalize=False)
492071
def list_securitygroup(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes function must be called with -f or --function.'
        )

    params = {
        'Action': 'DescribeSecurityGroups',
        'RegionId': get_location(),
        'PageSize': '50',
    }

    result = query(params)
    if 'Code' in result:
        return {}

    ret = {}
    for sg in result['SecurityGroups']['SecurityGroup']:
        ret[sg['SecurityGroupId']] = {}
        for item in sg:
            ret[sg['SecurityGroupId']][item] = sg[item]

    return ret
109016
def perm_by_group_and_perm_name(
        cls, resource_id, group_id, perm_name, db_session=None
    ):
        
        db_session = get_db_session(db_session)
        query = db_session.query(cls.models_proxy.GroupResourcePermission)
        query = query.filter(
            cls.models_proxy.GroupResourcePermission.group_id == group_id
        )
        query = query.filter(
            cls.models_proxy.GroupResourcePermission.perm_name == perm_name
        )
        query = query.filter(
            cls.models_proxy.GroupResourcePermission.resource_id == resource_id
        )
        return query.first()
527314
def rule_list(env, securitygroup_id, sortby):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)

    table = formatting.Table(COLUMNS)
    table.sortby = sortby

    rules = mgr.list_securitygroup_rules(securitygroup_id)
    for rule in rules:
        port_min = rule.get('portRangeMin')
        port_max = rule.get('portRangeMax')
        if port_min is None:
            port_min = formatting.blank()
        if port_max is None:
            port_max = formatting.blank()

        table.add_row([
            rule['id'],
            rule.get('remoteIp') or formatting.blank(),
            rule.get('remoteGroupId') or formatting.blank(),
            rule['direction'],
            rule.get('ethertype') or formatting.blank(),
            port_min,
            port_max,
            rule.get('protocol') or formatting.blank(),
            rule.get('createDate') or formatting.blank(),
            rule.get('modifyDate') or formatting.blank()
        ])

    env.fout(table)
38458
def get_group(self, group_id):
        
        api = self._get_api(iam.DeveloperApi)
        return Group(api.get_group_summary(group_id))
953364
def get_security_group_dict():
  """"""

  client = get_ec2_client()
  response = client.describe_security_groups()
  assert is_good_response(response)

  result = OrderedDict()
  ec2 = get_ec2_resource()
  for security_group_response in response['SecurityGroups']:
    key = get_name(security_group_response.get('Tags', []))
    if not key or key == EMPTY_NAME:
      continue  # ignore unnamed security groups
    #    key = security_group_response['GroupName']
    if key in result:
      util.log(f"Warning: Duplicate security group {key}")
      if DUPLICATE_CHECKING:
        assert key not in result, ("Duplicate security group " + key)
    result[key] = ec2.SecurityGroup(security_group_response['GroupId'])

  return result
1324436
def get_group_by_id(self, group_id: str) -> typing.Optional['Group']:
        
        VALID_POSITIVE_INT.validate(group_id, 'get_group_by_id', exc=ValueError)
        for group in self.groups:

            if group.group_id == group_id:
                return group
        return None
871591
def attach_securitygroup_components(self, group_id, component_ids):
        
        return self.security_group.attachNetworkComponents(component_ids,
                                                           id=group_id)
496711
def get_group_by_id(self, group_id) -> typing.Optional['Group']:
        
        VALID_POSITIVE_INT.validate(group_id, 'get_group_by_id')
        for group in self.groups:

            if group.group_id == group_id:
                return group

        return None
1048419
def get_group_id(groupname):
    
    gid = single_line_stdout('id -g {0}'.format(groupname), expected_errors=(1,), shell=False)
    return check_int(gid)
1266373
public function list_firewallgroups($group_id = null)
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallgroup/' . trim($group_id));

        return $this->process_response($response);
    }
1337795
def deletegroup(self, group_id):
        
        request = requests.delete(
            '{0}/{1}'.format(self.groups_url, group_id),
            headers=self.headers, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)

        return request.status_code == 200
1001224
def remove_from_group(server_context, user_ids, group_id, container_path=None):
    
    return __make_security_group_api_request(server_context, 'removeGroupMember.api', user_ids,
                                             group_id, container_path)
1338389
def _get_sg_ids(self):
        
        try:
            lambda_extras = self.settings['security_groups']['lambda_extras']
        except KeyError:
            lambda_extras = []

        security_groups = [self.app_name] + lambda_extras
        sg_ids = []
        for security_group in security_groups:
            sg_id = get_security_group_id(name=security_group, env=self.env, region=self.region)
            sg_ids.append(sg_id)
        return sg_ids
398837
def list_security_group_rules(self, retrieve_all=True, **_params):
        """"""
        return self.list('security_group_rules',
                         self.security_group_rules_path,
                         retrieve_all, **_params)