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

Commit

Permalink
update policy groups (#46)
Browse files Browse the repository at this point in the history
New capability of StackPath API of updating policy groups at once
  • Loading branch information
mendrugory committed May 8, 2020
1 parent 2c7b5fe commit 6b5cbb9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ cdnsite = sp.stacks().get(stackid).cdnsites().get(cdnsiteid).delete()
```python
cdnsiteid = "19e1a7b2-068f-491c-a95f-b64eae66dd34"
cdnsite = sp.stacks().get(stackid).cdnsites().get(cdnsiteid).enable()
cdnsite = cdnsite.enable()
cdnsite = cdnsite.disable()
```

### Purge a cdn resource and check the purge status.
Expand Down
20 changes: 20 additions & 0 deletions pystackpath/stacks/wafsites/policy_groups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ def get(self, policy_group_id):
response = self._client.get(f"{self._base_api}/policy_groups/{policy_group_id}")
return self.loaddict(response.json()["policyGroup"])

def update(self, policy_groups):
"""
Update all the policies in the given policy_groups
:param policy_groups: List of policy groups
Example:
[
{
"id": "d694f10e-7faf-4517-bc5b-265e95c04442",
"policies": [{ "enabled": false, "id": "S8758188" }]
}
]
"""
return self._client.patch(
f"{self._base_api}/policy_groups",
json={'policyGroups': policy_groups}
)

def enable(self):
"""
Enable all policies in a WAF policy group
Expand Down

0 comments on commit 6b5cbb9

Please sign in to comment.