Created
September 4, 2020 16:26
-
-
Save pirkla/f14facab3fb5fbb0d4d583e7927af84b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import json | |
import requests | |
networkId='' | |
apiKey='' | |
baseURL='https://url.jamfcloud.com/api' | |
eSimServerUrl="https://example.com" | |
requiresNetworkTether = False | |
csvPath='' | |
if not csvPath: | |
print('Enter CSV path or drag and drop: ', end="") | |
csvPath = input() | |
r1=requests.get(baseURL +"/devices", auth=(networkId,apiKey)) | |
devicesJson = json.loads(r1.text)['devices'] | |
udidBySerial = dict() | |
for entry in devicesJson: | |
udidBySerial[entry['serialNumber']] = entry['UDID'] | |
serialNumbers = [] | |
with open(csvPath,newline='') as csvfile: | |
snReader = csv.reader(csvfile, delimiter=',', quotechar='|') | |
next(snReader) | |
for row in snReader: | |
serialNumbers.append(row[0]) | |
json = dict(serverUrl=eSimServerUrl,requiresNetworkTether=requiresNetworkTether) | |
for sn in serialNumbers: | |
r2=requests.post(baseURL + "/devices/{udid}/cellularPlan".format(udid=udidBySerial.get(sn)),auth=(networkId,apiKey),json=json) | |
print(r2.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment