brynq-sdk-azure 2.0.2__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_azure
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Azure wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -17,6 +17,7 @@ class Entra(BrynQ):
17
17
  super().__init__()
18
18
  self.headers = self.__get_headers(label=label)
19
19
  self.endpoint = "https://graph.microsoft.com/v1.0"
20
+ self.timeout = 3600
20
21
 
21
22
  def __get_headers(self, label):
22
23
  credentials = self.get_system_credential(system='azure-entra-token', label=label)
@@ -44,7 +45,7 @@ class Entra(BrynQ):
44
45
  def __add_attribute_information(self, payload, custom_attributes):
45
46
  # First get the official name of the custom attribute and all the other information
46
47
  payload.update({"customSecurityAttributes": {}})
47
- metadata = requests.get('https://graph.microsoft.com/v1.0/directory/customSecurityAttributeDefinitions', headers=self.headers).json()
48
+ metadata = requests.get('https://graph.microsoft.com/v1.0/directory/customSecurityAttributeDefinitions', headers=self.headers, timeout=self.timeout).json()
48
49
  # Now loop through the given metadata and add the corresponding metadata and the values itself to the payload
49
50
  for attr, value in custom_attributes.items():
50
51
  for meta in metadata["value"]:
@@ -106,7 +107,7 @@ class Entra(BrynQ):
106
107
  loop = True
107
108
  url = f"{endpoint}/groups"
108
109
  while loop:
109
- response = requests.get(url, headers=self.headers)
110
+ response = requests.get(url, headers=self.headers, timeout=self.timeout)
110
111
  groups = response.json()['value']
111
112
  df_temp = pd.json_normalize(groups)
112
113
  df = pd.concat([df, df_temp], ignore_index=True)
@@ -126,7 +127,7 @@ class Entra(BrynQ):
126
127
  group_url = "https://graph.microsoft.com/v1.0/groups/"
127
128
  df = pd.DataFrame()
128
129
  while group_url:
129
- graph_r = requests.get(group_url, headers=self.headers)
130
+ graph_r = requests.get(group_url, headers=self.headers, timeout=self.timeout)
130
131
  graph_json = graph_r.json()
131
132
  groups = graph_json.get('value')
132
133
  for group in groups:
@@ -134,7 +135,7 @@ class Entra(BrynQ):
134
135
  # Get users in each group
135
136
  next_url_members = f"https://graph.microsoft.com/v1.0/groups/{group['id']}/members"
136
137
  while next_url_members:
137
- members_r = requests.get(next_url_members, headers=self.headers)
138
+ members_r = requests.get(next_url_members, headers=self.headers, timeout=self.timeout)
138
139
  members_json = members_r.json()
139
140
  members = members_json.get('value')
140
141
  df_temp = pd.json_normalize(members)
@@ -167,7 +168,7 @@ class Entra(BrynQ):
167
168
  "mailNickname": f"{mail_nickname}",
168
169
  "securityEnabled": security_enabled
169
170
  }
170
- response = requests.post(endpoint, headers=self.headers, json=payload)
171
+ response = requests.post(endpoint, headers=self.headers, json=payload, timeout=self.timeout)
171
172
  return response
172
173
 
173
174
  def update_group(self, id: int, name: str = '', description: str = '', mail_enabled: bool = False, mail_nickname: str = '', security_enabled: bool = True):
@@ -189,7 +190,7 @@ class Entra(BrynQ):
189
190
  "mailNickname": f"{mail_nickname}",
190
191
  "securityEnabled": security_enabled
191
192
  }
192
- response = requests.patch(endpoint, headers=self.headers, json=payload)
193
+ response = requests.patch(endpoint, headers=self.headers, json=payload, timeout=self.timeout)
193
194
  return response
194
195
 
195
196
  def delete_group(self, group_id):
@@ -199,7 +200,7 @@ class Entra(BrynQ):
199
200
  :return: Response of the request
200
201
  """
201
202
  endpoint = f"https://graph.microsoft.com/v1.0/groups/{group_id}"
202
- response = requests.delete(endpoint, headers=self.headers)
203
+ response = requests.delete(endpoint, headers=self.headers, timeout=self.timeout)
203
204
  return response
204
205
 
205
206
  def get_users(self, extra_fields: list = [], custom_attributes: bool = False, expand: str = '', expand_select: str = '') -> pd.DataFrame:
@@ -224,7 +225,7 @@ class Entra(BrynQ):
224
225
 
225
226
  df = pd.DataFrame()
226
227
  while endpoint:
227
- response = requests.get(endpoint, headers=self.headers)
228
+ response = requests.get(endpoint, headers=self.headers, timeout=self.timeout)
228
229
  endpoint = response.json().get('@odata.nextLink')
229
230
  data = response.json().get('value')
230
231
  df_temp = json_normalize(data, sep='.')
@@ -265,7 +266,7 @@ class Entra(BrynQ):
265
266
  # If there are any custom attributes, add them to the payload. But since the endpoint needs extra metadata, we need to do some extra work
266
267
  if len(custom_attributes) > 0:
267
268
  payload = self.__add_attribute_information(payload, custom_attributes)
268
- response = requests.post(endpoint, headers=self.headers, json=payload)
269
+ response = requests.post(endpoint, headers=self.headers, json=payload, timeout=self.timeout)
269
270
  return response
270
271
 
271
272
  def update_user(self, user_id, fields_to_update: dict = {}, custom_attributes: dict = {}, update_password: bool = False):
@@ -286,7 +287,7 @@ class Entra(BrynQ):
286
287
  }})
287
288
  if len(custom_attributes) > 0:
288
289
  payload = self.__add_attribute_information(payload, custom_attributes)
289
- response = requests.patch(endpoint, headers=self.headers, json=payload)
290
+ response = requests.patch(endpoint, headers=self.headers, json=payload, timeout=self.timeout)
290
291
  return response
291
292
 
292
293
  def delete_user(self, user_id, delete=False):
@@ -297,10 +298,10 @@ class Entra(BrynQ):
297
298
  """
298
299
  endpoint = f"https://graph.microsoft.com/v1.0/users/{user_id}"
299
300
  if delete:
300
- response = requests.delete(endpoint, headers=self.headers)
301
+ response = requests.delete(endpoint, headers=self.headers, timeout=self.timeout)
301
302
  else:
302
303
  payload = {"accountEnabled": False}
303
- response = requests.patch(endpoint, headers=self.headers, data=json.dumps(payload))
304
+ response = requests.patch(endpoint, headers=self.headers, data=json.dumps(payload), timeout=self.timeout)
304
305
  return response
305
306
 
306
307
  def assign_user_to_group(self, user_id, group_id):
@@ -312,7 +313,7 @@ class Entra(BrynQ):
312
313
  """
313
314
  url = f"https://graph.microsoft.com/v1.0/groups/{group_id}/members/$ref"
314
315
  data = {"@odata.id": f"https://graph.microsoft.com/v1.0/directoryObjects/{user_id}"}
315
- response = requests.post(url, headers=self.headers, data=json.dumps(data))
316
+ response = requests.post(url, headers=self.headers, data=json.dumps(data), timeout=self.timeout)
316
317
  return response
317
318
 
318
319
  def update_manager(self, user_id, manager_id):
@@ -324,7 +325,7 @@ class Entra(BrynQ):
324
325
  """
325
326
  url = f"https://graph.microsoft.com/v1.0/users/{user_id}/manager/$ref"
326
327
  content ={f"@odata.id": f"https://graph.microsoft.com/v1.0/users/{manager_id}"}
327
- response = requests.put(url, headers=self.headers, data=json.dumps(content))
328
+ response = requests.put(url, headers=self.headers, data=json.dumps(content), timeout=self.timeout)
328
329
  return response
329
330
 
330
331
  def remove_user_from_group(self, user_id, group_id):
@@ -335,5 +336,5 @@ class Entra(BrynQ):
335
336
  return: response
336
337
  """
337
338
  url = f"https://graph.microsoft.com/v1.0/groups/{group_id}/members/{user_id}/$ref"
338
- response = requests.delete(url, headers=self.headers)
339
+ response = requests.delete(url, headers=self.headers, timeout=self.timeout)
339
340
  return response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-azure
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Azure wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_azure',
5
- version='2.0.2',
5
+ version='2.0.3',
6
6
  description='Azure wrapper from BrynQ',
7
7
  long_description='Azure wrapper from BrynQ',
8
8
  author='BrynQ',