brynq-sdk-azure 2.0.3__tar.gz → 3.0.1__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.
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/PKG-INFO +1 -1
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure/blob_storage.py +6 -5
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure/entra.py +23 -18
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure.egg-info/PKG-INFO +1 -1
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure.egg-info/requires.txt +1 -1
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/setup.py +2 -2
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure/__init__.py +0 -0
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure/azure_connection.py +0 -0
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure.egg-info/SOURCES.txt +0 -0
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure.egg-info/dependency_links.txt +0 -0
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure.egg-info/not-zip-safe +0 -0
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure.egg-info/top_level.txt +0 -0
- {brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/setup.cfg +0 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
from brynq_sdk_brynq import BrynQ
|
|
2
2
|
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, generate_account_sas, ResourceTypes, AccountSasPermissions
|
|
3
|
-
from typing import Union, List, Tuple
|
|
3
|
+
from typing import Union, List, Tuple, Literal, Optional
|
|
4
4
|
from datetime import datetime, timedelta
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class BlobStorage(BrynQ):
|
|
8
|
-
def __init__(self,
|
|
8
|
+
def __init__(self, system_type: Optional[Literal['source', 'target']] = None):
|
|
9
9
|
super().__init__()
|
|
10
|
-
self.blob_service_client = self.
|
|
10
|
+
self.blob_service_client = self._get_authentication(system_type)
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
credentials = self.
|
|
12
|
+
def _get_authentication(self, system_type):
|
|
13
|
+
credentials = self.interfaces.credentials.get(system='azure-blob-storage', system_type=system_type)
|
|
14
|
+
credentials = credentials.get('data')
|
|
14
15
|
storage_account_name = credentials['storage_account_name']
|
|
15
16
|
storage_account_key = credentials['storage_account_key']
|
|
16
17
|
sas_token = generate_account_sas(
|
|
@@ -8,35 +8,40 @@ import json
|
|
|
8
8
|
import pandas as pd
|
|
9
9
|
from pandas import json_normalize
|
|
10
10
|
from msal import ConfidentialClientApplication
|
|
11
|
-
from typing import Union, List
|
|
11
|
+
from typing import Union, List, Literal, Optional
|
|
12
12
|
import os
|
|
13
13
|
|
|
14
14
|
class Entra(BrynQ):
|
|
15
15
|
|
|
16
|
-
def __init__(self,
|
|
16
|
+
def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug: bool = False):
|
|
17
17
|
super().__init__()
|
|
18
|
-
self.headers = self.__get_headers(
|
|
18
|
+
self.headers = self.__get_headers(system_type)
|
|
19
19
|
self.endpoint = "https://graph.microsoft.com/v1.0"
|
|
20
20
|
self.timeout = 3600
|
|
21
21
|
|
|
22
|
-
def __get_headers(self,
|
|
23
|
-
credentials = self.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
def __get_headers(self, system_type):
|
|
23
|
+
credentials = self.interfaces.credentials.get(system='azure-entra-o-auth-2', system_type=system_type)
|
|
24
|
+
credentials = credentials.get('data')
|
|
25
|
+
if credentials.get("type") == 'custom':
|
|
26
|
+
tenant_id = credentials['tenant_id']
|
|
27
|
+
client_id = credentials['client_id']
|
|
28
|
+
client_secret = credentials['client_secret']
|
|
29
|
+
authority = f"https://login.microsoftonline.com/{tenant_id}"
|
|
30
|
+
# Create a ConfidentialClientApplication for authentication
|
|
31
|
+
app = ConfidentialClientApplication(
|
|
32
|
+
client_id,
|
|
33
|
+
authority=authority,
|
|
34
|
+
client_credential=client_secret,
|
|
35
|
+
)
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
37
|
+
# Get an access token for the Graph API
|
|
38
|
+
result = app.acquire_token_for_client(scopes=["https://graph.microsoft.com/.default"])
|
|
39
|
+
access_token = result.get('access_token')
|
|
40
|
+
elif credentials.get("type") == 'oauth2':
|
|
41
|
+
access_token = credentials.get('access_token')
|
|
35
42
|
|
|
36
|
-
# Get an access token for the Graph API
|
|
37
|
-
result = app.acquire_token_for_client(scopes=["https://graph.microsoft.com/.default"])
|
|
38
43
|
headers = {
|
|
39
|
-
'Authorization': f"Bearer {
|
|
44
|
+
'Authorization': f"Bearer {access_token}",
|
|
40
45
|
'Content-Type': 'application/json'
|
|
41
46
|
}
|
|
42
47
|
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='brynq_sdk_azure',
|
|
5
|
-
version='
|
|
5
|
+
version='3.0.1',
|
|
6
6
|
description='Azure wrapper from BrynQ',
|
|
7
7
|
long_description='Azure 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>=
|
|
13
|
+
'brynq-sdk-brynq>=4,<5',
|
|
14
14
|
'azure-storage-file-share>=12.6.0',
|
|
15
15
|
'azure-storage-blob>=12.16.0',
|
|
16
16
|
'msal==1.22.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{brynq_sdk_azure-2.0.3 → brynq_sdk_azure-3.0.1}/brynq_sdk_azure.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|