Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Commit 6b5cbb9

Browse files
authored
update policy groups (#46)
New capability of StackPath API of updating policy groups at once
1 parent 2c7b5fe commit 6b5cbb9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ cdnsite = sp.stacks().get(stackid).cdnsites().get(cdnsiteid).delete()
7171
```python
7272
cdnsiteid = "19e1a7b2-068f-491c-a95f-b64eae66dd34"
7373
cdnsite = sp.stacks().get(stackid).cdnsites().get(cdnsiteid).enable()
74-
cdnsite = cdnsite.enable()
74+
cdnsite = cdnsite.disable()
7575
```
7676

7777
### Purge a cdn resource and check the purge status.

pystackpath/stacks/wafsites/policy_groups/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ def get(self, policy_group_id):
2121
response = self._client.get(f"{self._base_api}/policy_groups/{policy_group_id}")
2222
return self.loaddict(response.json()["policyGroup"])
2323

24+
def update(self, policy_groups):
25+
"""
26+
Update all the policies in the given policy_groups
27+
28+
:param policy_groups: List of policy groups
29+
30+
Example:
31+
[
32+
{
33+
"id": "d694f10e-7faf-4517-bc5b-265e95c04442",
34+
"policies": [{ "enabled": false, "id": "S8758188" }]
35+
}
36+
]
37+
38+
"""
39+
return self._client.patch(
40+
f"{self._base_api}/policy_groups",
41+
json={'policyGroups': policy_groups}
42+
)
43+
2444
def enable(self):
2545
"""
2646
Enable all policies in a WAF policy group

0 commit comments

Comments
 (0)