mpt-extension-sdk 4.0.4__py3-none-any.whl → 4.0.5__py3-none-any.whl
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.
- mpt_extension_sdk/flows/pipeline.py +1 -1
- mpt_extension_sdk/key_vault/__init__.py +0 -0
- mpt_extension_sdk/key_vault/base.py +110 -0
- {mpt_extension_sdk-4.0.4.dist-info → mpt_extension_sdk-4.0.5.dist-info}/METADATA +3 -1
- {mpt_extension_sdk-4.0.4.dist-info → mpt_extension_sdk-4.0.5.dist-info}/RECORD +8 -6
- {mpt_extension_sdk-4.0.4.dist-info → mpt_extension_sdk-4.0.5.dist-info}/LICENSE +0 -0
- {mpt_extension_sdk-4.0.4.dist-info → mpt_extension_sdk-4.0.5.dist-info}/WHEEL +0 -0
- {mpt_extension_sdk-4.0.4.dist-info → mpt_extension_sdk-4.0.5.dist-info}/entry_points.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
from typing import Callable
|
|
3
3
|
|
|
4
|
-
from mpt_extension_sdk.mpt_http.base import MPTClient
|
|
5
4
|
from mpt_extension_sdk.flows.context import Context
|
|
5
|
+
from mpt_extension_sdk.mpt_http.base import MPTClient
|
|
6
6
|
|
|
7
7
|
NextStep = Callable[[MPTClient, Context], None]
|
|
8
8
|
|
|
File without changes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from azure.core.exceptions import (
|
|
4
|
+
HttpResponseError,
|
|
5
|
+
ResourceNotFoundError,
|
|
6
|
+
)
|
|
7
|
+
from azure.identity import DefaultAzureCredential
|
|
8
|
+
from azure.keyvault.secrets import SecretClient
|
|
9
|
+
from requests import Session
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class KeyVault(Session):
|
|
15
|
+
def __init__(self, key_vault_name: str):
|
|
16
|
+
"""
|
|
17
|
+
Initialize the KeyVault client with the provided Key Vault name.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
key_vault_name (str): The name of the Azure Key Vault.
|
|
21
|
+
"""
|
|
22
|
+
super().__init__()
|
|
23
|
+
self.key_vault_name = key_vault_name
|
|
24
|
+
|
|
25
|
+
def get_secret(self, secret_name: str):
|
|
26
|
+
"""
|
|
27
|
+
Retrieve a secret from the Azure Key Vault.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
key_vault_url (str): The URL of the Azure Key Vault.
|
|
31
|
+
secret_name (str): The name of the secret to retrieve.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
str: The value of the secret.
|
|
35
|
+
"""
|
|
36
|
+
try:
|
|
37
|
+
client = self._get_key_vault_client(self.key_vault_name)
|
|
38
|
+
|
|
39
|
+
# Retrieve the secret from the Key Vault
|
|
40
|
+
secret = client.get_secret(secret_name)
|
|
41
|
+
|
|
42
|
+
return secret.value
|
|
43
|
+
except ResourceNotFoundError as e:
|
|
44
|
+
logger.error(
|
|
45
|
+
f"Secret '{secret_name}' not found in Key Vault '{self.key_vault_name}': {e}"
|
|
46
|
+
)
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
def set_secret(self, secret_name: str, secret_value: str):
|
|
50
|
+
"""
|
|
51
|
+
Set a secret in the Azure Key Vault.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
key_vault_url (str): The URL of the Azure Key Vault.
|
|
55
|
+
secret_name (str): The name of the secret to set.
|
|
56
|
+
secret_value (str): The value of the secret to set.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
None
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
# Set the secret in the Key Vault
|
|
63
|
+
try:
|
|
64
|
+
client = self._get_key_vault_client(self.key_vault_name)
|
|
65
|
+
|
|
66
|
+
client.set_secret(secret_name, secret_value)
|
|
67
|
+
|
|
68
|
+
updated_secret = client.get_secret(secret_name)
|
|
69
|
+
|
|
70
|
+
return updated_secret.value
|
|
71
|
+
except HttpResponseError as e:
|
|
72
|
+
logger.error(
|
|
73
|
+
f"Failed to set secret '{secret_name}' in Key Vault '{self.key_vault_name}': {e}"
|
|
74
|
+
)
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
def _get_key_vault_url(self, key_vault_name: str):
|
|
78
|
+
"""
|
|
79
|
+
Construct the Key Vault URL using the provided Key Vault name.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
key_vault_name (str): The name of the Azure Key Vault.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
str: The URL of the Azure Key Vault.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
# Construct the Key Vault URL
|
|
89
|
+
return f"https://{key_vault_name}.vault.azure.net/"
|
|
90
|
+
|
|
91
|
+
def _get_key_vault_client(self, key_vault_name: str):
|
|
92
|
+
"""
|
|
93
|
+
Create a Key Vault client using the provided Key Vault URL and secret name.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
key_vault_url (str): The URL of the Azure Key Vault.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
SecretClient: An instance of the SecretClient for the specified Key Vault.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
# Get the Key Vault URL
|
|
103
|
+
key_vault_url = self._get_key_vault_url(key_vault_name)
|
|
104
|
+
# Create a credential object using DefaultAzureCredential
|
|
105
|
+
credential = DefaultAzureCredential()
|
|
106
|
+
|
|
107
|
+
# Create a Key Vault client using the credential
|
|
108
|
+
client = SecretClient(vault_url=key_vault_url, credential=credential)
|
|
109
|
+
|
|
110
|
+
return client
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mpt-extension-sdk
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.5
|
|
4
4
|
Summary: Extensions SDK for SoftwareONE Marketplace Platform
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: SoftwareOne AG
|
|
@@ -9,6 +9,8 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Requires-Dist: azure-identity (>=1.21.0,<2.0.0)
|
|
13
|
+
Requires-Dist: azure-keyvault-secrets (>=4.9.0,<5.0.0)
|
|
12
14
|
Requires-Dist: azure-monitor-opentelemetry-exporter (==1.0.0b25)
|
|
13
15
|
Requires-Dist: boto3 (==1.34.*)
|
|
14
16
|
Requires-Dist: click (==8.1.*)
|
|
@@ -10,7 +10,9 @@ mpt_extension_sdk/core/security.py,sha256=0eCed1cmaNK1rCpgnsN9zw6wzr4m_Qb9aKxscO
|
|
|
10
10
|
mpt_extension_sdk/core/utils.py,sha256=LsvciwlVBJCBbd7L1rIWrTo_8Fi-W_SkL6IEezKUb4s,362
|
|
11
11
|
mpt_extension_sdk/flows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
mpt_extension_sdk/flows/context.py,sha256=J_U9nTtY89mUvrcOqdgpk-21F8f6YENSmjxgpVK6XWs,964
|
|
13
|
-
mpt_extension_sdk/flows/pipeline.py,sha256=
|
|
13
|
+
mpt_extension_sdk/flows/pipeline.py,sha256=3BO5X3jvuYnRTWrXRzImjVCVOCut8dSvkT2LZwfpaZk,1374
|
|
14
|
+
mpt_extension_sdk/key_vault/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
mpt_extension_sdk/key_vault/base.py,sha256=0aXH5c5n9-rUCwmBVY_HtIFUVB6JUC0137Duyh-basw,3321
|
|
14
16
|
mpt_extension_sdk/mpt_http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
17
|
mpt_extension_sdk/mpt_http/base.py,sha256=3qgo9BW-uTRAbex26urMvLZU0fwnYnBprDRIJCHvTOk,1284
|
|
16
18
|
mpt_extension_sdk/mpt_http/mpt.py,sha256=FatFnbAgyV42N2hJ14n09-WE3V1ioL-lYxuid6vd4Wo,10580
|
|
@@ -38,8 +40,8 @@ mpt_extension_sdk/runtime/master.py,sha256=oBI3WHpf2YkTRsRyT1SFIyvCM7gGQpbtXvI1l
|
|
|
38
40
|
mpt_extension_sdk/runtime/swoext.py,sha256=LS0YZXwQsHDaYjalDGfYQi5cAL3aKQhphf3chrNmNBk,1665
|
|
39
41
|
mpt_extension_sdk/runtime/utils.py,sha256=ZnRWIBwYzOerx30KFmBXLUe19qzwE4JFNkNMGVqjuyk,3365
|
|
40
42
|
mpt_extension_sdk/runtime/workers.py,sha256=k25jFlh-NdHVqeMV2AgoC6IHIlbRHcDoRB5xqWwMPFg,2411
|
|
41
|
-
mpt_extension_sdk-4.0.
|
|
42
|
-
mpt_extension_sdk-4.0.
|
|
43
|
-
mpt_extension_sdk-4.0.
|
|
44
|
-
mpt_extension_sdk-4.0.
|
|
45
|
-
mpt_extension_sdk-4.0.
|
|
43
|
+
mpt_extension_sdk-4.0.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
44
|
+
mpt_extension_sdk-4.0.5.dist-info/METADATA,sha256=xsj7JQDNE8Mrf2zZvrGkGO4_iMNlnY6YQp5i2BMV1ww,1666
|
|
45
|
+
mpt_extension_sdk-4.0.5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
46
|
+
mpt_extension_sdk-4.0.5.dist-info/entry_points.txt,sha256=8uZQihFseK4Kp5XWHl9EDYneg-CLS8BFO-ygp0h34nc,143
|
|
47
|
+
mpt_extension_sdk-4.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|