brynq-sdk-sharepoint 2.0.2__tar.gz → 3.0.0__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_sharepoint
3
- Version: 2.0.2
3
+ Version: 3.0.0
4
4
  Summary: Sharepoint wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -1,6 +1,6 @@
1
1
  from brynq_sdk_brynq import BrynQ
2
2
  import os
3
- from typing import List, Union
3
+ from typing import List, Union, Literal, Optional
4
4
  import requests
5
5
  import json
6
6
  from io import BytesIO
@@ -8,7 +8,7 @@ import typing
8
8
 
9
9
 
10
10
  class Sharepoint(BrynQ):
11
- def __init__(self, label: Union[str, List], site: str = None, site_id: str = None, json_subset: int = None, site_name: str = None, debug: bool = False):
11
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, site: str = None, site_id: str = None, json_subset: int = None, site_name: str = None, debug: bool = False):
12
12
  """
13
13
  :param label: label of the sharepoint system in BrynQ
14
14
  :param site: base url of the sharepoint site
@@ -17,13 +17,14 @@ class Sharepoint(BrynQ):
17
17
  :param debug: set to True to enable debug logging
18
18
  """
19
19
  super().__init__()
20
- credentials = self.get_system_credential(system='sharepoint', label=label)
20
+ self.system_type = system_type
21
+ credentials = self.interfaces.credentials.get(system="sharepoint", system_type=system_type)
22
+ credentials = credentials.get('data')
21
23
  self.debug = debug
22
24
  self.timeout = 3600
23
25
  if self.debug:
24
26
  print(f"credentials: {credentials}")
25
- self.access_token = credentials['auth']['access_token']
26
- self.brynq_system_id = credentials['id']
27
+ self.access_token = credentials['access_token']
27
28
  if site_name is not None:
28
29
  self.json_subset = 0 if json_subset is None else json_subset
29
30
  self.site_id = self.get_site_id(site_name=site_name)
@@ -33,11 +34,16 @@ class Sharepoint(BrynQ):
33
34
  else:
34
35
  raise KeyError('Either site_name or site_id, site and json_subset must be provided')
35
36
  if self.debug:
36
- print(f"site_id: {self.site_id}, json_subset: {self.json_subset}, credentials: {credentials}, brynq_system_id: {self.brynq_system_id}")
37
+ print(f"site_id: {self.site_id}, json_subset: {self.json_subset}, credentials: {credentials}")
38
+
39
+ def _refresh_credentials(self):
40
+ credentials = self.interfaces.credentials.get(system="sharepoint", system_type=self.system_type)
41
+ credentials = credentials.get('data')
42
+ self.access_token = credentials['access_token']
37
43
 
38
44
  def _get_sharepoint_headers(self):
39
- access_token = self.refresh_system_credential(system='sharepoint', system_id=self.brynq_system_id)['access_token']
40
- headers = {'Authorization': f'Bearer {access_token}'}
45
+ self._refresh_credentials()
46
+ headers = {'Authorization': f'Bearer {self.access_token}'}
41
47
  if self.debug:
42
48
  print(headers)
43
49
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-sharepoint
3
- Version: 2.0.2
3
+ Version: 3.0.0
4
4
  Summary: Sharepoint wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -0,0 +1,2 @@
1
+ brynq-sdk-brynq<5,>=4
2
+ requests<=3,>=2
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_sharepoint',
5
- version='2.0.2',
5
+ version='3.0.0',
6
6
  description='Sharepoint wrapper from BrynQ',
7
7
  long_description='Sharepoint wrapper from BrynQ',
8
8
  author='BrynQ',
@@ -10,7 +10,7 @@ setup(
10
10
  packages=find_namespace_packages(include=['brynq_sdk*']),
11
11
  license='BrynQ License',
12
12
  install_requires=[
13
- 'brynq-sdk-brynq>=2',
13
+ 'brynq-sdk-brynq>=4,<5',
14
14
  'requests>=2,<=3'
15
15
  ],
16
16
  zip_safe=False,
@@ -1,2 +0,0 @@
1
- brynq-sdk-brynq>=2
2
- requests<=3,>=2