-
Notifications
You must be signed in to change notification settings - Fork 27
deploy command support for drafts #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3860846
ec1d245
06aceb6
cfcf55a
acbb944
5ec10c4
5a2c5dc
dfcc5cc
2de9faa
79c8d70
421f391
4e7b148
ae19041
5be397a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -363,7 +363,7 @@ def __init__(self, server: Union[RSConnectServer, SPCSConnectServer], cookies: O | |
| def _tweak_response(self, response: HTTPResponse) -> JsonData | HTTPResponse: | ||
| return ( | ||
| response.json_data | ||
| if response.status and response.status == 200 and response.json_data is not None | ||
| if response.status and response.status >= 200 and response.status <= 299 and response.json_data is not None | ||
| else response | ||
| ) | ||
|
|
||
|
|
@@ -466,10 +466,32 @@ def content_get(self, content_guid: str) -> ContentItemV1: | |
| response = self._server.handle_bad_response(response) | ||
| return response | ||
|
|
||
| def content_build(self, content_guid: str, bundle_id: Optional[str] = None) -> BuildOutputDTO: | ||
| def content_build( | ||
| self, content_guid: str, bundle_id: Optional[str] = None, activate: bool = True | ||
| ) -> BuildOutputDTO: | ||
| body = {"bundle_id": bundle_id} | ||
| if not activate: | ||
| # The default behavior is to activate the app after building. | ||
| # So we only pass the parameter if we want to deactivate it. | ||
| # That way we can keep the API backwards compatible. | ||
| body["activate"] = False | ||
| response = cast( | ||
| Union[BuildOutputDTO, HTTPResponse], | ||
| self.post("v1/content/%s/build" % content_guid, body={"bundle_id": bundle_id}), | ||
| self.post("v1/content/%s/build" % content_guid, body=body), | ||
| ) | ||
| response = self._server.handle_bad_response(response) | ||
| return response | ||
|
|
||
| def content_deploy(self, app_guid: str, bundle_id: Optional[int] = None, activate: bool = True) -> BuildOutputDTO: | ||
| body = {"bundle_id": str(bundle_id)} | ||
| if not activate: | ||
| # The default behavior is to activate the app after deploying. | ||
| # So we only pass the parameter if we want to deactivate it. | ||
| # That way we can keep the API backwards compatible. | ||
| body["activate"] = False | ||
| response = cast( | ||
| Union[BuildOutputDTO, HTTPResponse], | ||
| self.post("v1/content/%s/deploy" % app_guid, body=body), | ||
| ) | ||
| response = self._server.handle_bad_response(response) | ||
| return response | ||
|
|
@@ -514,6 +536,7 @@ def deploy( | |
| title_is_default: bool, | ||
| tarball: IO[bytes], | ||
| env_vars: Optional[dict[str, str]] = None, | ||
| activate: bool = True, | ||
| ) -> RSConnectClientDeployResult: | ||
| if app_id is None: | ||
| if app_name is None: | ||
|
|
@@ -544,10 +567,10 @@ def deploy( | |
|
|
||
| app_bundle = self.app_upload(app_id, tarball) | ||
|
|
||
| task = self.app_deploy(app_id, app_bundle["id"]) | ||
| task = self.content_deploy(app_guid, app_bundle["id"], activate=activate) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the only use of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| return { | ||
| "task_id": task["id"], | ||
| "task_id": task["task_id"], | ||
| "app_id": app_id, | ||
| "app_guid": app["guid"], | ||
| "app_url": app["url"], | ||
|
|
@@ -1000,7 +1023,7 @@ def upload_posit_bundle(self, prepare_deploy_result: PrepareDeployResult, bundle | |
| upload_result = S3Server(upload_url).handle_bad_response(upload_result, is_httpresponse=True) | ||
|
|
||
| @cls_logged("Deploying bundle ...") | ||
| def deploy_bundle(self): | ||
| def deploy_bundle(self, activate: bool = True): | ||
| if self.deployment_name is None: | ||
| raise RSConnectException("A deployment name must be created before deploying a bundle.") | ||
| if self.bundle is None: | ||
|
|
@@ -1016,6 +1039,7 @@ def deploy_bundle(self): | |
| self.title_is_default, | ||
| self.bundle, | ||
| self.env_vars, | ||
| activate=activate, | ||
| ) | ||
| self.deployed_info = result | ||
| return self | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -379,6 +379,8 @@ def _do_request( | |
| logger.debug("Headers:") | ||
| for key, value in headers.items(): | ||
| logger.debug("--> %s: %s" % (key, value)) | ||
| logger.debug("Body:") | ||
| logger.debug("--> %s" % (body if body is not None else "<no body>")) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this extra logging of the Request body when in debug ( |
||
|
|
||
| # if we weren't called under a `with` statement, we'll need to manage the | ||
| # connection here. | ||
|
|
@@ -402,6 +404,7 @@ def _do_request( | |
| logger.debug("Headers:") | ||
| for key, value in response.getheaders(): | ||
| logger.debug("--> %s: %s" % (key, value)) | ||
| logger.debug("Body:") | ||
| logger.debug("--> %s" % response_body) | ||
| finally: | ||
| if local_connection: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/content/X/deployresponds with a 201 and a JSON body