seitime-frappe/frappe/integrations/doctype
Andy Zhu fcdb923d2e
fix: Missing bucket name check (#9546)
* fix: missing bucket name check when user make changes on s3 backup setting

Problem: If the user changed the backup limit, then press save. The validate function will give an error message that the bucket name already exists. It would be inconvenient for the user to use a different bucket name to save any changes.

So I implemented a flag ''bucket_name_exist'' to indicate if the bucket name exists, if not, then go to the flow of trying to create a bucket.

* fix: extra line removed

* fix: Use head_bucket Boto3 API 

1. Head_bucket will return 200 Ok if the bucket exists and you have permission to access it.
2. Error code 403 Forbidden, Error code 404 Not Found.
3. Use bucket_name_exist to check if need to create bucket.

Thanks @Mangesh-Khairnar suggestions.
Reference: 
1. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.head_bucket
2. https://boto3.amazonaws.com/v1/documentation/api/latest/guide/migrations3.html#accessing-a-bucket

Further improvements:
1. Use 'GET' Requestion to check if the Access Key ID and Secret Access Key is valid (Because AWS tier has 20,000 GET requests while only 2,000 LIST requests)
2. Edge case on Error prompts when head_bucket returns an error code other than '403' or '404'.

* fix: add an extra line to align with original code style

* Update frappe/integrations/doctype/s3_backup_settings/s3_backup_settings.py

Co-Authored-By: Chinmay Pai <chinmaydpai@gmail.com>

* fix: remove the flag and redundant exception

When we got a 404 error, we can just create the bucket as 1. The bucket name does not exist in the current bucket. 2. we have permission to access the bucket.

* Update frappe/integrations/doctype/s3_backup_settings/s3_backup_settings.py

Co-Authored-By: Himanshu <himanshuwarekar@yahoo.com>

* Update frappe/integrations/doctype/s3_backup_settings/s3_backup_settings.py

Co-Authored-By: Chinmay Pai <chinmaydpai@gmail.com>

* fix: missing handling the error code '400' - 'Bad Request'

* fix: applied with DeepSource analysis

1. Lines too long
2. Doc Lines too long
3. Expected 2 blank lines between class and method
4. Unused variable removed

Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
Co-authored-by: Himanshu <himanshuwarekar@yahoo.com>
2020-03-13 13:06:36 +05:30
..
braintree_settings Allow custom confirmation page (#5835) 2018-07-19 12:50:35 +05:30
dropbox_settings fix(Dropbox): Make "Take Backup Now" button visible only if dropbox is enabled 2019-07-05 15:24:40 +05:30
google_calendar fix: TypeError: 'NoneType' object is not iterable 2019-10-11 15:07:26 +05:30
google_contacts fix: TypeError: 'NoneType' object is not iterable 2019-10-11 15:07:26 +05:30
google_drive fix: translations 2019-08-29 18:12:57 +05:30
google_settings fix: translations 2019-08-29 18:12:57 +05:30
integration_request fix: Rename Reference DocType -> Reference Document Type 2019-09-05 15:47:40 +05:30
ldap_group_mapping add group ldap settings 2019-07-15 19:02:57 +08:00
ldap_settings Fix indentation 2019-08-07 17:08:58 +02:00
oauth_authorization_code [minor] remove in_dialog old property 2018-05-16 12:51:01 +05:30
oauth_bearer_token [minor] remove in_dialog old property 2018-05-16 12:51:01 +05:30
oauth_client fix(translations): Incorrect syntax 2020-01-29 15:22:35 +05:30
oauth_provider_settings [minor] remove in_dialog old property 2018-05-16 12:51:01 +05:30
paypal_settings fix: merge conflict 2019-06-18 18:45:21 +05:30
razorpay_settings Merge pull request #8808 from scmmishra/razorpay-orders 2019-11-25 12:10:15 +05:30
s3_backup_settings fix: Missing bucket name check (#9546) 2020-03-13 13:06:36 +05:30
slack_webhook_url fix: better logging for slack (#9474) 2020-02-17 14:49:45 +05:30
social_login_key Merge version-12-hotfix to develop (#9095) 2019-12-23 12:24:52 +05:30
social_login_keys fix(unicode): Import unicode_literals in every file (#6805) 2019-01-25 11:56:27 +05:30
stripe_settings fix: stripe api payment receipt email 2020-01-13 17:22:44 +05:30
webhook fix: hash secret before assigning to header 2020-01-13 15:43:57 +05:30
webhook_data Cleanup and Docs for Webhooks 2017-09-14 17:26:34 +05:30
webhook_header [Fix] Codacy Errors 2017-09-10 18:30:50 +05:30
__init__.py Moved Backup Manager and Social Login keys to the new Integrations Module, prepared frappe for Mandrill Integration 2015-08-11 12:03:13 +05:30