99import traceback
1010from concurrent .futures import ThreadPoolExecutor , as_completed
1111from datetime import datetime , timedelta
12- from typing import Iterator , Literal , Optional , Sequence , cast
12+ from typing import Iterator , Literal , Optional , Sequence , cast , Union
1313
1414import semver
1515
16- from .api import RSConnectClient , RSConnectServer , emit_task_log
16+ from .api import RSConnectServer , SPCSConnectServer , RSConnectClient , emit_task_log
1717from .exception import RSConnectException
1818from .log import logger
1919from .metadata import ContentBuildStore , ContentItemWithBuildState
@@ -33,7 +33,7 @@ def content_build_store() -> ContentBuildStore:
3333 return _content_build_store
3434
3535
36- def ensure_content_build_store (connect_server : RSConnectServer ) -> ContentBuildStore :
36+ def ensure_content_build_store (connect_server : Union [ RSConnectServer , SPCSConnectServer ] ) -> ContentBuildStore :
3737 global _content_build_store
3838 if not _content_build_store :
3939 logger .info ("Initializing ContentBuildStore for %s" % connect_server .url )
@@ -42,7 +42,7 @@ def ensure_content_build_store(connect_server: RSConnectServer) -> ContentBuildS
4242
4343
4444def build_add_content (
45- connect_server : RSConnectServer ,
45+ connect_server : Union [ RSConnectServer , SPCSConnectServer ] ,
4646 content_guids_with_bundle : Sequence [ContentGuidWithBundle ],
4747):
4848 """
@@ -85,7 +85,7 @@ def _validate_build_rm_args(guid: Optional[str], all: bool, purge: bool):
8585
8686
8787def build_remove_content (
88- connect_server : RSConnectServer ,
88+ connect_server : Union [ RSConnectServer , SPCSConnectServer ] ,
8989 guid : Optional [str ],
9090 all : bool ,
9191 purge : bool ,
@@ -109,20 +109,20 @@ def build_remove_content(
109109 return guids
110110
111111
112- def build_list_content (connect_server : RSConnectServer , guid : str , status : Optional [str ]):
112+ def build_list_content (connect_server : Union [ RSConnectServer , SPCSConnectServer ] , guid : str , status : Optional [str ]):
113113 build_store = ensure_content_build_store (connect_server )
114114 if guid :
115115 return [build_store .get_content_item (g ) for g in guid ]
116116 else :
117117 return build_store .get_content_items (status = status )
118118
119119
120- def build_history (connect_server : RSConnectServer , guid : str ):
120+ def build_history (connect_server : Union [ RSConnectServer , SPCSConnectServer ] , guid : str ):
121121 return ensure_content_build_store (connect_server ).get_build_history (guid )
122122
123123
124124def build_start (
125- connect_server : RSConnectServer ,
125+ connect_server : Union [ RSConnectServer , SPCSConnectServer ] ,
126126 parallelism : int ,
127127 aborted : bool = False ,
128128 error : bool = False ,
@@ -251,7 +251,9 @@ def build_start(
251251 build_monitor .shutdown ()
252252
253253
254- def _monitor_build (connect_server : RSConnectServer , content_items : list [ContentItemWithBuildState ]):
254+ def _monitor_build (
255+ connect_server : Union [RSConnectServer , SPCSConnectServer ], content_items : list [ContentItemWithBuildState ]
256+ ):
255257 """
256258 :return bool: True if the build completed without errors, False otherwise
257259 """
@@ -296,7 +298,9 @@ def _monitor_build(connect_server: RSConnectServer, content_items: list[ContentI
296298 return True
297299
298300
299- def _build_content_item (connect_server : RSConnectServer , content : ContentItemWithBuildState , poll_wait : int ):
301+ def _build_content_item (
302+ connect_server : Union [RSConnectServer , SPCSConnectServer ], content : ContentItemWithBuildState , poll_wait : int
303+ ):
300304 build_store = ensure_content_build_store (connect_server )
301305 with RSConnectClient (connect_server ) as client :
302306 # Pending futures will still try to execute when ThreadPoolExecutor.shutdown() is called
@@ -351,7 +355,7 @@ def write_log(line: str):
351355
352356
353357def emit_build_log (
354- connect_server : RSConnectServer ,
358+ connect_server : Union [ RSConnectServer , SPCSConnectServer ] ,
355359 guid : str ,
356360 format : str ,
357361 task_id : Optional [str ] = None ,
@@ -369,7 +373,7 @@ def emit_build_log(
369373 raise RSConnectException ("Log file not found for content: %s" % guid )
370374
371375
372- def download_bundle (connect_server : RSConnectServer , guid_with_bundle : ContentGuidWithBundle ):
376+ def download_bundle (connect_server : Union [ RSConnectServer , SPCSConnectServer ] , guid_with_bundle : ContentGuidWithBundle ):
373377 """
374378 :param guid_with_bundle: models.ContentGuidWithBundle
375379 """
@@ -387,7 +391,7 @@ def download_bundle(connect_server: RSConnectServer, guid_with_bundle: ContentGu
387391 return client .download_bundle (guid_with_bundle .guid , guid_with_bundle .bundle_id )
388392
389393
390- def get_content (connect_server : RSConnectServer , guid : str | list [str ]):
394+ def get_content (connect_server : Union [ RSConnectServer , SPCSConnectServer ] , guid : str | list [str ]):
391395 """
392396 :param guid: a single guid as a string or list of guids.
393397 :return: a list of content items.
@@ -401,7 +405,7 @@ def get_content(connect_server: RSConnectServer, guid: str | list[str]):
401405
402406
403407def search_content (
404- connect_server : RSConnectServer ,
408+ connect_server : Union [ RSConnectServer , SPCSConnectServer ] ,
405409 published : bool ,
406410 unpublished : bool ,
407411 content_type : Sequence [str ],
0 commit comments