-
Notifications
You must be signed in to change notification settings - Fork 60
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
feat: make app_id a public API #137
Closed
maartenbreddels
wants to merge
2
commits into
dominodatalab:master
from
maartenbreddels:feat_app_id_public_api
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -796,7 +796,7 @@ def collaborators_remove(self, username_or_email): | |
def app_publish(self, unpublishRunningApps=True, hardwareTierId=None): | ||
if unpublishRunningApps: | ||
self.app_unpublish() | ||
app_id = self._app_id | ||
app_id = self.app_id() | ||
if app_id is None: | ||
# No App Exists creating one | ||
app_id = self.__app_create(hardware_tier_id=hardwareTierId) | ||
|
@@ -806,24 +806,47 @@ def app_publish(self, unpublishRunningApps=True, hardwareTierId=None): | |
return response | ||
|
||
def app_unpublish(self): | ||
app_id = self._app_id | ||
app_id = self.app_id() | ||
if app_id is None: | ||
return | ||
status = self.__app_get_status(app_id) | ||
status = self.app_get_status(app_id) | ||
self.log.debug(f"App {app_id} status={status}") | ||
if status and status != "Stopped" and status != "Failed": | ||
url = self._routes.app_stop(app_id) | ||
response = self.request_manager.post(url) | ||
return response | ||
|
||
def __app_get_status(self, id) -> Optional[str]: | ||
app_id = self._app_id | ||
def app_id(self): | ||
url = self._routes.app_list(self.project_id) | ||
response = self._get(url) | ||
if len(response) != 0: | ||
app = response[0] | ||
else: | ||
return None | ||
key = "id" | ||
if key in app.keys(): | ||
app_id = app[key] | ||
else: | ||
app_id = None | ||
return app_id | ||
|
||
@property | ||
def _app_id(self): | ||
# for backwards compatibility, we keep this property | ||
return self.app_id() | ||
|
||
def app_get_status(self, id) -> Optional[str]: | ||
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.
|
||
app_id = self.app_id() | ||
if app_id is None: | ||
return None | ||
url = self._routes.app_get(app_id) | ||
response = self.request_manager.get(url).json() | ||
return response.get("status", None) | ||
|
||
def __app_get_status(self, id) -> Optional[str]: | ||
# for backwards compatibility, we keep this method | ||
return self.__app_get_status() | ||
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. meant to call |
||
|
||
def __app_create(self, name: str = "", hardware_tier_id: str = None) -> str: | ||
""" | ||
Private method to create app | ||
|
@@ -1178,20 +1201,4 @@ def project_id(self): | |
if key in response.keys(): | ||
return response[key] | ||
|
||
# This will fetch app_id of app in current project | ||
@property | ||
def _app_id(self): | ||
url = self._routes.app_list(self.project_id) | ||
response = self._get(url) | ||
if len(response) != 0: | ||
app = response[0] | ||
else: | ||
return None | ||
key = "id" | ||
if key in app.keys(): | ||
app_id = app[key] | ||
else: | ||
app_id = None | ||
return app_id | ||
|
||
_csrf_no_check_header = {"Csrf-Token": "nocheck"} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Set as a property as well.