gabstopper / smc-python

Forcepoint Security Management Center python library:(Moved to official Forcepoint repo)
https://github.com/Forcepoint/fp-NGFW-SMC-python
Apache License 2.0
29 stars 13 forks source link

Geolocation update #70

Open fgazelot opened 5 years ago

fgazelot commented 5 years ago

Hi David,

I have to update or create a Geolocation element in SMC.

Using ipython, I notice that the request update_or_create( with_status=True ) return always updated = True after creation.

This is the example :

In [4]: from smc.elements.other import Geolocation                                                      

In [5]: instance, updated, created = Geolocation.update_or_create( 
   ...:                 with_status=True, name='Geo_Test', latitude='48.86', longitude='2.33')
   ...:  
   ...: print('instance',instance) 
   ...: print('updated',updated) 
   ...: print('created',created)                                                                        
instance Geolocation(name=Geo_Test)
updated False
created True

In [6]: instance, updated, created = Geolocation.update_or_create( 
   ...:                 with_status=True, name='Geo_Test', latitude='48.86', longitude='2.33')
   ...:  
   ...: print('instance',instance) 
   ...: print('updated',updated) 
   ...: print('created',created)                                                                        
instance Geolocation(name=Geo_Test)
updated True
created False

In [7]: instance, updated, created = Geolocation.update_or_create( 
   ...:                 with_status=True, name='Geo_Test', latitude='48.86', longitude='2.33')
   ...:  
   ...: print('instance',instance) 
   ...: print('updated',updated) 
   ...: print('created',created)                                                                        
instance Geolocation(name=Geo_Test)
updated True
created False

I use this version of smc-python :

In [3]:  smc.__version__                                                                                
Out[3]: '0.7.0-b16'

Did I miss a step?

Best regards,

fgazelot commented 5 years ago

H David,

Do you have some mintues for check my issue ?

Best regards,

llarso commented 5 years ago

If you're attempting to create multiple Geolocations then it looks like the names of each of the Geo_Tests will need to be unique. Otherwise smc_python will look for the existing Geo_Test element and will update it instead of creating a new one.