Reply

API to feed a RPZ from a CSV file

rflores
Member
Posts: 0
206     0

Hi!!

Do you know the API call to import a CSV file to load into a Infoblox RPZ zone ?

 

Thanks

Re: API to feed a RPZ from a CSV file

MRichard Community Manager
Community Manager
Posts: 101
207     0

See this thread also:

 

https://community.infoblox.com/t5/API-Integration/Importing-a-CSV-file-to-Infoblox-using-webAPI/m-p/... 

 

#
# CSV Upload for RPZ records
#
# file to be uploaded is "rpz.csv in the same directory
#

# generate an upload url

curl -k1 -u admin:infoblox -X POST "https://192.168.1.2/wapi/v2.8/fileop?_function=uploadinit&filename=rpz_import.csv"

# returns:

{
    "token": "eJytUEFOwzAQvPsj7aVJNkmdhltRqYSECmrhvEpsp1hK7MV2qpbXYyPBkRMHW+OdHc/uCGHphk6d\nWbyENT64WQTrGAFbCm0G24/2mlmj0gk3Up7tutDhUQ2MSiYQ+1mPQRtEJrUIjCq2lFSz00JdSbsb\nBj2pBaM128O6gbLiBS+yuuQt3wDzp8XsxkjzKHgPgfxdnkORtRnwjOepglLH0QIOelSobe7UB2q5\nent5et7uVlAAh6ps6qKGtoQyd/SJeiLrQib8Jf7cJBMtI9pEj7/VsalN7TKuGDEUUZH7mEd3VnmY\n6F8GAvixQGWEldqcU7WMXvePhwSr34bJyhQepDx329ctHh/26b1mPhwJeMoamkgOWo3SY7Ao7ESd\n+1Zt2CHt3neE2tAc8KKc19Ykro1cn30B6CueVQ==\n",
    "url": "https://192.168.1.2/http_direct_file_io/req_id-UPLOAD-1016132740419212/rpz_import.csv"
}

# upload the file to the url returned above

curl -k1 -u admin:infoblox -X POST -F "name=rpz.csv" -F "filedata=@./rpz_import.csv" "https://192.168.1.2/http_direct_file_io/req_id-UPLOAD-1016132740419212/rpz_import.csv"


# start the import using the token returned above

curl -k1 -u admin:infoblox -X POST "https://192.168.1.2/wapi/v2.8/fileop?_function=csv_import" -H "Content-Type: application/json" -d \
'{
    "action":"START",
    "operation":"INSERT",
    "token": "eJytUEFOwzAQvPsj7aVJNkmdhltRqYSECmrhvEpsp1hK7MV2qpbXYyPBkRMHW+OdHc/uCGHphk6d\nWbyENT64WQTrGAFbCm0G24/2mlmj0gk3Up7tutDhUQ2MSiYQ+1mPQRtEJrUIjCq2lFSz00JdSbsb\nBj2pBaM128O6gbLiBS+yuuQt3wDzp8XsxkjzKHgPgfxdnkORtRnwjOepglLH0QIOelSobe7UB2q5\nent5et7uVlAAh6ps6qKGtoQyd/SJeiLrQib8Jf7cJBMtI9pEj7/VsalN7TKuGDEUUZH7mEd3VnmY\n6F8GAvixQGWEldqcU7WMXvePhwSr34bJyhQepDx329ctHh/26b1mPhwJeMoamkgOWo3SY7Ao7ESd\n+1Zt2CHt3neE2tAc8KKc19Ykro1cn30B6CueVQ==\n",
    "on_error": "CONTINUE"
}'

# returns

{
    "csv_import_task": {
        "_ref": "csvimporttask/b25lLmNzdl9pbXBvcnRfdGFzayQxNQ:2",
        "admin_name": "admin",
        "file_name": "rpz_import.csv",
        "file_size": 259,
        "import_id": 15,
        "lines_failed": 0,
        "lines_processed": 0,
        "lines_warning": 0,
        "on_error": "CONTINUE",
        "operation": "INSERT",
        "separator": "COMMA",
        "start_time": 1571232519,
        "status": "PENDING",
        "update_method": "OVERRIDE"
    }
}
# check on the task

curl -k1 -u admin:infoblox -X GET "https://192.168.1.2/wapi/v2.8/csvimporttask/b25lLmNzdl9pbXBvcnRfdGFzayQxNQ:2"

# returns

{
    "_ref": "csvimporttask/b25lLmNzdl9pbXBvcnRfdGFzayQxNQ:2",
    "admin_name": "admin",
    "end_time": 1571232527,
    "file_name": "rpz_import.csv",
    "file_size": 259,
    "import_id": 15,
    "lines_failed": 0,
    "lines_processed": 3,
    "lines_warning": 0,
    "on_error": "CONTINUE",
    "operation": "INSERT",
    "separator": "COMMA",
    "start_time": 1571232526,
    "status": "COMPLETED",
    "update_method": "OVERRIDE"
}

 

Re: API to feed a RPZ from a CSV file

MRichard Community Manager
Community Manager
Posts: 101
207     0

Here's the example CSV file:

 

header-responsepolicycnamerecord,fqdn*,_new_fqdn,canonical_name,comment,disabled,parent_zone,ttl,view
responsepolicycnamerecord,*.example.com.blacklist,,,,FALSE,blacklist,,Internal
responsepolicycnamerecord,example.com.blacklist,,,,FALSE,blacklist,,Internal
Showing results for 
Search instead for 
Do you mean 

Recommended for You