You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

auth0-python

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0-python - pypi Package Compare versions

Comparing version
4.10.0
to
4.11.0
+138
auth0/management/network_acls.py
from __future__ import annotations
from typing import Any, List # List is being used as list is already a method.
from ..rest import RestClient, RestClientOptions
from ..types import TimeoutType
class NetworkAcls:
"""Auth0 Netwrok Acls endpoints
Args:
domain (str): Your Auth0 domain, e.g: 'username.auth0.com'
token (str): Management API v2 Token
telemetry (bool, optional): Enable or disable Telemetry
(defaults to True)
timeout (float or tuple, optional): Change the requests
connect and read timeout. Pass a tuple to specify
both values separately or a float to set both to it.
(defaults to 5.0 for both)
protocol (str, optional): Protocol to use when making requests.
(defaults to "https")
rest_options (RestClientOptions): Pass an instance of
RestClientOptions to configure additional RestClient
options, such as rate-limit retries.
(defaults to None)
"""
def __init__(
self,
domain: str,
token: str,
telemetry: bool = True,
timeout: TimeoutType = 5.0,
protocol: str = "https",
rest_options: RestClientOptions | None = None,
) -> None:
self.domain = domain
self.protocol = protocol
self.client = RestClient(
jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options
)
def _url(self, id: str | None = None) -> str:
url = f"{self.protocol}://{self.domain}/api/v2/network-acls"
if id is not None:
return f"{url}/{id}"
return url
def all(
self,
page: int = 0,
per_page: int = 25,
include_totals: bool = True,
) -> List[dict[str, Any]]:
"""List self-service profiles.
Args:
page (int, optional): The result's page number (zero based). By default,
retrieves the first page of results.
per_page (int, optional): The amount of entries per page. By default,
retrieves 25 results per page.
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise. Defaults to True.
See: https://auth0.com/docs/api/management/v2/network-acls/get-network-acls
"""
params = {
"page": page,
"per_page": per_page,
"include_totals": str(include_totals).lower(),
}
return self.client.get(self._url(), params=params)
def create(self, body: dict[str, Any]) -> dict[str, Any]:
"""Create a new self-service profile.
Args:
body (dict): Attributes for the new access control list.
See: https://auth0.com/docs/api/management/v2/network-acls/post-network-acls
"""
return self.client.post(self._url(), data=body)
def get(self, id: str) -> dict[str, Any]:
"""Get a self-service profile.
Args:
id (str): The id of the access control list to retrieve.
See: https://auth0.com/docs/api/management/v2/network-acls/get-network-acls-by-id
"""
return self.client.get(self._url(id))
def delete(self, id: str) -> None:
"""Delete a self-service profile.
Args:
id (str): The id of the access control list to delete.
See: https://auth0.com/docs/api/management/v2/network-acls/delete-network-acls-by-id
"""
self.client.delete(self._url(id))
def update(self, id: str, body: dict[str, Any]) -> dict[str, Any]:
"""Update a access control list.
Args:
id (str): The id of the access control list to update.
body (dict): Attributes of the access control list to modify.
See: https://auth0.com/docs/api/management/v2/network-acls/put-network-acls-by-id
"""
return self.client.put(self._url(id), data=body)
def update_partial(self, id: str, body: dict[str, Any]) -> dict[str, Any]:
"""Update partially the access control list.
See: https://auth0.com/docs/api/management/v2/network-acls/patch-network-acls-by-id
"""
return self.client.patch(self._url(id), data=body)
import unittest
from unittest import mock
from ...management.network_acls import NetworkAcls
class TestNetworkAcls(unittest.TestCase):
def test_init_with_optionals(self):
t = NetworkAcls(
domain="domain", token="jwttoken", telemetry=False, timeout=(10, 2)
)
self.assertEqual(t.client.options.timeout, (10, 2))
telemetry_header = t.client.base_headers.get("Auth0-Client", None)
self.assertEqual(telemetry_header, None)
@mock.patch("auth0.management.network_acls.RestClient")
def test_all(self, mock_rc):
mock_instance = mock_rc.return_value
s = NetworkAcls(domain="domain", token="jwttoken")
s.all()
mock_instance.get.assert_called_with(
"https://domain/api/v2/network-acls",
params={"page": 0, "per_page": 25, "include_totals": "true"},
)
s.all(page=1, per_page=50, include_totals=False)
mock_instance.get.assert_called_with(
"https://domain/api/v2/network-acls",
params={"page": 1, "per_page": 50, "include_totals": "false"},
)
@mock.patch("auth0.management.network_acls.RestClient")
def test_create(self, mock_rc):
mock_instance = mock_rc.return_value
s = NetworkAcls(domain="domain", token="jwttoken")
s.create({"name": "test"})
mock_instance.post.assert_called_with(
"https://domain/api/v2/network-acls", data={"name": "test"}
)
@mock.patch("auth0.management.network_acls.RestClient")
def test_get(self, mock_rc):
mock_instance = mock_rc.return_value
s = NetworkAcls(domain="domain", token="jwttoken")
s.get("an-id")
mock_instance.get.assert_called_with(
"https://domain/api/v2/network-acls/an-id"
)
@mock.patch("auth0.management.network_acls.RestClient")
def test_delete(self, mock_rc):
mock_instance = mock_rc.return_value
s = NetworkAcls(domain="domain", token="jwttoken")
s.delete("an-id")
mock_instance.delete.assert_called_with(
"https://domain/api/v2/network-acls/an-id"
)
@mock.patch("auth0.management.network_acls.RestClient")
def test_update(self, mock_rc):
mock_instance = mock_rc.return_value
s = NetworkAcls(domain="domain", token="jwttoken")
s.update("an-id", {"a": "b", "c": "d"})
mock_instance.put.assert_called_with(
"https://domain/api/v2/network-acls/an-id",
data={"a": "b", "c": "d"},
)
@mock.patch("auth0.management.network_acls.RestClient")
def test_update_partial(self, mock_rc):
mock_instance = mock_rc.return_value
s = NetworkAcls(domain="domain", token="jwttoken")
s.update_partial("an-id", {"a": "b", "c": "d"})
mock_instance.patch.assert_called_with(
"https://domain/api/v2/network-acls/an-id",
data={"a": "b", "c": "d"},
)
+1
-1
# This value is updated by `poetry_dynamic_versioning` during build time from the latest git tag
__version__ = "4.10.0"
__version__ = "4.11.0"

@@ -4,0 +4,0 @@ from auth0.exceptions import Auth0Error, RateLimitError, TokenValidationError

@@ -20,2 +20,3 @@ from ..utils import is_async_available

from .logs import Logs
from .network_acls import NetworkAcls
from .organizations import Organizations

@@ -59,2 +60,3 @@ from .resource_servers import ResourceServers

"Logs",
"NetworkAcls"
"Organizations",

@@ -61,0 +63,0 @@ "ResourceServers",

@@ -23,2 +23,3 @@ from __future__ import annotations

from .logs import Logs
from .network_acls import NetworkAcls
from .organizations import Organizations

@@ -83,2 +84,3 @@ from .prompts import Prompts

self.logs = Logs(domain, token, rest_options=rest_options)
self.network_acls = NetworkAcls(domain, token, rest_options=rest_options)
self.organizations = Organizations(domain, token, rest_options=rest_options)

@@ -85,0 +87,0 @@ self.prompts = Prompts(domain, token, rest_options=rest_options)

@@ -21,2 +21,3 @@ import unittest

from ...management.logs import Logs
from ...management.network_acls import NetworkAcls
from ...management.organizations import Organizations

@@ -93,2 +94,5 @@ from ...management.prompts import Prompts

self.assertIsInstance(self.a0.logs, Logs)
def test_network_acls(self):
self.assertIsInstance(self.a0.network_acls, NetworkAcls)

@@ -95,0 +99,0 @@ def test_organizations(self):

Metadata-Version: 2.3
Name: auth0-python
Version: 4.10.0
Version: 4.11.0
Summary:

@@ -144,2 +144,3 @@ License: MIT

- Logs() ( `Auth0().logs` )
- NetworkAcls() ( `Auth0().network_acls` )
- Organizations() ( `Auth0().organizations` )

@@ -146,0 +147,0 @@ - Prompts() ( `Auth0().prompts` )

@@ -7,3 +7,3 @@ [build-system]

name = "auth0-python"
version = "4.10.0" # This is replaced by dynamic versioning
version = "4.11.0" # This is replaced by dynamic versioning
description = ""

@@ -38,3 +38,3 @@ authors = ["Auth0 <support@auth0.com>"]

[tool.poetry.group.dev.dependencies]
aioresponses = "^0.7.4"
aioresponses = "^0.7.8"
mock = "^5.1.0"

@@ -46,2 +46,2 @@ pipx = "^1.7.1"

pytest-cov = "^4.1.0"
responses = ">=0.23.3,<0.25.0"
responses = ">=0.23.3,<0.26.0"

@@ -119,2 +119,3 @@ ![Auth0 SDK for Python](https://cdn.auth0.com/website/sdks/banners/auth0-python-banner.png)

- Logs() ( `Auth0().logs` )
- NetworkAcls() ( `Auth0().network_acls` )
- Organizations() ( `Auth0().organizations` )

@@ -121,0 +122,0 @@ - Prompts() ( `Auth0().prompts` )