Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilliams9999 authored Jan 12, 2017
1 parent e4d6c40 commit c321841
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions fmc-obj-del.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@

url = "https://%s/api/fmc_platform/v1/auth/generatetoken" % ipaddr

results=[]

headers = {
'cache-control': "no-cache",
'postman-token': "ff30c506-4739-9d4d-2e53-0dc7efc2036a"
Expand All @@ -98,21 +100,38 @@

# get all objects type based in user reponse from FMC
response = requests.request("GET", url, headers=headers, params=querystring, verify=False)

# format response in JSON format
data = response.json()

p=data['paging']['pages']

offset= 1000

# FMC get all objects for user specified type
for pages in [p]:
querystring = {"offset":"%d" % offset,"limit":"1000"}
response = requests.request("GET", url, headers=headers, params=querystring, verify=False)
offset += 1000
raw=response.json()
data['items'].append(raw['items'])
results=[]
raw = response.json()
offset = 0

if raw['paging']['pages'] == 0:
for pages in range(p):
querystring = {"offset":"%d" % offset,"limit":"1000"}
response = requests.request("GET", url, headers=headers, params=querystring, verify=False)
offset += 1000
raw=response.json()
#print [raw[i] for i in raw.keys()]
#print raw['items'][1]['name']
#print [raw[i][0][0].get('name') for i in raw.keys()]
for i in raw['items']:
results.append(i)

else:
p=raw['paging']['pages']
# FMC get all objects for user specified type
for pages in range(p):
querystring = {"offset":"%d" % offset,"limit":"1000"}
response = requests.request("GET", url, headers=headers, params=querystring, verify=False)
offset += 1000
raw=response.json()
#print [raw[i] for i in raw.keys()]
#print raw['items'][1]['name']
#print [raw[i][0][0].get('name') for i in raw.keys()]
for i in raw['items']:
results.append(i)
#test of results link
#for i in results:
# print i['links']['self']

def delobj(obj):

Expand All @@ -122,10 +141,8 @@ def delobj(obj):
global user1
global pass1
netdel = response

if 'items' in obj:

for id in obj['items']:
for id in obj:

#Sends a delete http for all network objects, but only deletes unused objects

Expand All @@ -152,9 +169,9 @@ def delobj(obj):
}

netdel.status_code = 200




delobj(data)

delobj(results)

0 comments on commit c321841

Please sign in to comment.