-
Notifications
You must be signed in to change notification settings - Fork 0
Add admin endpoint for publishing and unpublishing a project #558
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6aa814c
Add endpoint for publishing and unpublishing a project
GianlucaFicarelli 91b2f7c
Improve logging and coverage
GianlucaFicarelli b6f1a0b
Return errors instead of raising exceptions
GianlucaFicarelli 5a36160
Improve coverage
GianlucaFicarelli e846e3d
Add warning
GianlucaFicarelli ca72f1c
Merge branch 'main' into publish_project
GianlucaFicarelli d35de4a
Use s3_client.copy instead of s3_client.copy_object
GianlucaFicarelli 0bd4ed3
Set multipart params for copy and upload
GianlucaFicarelli 6b20ee3
Make copy_file return the success status
GianlucaFicarelli 2a70725
Improve coverage
GianlucaFicarelli 922afc3
Enable S3 versioning in moto for tests
GianlucaFicarelli 4f4175b
review
GianlucaFicarelli b8d0a11
Merge branch 'main' into publish_project
GianlucaFicarelli 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,66 @@ | ||
| import uuid | ||
| from typing import Annotated | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
|
|
||
| class MoveFileResult(BaseModel): | ||
| size: Annotated[int, Field(description="Size of the file")] | ||
| error: str | None = None | ||
|
|
||
|
|
||
| class MoveDirectoryResult(BaseModel): | ||
| size: Annotated[int, Field(description="Size of moved files in the directory")] = 0 | ||
| file_count: Annotated[int, Field(description="Number of moved files in the directory")] = 0 | ||
| errors: list[str] = [] | ||
|
|
||
| def update_from_file_result(self, file_result: MoveFileResult) -> None: | ||
| self.size += file_result.size | ||
| self.file_count += 1 | ||
| if file_result.error: | ||
| self.errors.append(file_result.error) | ||
|
|
||
|
|
||
| class MoveAssetsResult(BaseModel): | ||
| total_size: Annotated[int, Field(description="Total size of moved files")] = 0 | ||
| file_count: Annotated[int, Field(description="Number of moved files")] = 0 | ||
| asset_count: Annotated[int, Field(description="Number of updated assets")] = 0 | ||
| errors: list[str] = [] | ||
|
|
||
| def update_from_file_result(self, file_result: MoveFileResult) -> None: | ||
| self.total_size += file_result.size | ||
| self.file_count += 1 | ||
| self.asset_count += 1 | ||
| if file_result.error: | ||
| self.errors.append(file_result.error) | ||
|
|
||
| def update_from_directory_result(self, directory_result: MoveDirectoryResult) -> None: | ||
| self.total_size += directory_result.size | ||
| self.file_count += directory_result.file_count | ||
| self.asset_count += 1 | ||
| self.errors.extend(directory_result.errors) | ||
|
|
||
|
|
||
| class ChangeProjectVisibilityResponse(BaseModel): | ||
| """Successful response to the publish or unpublish operation.""" | ||
|
|
||
| message: Annotated[str, Field(description="A human-readable message describing the result")] | ||
| project_id: Annotated[uuid.UUID, Field(description="ID of the project")] | ||
| public: Annotated[bool, Field(description="Whether the content is now public or private")] | ||
| resource_count: Annotated[ | ||
| int, | ||
| Field(description="Number of updated resources (activities, entities, classifications)"), | ||
| ] | ||
| move_assets_result: Annotated[ | ||
| MoveAssetsResult, Field(description="Result of the assets movement") | ||
| ] | ||
| dry_run: Annotated[bool, Field(description="True if the operation has been simulated only")] | ||
| completed: Annotated[ | ||
| bool, | ||
| Field( | ||
| description=( | ||
| "Whether the assets have been fully updated. It may be False if `max_assets` " | ||
| "have been specified, and there are still assets to be moved." | ||
| ) | ||
| ), | ||
| ] |
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.
Uh oh!
There was an error while loading. Please reload this page.