cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
540
Views
2
Helpful
0
Replies

RADKit and FMC

RichardAtkin
Level 3
Level 3

I recently had need of pulling out information about all the FTDs from multiple FMCs within a RADKit deployment.  I haven't really done much with FMC before, but I was surprised at how easy it was...  Here's my quick solution.  The only real assumptions are that your FMCs are in RADKit, and that you have Swagger enabled.  The only tricky part was that the API calls all need a domainUUID, which is normally returned when you authenticate to the API, but as RADKit does that for you, I was a bit confiused about where the UUID info is stored... turns out, it is kept in yourFmcHere.swagger.metadata.  Once you know this, you can pass the UUID value in easily enough as shown below.

 

 

import json

deviceDetails = [] # this is where we'll store details of each FTD we find

fmc = service.inventory.filter("device_type","FMC") # These are all the FMCs in RADKit

fmc.update_swagger().wait() # Update Swagger for each FMC

for thisFmc in fmc:
  deviceRecordsResult = fmc[thisFmc].swagger.paths["/api/fmc_config/v1/domain/{domainUUID}/devices/devicerecords"].get(domainUUID=fmc[thisFmc].swagger.metadata["domain_uuid"]).wait() # Get high level view of all devices in this FMC
  devices = json.loads(deviceRecordsResult.result.content)

  for device in devices["items"]: # For each FTD in the FMC, pull details...
    thisDeviceRecordsResult = fmc[thisFmc].swagger.paths["/api/fmc_config/v1/domain/{domainUUID}/devices/devicerecords/{objectId}"].get(domainUUID=uuid,objectId=device["id"]).wait()
    deviceDetails.append(json.loads(thisDeviceRecordsResult.result.content))

print(deviceDetails)  

 

 

The other useful thing that's not shown in the example above, is that you can use RADKit / Swagger to explore the API if you don't know what you're looking for... continuing from above, you can do stuff like...

See all the paths:

 

>>> fmc[thisFmc].swagger.paths
<radkit_client.sync.swagger.SwaggerPathsDict object at 0x7fbc75a00790>
path                                                                                                verbs

-------------------------------------------------------------------------------- --------------
/api/fmc_config/v1/domain/{domainUUID}/analysis/activesessions                                       GET, DELETE
/api/fmc_config/v1/domain/{domainUUID}/analysis/useractivity                                         GET, DELETE
/api/fmc_config/v1/domain/{domainUUID}/assignment/policyassignments                                  GET, POST
/api/fmc_config/v1/domain/{domainUUID}/assignment/policyassignments/{objectId}                       GET, PUT

 

 Get the details for a specific path:

 

 

>>>  fmc[thisFmc].swagger.paths["/api/fmc_config/v1/domain/{domainUUID}/devices/devicerecords"]
Path: /api/fmc_config/v1/domain/{domainUUID}/devices/devicerecords
Operations:
- [GET]
  **Retrieves or modifies the device record associated with the specified ID. Registers or unregisters a device. If no ID is specified for a GET, retrieves list of all devic
e records.**
  Parameters:
  - 'filter'
    Filter to retrieve or delete device records based upon filter parameters specified. 

<< snipped off loads of content >>

 

 

Hopefully this helps somebody out there..

0 Replies 0