-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor: use typed patch instance for session updates #500
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1c04e59
refactor: use typed patch instance for user updates
leafty 15945ce
refactor: use typed patch instance for platform config updates
leafty c673150
wip
leafty 85cc1ef
more wip
leafty 79e8628
more wip
leafty bd09063
done
leafty 5053f05
format
leafty 40553f0
fix responses
leafty ac7ab20
Merge remote-tracking branch 'origin/main' into leafty/fix-db-update-…
leafty c716c67
Merge branch 'main' into leafty/fix-db-update-session
leafty c2525fd
address comments
leafty 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
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Business logic for sessions.""" | ||
|
||
from ulid import ULID | ||
|
||
from renku_data_services.session import apispec, models | ||
|
||
|
||
def validate_unsaved_environment(environment: apispec.EnvironmentPost) -> models.UnsavedEnvironment: | ||
"""Validate an unsaved session environment.""" | ||
return models.UnsavedEnvironment( | ||
name=environment.name, | ||
description=environment.description, | ||
container_image=environment.container_image, | ||
default_url=environment.default_url, | ||
) | ||
|
||
|
||
def validate_environment_patch(patch: apispec.EnvironmentPatch) -> models.EnvironmentPatch: | ||
"""Validate the update to a session environment.""" | ||
return models.EnvironmentPatch( | ||
name=patch.name, | ||
description=patch.description, | ||
container_image=patch.container_image, | ||
default_url=patch.default_url, | ||
) | ||
|
||
|
||
def validate_unsaved_session_launcher(launcher: apispec.SessionLauncherPost) -> models.UnsavedSessionLauncher: | ||
"""Validate an unsaved session launcher.""" | ||
return models.UnsavedSessionLauncher( | ||
project_id=ULID.from_str(launcher.project_id), | ||
name=launcher.name, | ||
description=launcher.description, | ||
environment_kind=launcher.environment_kind, | ||
environment_id=launcher.environment_id, | ||
resource_class_id=launcher.resource_class_id, | ||
container_image=launcher.container_image, | ||
default_url=launcher.default_url, | ||
) | ||
|
||
|
||
def validate_session_launcher_patch(patch: apispec.SessionLauncherPatch) -> models.SessionLauncherPatch: | ||
"""Validate the update to a session launcher.""" | ||
return models.SessionLauncherPatch( | ||
name=patch.name, | ||
description=patch.description, | ||
environment_kind=patch.environment_kind, | ||
environment_id=patch.environment_id, | ||
resource_class_id=patch.resource_class_id, | ||
container_image=patch.container_image, | ||
default_url=patch.default_url, | ||
) |
Oops, something went wrong.
Oops, something went wrong.
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.
that's a nice way to handle it 👍 , we might want to add that for the other apispec_base.py's as well
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.
I was thinking that we should have a common
apispec_base.py
file because otherwise we have a lot of code fragmentation.