@@ -64,9 +64,9 @@ def handle_bad_response(self, response):
64
64
)
65
65
66
66
67
- class RStudioServer (AbstractRemoteServer ):
67
+ class PositServer (AbstractRemoteServer ):
68
68
"""
69
- A class used to represent the server of the shinyapps.io and RStudio Cloud APIs.
69
+ A class used to represent the server of the shinyapps.io and Posit Cloud APIs.
70
70
"""
71
71
72
72
def __init__ (self , remote_name : str , url : str , account_name : str , token : str , secret : str ):
@@ -76,7 +76,7 @@ def __init__(self, remote_name: str, url: str, account_name: str, token: str, se
76
76
self .secret = secret
77
77
78
78
79
- class ShinyappsServer (RStudioServer ):
79
+ class ShinyappsServer (PositServer ):
80
80
"""
81
81
A class to encapsulate the information needed to interact with an
82
82
instance of the shinyapps.io server.
@@ -89,16 +89,16 @@ def __init__(self, url: str, account_name: str, token: str, secret: str):
89
89
super ().__init__ (remote_name = remote_name , url = url , account_name = account_name , token = token , secret = secret )
90
90
91
91
92
- class CloudServer (RStudioServer ):
92
+ class CloudServer (PositServer ):
93
93
"""
94
94
A class to encapsulate the information needed to interact with an
95
- instance of the RStudio Cloud server.
95
+ instance of the Posit Cloud server.
96
96
"""
97
97
98
98
def __init__ (self , url : str , account_name : str , token : str , secret : str ):
99
- remote_name = "RStudio Cloud"
100
- if url == " rstudio.cloud" or url is None :
101
- url = "https://api.rstudio .cloud"
99
+ remote_name = "Posit Cloud"
100
+ if url in { "posit.cloud" , " rstudio.cloud", None } :
101
+ url = "https://api.posit .cloud"
102
102
super ().__init__ (remote_name = remote_name , url = url , account_name = account_name , token = token , secret = secret )
103
103
104
104
@@ -475,7 +475,7 @@ def setup_remote_server(
475
475
if api_key :
476
476
self .remote_server = RSConnectServer (url , api_key , insecure , ca_data )
477
477
elif token and secret :
478
- if url and "rstudio.cloud" in url :
478
+ if url and ( "rstudio.cloud" in url or "posit.cloud" in url ) :
479
479
self .remote_server = CloudServer (url , account_name , token , secret )
480
480
else :
481
481
self .remote_server = ShinyappsServer (url , account_name , token , secret )
@@ -485,8 +485,8 @@ def setup_remote_server(
485
485
def setup_client (self , cookies = None , timeout = 30 , ** kwargs ):
486
486
if isinstance (self .remote_server , RSConnectServer ):
487
487
self .client = RSConnectClient (self .remote_server , cookies , timeout )
488
- elif isinstance (self .remote_server , RStudioServer ):
489
- self .client = RStudioClient (self .remote_server , timeout )
488
+ elif isinstance (self .remote_server , PositServer ):
489
+ self .client = PositClient (self .remote_server , timeout )
490
490
else :
491
491
raise RSConnectException ("Unable to infer Connect client." )
492
492
@@ -515,7 +515,7 @@ def validate_server(
515
515
):
516
516
if (url and api_key ) or isinstance (self .remote_server , RSConnectServer ):
517
517
self .validate_connect_server (name , url , api_key , insecure , cacert , api_key_is_required )
518
- elif (url and token and secret ) or isinstance (self .remote_server , RStudioServer ):
518
+ elif (url and token and secret ) or isinstance (self .remote_server , PositServer ):
519
519
self .validate_rstudio_server (url , account_name , token , secret )
520
520
else :
521
521
raise RSConnectException ("Unable to validate server from information provided." )
@@ -596,11 +596,11 @@ def validate_rstudio_server(
596
596
secret = secret or self .remote_server .secret
597
597
server = (
598
598
CloudServer (url , account_name , token , secret )
599
- if "rstudio.cloud" in url
599
+ if "rstudio.cloud" in url or "posit.cloud" in url
600
600
else ShinyappsServer (url , account_name , token , secret )
601
601
)
602
602
603
- with RStudioClient (server ) as client :
603
+ with PositClient (server ) as client :
604
604
try :
605
605
result = client .get_current_user ()
606
606
server .handle_bad_response (result )
@@ -657,7 +657,7 @@ def check_server_capabilities(self, capability_functions):
657
657
:param details_source: the source for obtaining server details, gather_server_details(),
658
658
by default.
659
659
"""
660
- if isinstance (self .remote_server , RStudioServer ):
660
+ if isinstance (self .remote_server , PositServer ):
661
661
return self
662
662
663
663
details = self .server_details
@@ -847,12 +847,12 @@ def validate_app_mode(self, *args, **kwargs):
847
847
if isinstance (self .remote_server , RSConnectServer ):
848
848
app = get_app_info (self .remote_server , app_id )
849
849
existing_app_mode = AppModes .get_by_ordinal (app .get ("app_mode" , 0 ), True )
850
- elif isinstance (self .remote_server , RStudioServer ):
850
+ elif isinstance (self .remote_server , PositServer ):
851
851
app = get_rstudio_app_info (self .remote_server , app_id )
852
852
existing_app_mode = AppModes .get_by_cloud_name (app .json_data ["mode" ])
853
853
else :
854
854
raise RSConnectException ("Unable to infer Connect client." )
855
- if existing_app_mode and app_mode != existing_app_mode :
855
+ if existing_app_mode and existing_app_mode not in ( None , AppModes . UNKNOWN , app_mode ) :
856
856
msg = (
857
857
"Deploying with mode '%s',\n "
858
858
+ "but the existing deployment has mode '%s'.\n "
@@ -1008,14 +1008,14 @@ def __init__(
1008
1008
self .output_id = output_id
1009
1009
1010
1010
1011
- class RStudioClient (HTTPServer ):
1011
+ class PositClient (HTTPServer ):
1012
1012
"""
1013
- An HTTP client to call the RStudio Cloud and shinyapps.io APIs.
1013
+ An HTTP client to call the Posit Cloud and shinyapps.io APIs.
1014
1014
"""
1015
1015
1016
1016
_TERMINAL_STATUSES = {"success" , "failed" , "error" }
1017
1017
1018
- def __init__ (self , rstudio_server : RStudioServer , timeout : int = 30 ):
1018
+ def __init__ (self , rstudio_server : PositServer , timeout : int = 30 ):
1019
1019
self ._token = rstudio_server .token
1020
1020
try :
1021
1021
self ._key = base64 .b64decode (rstudio_server .secret )
@@ -1156,7 +1156,7 @@ class ShinyappsService:
1156
1156
Encapsulates operations involving multiple API calls to shinyapps.io.
1157
1157
"""
1158
1158
1159
- def __init__ (self , rstudio_client : RStudioClient , server : ShinyappsServer ):
1159
+ def __init__ (self , rstudio_client : PositClient , server : ShinyappsServer ):
1160
1160
self ._rstudio_client = rstudio_client
1161
1161
self ._server = server
1162
1162
@@ -1202,10 +1202,10 @@ def do_deploy(self, bundle_id, app_id):
1202
1202
1203
1203
class CloudService :
1204
1204
"""
1205
- Encapsulates operations involving multiple API calls to RStudio Cloud.
1205
+ Encapsulates operations involving multiple API calls to Posit Cloud.
1206
1206
"""
1207
1207
1208
- def __init__ (self , rstudio_client : RStudioClient , server : CloudServer ):
1208
+ def __init__ (self , rstudio_client : PositClient , server : CloudServer ):
1209
1209
self ._rstudio_client = rstudio_client
1210
1210
self ._server = server
1211
1211
@@ -1216,17 +1216,6 @@ def prepare_deploy(
1216
1216
bundle_size : int ,
1217
1217
bundle_hash : str ,
1218
1218
):
1219
- accounts = self ._rstudio_client .get_accounts ()
1220
- self ._server .handle_bad_response (accounts )
1221
- account = next (
1222
- filter (lambda acct : acct ["name" ] == self ._server .account_name , accounts .json_data ["accounts" ]), None
1223
- )
1224
- # TODO: also check this during `add` command
1225
- if account is None :
1226
- raise RSConnectException (
1227
- "No account found by name : %s for given user credential" % self ._server .account_name
1228
- )
1229
-
1230
1219
if app_id is None :
1231
1220
project_application_id = os .getenv ("LUCID_APPLICATION_ID" )
1232
1221
if project_application_id is not None :
@@ -1343,7 +1332,7 @@ def get_app_info(connect_server, app_id):
1343
1332
1344
1333
1345
1334
def get_rstudio_app_info (server , app_id ):
1346
- with RStudioClient (server ) as client :
1335
+ with PositClient (server ) as client :
1347
1336
result = client .get_application (app_id )
1348
1337
server .handle_bad_response (result )
1349
1338
return result
@@ -1552,7 +1541,7 @@ def find_unique_name(remote_server: TargetableServer, name: str):
1552
1541
mapping_function = lambda client , app : app ["name" ],
1553
1542
)
1554
1543
elif isinstance (remote_server , ShinyappsServer ):
1555
- client = RStudioClient (remote_server )
1544
+ client = PositClient (remote_server )
1556
1545
existing_names = client .get_applications_like_name (name )
1557
1546
else :
1558
1547
# non-unique names are permitted in cloud
0 commit comments