# # Mender API endpoint for generating artifacts
mender_api_url = "https://eu.hosted.mender.io/api/management/v1/deployments/artifacts/generate"
headers = {
"Authorization": f'Bearer {token.decode()}'
}
# Read the content of the certificate file
with open('testcert.pem', 'r') as cert_file:
certificate_content = cert_file.read()
# Convert the content to raw bytes
certificate_bytes = certificate_content.encode('utf-8')
# Define the artifact data
data = {
"name": "TEST",
"description": "Test artifact generated via REST API - 01",
"device_types_compatible": ["raspberrypi4"],
"type": "single-file"
}
# Send the POST request to generate the artifact
response = requests.post(mender_api_url, headers=headers, data=data, files={'file': ('my_cert.pem', certificate_bytes)})