Skip to content

Commit 16f62f1

Browse files
committed
PYAPI-15 Confluence: Create Page
1 parent 1732245 commit 16f62f1

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

atlassian/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import requests
23

34

@@ -8,17 +9,18 @@ def __init__(self, url, username, password):
89
self.username = username
910
self.password = password
1011

11-
def get(self, path):
12+
def get(self, path, headers={"Content-Type": "application/json", "Accept": "application/json"}):
1213
url = "{0}{1}".format(self.url, path)
13-
return requests.get(url, auth=(self.username, self.password))
14+
return requests.get(url, headers=headers, auth=(self.username, self.password))
1415

15-
def post(self, path, data=None):
16+
def post(self, path, data=None, headers={"Content-Type": "application/json", "Accept": "application/json"}):
1617
url = "{0}{1}".format(self.url, path)
17-
return requests.post(url, data, auth=(self.username, self.password))
18+
return requests.post(url, json.dumps(data), headers=headers, auth=(self.username, self.password))
1819

19-
def delete(self, path):
20+
def delete(self, path, headers={"Content-Type": "application/json", "Accept": "application/json"}):
2021
url = "{0}{1}".format(self.url, path)
21-
return requests.delete(url, auth=(self.username, self.password))
22+
return requests.delete(url, headers=headers, auth=(self.username, self.password))
2223

2324

25+
from .confluence import Confluence
2426
from .jira import Jira

atlassian/confluence.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from atlassian import Atlassian
2+
3+
4+
class Confluence(Atlassian):
5+
6+
def create_page(self, space, title, body):
7+
return self.post("/rest/api/content/", {
8+
"type": "page",
9+
"title": title,
10+
"space": {"key": space},
11+
"body": {"storage": {
12+
"value": body,
13+
"representation": "storage"}}})

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
name="atlassian-python-api",
1111
description="Atlassian Python API",
1212
license="Apache License 2.0",
13-
version="0.1.1",
13+
version="0.2.1",
1414
download_url="https://github.com/AgileBoss/atlassian-python-api",
1515

1616
author="Matt Harasymczuk",

0 commit comments

Comments
 (0)