@@ -546,6 +546,74 @@ def create_key_from_template(token, license_template_id):
546546 return (False , "Could not contact the server." )
547547
548548 return (jobj ["key" ], jobj ["rawResponse" ], jobj ["message" ])
549+
550+ def add_feature (token , product_id , key , feature ):
551+ """
552+ This method will set a certain feature (F1..F8) to true.
553+ If the key algorithm in the product is SKGL, the key string will be
554+ changed if necessary. Otherwise, if SKM15 is used, the key will stay
555+ the same. To do the reverse, please see RemoveFeature.
556+
557+ More docs: https://app.cryptolens.io/docs/api/v3/AddFeature
558+ """
559+
560+ response = ""
561+
562+ try :
563+ response = HelperMethods .send_request ("/key/AddFeature" , {"token" :token ,\
564+ "ProductId" :product_id ,\
565+ "Key" : key ,\
566+ "Feature" : feature })
567+ except HTTPError as e :
568+ response = e .read ()
569+ except URLError as e :
570+ return (None , "Could not contact the server. Error message: " + str (e ))
571+ except Exception :
572+ return (None , "Could not contact the server." )
573+
574+ jobj = json .loads (response )
575+
576+ if jobj == None or not ("result" in jobj ) or jobj ["result" ] == 1 :
577+ if jobj != None :
578+ return (False , jobj ["message" ])
579+ else :
580+ return (False , "Could not contact the server." )
581+
582+ return (True , jobj ["message" ])
583+
584+ def remove_feature (token , product_id , key , feature ):
585+ """
586+ This method will set a certain feature (F1..F8) to false. If the key
587+ algorithm in the product is SKGL, the key string will be changed if
588+ necessary. Otherwise, if SKM15 is used, the key will stay the same.
589+ To do the reverse, please see AddFeature.
590+
591+ More docs: https://app.cryptolens.io/docs/api/v3/RemoveFeature
592+ """
593+
594+ response = ""
595+
596+ try :
597+ response = HelperMethods .send_request ("/key/RemoveFeature" , {"token" :token ,\
598+ "ProductId" :product_id ,\
599+ "Key" : key ,\
600+ "Feature" : feature })
601+ except HTTPError as e :
602+ response = e .read ()
603+ except URLError as e :
604+ return (None , "Could not contact the server. Error message: " + str (e ))
605+ except Exception :
606+ return (None , "Could not contact the server." )
607+
608+ jobj = json .loads (response )
609+
610+ if jobj == None or not ("result" in jobj ) or jobj ["result" ] == 1 :
611+ if jobj != None :
612+ return (False , jobj ["message" ])
613+ else :
614+ return (False , "Could not contact the server." )
615+
616+ return (True , jobj ["message" ])
549617
550618class AI :
551619
0 commit comments