-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Feature: Backup api #7231
Feature: Backup api #7231
Conversation
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.
Hi @archinksagar, thanks for the PR! This looks good overall, I just have a few nitpicks.
Note that the linter is currently failing as well: https://github.com/getmoto/moto/actions/runs/7586740652/job/20665598379?pr=7231
tests/test_backup/test_server.py
Outdated
@@ -0,0 +1,13 @@ | |||
"""Test different server responses.""" |
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.
This file doesn't seem to add anything, so let's just delete it
moto/__init__.py
Outdated
mock_backup = lazy_load(".backup", "mock_backup", boto3_name="backup") | ||
mock_backup = lazy_load(".backup", "mock_backup", boto3_name="backup") | ||
mock_backup = lazy_load(".backup", "mock_backup", boto3_name="backup") | ||
mock_backup = lazy_load(".backup", "mock_backup", boto3_name="backup") |
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.
This needs to only be added once (I know it's a bug in the scaffold
-script, it adds this line without checking)
moto/backup/models.py
Outdated
def random_str_utf8(self) -> str: | ||
ran_str = mock_random.get_random_string(length=48) | ||
utf8_bytes = ran_str.encode('utf-8') | ||
return utf8_bytes.decode('utf-8') |
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.
What is the reasoning behind the decode/encode operation? It looks like we can just return mock_random.get_random_string(length=48)
to get the same outcome. (Or even get rid of the function altogether..)
Out of interest - do you want to add them to this PR as well? Part of a later PR? Or is it just a general note that they are for someone else to implement? All options are fine by me - I'm just trying to get a feel for how 'ready' this PR is 🙂 |
@bblommers Thanks for your feedback. Except for pagination and describe_backup_vault , I will implement Exceptions and others I listed. Apart from that, I realized i have to modify "resourcegroupstaggingapi" to use vault tags. I am having trouble figuring out the values for these fields, I don't know when and how they get populated- "Deletion_date" and "LastExecutionDate", "NumberOfRecoveryPoints". Is there any documentation I can refer? |
If I read the docs here correctly:
The term |
hi @bblommers I have added code to resourcegrouptaggingapi and made few other modifications. I did run make lint, and fixed linting errors. Not sure why the linting is failing. |
Hey @archinksagar, which version of Running https://github.com/getmoto/moto/actions/runs/7659295607/job/20874125053?pr=7231 |
moto/backup/models.py
Outdated
self.deletion_date: Optional[float] = None | ||
# Deletion Date is updated when the backup_plan is deleted | ||
self.last_execution_date = None # start_restore_job not yet supported | ||
rules = backup_plan.get("Rules") |
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.
rules = backup_plan.get("Rules") | |
rules = backup_plan["Rules"] |
The Rules
argument is mandatory anyway. This should fix the mypy error (moto/backup/models.py:34:21: error: Item "None" of "Any | None" has no attribute "__iter__" (not iterable) [union-attr]
)
@bblommers Its failing at test/test with "def delete_backup_plan(self, backup_plan_id: str) -> tuple[str, str, float, str]: |
@archinksagar You could just run You can use |
@archinksagar Hope you don't mind - I just pushed a fix that should get the ServerMode tests to pass. The initial version intercepted all URL's ( |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #7231 +/- ##
========================================
Coverage 95.90% 95.91%
========================================
Files 840 845 +5
Lines 82608 82958 +350
========================================
+ Hits 79226 79569 +343
- Misses 3382 3389 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@bblommers Thanks for fixing it. |
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.
LGTM - thank you so much for adding this feature to Moto @archinksagar!
Hi @archinksagar, Thank you again for contributing to Moto, because PR's like this are the big reason that Moto is as successful as it is. To show our thanks, we'd like to share some of the donations that we've received with you - it's only fair that you, as a contributor, get to share the spoils. We've created a companion website with more information: Feel free to open a bug or discussion if you run into any problems: |
This is now part of moto >= 4.2.14.dev30 |
Please provide feedback on this initial draft of Backup API.
I have added the following API endpoints.
Things yet to be implemented