Skip to content

Commit b512fb0

Browse files
committed
spcs support
add support for deployments and administrative actions for Connect in SPCS
1 parent d544fc1 commit b512fb0

File tree

12 files changed

+960
-103
lines changed

12 files changed

+960
-103
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ test = [
3838
"twine",
3939
"types-Flask",
4040
]
41+
snowflake = ["snowflake-cli"]
4142

4243
[project.urls]
4344
Repository = "http://github.com/posit-dev/rsconnect-python"

rsconnect/actions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ def test_rstudio_server(server: api.PositServer):
172172
raise RSConnectException("Failed to verify with {} ({}).".format(server.remote_name, exc))
173173

174174

175+
def test_spcs_server(server: api.SPCSConnectServer):
176+
with api.RSConnectClient(server) as client:
177+
try:
178+
client.me()
179+
except RSConnectException as exc:
180+
raise RSConnectException("Failed to verify with {} ({}).".format(server.remote_name, exc))
181+
182+
175183
def test_api_key(connect_server: api.RSConnectServer) -> str:
176184
"""
177185
Test that an API Key may be used to authenticate with the given Posit Connect server.

rsconnect/actions_content.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import semver
1515

16-
from .api import RSConnectClient, RSConnectServer, emit_task_log
16+
from .api import PositConnectServer, RSConnectClient, emit_task_log
1717
from .exception import RSConnectException
1818
from .log import logger
1919
from .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: PositConnectServer) -> 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

4444
def build_add_content(
45-
connect_server: RSConnectServer,
45+
connect_server: PositConnectServer,
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

8787
def build_remove_content(
88-
connect_server: RSConnectServer,
88+
connect_server: PositConnectServer,
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: PositConnectServer, 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: PositConnectServer, guid: str):
121121
return ensure_content_build_store(connect_server).get_build_history(guid)
122122

123123

124124
def build_start(
125-
connect_server: RSConnectServer,
125+
connect_server: PositConnectServer,
126126
parallelism: int,
127127
aborted: bool = False,
128128
error: bool = False,
@@ -251,7 +251,7 @@ def build_start(
251251
build_monitor.shutdown()
252252

253253

254-
def _monitor_build(connect_server: RSConnectServer, content_items: list[ContentItemWithBuildState]):
254+
def _monitor_build(connect_server: PositConnectServer, content_items: list[ContentItemWithBuildState]):
255255
"""
256256
:return bool: True if the build completed without errors, False otherwise
257257
"""
@@ -296,7 +296,7 @@ def _monitor_build(connect_server: RSConnectServer, content_items: list[ContentI
296296
return True
297297

298298

299-
def _build_content_item(connect_server: RSConnectServer, content: ContentItemWithBuildState, poll_wait: int):
299+
def _build_content_item(connect_server: PositConnectServer, content: ContentItemWithBuildState, poll_wait: int):
300300
build_store = ensure_content_build_store(connect_server)
301301
with RSConnectClient(connect_server) as client:
302302
# Pending futures will still try to execute when ThreadPoolExecutor.shutdown() is called
@@ -351,7 +351,7 @@ def write_log(line: str):
351351

352352

353353
def emit_build_log(
354-
connect_server: RSConnectServer,
354+
connect_server: PositConnectServer,
355355
guid: str,
356356
format: str,
357357
task_id: Optional[str] = None,
@@ -369,7 +369,7 @@ def emit_build_log(
369369
raise RSConnectException("Log file not found for content: %s" % guid)
370370

371371

372-
def download_bundle(connect_server: RSConnectServer, guid_with_bundle: ContentGuidWithBundle):
372+
def download_bundle(connect_server: PositConnectServer, guid_with_bundle: ContentGuidWithBundle):
373373
"""
374374
:param guid_with_bundle: models.ContentGuidWithBundle
375375
"""
@@ -387,7 +387,7 @@ def download_bundle(connect_server: RSConnectServer, guid_with_bundle: ContentGu
387387
return client.download_bundle(guid_with_bundle.guid, guid_with_bundle.bundle_id)
388388

389389

390-
def get_content(connect_server: RSConnectServer, guid: str | list[str]):
390+
def get_content(connect_server: PositConnectServer, guid: str | list[str]):
391391
"""
392392
:param guid: a single guid as a string or list of guids.
393393
:return: a list of content items.
@@ -401,7 +401,7 @@ def get_content(connect_server: RSConnectServer, guid: str | list[str]):
401401

402402

403403
def search_content(
404-
connect_server: RSConnectServer,
404+
connect_server: PositConnectServer,
405405
published: bool,
406406
unpublished: bool,
407407
content_type: Sequence[str],

0 commit comments

Comments
 (0)