IP Address lists can be created, edited and viewed using the api. When you have created an IP Address list, you can attach that list to a demand or supply tag for targeting.
Table of Contents
Creating an IP Address List
SDK
Use tab completion with SDK to auto-complete function names or show field options!
...
IP Address lists can be created, edited and viewed using the api. When you have created an IP Address list, you can attach that list to a demand or supply tag for targeting.
Table of Contents
Creating an IP Address List
SDK
Use tab completion with SDK to auto-complete function names or show field options!
Code Block | ||
---|---|---|
| ||
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 |
REST API
POST /api/v0/ip_lists
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Body (example)
{ "name" : "My IP List" , "description": "My description" } |
Required parameters: name
Response
Status code 200
Code Block |
---|
{
"id": 6,
"account_id": 1,
"name": "My IP List",
"description": "My description",
"active": true,
"created_at": "2018-08-08T21:06:09.923Z"
} |
Get an IP Address List
SDK
Code Block | ||
---|---|---|
| ||
In [1]: ip_list = springserve.ip_lists.get(9)
In [2]: print ip_list.name
"My Test IP List" |
REST API
GET /api/v0/ip_lists/<id>
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Response
Status code 200
Code Block |
---|
{
"id": 6,
"account_id": 1,
"name": "My IP List",
"description": "My description",
"active": true,
"created_at": "2018-08-08T17:19:44.516Z"
} |
Add IPs to an Address list
SDK
Code Block |
---|
In [1]: ip_list import= springserve .ip_lists.get(9) In [2]: add = ip_list = springserve.ip_lists.new({"name":"My Test IP List"}) .bulk_create(['158.106.194.74', '158.106.194.75']) In [3]: print ip_listadd.ok, ip_list.id True 9 Out [3]: True |
- Please note that only valid IP addresses will save to list
REST API
POST /api/v0/ip_lists/<id>/ips/bulk_create
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Body (example)
...
{
"name"
:
"My IP List"
,
}
Required parameters: name
Response
...
"yourAuthToken" |
Body (example)
Code Block |
---|
{ "idips": 6, "account_id": 1, "name": "My IP List", "description": "My description", "active": true, "created_at": "2018-08-08T21:06:09.923Z" } |
Get an IP Address List
SDK
Code Block | ||
---|---|---|
| ||
In [1]: ip_list = springserve.ip_lists.get(9)
In [2]: print ip_list.name
"My Test IP List" |
REST API
...
["158.106.194.74", "158.106.194.75"]
}
|
Response
Status code 200
Code Block |
---|
{"created": True} |
Add IPs to an Address list from a File
Appends ip addresses in the csv file to the list
SDK
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 |
- Please note that only valid IP addresses will save to list
REST API
POST /api/v0/ip_lists/<id>/ips/file_bulk_create
Code Block |
---|
curl --location --request POST 'https://console.springserve.com/api/v0/ip_lists/<id> |
...
Headers
Code Block |
---|
/ips/file_bulk_create' \ --header 'Content-Type: application/json Authorization "yourAuthToken"json' \ --header 'Authorization: <yourAuthToken>' \ --form 'csv_file=@"/<filepath>/appending_ip_list.csv"' |
Response
Status code 200201
Code Block |
---|
{
"id": 6,
"account_id": 1,
"name": "My IP List",
"description": "My description",
"active": true,
"created_at": "2018-08-08T17:19:44.516Z"
} |
Add an IP Address list
SDK
Code Block |
---|
In [1]: ip_list = springserve.ip_lists.get(9)
In [2]: add = ip_list.add_ips(['158.106.194.74', '158.106.194.75'])
In [3]: print add.ok
True |
- Please note that only valid IP addresses will save to list
REST API
POST /api/v0/ip_lists/<id>/ips/bulk_create
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Body (example)
Code Block |
---|
{
"ips": ["158.106.194.74", "158.106.194.75"]
}
|
Response
Status code 200
Code Block |
---|
{"created": True} |
Add IP Addresses from a File
...
"created": True} |
Replace Entire IP Address List
SDK
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]: replaced.ok
Out [3]: True |
REST API
POST /api/v0/ip_lists/<id>ips/bulk_replace
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Body (example)
Code Block |
---|
{
"ips": ["1.1.11.1", "1.0.11.1"]
} |
Response
Status code 201
Code Block |
---|
{"created": True} |
Replace Entire IP List with File
Replaces ip list with the ip addresses in the csv file
SDK
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]: replaced.ok
Out [3]: True |
REST API
POST /api/v0/ip_lists/<id>/ips/file_bulk_createreplace
Code Block |
---|
curl --location --request POST 'https://console.springserve.com/api/v0/ip_lists/<id>/ips/file_bulk_createreplace' \ --header 'Content-Type: application/json' \ --header 'Authorization: <yourAuthToken>' \ --form 'csv_file=@"/<filepath>/appendingreplacement_ip_list.csv"' |
Response
Status code 201
Code Block |
---|
{"created": True} |
...
Get IP Addresses in a IP Address List
SDK
REST API
POST /api/v0/ip_lists/<id>ips/bulk_replace
Headers
Code Block |
---|
Content-Type application/json
Authorization "yourAuthToken" |
Body (example)
Code Block |
---|
{
"ips": ["1.1.11.1", "1.0.11.1"]
} |
Response
Status code 201
Code Block |
---|
{"created": True} |
Replace Entire IP List with File
Replaces ip list with the ip addresses in the csv file
REST API
POST /api/v0/ip_lists/<id>/ips/file_bulk_replace
Code Block |
---|
Code Block |
In [1]: ip_list = springserve.ip_lists.get(9)
In [2]: resp = ip_list.get_list()
In [3]: for ip in resp:
....: print ip.ip
....:
158.106.194.74
158.106.194.75 |
REST API
GET /api/v0/ip_lists/<id>/ips
...
Headers
Code Block |
---|
Content-Type: application/json' \ --header 'Authorization: <yourAuthToken>' \ --form 'csv_file=@"/<filepath>/replacement_ip_list.csv"' |
Response
Status code 201
Code Block |
---|
{"created": True} |
...
"yourAuthToken" |
Response (note you need to paginate)
Status code 200
Code Block |
---|
{
"ip": "158.106.194.74"
"ip": "158.106.194.75"
} |
Remove specific IP Addresses
SDK
Code Block |
---|
In [1513]: respip_list = springserve.ip_listlists.get_ips(9) In [1614]: for ip in resp: ....: print ip.ip ....: del = ip_list.bulk_delete(['158.106.194.74 ','158.106.194.75.76']) In [15]: del.ok Out [15]: True |
REST API
GET DELETE /api/v0/ip_lists/<id>/ips/bulk_delete
Headers
Code Block |
---|
Content-Type application/json Authorization "yourAuthToken" |
Response (note you need to pagenate)
Status code 200Body (example) where "1" and "2" are the numeric
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]: respdel = ip_list.removebulk_ips(['158.106.194.75']) delete(file_path='/<filepath>/ips_to_delete.csv') In [15]: respdel.ok Out [15]: True In [16]: print resp.deleted Out [15]: True |
REST API
DELETE /api/v0/ip_lists/<id>/ips/file_bulk_delete
Headers
...
Code Block |
---|
curl --location --request POST 'https://console.springserve.com/api/v0/ip_lists/<id>/ips/file_bulk_delete' \ --header 'Content-Type: application/json' Authorization "yourAuthToken" |
Body (example) where "1" and "2" are the numeric
Code Block |
---|
{
"ip": "158.106.194.74"
"ip": "158.106.194.75"
}
|
...
\
--header 'Authorization: <yourAuthToken>' \
--form 'csv_file=@"/<filepath>/delete_these_ips.csv"' |
Response
Status code 200
Code Block |
---|
{"deleted": True} |
Remove IP Addresses using a File
Removes IP addreses in the csv file from the list
REST API
DELETE /api/v0/ip_lists/<id>/ips/file_bulk_delete
Code Block |
---|
curl --location --request POST 'https://console.springserve.com/api/v0/ip_lists/<id>/ips/file_bulk_delete' \
--header 'Content-Type: application/json' \
--header 'Authorization: <yourAuthToken>' \
--form 'csv_file=@"/<filepath>/delete_these_ips.csv"' |
Response
Status code 200
...
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
To attach an ip list to a supply or demand tag you must set the following fields on a supply or demand 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 |
REST API
See documentation on the Supply and Demand Tag APIs