List firewall rules (using REST)
----------------------------------
returns an array containing the current firewall rules on success
165741
public function list_firewallrules()
    {
        if (!$this->is_loggedin) {
            return false;
        }

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

        return $this->process_response($response);
    }
800643
def _server_whitelist(self):
        '''
        
        '''
        whitelist = []
        for server in self.servers:
            if (server not in self.last_error
                    or self.last_error[server] < time.time() - self.PENALTY_BOX_TIME):
                whitelist.append(server)
        if not whitelist:
            whitelist.append(sorted(
                self.last_error.items(), key=lambda kv: kv[1])[0][0])
        return whitelist
520397
def list(self):
        
        params = {'user': self.user_id}
        response = self.session.get(self.url, params=params)
        blocks = response.data['blocks']
        return [Block(self, **block) for block in blocks]
608614
def list_icmp_block(zone, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --list-icmp-blocks'.format(zone)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd).split()
689474
def iter_rules(self, endpoint=None):
        
        self.update()
        if endpoint is not None:
            return iter(self._rules_by_endpoint[endpoint])
        return iter(self._rules)
895867
def list_connections(self, status=None):
        '''  '''
        if status is None:
            status = 'ALL'
        response, status_code = self.__pod__.Connection.get_v1_connection_list(
            sessionToken=self.__session__,
            status=status
        ).result()
        self.logger.debug('%s: %s' % (status_code, response))
        return status_code, response
285464
public function rules(): array
    {
        $manager = $this->route('manager') ?? app('cortex.auth.manager');
        $manager->updateRulesUniques();
        $rules = $manager->getRules();

        $rules['roles'] = 'nullable|array';
        $rules['tenants'] = 'nullable|array';
        $rules['abilities'] = 'nullable|array';
        $rules['password'] = $manager->exists
            ? 'confirmed|min:'.config('cortex.auth.password_min_chars')
            : 'required|confirmed|min:'.config('cortex.auth.password_min_chars');

        return $rules;
    }
22370
def sync(self, rules: list):
        
        self.client = self.connect()
        try:
            server_rules = set(self.server_rules)
            rules = set(rules)
            to_remove_rules = server_rules.difference(rules)
            to_add_rules = rules.difference(server_rules)
            for to_remove_rule in to_remove_rules:
                stdin, stdout, stderr = self.client.exec_command(
                    to_remove_rule.remove_command
                )
                stdout.read()
                stderr.read()
            for to_add_rule in to_add_rules:
                stdin, stdout, stderr = self.client.exec_command(
                    to_add_rule.add_command
                )
                stdout.read()
                stderr.read()

            if len(to_remove_rules) or len(to_add_rules):
                self._write_to_server(rules)
                stdin, stdout, stderr = self.client.exec_command(
                    'ip route flush cache'
                )
                stdout.read()
                stderr.read()
        finally:
            self.client.close()
798499
def get_urlpatterns(self):
        
        return [
            path(
                _('topic/<str:slug>-<int:pk>/lock/'),
                self.topic_lock_view.as_view(),
                name='topic_lock',
            ),
            path(
                _('topic/<str:slug>-<int:pk>/unlock/'),
                self.topic_unlock_view.as_view(),
                name='topic_unlock',
            ),
            path(
                _('topic/<str:slug>-<int:pk>/delete/'),
                self.topic_delete_view.as_view(),
                name='topic_delete',
            ),
            path(
                _('topic/<str:slug>-<int:pk>/move/'),
                self.topic_move_view.as_view(),
                name='topic_move',
            ),
            path(
                _('topic/<str:slug>-<int:pk>/change/topic/'),
                self.topic_update_to_normal_topic_view.as_view(),
                name='topic_update_to_post',
            ),
            path(
                _('topic/<str:slug>-<int:pk>/change/sticky/'),
                self.topic_update_to_sticky_topic_view.as_view(),
                name='topic_update_to_sticky',
            ),
            path(
                _('topic/<str:slug>-<int:pk>/change/announce/'),
                self.topic_update_to_announce_view.as_view(),
                name='topic_update_to_announce',
            ),
            path(_('queue/'), self.moderation_queue_list_view.as_view(), name='queue'),
            path(
                _('queue/<int:pk>/'),
                self.moderation_queue_detail_view.as_view(),
                name='queued_post',
            ),
            path(
                _('queue/<int:pk>/approve/'),
                self.post_approve_view.as_view(),
                name='approve_queued_post',
            ),
            path(
                _('queue/<int:pk>/disapprove/'),
                self.post_disapprove_view.as_view(),
                name='disapprove_queued_post',
            ),
        ]
1055712
def list_rules(region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        ret = []
        NextToken = ''
        while NextToken is not None:
            args = {'NextToken': NextToken} if NextToken else {}
            r = conn.list_rules(**args)
            ret += r.get('Rules', [])
            NextToken = r.get('NextToken')
        return ret
    except ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
1049720
def list_firewall_policies(self, retrieve_all=True, **_params):
        """"""
        # Pass filters in "params" argument to do_request

        return self.list('firewall_policies', self.firewall_policies_path,
                         retrieve_all, **_params)
1344772
def list_ports(zone, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --list-ports'.format(zone)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd).split()
274801
def list_bandwidth_limit_rules(self, policy_id,
                                   retrieve_all=True, **_params):
        """"""
        return self.list('bandwidth_limit_rules',
                         self.qos_bandwidth_limit_rules_path % policy_id,
                         retrieve_all, **_params)
1107601
public function getIPRules()
    {
        $rules = [];
        if ($this->enableIP & static::$ipv4) {
            $rules = [
                [[$this->ipAttribute],
                    'string', 'max' => 4
                ],
            ];
        }
        if ($this->enableIP & static::$ipv6) {
            $rules = [
                [[$this->ipAttribute],
                    'string', 'max' => 16
                ],
            ];
        }
        if ($this->enableIP & static::$ipAll) {
            $rules[] = [
                [$this->ipTypeAttribute], 'in', 'range' => [IP::IPv4, IP::IPv6],
            ];
        }
        return $rules;
    }
732608
def checks_list():
    '''
    
    '''
    application_url = _get_application_url()
    log.debug('[uptime] get checks')
    jcontent = requests.get('{0}/api/checks'.format(application_url)).json()
    return [x['url'] for x in jcontent]
229834
def GetValidHostsForCert(cert):
  
  if 'subjectAltName' in cert:
    return [x[1] for x in cert['subjectAltName'] if x[0].lower() == 'dns']
  else:
    return [x[0][1] for x in cert['subject']
            if x[0][0].lower() == 'commonname']
789505
def get_firewall_rule(self, server_uuid, firewall_rule_position, server_instance=None):
        
        url = '/server/{0}/firewall_rule/{1}'.format(server_uuid, firewall_rule_position)
        res = self.get_request(url)
        return FirewallRule(**res['firewall_rule'])