small script changes and notes

This commit is contained in:
Norm Rasmussen
2023-05-12 16:45:50 -04:00
parent aa64ae8ba5
commit 5c8b9a7a3b
29 changed files with 695 additions and 1702 deletions

View File

@ -3,78 +3,77 @@ from requests.auth import HTTPBasicAuth
import json
import os
# Information
#url = "https://northpass.atlassian.net/wiki/rest/api/content/2210463745/child/page"
# Information
# url = "https://northpass.atlassian.net/wiki/rest/api/content/2210463745/child/page"
url = "https://northpass.atlassian.net/wiki/rest/api/content/"
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
auth = HTTPBasicAuth("nrasmussen@northpass.com","ATATT3xFfGF0QZUomC1s3hvD4Hiqh_usOVFAVLsT1n8lt6gzD7wfL8D8x5ner3SE24JD4E590xoT9PKPIi1Eppanx12q5ALzMHKce-KrcIZRT23BvO8MDXwyvbzAO2R4hALc8ZUTI_8-OM-x9o_tjbCHLxEMFOr6QFDYprwdHGZjAxpviSwXrCQ=218AC438")
rootdir = "/Users/normrasmussen/Documents/Work/CustomerNotes/"
rootdir = "/Users/normrasmussen/Documents/Northpass/CustomerNotes/"
def getCompany():
rootdir = "/Users/normrasmussen/Documents/Northpass/Scripts/Confluence_Notes/SampleNotes/"
rootdir = (
"/Users/normrasmussen/Documents/Work/CustomerNotes/"
)
companyName = os.listdir(rootdir)
for fileName in companyName:
company = fileName[:-3]
getPages(company)
def readNewNotes(company):
rootdir = "/Users/normrasmussen/Documents/Northpass/Scripts/Confluence_Notes/SampleNotes/"
with open(rootdir+company+".md", "r") as companyfile:
rootdir = (
"/Users/normrasmussen/Documents/Work/CustomerNotes/"
)
with open(rootdir + company + ".md", "r") as companyfile:
notes = companyfile.read()
conversion = markdown.markdown(notes)
createNewPage(company, conversion)
def getPages(company):
headers = {
"Accept": "application/json",
}
response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)
response = requests.request("GET", url, headers=headers, auth=auth)
jsonResponse = response.json()
for response in jsonResponse['results']:
if response['title'] == company:
for response in jsonResponse["results"]:
if response["title"] == company:
print(f"{company} Found. Updating page....")
else:
print(f"{company} not found. Create new page...")
readNewNotes(company)
# readNewNotes(company)
def createNewPage(company, notes):
def createNewPage(company, notes):
url = "https://northpass.atlassian.net/wiki/rest/api/content/"
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
headers = {
"X-Atlassian-Token": "no-check",
"Accept": "application/json",
"Content-Type": "application/json"
"Content-Type": "application/json",
}
payload = json.dumps( {
"type":"page",
"title": company,
"ancestors":[{"id":2210463745}],
"space":
{"key":"~350535240"},
"body":
{"storage":
{"value": notes,
"representation":"storage"}}
} )
response = requests.request(
"POST",
url,
data=payload,
headers=headers,
auth=auth
payload = json.dumps(
{
"type": "page",
"title": company,
"ancestors": [{"id": 2210463745}],
"space": {"key": "~350535240"},
"body": {"storage": {"value": notes, "representation": "storage"}},
}
)
response = requests.request("POST", url, data=payload, headers=headers, auth=auth)
print("createNewPage function has run")
response = json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))
response = json.dumps(
json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")
)
print(response)
#jsonResponse = response.json()
#print(jsonResponse)
# jsonResponse = response.json()
# print(jsonResponse)
if __name__ == "__main__":
createNewPage()
#readNewNotes(company="Flink")
getCompany()
# createNewPage()
# readNewNotes(company="Flink")