Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some handling for tag edge cases #118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions md2cf/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from urllib.parse import urljoin

import requests
Expand Down Expand Up @@ -207,7 +208,9 @@ def update_page(

if labels is not None:
update_structure["metadata"] = {
"labels": [{"name": label, "prefix": "global"} for label in labels]
"labels": json.dumps(
[{"name": label, "prefix": "global"} for label in labels]
)
}

return self._put(f"content/{page.id}", json=update_structure)
Expand Down Expand Up @@ -243,7 +246,8 @@ def add_labels(self, page, labels):
# return self.api.content(page.id).post(
return self._post(
f"content/{page.id}/label",
data=[{"name": label, "type": "global"} for label in labels],
data=json.dumps([{"name": label, "type": "global"} for label in labels]),
Copy link
Author

@nate-woythaler nate-woythaler Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the correct approach, but our Confluence instance was giving me back HTTP 415s when submitting binary data via the **kwargs expansion on line 68

415 Client Error: Unsupported Media Type for url: https://${CONFLUENCE_URL}/rest/api/content/515736017/label - b''

headers={"Content-Type": "application/json"},
)

def get_url(self, page):
Expand Down
7 changes: 6 additions & 1 deletion md2cf/upsert.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ def labels_need_updating(page, existing_page):
return False

if sorted(
[label.name for label in existing_page.metadata.labels.results]
[
label.name
for label in existing_page.get("metadata", {})
.get("labels", {})
.get("results", {})
]
) != sorted(page.labels):
return True

Expand Down