Skip to content

Commit

Permalink
Black
Browse files Browse the repository at this point in the history
  • Loading branch information
marksull committed Dec 11, 2023
1 parent cfba116 commit 6c7f2ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion fmcapi/api_objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,5 @@
"Backup",
"Usage",
"DynamicObject",
"DynamicObjectMappings"
"DynamicObjectMappings",
]
2 changes: 1 addition & 1 deletion fmcapi/api_objects/object_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@
"VlanGroupTags",
"VlanTags",
"DynamicObjectMappings",
"DynamicObject"
"DynamicObject",
]
25 changes: 9 additions & 16 deletions fmcapi/api_objects/object_services/dynamicobjectmappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DynamicObjectMappings(APIClassTemplate):
VALID_CHARACTERS_FOR_NAME = """[.\w\d_\- ]"""

REQUIRED_FOR_POST = []
obj_id = ''
obj_id = ""

def __init__(self, fmc, **kwargs):
"""
Expand All @@ -31,12 +31,11 @@ def __init__(self, fmc, **kwargs):
self.obj_id = kwargs["id"]

def mappings(self, action, value, name):

"""
Associate mappings to dynamic object.
Associate mappings to dynamic object.
:param action: (str) 'add', 'remove', or 'clear'
:param dynamic_objects: (DynamicObject) Dynamic object to be mapped.
:param action: (str) 'add', 'remove', or 'clear'
:param dynamic_objects: (DynamicObject) Dynamic object to be mapped.
"""
logging.debug("In mappings for dynamic object")

Expand All @@ -47,9 +46,9 @@ def mappings(self, action, value, name):
"dynamicObject": {
"name": response["name"],
"id": response["id"],
"type": response["type"]
"type": response["type"],
},
"mappings": value
"mappings": value,
}
if action == "add":
if "add" in self.__dict__:
Expand All @@ -58,7 +57,7 @@ def mappings(self, action, value, name):
else:
self.add = [new_obj]

logging.info(f'Adding mappings to Dynamic Object.')
logging.info(f"Adding mappings to Dynamic Object.")

elif action == "remove":
if "remove" in self.__dict__:
Expand All @@ -67,20 +66,14 @@ def mappings(self, action, value, name):
else:
self.remove = [new_obj]

logging.info(f'Remove mappings to Dynamic Object.')
logging.info(f"Remove mappings to Dynamic Object.")

else:
logging.warning(
f'Dynamic Object "{name}" is not found in FMC. Cannot add mappings.'
)

def get(self):
self.URL_SUFFIX = f"/object/dynamicobjects/{str(self.obj_id)}/mappings"
super().__init__(self.fmc)
return super().get()







4 changes: 1 addition & 3 deletions fmcapi/api_objects/object_services/dynamicobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class DynamicObject(APIClassTemplate):

VALID_GET_FILTERS = [
"unusedOnly",
"ids"
"nameStartsWith"
"ids" "nameStartsWith",
] # unusedOnly:Bool, "ids:id1,id2,..." ,nameStartsWith:String

def __init__(self, fmc, **kwargs):
Expand All @@ -30,4 +29,3 @@ def __init__(self, fmc, **kwargs):
logging.debug("In __init__() for Dynamic Object class.")
self.parse_kwargs(**kwargs)
self.type = "DynamicObject"

4 changes: 3 additions & 1 deletion fmcapi/api_objects/policy_services/autonatrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def parse_kwargs(self, **kwargs):
"""
super().parse_kwargs(**kwargs)
logging.debug("In parse_kwargs() for AutoNatRules class.")
if ("translatedNetwork" in kwargs) and ("interfaceInTranslatedNetwork" in kwargs):
if ("translatedNetwork" in kwargs) and (
"interfaceInTranslatedNetwork" in kwargs
):
logging.warning(
"Cannot have both a translatedNetwork and interfaceInTranslatedNetwork"
)
Expand Down

0 comments on commit 6c7f2ab

Please sign in to comment.