This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improved documentation * waf policy groups and policies handling
- Loading branch information
1 parent
3aec8db
commit 021f28b
Showing
4 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pystackpath.util import BaseObject | ||
from pystackpath.stacks.wafsites.policy_groups.policies import Policies | ||
|
||
|
||
class PolicyGroups(BaseObject): | ||
def index(self): | ||
""" | ||
Retrieve all WAF policy groups | ||
:return: a list of policy groups on a site | ||
""" | ||
response = self._client.get(f"{self._base_api}/policy_groups") | ||
items = [self.loaddict(item) for item in response.json()["policyGroups"]] | ||
|
||
return items | ||
|
||
def get(self, policy_group_id): | ||
""" | ||
Retrieve an individual WAF policy group | ||
:param policy_group_id: The ID of the WAF policy group to retrieve | ||
""" | ||
response = self._client.get(f"{self._base_api}/policy_groups/{policy_group_id}") | ||
return self.loaddict(response.json()["policyGroup"]) | ||
|
||
def enable(self): | ||
""" | ||
Enable all policies in a WAF policy group | ||
""" | ||
response = self._client.post(f"{self._base_api}/policy_groups/{self.id}/enable") | ||
|
||
def disable(self): | ||
""" | ||
Disable all policies in a WAF policy group | ||
""" | ||
response = self._client.post(f"{self._base_api}/policy_groups/{self.id}/disable") | ||
|
||
def policies(self): | ||
return Policies(self._client, f"{self._base_api}/policy_groups/{self.id}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pystackpath.util import BaseObject | ||
|
||
|
||
class Policies(BaseObject): | ||
def index(self): | ||
""" | ||
Retrieve all policies in a WAF policy group | ||
:return: a list of policies in a WAF policy group | ||
""" | ||
response = self._client.get(f"{self._base_api}/policies") | ||
items = [self.loaddict(item) for item in response.json()["policies"]] | ||
|
||
return items | ||
|
||
def get(self, policy_id): | ||
""" | ||
Retrieve an individual WAF policy | ||
:param policy_id: The ID of the WAF policy to retrieve | ||
""" | ||
response = self._client.get(f"{self._base_api}/policies/{policy_id}") | ||
return self.loaddict(response.json()["policyGroup"]) | ||
|
||
def enable(self): | ||
""" | ||
Enable a WAF policy | ||
""" | ||
response = self._client.post(f"{self._base_api}/policies/{self.id}/enable") | ||
|
||
def disable(self): | ||
""" | ||
Disable a WAF policy | ||
""" | ||
response = self._client.post(f"{self._base_api}/policies/{self.id}/disable") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters