Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
In [1]: import springserve
 
In [2]: ip_list = springserve.ip_lists.new({"name":"My Test IP List"})
 
In [3]: print ip_list.ok, ip_list.id
True 9

...

Code Block
In [1]:  ip_list = springserve.ip_lists.get(9)

In [2]:  add = ip_list.bulk_create(['158.106.194.74', '158.106.194.75'])

In [3]: print add.ok
Out [3]: True
  • Please note that only valid IP addresses will save to list

...

Code Block
In [1]:  ip_list = springserve.ip_lists.get(9)

In [2]:  add = ip_list.bulk_create(file_path='/<filepath>/appending_ip_list.csv')

In [3]: print add.ok
True

...

Code Block
In [1]:  ip_list = springserve.ip_lists.get(9)

In [2]:  replaced = ip_list.bulk_replace(['158.106.194.76', '158.106.194.80'])

In [3]: print replaced.ok
Out [3]: True

REST API

POST /api/v0/ip_lists/<id>ips/bulk_replace

...

Code Block
In [1]:  ip_list = springserve.ip_lists.get(9)

In [2]:  replaced = ip_list.bulk_replace(file_path='/<filepath>/replacement_ip_list.csv')

In [3]: print replaced.ok
Out [3]: True

REST API

POST /api/v0/ip_lists/<id>/ips/file_bulk_replace

...

Get IP Addresses in a IP Address List

SDK

Code Block
In [151]:  ip_list = springserve.ip_lists.get(9)
In [2]: resp = ip_list.get_ipslist() 

In [163]: for ip in resp:
   ....:     print ip.ip
   ....:     
158.106.194.74
158.106.194.75

...

Code Block
{
	"ip": "158.106.194.74"
    "ip": "158.106.194.75"
 }

...

Remove specific IP Addresses

SDK

Code Block
 In [13]: ip_list = springserve.ip_lists.get(9)

 In [14]: respdel = ip_list.bulk_replacedelete(['158.106.194.74','158.106.194.76'])
 
 In [15]: respdel.ok
 Out [15]: True

REST API

...


Code Block
{
	"ip": "158.106.194.74"
    "ip": "158.106.194.75"
 }

Response (note you need to pagenate)

Status code 200

Code Block
{"deleted": True}

Remove IP Addresses using a File

Removes IP addresses in the csv file from the list

SDK

Code Block
 In [13]: ip_list = springserve.ip_lists.get(9)

 In [14]: del = ip_list.bulk_delete(file_path='/<filepath>/ips_to_delete.csv')
 In [15]: del.ok
 Out [15]: True

REST API

DELETE /api/v0/ip_lists/<id>/ips/file_bulk_delete

...

Code Block
{"deleted": True}

Delete all ip addresses in a list

SDK

Code Block
In [13]: ip_list = springserve.ip_lists.get(9)

In [14]: resp = ip_list.bulk_replace([''])
In [15]: resp.ok
Out [15]: True

Attach to a Demand or Supply Tag

...

  • ip_list_ids → this is a list of ip list ids that you want to target on the supply or demand tag
  • ip_targeting → Whether or not to treat it like an 'Allowlist' or 'Blocklist'

SDK

Code Block
In [18]: tag = springserve.demand_tags.get(2)

In [19]: tag.ip_list_ids.append(9)

In [20]: tag.ip_targeting = "Allowlist"

In [21]: print tag.save().ok
True

...