Thanks to the awesome answer to a similar question by @afromero2, I was able to figure out how to accomplish my goal!
I refactored the php code that was used in that answer. In case anyone else is interested in doing this, here's the snippet I wrote:
import requests
import json
# Pretend canvas url
url = "https://my.canvas.edu"
# Pretend course id
course = "12345"
#Pretend assignment id
assignment = "54321"
#Pretend plagiarism LTI id
lti = "999"
#Pretend bearer token
token = "abc123"
request_url = "{}/api/v1/courses/{}/assignments/{}".format(url, course, assignment)
# Create the payload
payload = {
'assignment': {
'id': assignment,
'submission_types': ['online_upload'],
'submission_type': 'online',
'similarityDetectionTool': 'Lti::MessageHandler_' + lti,
'configuration_tool_type': 'Lti::MessageHandler',
'report_visibility': 'immediate'
}
}
# Define the headers
headers = {
'Authorization': 'Bearer {}'.format(token),
'Content-Type': 'application/json',
'cache-control': 'no-cache'
}
# Make the PUT request
response = requests.put(url, headers=headers, data=json.dumps(payload))
# Check on response status
if response.status_code == 200:
print("Yay!")
else:
print("Boo!")