@@ -330,8 +330,8 @@ def add_comment(self, page_id, text):
330330 data = {'type' : 'comment' ,
331331 'container' : {'id' : page_id , 'type' : 'page' , 'status' : 'current' },
332332 'body' : {'storage' : {'value' : text , 'representation' : 'storage' }}}
333- return self .post ('rest/api/content/' , data = data )
334-
333+ return self .post ('rest/api/content/' , data = data )
334+
335335 def attach_file (self , filename , page_id = None , title = None , space = None , comment = None ):
336336 """
337337 Attach (upload) a file to a page, if it exists it will update the
@@ -635,6 +635,28 @@ def get_space(self, space_key, expand='description.plain,homepage'):
635635 expand = expand )
636636 return self .get (url )
637637
638+ def create_space (self , space_key , space_name ):
639+ """
640+ Create space
641+ :param space_key:
642+ :param space_name:
643+ :return:
644+ """
645+ data = {
646+ 'key' : space_key ,
647+ 'name' : space_name
648+ }
649+ self .post ('rest/api/space' , data = data )
650+
651+ def delete_space (self , space_key ):
652+ """
653+ Delete space
654+ :param space_key:
655+ :return:
656+ """
657+ url = 'rest/api/space/{}' .format (space_key )
658+ return self .delete (url )
659+
638660 def get_user_details_by_username (self , username , expand = None ):
639661 """
640662 Get information about a user through username
@@ -710,7 +732,7 @@ def get_page_as_pdf(self, page_id):
710732 url = self .get_pdf_download_url_for_confluence_cloud (url )
711733
712734 return self .get (url , headers = headers , not_json_response = True )
713-
735+
714736 def export_page (self , page_id ):
715737 """
716738 Alias method for export page as pdf
@@ -790,7 +812,8 @@ def get_pdf_download_url_for_confluence_cloud(self, url):
790812 poll_url = 'runningtaskxml.action?taskId={0}' .format (task_id )
791813 while long_running_task :
792814 long_running_task_response = self .get (poll_url , headers = headers , not_json_response = True )
793- long_running_task_response_parts = long_running_task_response .decode (encoding = 'utf-8' , errors = 'strict' ).split ('\n ' )
815+ long_running_task_response_parts = long_running_task_response .decode (encoding = 'utf-8' ,
816+ errors = 'strict' ).split ('\n ' )
794817 percentage_complete = long_running_task_response_parts [6 ].strip ()
795818 is_successful = long_running_task_response_parts [7 ].strip ()
796819 is_complete = long_running_task_response_parts [8 ].strip ()
@@ -813,5 +836,5 @@ def get_pdf_download_url_for_confluence_cloud(self, url):
813836 except IndexError as e :
814837 log .error (e )
815838 return None
816-
839+
817840 return download_url
0 commit comments