How to use the fmcapi.api_objects.object_services.securityzones.SecurityZones function in fmcapi

To help you get started, we’ve selected a few fmcapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daxm / fmcapi / fmcapi / api_objects / device_services / subinterfaces.py View on Github external
def sz(self, name):
        """
        Assign Security Zone to this subinterface.

        :param name: (str) Name of Security Zone.
        :return: None
        """
        logging.debug("In sz() for SubInterfaces class.")
        sz = SecurityZones(fmc=self.fmc)
        sz.get(name=name)
        if "id" in sz.__dict__:
            new_zone = {"name": sz.name, "id": sz.id, "type": sz.type}
            self.securityZone = new_zone
        else:
            logging.warning(
                f'Security Zone, "{name}", not found.  Cannot add to SubInterfaces.'
            )
github daxm / fmcapi / fmcapi / api_objects / policy_services / prefilterrules.py View on Github external
def get_zone_id(self, name):
        """
        Pull the ID for a security zone
        Args:
            name (str): Name of interface zone object

        Returns:
            UUID of zone object (str)
        """
        sec_zone = SecurityZones(fmc=self.fmc)
        sec_zone.get(name=name)
        if "id" in sec_zone.__dict__:
            return sec_zone.id, sec_zone.type
        else:
            return None, None
github daxm / fmcapi / fmcapi / api_objects / device_services / bridgegroupinterfaces.py View on Github external
def sz(self, name):
        """
        Assign Security Zone to this group.

        :param name: (str) Name of Security Zone.
        :return: None
        """
        logging.debug("In sz() for BridgeGroupInterfaces class.")
        sz = SecurityZones(fmc=self.fmc)
        sz.get(name=name)
        if "id" in sz.__dict__:
            new_zone = {"name": sz.name, "id": sz.id, "type": sz.type}
            self.securityZone = new_zone
        else:
            logging.warning(
                f'Security Zone, "{name}", not found.  Cannot add to BridgeGroupInterfaces.'
            )
github daxm / fmcapi / fmcapi / api_objects / device_services / redundantinterfaces.py View on Github external
def sz(self, name):
        """
        Assign Security Zone to this redundant interface.

        :param name: (str) Name of Security Zone.
        :return: None
        """
        logging.debug("In sz() for RedundantInterfaces class.")
        sz = SecurityZones(fmc=self.fmc)
        sz.get(name=name)
        if "id" in sz.__dict__:
            new_zone = {"name": sz.name, "id": sz.id, "type": sz.type}
            self.securityZone = new_zone
        else:
            logging.warning(
                f'Security Zone, "{name}", not found.  Cannot add to RedundantInterfaces.'
            )
github daxm / fmcapi / fmcapi / api_objects / device_services / physicalinterfaces.py View on Github external
def sz(self, name):
        logging.debug("In sz() for PhysicalInterface class.")
        sz = SecurityZones(fmc=self.fmc)
        sz.get(name=name)
        if 'id' in sz.__dict__:
            new_zone = {'name': sz.name, 'id': sz.id, 'type': sz.type}
            self.securityZone = new_zone
        else:
            logging.warning(f'Security Zone, "{name}", not found.  Cannot add to PhysicalInterface.')
github daxm / fmcapi / fmcapi / api_objects / object_services / securityzones.py View on Github external
def parse_kwargs(self, **kwargs):
        """
        Parse the kwargs and set self variables to match.

        :return: None
        """
        super().parse_kwargs(**kwargs)
        logging.debug("In parse_kwargs() for SecurityZones class.")
        if "interfaceMode" in kwargs:
            self.interfaceMode = kwargs["interfaceMode"]
        else:
            self.interfaceMode = "ROUTED"


class SecurityZone(SecurityZones):
    """
    Dispose of this Class after 20210101.

    Use SecurityZones() instead.
    """

    def __init__(self, fmc, **kwargs):
        warnings.resetwarnings()
        warnings.warn(
            "Deprecated: SecurityZone() should be called via SecurityZones()."
        )
        super().__init__(fmc, **kwargs)
github daxm / fmcapi / fmcapi / api_objects / policy_services / accessrules.py View on Github external
def source_zone(self, action, name=""):
        """
        Add/modify name to sourceZones field of AccessRules object.

        :param action: (str) 'add', 'remove', or 'clear'
        :param name: (str) Name of Security Zone in FMC.
        :return: None
        """
        logging.debug("In source_zone() for AccessRules class.")
        if action == "add":
            sz = SecurityZones(fmc=self.fmc)
            sz.get(name=name)
            if "id" in sz.__dict__:
                if "sourceZones" in self.__dict__:
                    new_zone = {"name": sz.name, "id": sz.id, "type": sz.type}
                    duplicate = False
                    for obj in self.sourceZones["objects"]:
                        if obj["name"] == new_zone["name"]:
                            duplicate = True
                            break
                    if not duplicate:
                        self.sourceZones["objects"].append(new_zone)
                        logging.info(
                            f'Adding "{name}" to sourceZones for this AccessRules.'
                        )
                else:
                    self.sourceZones = {
github daxm / fmcapi / fmcapi / api_objects / policy_services / accessrules.py View on Github external
def destination_zone(self, action, name=""):
        """
        Add/modify name to destinationZones field of AccessRules object.

        :param action: (str) 'add', 'remove', or 'clear'
        :param name: (str) Name of Security Zone in FMC.
        :return: None
        """
        logging.debug("In destination_zone() for AccessRules class.")
        if action == "add":
            sz = SecurityZones(fmc=self.fmc)
            sz.get(name=name)
            if "id" in sz.__dict__:
                if "destinationZones" in self.__dict__:
                    new_zone = {"name": sz.name, "id": sz.id, "type": sz.type}
                    duplicate = False
                    for obj in self.destinationZones["objects"]:
                        if obj["name"] == new_zone["name"]:
                            duplicate = True
                            break
                    if not duplicate:
                        self.destinationZones["objects"].append(new_zone)
                        logging.info(
                            f'Adding "{name}" to destinationZones for this AccessRules.'
                        )
                else:
                    self.destinationZones = {