certanet / firepyer Goto Github PK
View Code? Open in Web Editor NEWInteracting with Cisco FTD devices via the FDM REST API in Python
Home Page: https://certanet.github.io/firepyer/
License: Apache License 2.0
Interacting with Cisco FTD devices via the FDM REST API in Python
Home Page: https://certanet.github.io/firepyer/
License: Apache License 2.0
Hi, would be nice to add a new feature where we can send overwrite=True
in case we want to overwrite an object that's already exists.
I have kind of created my own functions for it, cuz I want "idempotency" in my automation, so if someone has already created a network-object group, I want to overwrite it, or later, that network-object changed it's value, i want to overwrite it,
I am not proficient enough in python to create a PR but would love to do it.
def create_network_object(fdm_object: object, name: str, value: str, type: str) -> dict:
"""
Create a network object in FDM, overwrite if already exists.
"""
try:
network_object = fdm_object.create_network(type=type, name=name, value=value)
return network_object
except FirepyerError as e:
if "duplicate name" in str(e):
existing_network_object = fdm_object.get_net_objects(name)
pprint(existing_network_object)
print(f"Network object {name} already exists")
print("Updating network object")
existing_network_object["value"] = value
existing_network_object[
"subType"
] = (
type.upper()
) # Capitalization needed since we're sending directly to api
pprint(existing_network_object)
put_it = fdm_object.put_api(
f"/object/networks/{existing_network_object['id']}",
json.dumps(existing_network_object),
)
if put_it.status_code == 200 or put_it.status_code == 204:
print("Network object updated")
return existing_network_object
else:
raise FirepyerError(
f"Failed to update network object {name} with status code {put_it.status_code}\n{put_it.text}"
)
else:
raise e
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.