Unknown Changes
This commit is contained in:
@ -55,3 +55,5 @@ Ideal information in Salesforce:
|
|||||||
|
|
||||||
DONE: Added a new group to homepage's access.
|
DONE: Added a new group to homepage's access.
|
||||||
TODO: Submit tickets from [this page](https://docs.google.com/spreadsheets/d/1kV93XzZuXTbIrh4HfqhZoFwGvBhNxCRZTC36eBqxaV0/edit#gid=0). Specifically: Static Banner (140), Popup (120), And Embed the Website (124).
|
TODO: Submit tickets from [this page](https://docs.google.com/spreadsheets/d/1kV93XzZuXTbIrh4HfqhZoFwGvBhNxCRZTC36eBqxaV0/edit#gid=0). Specifically: Static Banner (140), Popup (120), And Embed the Website (124).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,112 +7,106 @@ import sys
|
|||||||
input = sys.argv[1]
|
input = sys.argv[1]
|
||||||
company = input.split("/")[6]
|
company = input.split("/")[6]
|
||||||
|
|
||||||
|
|
||||||
def readFile(company):
|
def readFile(company):
|
||||||
rootdir = "/Users/normrasmussen/Documents/Northpass/Scripts/API_Notes/SampleNotes/"
|
rootdir = "/Users/normrasmussen/Documents/Northpass/Scripts/API_Notes/SampleNotes/"
|
||||||
with open(rootdir+company+".md", "r") as companyfile:
|
with open(rootdir + company + ".md", "r") as companyfile:
|
||||||
notes = companyfile.read()
|
notes = companyfile.read()
|
||||||
notes = markdown.markdown(notes)
|
notes = markdown.markdown(notes)
|
||||||
getContent(company, notes)
|
getContent(company, notes)
|
||||||
|
|
||||||
|
|
||||||
def createNewPage(company, notes):
|
def createNewPage(company, notes):
|
||||||
url = "https://northpass.atlassian.net/wiki/rest/api/content/"
|
url = "https://northpass.atlassian.net/wiki/rest/api/content/"
|
||||||
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
|
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
|
||||||
headers = {
|
headers = {
|
||||||
"X-Atlassian-Token": "no-check",
|
"X-Atlassian-Token": "no-check",
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
payload = json.dumps( {
|
payload = json.dumps(
|
||||||
"type":"page",
|
{
|
||||||
"title": company,
|
"type": "page",
|
||||||
"ancestors":[{"id":2210463745}],
|
"title": company,
|
||||||
"space":
|
"ancestors": [{"id": 2210463745}],
|
||||||
{"key":"~350535240"},
|
"space": {"key": "~350535240"},
|
||||||
"body":
|
"body": {"storage": {"value": notes, "representation": "storage"}},
|
||||||
{"storage":
|
}
|
||||||
{"value": notes,
|
|
||||||
"representation":"storage"}}
|
|
||||||
} )
|
|
||||||
response = requests.request(
|
|
||||||
"POST",
|
|
||||||
url,
|
|
||||||
data=payload,
|
|
||||||
headers=headers,
|
|
||||||
auth=auth
|
|
||||||
)
|
)
|
||||||
#print("createNewPage function has run")
|
response = requests.request("POST", url, data=payload, headers=headers, auth=auth)
|
||||||
response = json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))
|
# print("createNewPage function has run")
|
||||||
#print(response)
|
response = json.dumps(
|
||||||
|
json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")
|
||||||
|
)
|
||||||
|
# print(response)
|
||||||
exists = "already exists"
|
exists = "already exists"
|
||||||
# This if statement checks if the response from the call includes that the page already exists.
|
# This if statement checks if the response from the call includes that the page already exists.
|
||||||
# If the page does exist, it will get the ID and Version of the page and then run a PUT call to update the page.
|
# If the page does exist, it will get the ID and Version of the page and then run a PUT call to update the page.
|
||||||
if exists in response:
|
if exists in response:
|
||||||
#print("This page exists! Updating page instead.")
|
# print("This page exists! Updating page instead.")
|
||||||
getContent(company, notes)
|
getContent(company, notes)
|
||||||
|
|
||||||
|
|
||||||
def getContent(company, notes):
|
def getContent(company, notes):
|
||||||
url = "https://northpass.atlassian.net/wiki/rest/api/content/search?cql=parent=2210463745&expand=body.storage,version"
|
url = "https://northpass.atlassian.net/wiki/rest/api/content/search?cql=parent=2210463745&expand=body.storage,version"
|
||||||
# Found the answer to this URL here: https://community.atlassian.com/t5/Confluence-questions/How-can-i-get-the-page-version-using-a-specific-page-id/qaq-p/898721
|
# Found the answer to this URL here: https://community.atlassian.com/t5/Confluence-questions/How-can-i-get-the-page-version-using-a-specific-page-id/qaq-p/898721
|
||||||
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
|
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
|
||||||
headers = {
|
headers = {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
}
|
}
|
||||||
response = requests.request("GET", url, headers=headers, auth=auth)
|
response = requests.request("GET", url, headers=headers, auth=auth)
|
||||||
jsonResponse = response.json()
|
jsonResponse = response.json()
|
||||||
text = json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",",": "))
|
text = json.dumps(
|
||||||
#print(text)
|
json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")
|
||||||
|
)
|
||||||
|
# print(text)
|
||||||
listCompanies = []
|
listCompanies = []
|
||||||
for response in jsonResponse['results']:
|
for response in jsonResponse["results"]:
|
||||||
if response['title'] == company:
|
if response["title"] == company:
|
||||||
#print(f"{company} Found.")
|
# print(f"{company} Found.")
|
||||||
version = int(response["version"]["_links"]["self"][-1])
|
version = int(response["version"]["_links"]["self"][-1])
|
||||||
if version == "":
|
if version == "":
|
||||||
version = 1
|
version = 1
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
id = response['id']
|
id = response["id"]
|
||||||
#print(id)
|
# print(id)
|
||||||
#print(version)
|
# print(version)
|
||||||
updatePage(company, notes, id, version)
|
updatePage(company, notes, id, version)
|
||||||
else:
|
else:
|
||||||
listCompanies.append(response["title"])
|
listCompanies.append(response["title"])
|
||||||
pass
|
pass
|
||||||
#print("Other Companies, not pertinent right now. List of companies:")
|
# print("Other Companies, not pertinent right now. List of companies:")
|
||||||
#print(listCompanies)
|
# print(listCompanies)
|
||||||
|
|
||||||
|
|
||||||
def updatePage(company, notes, id, version):
|
def updatePage(company, notes, id, version):
|
||||||
url = f"https://northpass.atlassian.net/wiki/rest/api/content/{id}"
|
url = f"https://northpass.atlassian.net/wiki/rest/api/content/{id}"
|
||||||
newVersion = version+1
|
newVersion = version + 1
|
||||||
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
|
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
|
||||||
headers = {
|
headers = {
|
||||||
"X-Atlassian-Token": "no-check",
|
"X-Atlassian-Token": "no-check",
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"User-Agent" : "python-requests/2.28.1",
|
"User-Agent": "python-requests/2.28.1",
|
||||||
}
|
}
|
||||||
payload = json.dumps( {
|
payload = json.dumps(
|
||||||
"version": {
|
{
|
||||||
"number": newVersion
|
"version": {"number": newVersion},
|
||||||
},
|
"type": "page",
|
||||||
"type":"page",
|
"title": company,
|
||||||
"title": company,
|
"status": "current",
|
||||||
"status": "curent",
|
"ancestors": [{"id": 2210463745}],
|
||||||
"ancestors":[{"id": 2210463745}],
|
"body": {"storage": {"value": notes, "representation": "storage"}},
|
||||||
"body":
|
}
|
||||||
{"storage":
|
|
||||||
{"value": notes,
|
|
||||||
"representation":"storage"}}
|
|
||||||
} )
|
|
||||||
response = requests.request(
|
|
||||||
"PUT",
|
|
||||||
url,
|
|
||||||
data=payload,
|
|
||||||
headers=headers,
|
|
||||||
auth=auth
|
|
||||||
)
|
)
|
||||||
response = json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))
|
response = requests.request("PUT", url, data=payload, headers=headers, auth=auth)
|
||||||
#print(response)
|
response = json.dumps(
|
||||||
#print("updatePage function has run")
|
json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")
|
||||||
|
)
|
||||||
|
# print(response)
|
||||||
|
# print("updatePage function has run")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
readFile(company)
|
readFile(company)
|
||||||
|
|||||||
@ -4,124 +4,117 @@ from requests.auth import HTTPBasicAuth
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def findCompanies():
|
def findCompanies():
|
||||||
rootdir = "/Users/normrasmussen/Documents/Northpass/CustomerNotes/"
|
rootdir = "/Users/normrasmussen/Documents/Work/CustomerNotes/"
|
||||||
files = os.listdir(rootdir)
|
files = os.listdir(rootdir)
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
if fileName.startswith(".") or fileName.startswith("ima"):
|
if fileName.startswith(".") or fileName.startswith("ima"):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
company = fileName[:-3]
|
company = fileName[:-3]
|
||||||
#print(company)
|
print(company)
|
||||||
readFile(company)
|
readFile(company)
|
||||||
|
|
||||||
|
|
||||||
def readFile(company):
|
def readFile(company):
|
||||||
rootdir = "/Users/normrasmussen/Documents/Northpass/CustomerNotes/"
|
rootdir = "/Users/normrasmussen/Documents/Work/CustomerNotes/"
|
||||||
with open(rootdir+company+".md", "r") as companyfile:
|
with open(rootdir + company + ".md", "r") as companyfile:
|
||||||
notes = companyfile.read()
|
notes = companyfile.read()
|
||||||
notes = markdown.markdown(notes)
|
notes = markdown.markdown(notes)
|
||||||
createNewPage(company, notes)
|
createNewPage(company, notes)
|
||||||
|
|
||||||
|
|
||||||
def createNewPage(company, notes):
|
def createNewPage(company, notes):
|
||||||
url = "https://northpass.atlassian.net/wiki/rest/api/content/"
|
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")
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"X-Atlassian-Token": "no-check",
|
"X-Atlassian-Token": "no-check",
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
payload = json.dumps( {
|
payload = json.dumps(
|
||||||
"type":"page",
|
{
|
||||||
"title": company,
|
"type": "page",
|
||||||
"ancestors":[{"id":2210463745}],
|
"title": company,
|
||||||
"space":
|
"ancestors": [{"id": 2210463745}],
|
||||||
{"key":"~350535240"},
|
"space": {"key": "~350535240"},
|
||||||
"body":
|
"body": {"storage": {"value": notes, "representation": "storage"}},
|
||||||
{"storage":
|
}
|
||||||
{"value": notes,
|
|
||||||
"representation":"storage"}}
|
|
||||||
} )
|
|
||||||
response = requests.request(
|
|
||||||
"POST",
|
|
||||||
url,
|
|
||||||
data=payload,
|
|
||||||
headers=headers,
|
|
||||||
auth=auth
|
|
||||||
)
|
)
|
||||||
#print("createNewPage function has run")
|
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)
|
|
||||||
exists = "already exists"
|
exists = "already exists"
|
||||||
# This if statement checks if the response from the call includes that the page already exists.
|
# This if statement checks if the response from the call includes that the page already exists.
|
||||||
# If the page does exist, it will get the ID and Version of the page and then run a PUT call to update the page.
|
# If the page does exist, it will get the ID and Version of the page and then run a PUT call to update the page.
|
||||||
if exists in response:
|
if exists in response:
|
||||||
#print("This page exists! Updating page instead.")
|
print("This page exists! Updating page instead.")
|
||||||
getContent(company, notes)
|
getContent(company, notes)
|
||||||
|
|
||||||
|
|
||||||
def getContent(company, notes):
|
def getContent(company, notes):
|
||||||
url = "https://northpass.atlassian.net/wiki/rest/api/content/search?cql=parent=2210463745&expand=body.storage,version"
|
url = "https://northpass.atlassian.net/wiki/rest/api/content/search?cql=parent=2210463745&expand=body.storage,version"
|
||||||
# Found the answer to this URL here: https://community.atlassian.com/t5/Confluence-questions/How-can-i-get-the-page-version-using-a-specific-page-id/qaq-p/898721
|
# Found the answer to this URL here: https://community.atlassian.com/t5/Confluence-questions/How-can-i-get-the-page-version-using-a-specific-page-id/qaq-p/898721
|
||||||
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
|
auth = HTTPBasicAuth("nrasmussen@northpass.com",
|
||||||
|
"ATATT3xFfGF0QZUomC1s3hvD4Hiqh_usOVFAVLsT1n8lt6gzD7wfL8D8x5ner3SE24JD4E590xoT9PKPIi1Eppanx12q5ALzMHKce-KrcIZRT23BvO8MDXwyvbzAO2R4hALc8ZUTI_8-OM-x9o_tjbCHLxEMFOr6QFDYprwdHGZjAxpviSwXrCQ=218AC438")
|
||||||
headers = {
|
headers = {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
}
|
}
|
||||||
response = requests.request("GET", url, headers=headers, auth=auth)
|
response = requests.request("GET", url, headers=headers, auth=auth)
|
||||||
jsonResponse = response.json()
|
jsonResponse = response.json()
|
||||||
#print(jsonResponse[''])
|
text = json.dumps(
|
||||||
text = json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",",": "))
|
json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")
|
||||||
print(text)
|
)
|
||||||
listCompanies = []
|
listCompanies = []
|
||||||
for response in jsonResponse['results']:
|
for response in jsonResponse["results"]:
|
||||||
if response['title'] == company:
|
if response["title"] == company:
|
||||||
#print(f"{company} Found.")
|
print(f"{company} Found.")
|
||||||
version = int(response["version"]["_links"]["self"][-1])
|
version = int(response["version"]["_links"]["self"][-1])
|
||||||
if version == "":
|
if version == "":
|
||||||
version = 1
|
version = 1
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
id = response['id']
|
id = response["id"]
|
||||||
#print(id)
|
# print(id)
|
||||||
#print(version)
|
# print(version)
|
||||||
updatePage(company, notes, id, version)
|
updatePage(company, notes, id, version)
|
||||||
else:
|
else:
|
||||||
listCompanies.append(response["title"])
|
listCompanies.append(response["title"])
|
||||||
pass
|
pass
|
||||||
#print("Other Companies, not pertinent right now. List of companies:")
|
# print("Other Companies, not pertinent right now. List of companies:")
|
||||||
#print(listCompanies)
|
# print(listCompanies)
|
||||||
|
|
||||||
|
|
||||||
def updatePage(company, notes, id, version):
|
def updatePage(company, notes, id, version):
|
||||||
url = f"https://northpass.atlassian.net/wiki/rest/api/content/{id}"
|
url = f"https://northpass.atlassian.net/wiki/rest/api/content/{id}"
|
||||||
newVersion = version+1
|
newVersion = version + 1
|
||||||
auth = HTTPBasicAuth("nrasmussen@northpass.com", "qf9Il7X4wkthgQKBOIly5737")
|
auth = HTTPBasicAuth("nrasmussen@northpass.com",
|
||||||
|
"ATATT3xFfGF0QZUomC1s3hvD4Hiqh_usOVFAVLsT1n8lt6gzD7wfL8D8x5ner3SE24JD4E590xoT9PKPIi1Eppanx12q5ALzMHKce-KrcIZRT23BvO8MDXwyvbzAO2R4hALc8ZUTI_8-OM-x9o_tjbCHLxEMFOr6QFDYprwdHGZjAxpviSwXrCQ=218AC438")
|
||||||
headers = {
|
headers = {
|
||||||
"X-Atlassian-Token": "no-check",
|
"X-Atlassian-Token": "no-check",
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"User-Agent" : "python-requests/2.28.1",
|
"User-Agent": "python-requests/2.28.1",
|
||||||
}
|
}
|
||||||
payload = json.dumps( {
|
payload = json.dumps(
|
||||||
"version": {
|
{
|
||||||
"number": newVersion
|
"version": {"number": newVersion},
|
||||||
},
|
"type": "page",
|
||||||
"type":"page",
|
"title": company,
|
||||||
"title": company,
|
"status": "current",
|
||||||
"status": "curent",
|
"ancestors": [{"id": 2210463745}],
|
||||||
"ancestors":[{"id": 2210463745}],
|
"body": {"storage": {"value": notes, "representation": "storage"}},
|
||||||
"body":
|
}
|
||||||
{"storage":
|
|
||||||
{"value": notes,
|
|
||||||
"representation":"storage"}}
|
|
||||||
} )
|
|
||||||
response = requests.request(
|
|
||||||
"PUT",
|
|
||||||
url,
|
|
||||||
data=payload,
|
|
||||||
headers=headers,
|
|
||||||
auth=auth
|
|
||||||
)
|
)
|
||||||
response = json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))
|
response = requests.request("PUT", url, data=payload, headers=headers, auth=auth)
|
||||||
#print(response)
|
response = json.dumps(
|
||||||
#print("updatePage function has run")
|
json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")
|
||||||
|
)
|
||||||
|
print("updatePage function has run")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
findCompanies()
|
findCompanies()
|
||||||
|
|||||||
Reference in New Issue
Block a user