[python] Atlassian API 활용한 Confluence 작업 자동화

Seunghyun Moon·2023년 5월 4일
0

python

목록 보기
3/4

자동화 목적의 python backend api 와 연동하기 위해 Atlassian API 활용 방법을 알아봅니다.


Atlassian 에서 오픈소스로 api python 라이브러리를 제공합니다.
https://github.com/atlassian-api/atlassian-python-api#atlassian-python-api-wrapper

공식 도큐먼테이션도 제공하고 있습니다.
https://atlassian-python-api.readthedocs.io/

라이브러리 설치

pip3 install atlassian-python-api

테스트

테스트용으로 Confluence 에서 몇가지를 테스트해봅니다.
https://atlassian-python-api.readthedocs.io/confluence.html

연결 테스트

from atlassian import Confluence
 
 
confluence = Confluence(
    url='https://confluence.wemakeprice.com/',
    username=USERNAME,
    password=PASSWORD)
 
 
space='~shmoon2'
title=''
page_id=244735450
 
 
 
print(confluence.get_page_space(page_id))
 
print(confluence.get_all_pages_from_space(space, start=0, limit=1, status=None, expand=None, content_type='page'))

결과

페이지 생성 테스트

space='~shmoon2'
title='apitest'
parent_id=253388724
 
status = confluence.create_page(space=space, parent_id=parent_id, title=title, body="This is the body")
 
print(status)

페이지 생성 테스트 w/ table

space='~shmoon2'
title='apitest5'
parent_id=253388724
body='''
||Key||Name||Updated||
|halo|koniziwa|hi|
'''
 
 
status = confluence.create_page(space=space, parent_id=parent_id, title=title, body=body, representation='wiki')
 
#print(status)

결과

페이지 업데이트 테스트

space='~shmoon2'
title='apitest5'
page_id=253388961
parent_id=253388724
body='''
||Key||Name||Updated||
|halo|koniziwa|hi|
|halo|koniziwa|hi|
|halo|koniziwa|hi|
|halo|koniziwa|i|
'''
 
 
status = confluence.update_page(
    parent_id=parent_id,
    page_id=page_id,
    title=title,
    body=body,
    representation='wiki'
)
 
 
#print(status)

결과

profile
I live fullest

0개의 댓글