Added editing subscribers with PythonAPI Interface

Using the UpdateSubscriber call. Input variables are the IMSI and the subscriber data, which is the same as the outputted data of GetSubscriber.
This commit is contained in:
Nick
2020-03-15 17:28:17 +11:00
committed by GitHub
parent 1e56141d1e
commit 85dbeb05cc

View File

@@ -42,6 +42,17 @@ class Open5GS:
print("Added subscriber with Inserted ID : " + str(x.inserted_id))
return x.inserted_id
def UpdateSubscriber(self, imsi, sub_data):
myclient = pymongo.MongoClient("mongodb://" + str(self.server) + ":" + str(self.port) + "/")
mydb = myclient["open5gs"]
mycol = mydb["subscribers"]
print("Attempting to update IMSI " + str(imsi))
newvalues = { "$set": sub_data }
myquery = { "imsi": str(imsi)}
x = mycol.update_one(myquery, newvalues)
print(x)
return True
def DeleteSubscriber(self, imsi):
myclient = pymongo.MongoClient("mongodb://" + str(self.server) + ":" + str(self.port) + "/")
@@ -51,5 +62,3 @@ class Open5GS:
x = mycol.delete_many(myquery)
print(x.deleted_count, " subscribers deleted.")
return x.deleted_count