Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Giu52
Explorer

delete-objects-batch web service request structure

Hello,

I am working on a script which uses the show-unused-objects and delete-objects-batch api commands. My plan is to gather all the unused objects with an show-unused-objects call and use the response for the delete-objects-batch call. I am coding the script in python and cant find a way to create the required JSON file for the delete-objects-batch request.

According to the management api reference following structure is required:

 

{
  "objects" : [ {
    "type" : "host",
    "list" : [ {
      "name" : "New Host 1"
    }, {
      "name" : "New Host 2"
    } ]
  }, {
    "type" : "address-range",
    "list" : [ {
      "name" : "New Address Range 1"
    }, {
      "name" : "New Address Range 2"
    } ]
  } ]
}

 

As mentioned before, I am struggling to create this structure. Does anyone have an idea how to create this structure?

 

Kind regards,

Peter

0 Kudos
2 Replies
Sorin_Gogean
Advisor

Like you know already, this is a JSON format, so you can build your list into an CSV or smth similar, and then convert it to JSON.

But doesn't the response from the show-unused-objects gets you a JSON file ?

 

Ty,

0 Kudos
delToro1
Participant

Hello,

Maybe that post can help you: 

https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-to-delete-all-objects-matching-a-pat...

You might adjust this script adding diferents objects types to reach your goal, delete all unused objects. In the other hand, from smartConsole you can filter for unused objects and delete them.