Skip to content

Commit

Permalink
Merge branch 'release/1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchos committed Jun 24, 2022
2 parents 4197cf8 + 3613d62 commit 5adb1b5
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 21 deletions.
12 changes: 6 additions & 6 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
sphinx==4.5.0
sphinx==5.0.2
restfly==1.4.6
python-box==6.0.2
furo==2022.4.7
pre-commit==2.18.1
pytest==7.1.1
responses==0.20.0
requests==2.27.1
furo==2022.6.21
pre-commit==2.19.0
pytest==7.1.2
responses==0.21.0
requests==2.28.0
toml==0.10.2
8 changes: 4 additions & 4 deletions docsrc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
# -- Project information -----------------------------------------------------

project = "pyZscaler"
copyright = "2021, Mitch Kelly"
copyright = "2022, Mitch Kelly"
author = "Mitch Kelly"
html_title = ""

# The short X.Y version
version = '1.2'
# The full version, including alpha/beta/rc tags
release = '1.2.0'
release = '1.2.1'

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -66,7 +66,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -155,7 +155,7 @@
"pyZscaler Documentation",
author,
"pyZscaler",
"One line description of project.",
"An unofficial Python SDK for Zscaler products.",
"Miscellaneous",
),
]
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyzscaler"
version = "1.2.0"
version = "1.2.1"
description = "A python SDK for the Zscaler API."
authors = ["Mitch Kelly <me@mkelly.dev>"]
license = "MIT"
Expand Down Expand Up @@ -38,12 +38,12 @@ python-box = "6.0.2"
python = "^3.7"
restfly = "1.4.6"
python-box = "6.0.2"
Sphinx = "4.5.0"
furo = "2022.4.7"
pytest = "7.1.1"
requests = "2.27.1"
pre-commit = "2.18.1"
responses = "0.20.0"
Sphinx = "5.0.2"
furo = "2022.6.21"
pytest = "7.1.2"
requests = "2.28.0"
pre-commit = "2.19.0"
responses = "0.21.0"
toml = "0.10.2"

[build-system]
Expand Down
2 changes: 1 addition & 1 deletion pyzscaler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Dax Mickelson",
"Jacob Gårder",
]
__version__ = "1.2.0"
__version__ = "1.2.1"

from pyzscaler.zcc import ZCC # noqa
from pyzscaler.zia import ZIA # noqa
Expand Down
2 changes: 1 addition & 1 deletion pyzscaler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def keys_exists(element: dict, *keys):


# Takes a tuple if id_groups, kwargs and the payload dict; reformat for API call
def add_id_groups(id_groups: tuple, kwargs: dict, payload: dict):
def add_id_groups(id_groups: list, kwargs: dict, payload: dict):
for entry in id_groups:
if kwargs.get(entry[0]):
payload[entry[1]] = [{"id": param_id} for param_id in kwargs.pop(entry[0])]
Expand Down
14 changes: 12 additions & 2 deletions pyzscaler/zpa/app_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,32 @@ def get_segment(self, segment_id: str) -> Box:
"""
return self._get(f"application/{segment_id}")

def delete_segment(self, segment_id: str) -> int:
def delete_segment(self, segment_id: str, force_delete: bool = False) -> int:
"""
Delete an application segment.
Args:
force_delete (bool):
Setting this field to true deletes the mapping between Application Segment and Segment Group.
segment_id (str):
The unique identifier for the application segment.
Returns:
:obj:`int`: The operation response code.
Examples:
Delete an Application Segment with an id of 99999.
>>> zpa.app_segments.delete('99999')
Force deletion of an Application Segment with an id of 88888.
>>> zpa.app_segments.delete('88888', force_delete=True)
"""
return self._delete(f"application/{segment_id}").status_code
payload = {"forceDelete": force_delete}

return self._delete(f"application/{segment_id}", params=payload).status_code

def add_segment(
self,
Expand Down
11 changes: 11 additions & 0 deletions tests/zpa/test_zpa_app_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ def test_delete_segment(zpa, app_segments):
assert resp == 204


@responses.activate
def test_delete_segment_force(zpa, app_segments):
responses.add(
responses.DELETE,
url="https://config.private.zscaler.com/mgmtconfig/v1/admin/customers/1/application/1?forceDelete=True",
status=204,
)
resp = zpa.app_segments.delete_segment("1", force_delete=True)
assert resp == 204


@responses.activate
def test_add_segment(zpa, app_segments):
responses.add(
Expand Down

0 comments on commit 5adb1b5

Please sign in to comment.