11import os
22
3- from azure .storage .blob import BlobServiceClient # type: ignore
4- from azure .storage .queue import QueueServiceClient # type: ignore
5- from django .core .management .base import BaseCommand # type: ignore
6- from minio import Minio # type: ignore
3+ from azure .storage .blob import BlobServiceClient
4+ from django .core .management .base import BaseCommand
5+ from minio import Minio
76
87
98class Command (BaseCommand ):
@@ -29,42 +28,7 @@ class Command(BaseCommand):
2928
3029 CONTAINERS = ["scan-reports" , "data-dictionaries" , "rules-exports" , "airflow-logs" ]
3130
32- def _create_azure_queues (self , queue_service : str ):
33- """
34- Creates the required Azure Queues.
35-
36- Args:
37- queue_service: QueueServiceClient instance.
38-
39- Returns:
40- - Creates queue if it doesn't exist
41- - If the queue exists, it will skip and
42- returns a message.
43- """
44- try :
45- for queue_name in self .QUEUES :
46- queue_client = queue_service .get_queue_client (queue_name )
47- try :
48- # Check if the queue exists
49- queue_client .get_queue_properties ()
50- self .stdout .write (
51- self .style .WARNING (
52- f"Queue '{ queue_name } ' already exists. Skipping creation."
53- )
54- )
55- # If the queue does not exist, create it
56- except Exception :
57- queue_client .create_queue ()
58- self .stdout .write (
59- self .style .SUCCESS (
60- f"Queue '{ queue_name } ' created successfully."
61- )
62- )
63-
64- except Exception as e :
65- raise ValueError (f"Error when creating Azure Queue: { e } " )
66-
67- def _create_blob_containers (self , blob_service : str ):
31+ def _create_blob_containers (self , blob_service : BlobServiceClient ):
6832 """
6933 Creates the required Azure Blob Containers.
7034
@@ -96,7 +60,7 @@ def _create_blob_containers(self, blob_service: str):
9660 except Exception as e :
9761 raise ValueError (f"Error when creating Azure Blob Container: { e } " )
9862
99- def _create_minio_buckets (self , minio_client : str ):
63+ def _create_minio_buckets (self , minio_client : Minio ):
10064 """
10165 Creates the required MinIO Buckets.
10266
@@ -145,15 +109,11 @@ def _create_azure_resources(self):
145109 return
146110
147111 try :
148- queue_service = QueueServiceClient .from_connection_string (
149- self .AZURE_CONN_STRING
150- )
151112 blob_service = BlobServiceClient .from_connection_string (
152113 self .AZURE_CONN_STRING
153114 )
154115
155- # Create Queues and Blob Containers
156- self ._create_azure_queues (queue_service )
116+ # Create Blob Containers
157117 self ._create_blob_containers (blob_service )
158118
159119 self .stdout .write (self .style .SUCCESS ("Azurite Storage setup complete." ))
0 commit comments