@@ -8,7 +8,7 @@ class Handler(abc.ABC):
88 def __init__ (self , client ):
99 self .client = client
1010 self .cls = None
11-
11+
1212 @staticmethod
1313 def create (client , cls ):
1414 k = cls .__name__
@@ -19,7 +19,7 @@ def create(client, cls):
1919 if handler is None :
2020 raise ValueError (f"Handler not found for class '{ k } '" )
2121 return handler (client )
22-
22+
2323 @abc .abstractmethod
2424 def get (self ):
2525 pass
@@ -79,7 +79,7 @@ def all(self) -> List[Project]:
7979 for project_data in resp .json ()['data' ]:
8080 projects .append (self .cls .from_dict (project_data ))
8181 return projects
82-
82+
8383 def get (self , id :int ) -> Project :
8484 """
8585 Retrieves a project by its ID.
@@ -94,7 +94,7 @@ def get(self, id:int) -> Project:
9494 resp = self .client .request ("GET" , url_part = path )
9595 project_data = resp .json ()['data' ]
9696 return self .cls .from_dict (project_data )
97-
97+
9898 def get_id (self , project_name :str ) -> int :
9999 """
100100 Retrieves the ID of a project based on its name.
@@ -190,7 +190,24 @@ def get_inventory(self,project_id:int,
190190 project .inventoryItems .extend (chunk .inventoryItems )
191191
192192 return project
193-
193+
194+ def upload_codebase (self , project_id :int ,
195+ codebase_path :str ,
196+ deleteExistingFileOnServer : bool = False ,
197+ expansionLevel : int = 1 ,
198+ deleteArchiveAfterExpand : bool = False ,
199+ archiveDirSuffix : str = None ,
200+ ) -> int :
201+ path = "project/uploadProjectCodebase"
202+ params = {"projectId" : project_id ,
203+ "deleteExistingFileOnServer" : deleteExistingFileOnServer ,
204+ "expansionLevel" : expansionLevel ,
205+ "deleteArchiveAfterExpand" : deleteArchiveAfterExpand ,
206+ "archiveDirSuffix" : archiveDirSuffix }
207+ code_file = {"file" : open (codebase_path , 'rb' )}
208+ content_type = "application/octet-stream"
209+ resp = self .client .request ("POST" , url_part = path , params = params , data = code_file ,content_type = content_type )
210+ return resp .status_code
194211
195212class ReportHandler (Handler ):
196213 """
0 commit comments