1+ from __future__ import annotations
2+
3+ from typing import Any , List # List is being used as list is already a method.
4+
5+ from ..rest import RestClient , RestClientOptions
6+ from ..types import TimeoutType
7+
8+
9+ class NetworkAcls :
10+ """Auth0 Netwrok Acls endpoints
11+
12+ Args:
13+ domain (str): Your Auth0 domain, e.g: 'username.auth0.com'
14+
15+ token (str): Management API v2 Token
16+
17+ telemetry (bool, optional): Enable or disable Telemetry
18+ (defaults to True)
19+
20+ timeout (float or tuple, optional): Change the requests
21+ connect and read timeout. Pass a tuple to specify
22+ both values separately or a float to set both to it.
23+ (defaults to 5.0 for both)
24+
25+ protocol (str, optional): Protocol to use when making requests.
26+ (defaults to "https")
27+
28+ rest_options (RestClientOptions): Pass an instance of
29+ RestClientOptions to configure additional RestClient
30+ options, such as rate-limit retries.
31+ (defaults to None)
32+ """
33+
34+ def __init__ (
35+ self ,
36+ domain : str ,
37+ token : str ,
38+ telemetry : bool = True ,
39+ timeout : TimeoutType = 5.0 ,
40+ protocol : str = "https" ,
41+ rest_options : RestClientOptions | None = None ,
42+ ) -> None :
43+ self .domain = domain
44+ self .protocol = protocol
45+ self .client = RestClient (
46+ jwt = token , telemetry = telemetry , timeout = timeout , options = rest_options
47+ )
48+
49+ def _url (self , id : str | None = None ) -> str :
50+ url = f"{ self .protocol } ://{ self .domain } /api/v2/network-acls"
51+ if id is not None :
52+ return f"{ url } /{ id } "
53+ return url
54+
55+ def all (
56+ self ,
57+ page : int = 0 ,
58+ per_page : int = 25 ,
59+ include_totals : bool = True ,
60+ ) -> List [dict [str , Any ]]:
61+ """List self-service profiles.
62+
63+ Args:
64+ page (int, optional): The result's page number (zero based). By default,
65+ retrieves the first page of results.
66+
67+ per_page (int, optional): The amount of entries per page. By default,
68+ retrieves 25 results per page.
69+
70+ include_totals (bool, optional): True if the query summary is
71+ to be included in the result, False otherwise. Defaults to True.
72+
73+ See: https://auth0.com/docs/api/management/v2/network-acls/get-network-acls
74+ """
75+
76+ params = {
77+ "page" : page ,
78+ "per_page" : per_page ,
79+ "include_totals" : str (include_totals ).lower (),
80+ }
81+
82+ return self .client .get (self ._url (), params = params )
83+
84+ def create (self , body : dict [str , Any ]) -> dict [str , Any ]:
85+ """Create a new self-service profile.
86+
87+ Args:
88+ body (dict): Attributes for the new access control list.
89+
90+ See: https://auth0.com/docs/api/management/v2/network-acls/post-network-acls
91+ """
92+
93+ return self .client .post (self ._url (), data = body )
94+
95+ def get (self , id : str ) -> dict [str , Any ]:
96+ """Get a self-service profile.
97+
98+ Args:
99+ id (str): The id of the access control list to retrieve.
100+
101+ See: https://auth0.com/docs/api/management/v2/network-acls/get-network-acls-by-id
102+ """
103+
104+ return self .client .get (self ._url (id ))
105+
106+ def delete (self , id : str ) -> None :
107+ """Delete a self-service profile.
108+
109+ Args:
110+ id (str): The id of the access control list to delete.
111+
112+ See: https://auth0.com/docs/api/management/v2/network-acls/delete-network-acls-by-id
113+ """
114+
115+ self .client .delete (self ._url (id ))
116+
117+ def update (self , id : str , body : dict [str , Any ]) -> dict [str , Any ]:
118+ """Update a access control list.
119+
120+ Args:
121+ id (str): The id of the access control list to update.
122+
123+ body (dict): Attributes of the access control list to modify.
124+
125+ See: https://auth0.com/docs/api/management/v2/network-acls/put-network-acls-by-id
126+ """
127+
128+ return self .client .put (self ._url (id ), data = body )
129+
130+ def update_partial (self , id : str , body : dict [str , Any ]) -> dict [str , Any ]:
131+ """Update partially the access control list.
132+
133+ See: https://auth0.com/docs/api/management/v2/network-acls/patch-network-acls-by-id
134+ """
135+
136+ return self .client .patch (self ._url (id ), data = body )
137+
138+
0 commit comments