Skip to content

Commit

Permalink
Merge pull request #38 from dataiku/feature/sc-88223-recycle-lists
Browse files Browse the repository at this point in the history
Moving lists to recycle bin instead of deleting them
  • Loading branch information
alexbourret authored Jun 21, 2022
2 parents ebbb388 + 0012d1e commit f7a9ef9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions python-lib/sharepoint_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def __init__(self, config):
self.assert_login_details(DSSConstants.SITE_APP_DETAILS, login_details)
self.setup_sharepoint_online_url(login_details)
self.setup_login_details(login_details)
self.apply_paths_overwrite(config)
self.tenant_id = login_details.get("tenant_id")
self.client_secret = login_details.get("client_secret")
self.client_id = login_details.get("client_id")
Expand Down Expand Up @@ -326,13 +327,10 @@ def create_list(self, list_name):
json = response.json()
return json.get(SharePointConstants.RESULTS_CONTAINER_V2, {})

def delete_list(self, list_name):
headers = {
"X-HTTP-Method": "DELETE",
"IF-MATCH": "*"
}
def recycle_list(self, list_name):
headers = DSSConstants.JSON_HEADERS
response = self.session.post(
self.get_lists_by_title_url(list_name),
self.get_lists_by_title_url(list_name)+"/recycle()",
headers=headers
)
return response
Expand Down
4 changes: 2 additions & 2 deletions python-lib/sharepoint_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def __init__(self, config, parent, dataset_schema, dataset_partitioning, partiti
self.web_name = self.parent.sharepoint_list_title

if write_mode == SharePointConstants.WRITE_MODE_CREATE:
logger.info('flush:delete_list "{}"'.format(self.parent.sharepoint_list_title))
self.parent.client.delete_list(self.parent.sharepoint_list_title)
logger.info('flush:recycle_list "{}"'.format(self.parent.sharepoint_list_title))
self.parent.client.recycle_list(self.parent.sharepoint_list_title)
logger.info('flush:create_list "{}"'.format(self.parent.sharepoint_list_title))
created_list = self.parent.client.create_list(self.parent.sharepoint_list_title)
self.entity_type_name = created_list.get("EntityTypeName")
Expand Down

0 comments on commit f7a9ef9

Please sign in to comment.