sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def create(cls, name, members=None, comment=None): """ Create the TCP Service group :param str name: name of tcp service group :param list element: tcp services by element or href :type element: list(str,Element) :raises CreateElementFailed: element creation failed with ...
Create the TCP Service group :param str name: name of tcp service group :param list element: tcp services by element or href :type element: list(str,Element) :raises CreateElementFailed: element creation failed with reason :return: instance with meta :rtype: TCPServiceGr...
entailment
def generate(self, start_time=0, end_time=0, senders=None, wait_for_finish=False, timeout=5, **kw): # @ReservedAssignment """ Generate the report and optionally wait for results. You can optionally add filters to the report by providing the senders argument as a list of typ...
Generate the report and optionally wait for results. You can optionally add filters to the report by providing the senders argument as a list of type Element:: report = ReportDesign('Firewall Weekly Summary') begin = datetime_to_ms(datetime.strptime("2018-02-03T00:00:00"...
entailment
def create_design(self, name): """ Create a report design based on an existing template. :param str name: Name of new report design :raises CreateElementFailed: failed to create template :rtype: ReportDesign """ result = self.make_request( Cre...
Create a report design based on an existing template. :param str name: Name of new report design :raises CreateElementFailed: failed to create template :rtype: ReportDesign
entailment
def export_pdf(self, filename): """ Export the report in PDF format. Specify a path for which to save the file, including the trailing filename. :param str filename: path including filename :return: None """ self.make_request( raw_result=True,...
Export the report in PDF format. Specify a path for which to save the file, including the trailing filename. :param str filename: path including filename :return: None
entailment
def export_text(self, filename=None): """ Export in text format. Optionally provide a filename to save to. :param str filename: path including filename (optional) :return: None """ result = self.make_request( resource='export', par...
Export in text format. Optionally provide a filename to save to. :param str filename: path including filename (optional) :return: None
entailment
def create_ipsec_tunnel(cls, name, local_endpoint, remote_endpoint, preshared_key=None, monitoring_group=None, vpn_profile=None, mtu=0, pmtu_discovery=True, ttl=0, enabled=True, comment=None): """ The VPN tunnel type neg...
The VPN tunnel type negotiates IPsec tunnels in the same way as policy-based VPNs, but traffic is selected to be sent into the tunnel based on routing. :param str name: name of VPN :param TunnelEndpoint local_endpoint: the local side endpoint for this VPN. :p...
entailment
def create_gre_tunnel_mode(cls, name, local_endpoint, remote_endpoint, policy_vpn, mtu=0, pmtu_discovery=True, ttl=0, enabled=True, comment=None): """ Create a GRE based tunnel mode route VPN. Tunnel mode GRE wraps the GRE tunnel in an IPSEC tu...
Create a GRE based tunnel mode route VPN. Tunnel mode GRE wraps the GRE tunnel in an IPSEC tunnel to provide encrypted end-to-end security. Therefore a policy based VPN is required to 'wrap' the GRE into IPSEC. :param str name: name of VPN :param TunnelEndpoint local_en...
entailment
def create_gre_tunnel_no_encryption(cls, name, local_endpoint, remote_endpoint, mtu=0, pmtu_discovery=True, ttl=0, enabled=True, comment=None): """ Create a GRE Tunnel with no encryption. See `create_gre_tunnel_mode` for constructor description...
Create a GRE Tunnel with no encryption. See `create_gre_tunnel_mode` for constructor descriptions.
entailment
def set_preshared_key(self, new_key): """ Set the preshared key for this VPN. A pre-shared key is only present when the tunnel type is 'VPN' or the encryption mode is 'transport'. :return: None """ if self.data.get('preshared_key'): self.updat...
Set the preshared key for this VPN. A pre-shared key is only present when the tunnel type is 'VPN' or the encryption mode is 'transport'. :return: None
entailment
def endpoint(self): """ Endpoint is used to specify which interface is enabled for VPN. This is the InternalEndpoint property of the InternalGateway. :return: internal endpoint where VPN is enabled :rtype: InternalEndpoint,ExternalGateway """ if s...
Endpoint is used to specify which interface is enabled for VPN. This is the InternalEndpoint property of the InternalGateway. :return: internal endpoint where VPN is enabled :rtype: InternalEndpoint,ExternalGateway
entailment
def create_gre_tunnel_endpoint(cls, endpoint=None, tunnel_interface=None, remote_address=None): """ Create the GRE tunnel mode or no encryption mode endpoint. If the GRE tunnel mode endpoint is an SMC managed device, both an endpoint and a tunnel interf...
Create the GRE tunnel mode or no encryption mode endpoint. If the GRE tunnel mode endpoint is an SMC managed device, both an endpoint and a tunnel interface is required. If the endpoint is externally managed, only an IP address is required. :param InternalEndpoint,ExternalEndpoi...
entailment
def create_gre_transport_endpoint(cls, endpoint, tunnel_interface=None): """ Create the GRE transport mode endpoint. If the GRE transport mode endpoint is an SMC managed device, both an endpoint and a tunnel interface is required. If the GRE endpoint is an externally managed devi...
Create the GRE transport mode endpoint. If the GRE transport mode endpoint is an SMC managed device, both an endpoint and a tunnel interface is required. If the GRE endpoint is an externally managed device, only an endpoint is required. :param InternalEndpoint,ExternalEndpoint e...
entailment
def create_ipsec_endpoint(cls, gateway, tunnel_interface=None): """ Create the VPN tunnel endpoint. If the VPN tunnel endpoint is an SMC managed device, both a gateway and a tunnel interface is required. If the VPN endpoint is an externally managed device, only a gateway is r...
Create the VPN tunnel endpoint. If the VPN tunnel endpoint is an SMC managed device, both a gateway and a tunnel interface is required. If the VPN endpoint is an externally managed device, only a gateway is required. :param InternalGateway,ExternalGateway gateway: the gateway ...
entailment
def set_auth_request(self, interface_id, address=None): """ Set the authentication request field for the specified engine. """ self.interface.set_auth_request(interface_id, address) self._engine.update()
Set the authentication request field for the specified engine.
entailment
def set_primary_heartbeat(self, interface_id): """ Set this interface as the primary heartbeat for this engine. This will 'unset' the current primary heartbeat and move to specified interface_id. Clusters and Master NGFW Engines only. :param str,int interface_id...
Set this interface as the primary heartbeat for this engine. This will 'unset' the current primary heartbeat and move to specified interface_id. Clusters and Master NGFW Engines only. :param str,int interface_id: interface specified for primary mgmt :raises InterfaceNot...
entailment
def set_backup_heartbeat(self, interface_id): """ Set this interface as the backup heartbeat interface. Clusters and Master NGFW Engines only. :param str,int interface_id: interface as backup :raises InterfaceNotFound: specified interface is not found :raises Upd...
Set this interface as the backup heartbeat interface. Clusters and Master NGFW Engines only. :param str,int interface_id: interface as backup :raises InterfaceNotFound: specified interface is not found :raises UpdateElementFailed: failure to update interface :return: Non...
entailment
def set_primary_mgt(self, interface_id, auth_request=None, address=None): """ Specifies the Primary Control IP address for Management Server contact. For single FW and cluster FW's, this will enable 'Outgoing', 'Auth Request' and the 'Primary Control' interface. F...
Specifies the Primary Control IP address for Management Server contact. For single FW and cluster FW's, this will enable 'Outgoing', 'Auth Request' and the 'Primary Control' interface. For clusters, the primary heartbeat will NOT follow this change and should be set separately using :met...
entailment
def set_backup_mgt(self, interface_id): """ Set this interface as a backup management interface. Backup management interfaces cannot be placed on an interface with only a CVI (requires node interface/s). To 'unset' the specified interface address, set interface id to Non...
Set this interface as a backup management interface. Backup management interfaces cannot be placed on an interface with only a CVI (requires node interface/s). To 'unset' the specified interface address, set interface id to None :: engine.interface_options.s...
entailment
def set_outgoing(self, interface_id): """ Specifies the IP address that the engine uses to initiate connections (such as for system communications and ping) through an interface that has no Node Dedicated IP Address. In clusters, you must select an interface that has an IP addres...
Specifies the IP address that the engine uses to initiate connections (such as for system communications and ping) through an interface that has no Node Dedicated IP Address. In clusters, you must select an interface that has an IP address defined for all nodes. Setting primary_mgt also ...
entailment
def dscp_marking_and_throttling(self, qos_policy): """ Enable DSCP marking and throttling on the interface. This requires that you provide a QoS policy to which identifies DSCP tags and how to prioritize that traffic. :param QoSPolicy qos_policy: the qos policy to apply ...
Enable DSCP marking and throttling on the interface. This requires that you provide a QoS policy to which identifies DSCP tags and how to prioritize that traffic. :param QoSPolicy qos_policy: the qos policy to apply to the interface
entailment
def delete(self): """ Override delete in parent class, this will also delete the routing configuration referencing this interface. :: engine = Engine('vm') interface = engine.interface.get(2) interface.delete() """ super(Interface, sel...
Override delete in parent class, this will also delete the routing configuration referencing this interface. :: engine = Engine('vm') interface = engine.interface.get(2) interface.delete()
entailment
def update(self, *args, **kw): """ Update/save this interface information back to SMC. When interface changes are made, especially to sub interfaces, call `update` on the top level interface. Example of changing the IP address of an interface:: >>> engine = Engine('...
Update/save this interface information back to SMC. When interface changes are made, especially to sub interfaces, call `update` on the top level interface. Example of changing the IP address of an interface:: >>> engine = Engine('sg_vm') >>> interface = engine.physical...
entailment
def addresses(self): """ Return 3-tuple with (address, network, nicid) :return: address related information of interface as 3-tuple list :rtype: list """ addresses = [] for i in self.all_interfaces: if isinstance(i, VlanInterface): for...
Return 3-tuple with (address, network, nicid) :return: address related information of interface as 3-tuple list :rtype: list
entailment
def sub_interfaces(self): """ Flatten out all top level interfaces and only return sub interfaces. It is recommended to use :meth:`~all_interfaces`, :meth:`~interfaces` or :meth:`~vlan_interfaces` which return collections with helper methods to get sub interfaces based on index o...
Flatten out all top level interfaces and only return sub interfaces. It is recommended to use :meth:`~all_interfaces`, :meth:`~interfaces` or :meth:`~vlan_interfaces` which return collections with helper methods to get sub interfaces based on index or attribute value pairs. :rtype: list...
entailment
def get_boolean(self, name): """ Get the boolean value for attribute specified from the sub interface/s. """ for interface in self.all_interfaces: if isinstance(interface, VlanInterface): if any(vlan for vlan in interface.interfaces ...
Get the boolean value for attribute specified from the sub interface/s.
entailment
def delete_invalid_route(self): """ Delete any invalid routes for this interface. An invalid route is a left over when an interface is changed to a different network. :return: None """ try: routing = self._engine.routing.get(self.interface_id) ...
Delete any invalid routes for this interface. An invalid route is a left over when an interface is changed to a different network. :return: None
entailment
def reset_interface(self): """ Reset the interface by removing all assigned addresses and VLANs. This will not delete the interface itself, only the sub interfaces that may have addresses assigned. This will not affect inline or capture interfaces. Note that if this inter...
Reset the interface by removing all assigned addresses and VLANs. This will not delete the interface itself, only the sub interfaces that may have addresses assigned. This will not affect inline or capture interfaces. Note that if this interface is used as a primary control, auth request...
entailment
def change_interface_id(self, interface_id): """ Change the interface ID for this interface. This can be used on any interface type. If the interface is an Inline interface, you must provide the ``interface_id`` in format '1-2' to define both interfaces in the pair. The change is...
Change the interface ID for this interface. This can be used on any interface type. If the interface is an Inline interface, you must provide the ``interface_id`` in format '1-2' to define both interfaces in the pair. The change is committed after calling this method. :: ...
entailment
def _update_interface(self, other_interface): """ Update the physical interface base settings with another interface. Only set updated if a value has changed. You must also call `update` on the interface if modifications are made. This is called from other interfaces (i.e. Physic...
Update the physical interface base settings with another interface. Only set updated if a value has changed. You must also call `update` on the interface if modifications are made. This is called from other interfaces (i.e. PhysicalInterface, ClusterPhysicalInterface, etc) to update the ...
entailment
def update_interface(self, other_interface, ignore_mgmt=True): """ Update an existing interface by comparing values between two interfaces. If a VLAN interface is defined in the other interface and it doesn't exist on the existing interface, it will be created. :param ot...
Update an existing interface by comparing values between two interfaces. If a VLAN interface is defined in the other interface and it doesn't exist on the existing interface, it will be created. :param other_interface Interface: an instance of an interface where values in th...
entailment
def name(self): """ Read only name tag """ name = super(Interface, self).name return name if name else self.data.get('name')
Read only name tag
entailment
def _add_interface(self, interface_id, **kw): """ Create a tunnel interface. Kw argument list is as follows """ base_interface = ElementCache() base_interface.update( interface_id=str(interface_id), interfaces=[]) if 'zone_ref' in kw: ...
Create a tunnel interface. Kw argument list is as follows
entailment
def ndi_interfaces(self): """ Return a formatted dict list of NDI interfaces on this engine. This will ignore CVI or any inline or layer 2 interface types. This can be used to identify to indicate available IP addresses for a given interface which can be used to run services suc...
Return a formatted dict list of NDI interfaces on this engine. This will ignore CVI or any inline or layer 2 interface types. This can be used to identify to indicate available IP addresses for a given interface which can be used to run services such as SNMP or DNS Relay. ...
entailment
def change_vlan_id(self, original, new): """ Change VLAN ID for a single VLAN, cluster VLAN or inline interface. When changing a single or cluster FW vlan, you can specify the original VLAN and new VLAN as either single int or str value. If modifying an inline interface VLAN when...
Change VLAN ID for a single VLAN, cluster VLAN or inline interface. When changing a single or cluster FW vlan, you can specify the original VLAN and new VLAN as either single int or str value. If modifying an inline interface VLAN when the interface pair has two different VLAN identifier...
entailment
def enable_aggregate_mode(self, mode, interfaces): """ Enable Aggregate (LAGG) mode on this interface. Possible LAGG types are 'ha' and 'lb' (load balancing). For HA, only one secondary interface ID is required. For load balancing mode, up to 7 additional are supported (8 max...
Enable Aggregate (LAGG) mode on this interface. Possible LAGG types are 'ha' and 'lb' (load balancing). For HA, only one secondary interface ID is required. For load balancing mode, up to 7 additional are supported (8 max interfaces). :param str mode: 'lb' or 'ha' :param...
entailment
def static_arp_entry(self, ipaddress, macaddress, arp_type='static', netmask=32): """ Add an arp entry to this physical interface. :: interface = engine.physical_interface.get(0) interface.static_arp_entry( ipaddress='23.23.23.23', arp_typ...
Add an arp entry to this physical interface. :: interface = engine.physical_interface.get(0) interface.static_arp_entry( ipaddress='23.23.23.23', arp_type='static', macaddress='02:02:02:02:04:04') interface.save() :par...
entailment
def _add_interface(self, interface_id, mgt=None, **kw): """ Add the Cluster interface. If adding a cluster interface to an existing node, retrieve the existing interface and call this method. Use the supported format for defining an interface. """ _kw = copy.deepcopy(kw) ...
Add the Cluster interface. If adding a cluster interface to an existing node, retrieve the existing interface and call this method. Use the supported format for defining an interface.
entailment
def delete(self): """ Delete this Vlan interface from the parent interface. This will also remove stale routes if the interface has networks associated with it. :return: None """ if self in self._parent.vlan_interface: self._parent.data['vlanI...
Delete this Vlan interface from the parent interface. This will also remove stale routes if the interface has networks associated with it. :return: None
entailment
def change_vlan_id(self, vlan_id): """ Change the VLAN id for this VLAN interface. If this is an inline interface, you can specify two interface values to create unique VLANs on both sides of the inline pair. Or provide a single to use the same VLAN id. :param st...
Change the VLAN id for this VLAN interface. If this is an inline interface, you can specify two interface values to create unique VLANs on both sides of the inline pair. Or provide a single to use the same VLAN id. :param str vlan_id: string value for new VLAN id. :raise...
entailment
def get(self, *args, **kwargs): """ Get from the interface collection. It is more accurate to use kwargs to specify an attribute of the sub interface to retrieve rather than using an index value. If retrieving using an index, the collection will first check vlan interfaces and st...
Get from the interface collection. It is more accurate to use kwargs to specify an attribute of the sub interface to retrieve rather than using an index value. If retrieving using an index, the collection will first check vlan interfaces and standard interfaces second. In most cases, if ...
entailment
def get_vlan(self, *args, **kwargs): """ Get the VLAN from this PhysicalInterface. Use args if you want to specify only the VLAN id. Otherwise you can specify a valid attribute for the VLAN sub interface such as `address` for example:: >>> vlan = itf.vlan_int...
Get the VLAN from this PhysicalInterface. Use args if you want to specify only the VLAN id. Otherwise you can specify a valid attribute for the VLAN sub interface such as `address` for example:: >>> vlan = itf.vlan_interface.get_vlan(4) >>> vlan Layer...
entailment
def get(self, *args, **kwargs): """ Get the sub interfaces for this VlanInterface >>> itf = engine.interface.get(3) >>> list(itf.vlan_interface) [Layer3PhysicalInterfaceVlan(name=VLAN 3.3), Layer3PhysicalInterfaceVlan(name=VLAN 3.5), Layer3Physica...
Get the sub interfaces for this VlanInterface >>> itf = engine.interface.get(3) >>> list(itf.vlan_interface) [Layer3PhysicalInterfaceVlan(name=VLAN 3.3), Layer3PhysicalInterfaceVlan(name=VLAN 3.5), Layer3PhysicalInterfaceVlan(name=VLAN 3.4)] :par...
entailment
def find_mgmt_interface(self, mgmt): """ Find the management interface specified and return either the string representation of the interface_id. Valid options: primary_mgt, backup_mgt, primary_heartbeat, backup_heartbeat, outgoing, auth_request :ret...
Find the management interface specified and return either the string representation of the interface_id. Valid options: primary_mgt, backup_mgt, primary_heartbeat, backup_heartbeat, outgoing, auth_request :return: str interface_id
entailment
def get(self, interface_id): """ Get the interface from engine json :param str interface_id: interface ID to find :raises InterfaceNotFound: Cannot find interface """ # From within engine, skips nested iterators for this find # Make sure were dealing with...
Get the interface from engine json :param str interface_id: interface ID to find :raises InterfaceNotFound: Cannot find interface
entailment
def set_unset(self, interface_id, attribute, address=None): """ Set attribute to True and unset the same attribute for all other interfaces. This is used for interface options that can only be set on one engine interface. :raises InterfaceNotFound: raise if specified ad...
Set attribute to True and unset the same attribute for all other interfaces. This is used for interface options that can only be set on one engine interface. :raises InterfaceNotFound: raise if specified address does not exist or if the interface is not supported for this m...
entailment
def set_auth_request(self, interface_id, address=None): """ Set auth request, there can only be one per engine so unset all other interfaces. If this is a cluster, auth request can only be set on an interface with a CVI (not valid on NDI only cluster interfaces). If this ...
Set auth request, there can only be one per engine so unset all other interfaces. If this is a cluster, auth request can only be set on an interface with a CVI (not valid on NDI only cluster interfaces). If this is a cluster interface, address should be CVI IP.
entailment
def as_dotted(dotted_str): """ Implement RFC 5396 to support 'asdotted' notation for BGP AS numbers. Provide a string in format of '1.10', '65000.65015' and this will return a 4-byte decimal representation of the AS number. Get the binary values for the int's and pad to 16 bits if necessary (val...
Implement RFC 5396 to support 'asdotted' notation for BGP AS numbers. Provide a string in format of '1.10', '65000.65015' and this will return a 4-byte decimal representation of the AS number. Get the binary values for the int's and pad to 16 bits if necessary (values <255). Concatenate the first 2 byte...
entailment
def update_antispoofing(self, networks=None): """ Pass a list of networks to update antispoofing networks with. You can clear networks by providing an empty list. If networks are provided but already exist, no update is made. :param list networks: networks, groups or hos...
Pass a list of networks to update antispoofing networks with. You can clear networks by providing an empty list. If networks are provided but already exist, no update is made. :param list networks: networks, groups or hosts for antispoofing :rtype: bool
entailment
def enable(self, autonomous_system, announced_networks, router_id=None, bgp_profile=None): """ Enable BGP on this engine. On master engine, enable BGP on the virtual firewall. When adding networks to `announced_networks`, the element types can be of type :class:`smc.elemen...
Enable BGP on this engine. On master engine, enable BGP on the virtual firewall. When adding networks to `announced_networks`, the element types can be of type :class:`smc.elements.network.Host`, :class:`smc.elements.network.Network` or :class:`smc.elements.group.Group`. If passing a Gro...
entailment
def update_configuration(self, **kwargs): """ Update configuration using valid kwargs as defined in the enable constructor. :param dict kwargs: kwargs to satisfy valid args from `enable` :rtype: bool """ updated = False if 'announced_networks' in ...
Update configuration using valid kwargs as defined in the enable constructor. :param dict kwargs: kwargs to satisfy valid args from `enable` :rtype: bool
entailment
def announced_networks(self): """ Show all announced networks for the BGP configuration. Returns tuple of advertised network, routemap. Route map may be None. :: for advertised in engine.bgp.advertisements: net, route_map = advertised ...
Show all announced networks for the BGP configuration. Returns tuple of advertised network, routemap. Route map may be None. :: for advertised in engine.bgp.advertisements: net, route_map = advertised :return: list of tuples (advertised_netwo...
entailment
def create(cls, name, as_number, comment=None): """ Create an AS to be applied on the engine BGP configuration. An AS is a required parameter when creating an ExternalBGPPeer. You can also provide an AS number using an 'asdot' syntax:: AutonomousSystem.create(name='m...
Create an AS to be applied on the engine BGP configuration. An AS is a required parameter when creating an ExternalBGPPeer. You can also provide an AS number using an 'asdot' syntax:: AutonomousSystem.create(name='myas', as_number='200.600') :param str name: name of this AS...
entailment
def create(cls, name, port=179, external_distance=20, internal_distance=200, local_distance=200, subnet_distance=None): """ Create a custom BGP Profile :param str name: name of profile :param int port: port for BGP process :param int external_distance: external ad...
Create a custom BGP Profile :param str name: name of profile :param int port: port for BGP process :param int external_distance: external administrative distance; (1-255) :param int internal_distance: internal administrative distance (1-255) :param int local_distance: local admi...
entailment
def subnet_distance(self): """ Specific subnet administrative distances :return: list of tuple (subnet, distance) """ return [(Element.from_href(entry.get('subnet')), entry.get('distance')) for entry in self.data.get('distance_entry')]
Specific subnet administrative distances :return: list of tuple (subnet, distance)
entailment
def create(cls, name, neighbor_as, neighbor_ip, neighbor_port=179, comment=None): """ Create an external BGP Peer. :param str name: name of peer :param str,AutonomousSystem neighbor_as_ref: AutonomousSystem element or href. :param str neighbor_ip: ip...
Create an external BGP Peer. :param str name: name of peer :param str,AutonomousSystem neighbor_as_ref: AutonomousSystem element or href. :param str neighbor_ip: ip address of BGP peer :param int neighbor_port: port for BGP, default 179. :raises CreateElementFailed...
entailment
def create(cls, name, connection_profile_ref=None, md5_password=None, local_as_option='not_set', max_prefix_option='not_enabled', send_community='no', connected_check='disabled', orf_option='disabled', next_hop_self=True, override_capability=False, ...
Create a new BGPPeering configuration. :param str name: name of peering :param str,BGPConnectionProfile connection_profile_ref: required BGP connection profile. System default used if not provided. :param str md5_password: optional md5_password :param str local_as_option: th...
entailment
def create(cls, name, md5_password=None, connect_retry=120, session_hold_timer=180, session_keep_alive=60): """ Create a new BGP Connection Profile. :param str name: name of profile :param str md5_password: optional md5 password :param int connect_retry: The conne...
Create a new BGP Connection Profile. :param str name: name of profile :param str md5_password: optional md5 password :param int connect_retry: The connect retry timer, in seconds :param int session_hold_timer: The session hold timer, in seconds :param int session_keep_alive: The...
entailment
def enable(self, values): """ Enable specific permissions on this role. Use :py:attr:`~permissions` to view valid permission settings and current value/s. Change is committed immediately. :param list values: list of values by allowed types :return: None "...
Enable specific permissions on this role. Use :py:attr:`~permissions` to view valid permission settings and current value/s. Change is committed immediately. :param list values: list of values by allowed types :return: None
entailment
def disable(self, values): """ Disable specific permissions on this role. Use :py:attr:`~permissions` to view valid permission settings and current value/s. Change is committed immediately. :param list values: list of values by allowed types :return: None ...
Disable specific permissions on this role. Use :py:attr:`~permissions` to view valid permission settings and current value/s. Change is committed immediately. :param list values: list of values by allowed types :return: None
entailment
def permissions(self): """ Return valid permissions and setting for this role. Permissions are returned as a list of dict items, {permission: state}. State for the permission is either True or False. Use :meth:`~enable` and :meth:`~disable` to toggle role settings. ...
Return valid permissions and setting for this role. Permissions are returned as a list of dict items, {permission: state}. State for the permission is either True or False. Use :meth:`~enable` and :meth:`~disable` to toggle role settings. :return: list of permission settings ...
entailment
def _extract_ports(port_string): """ Return a dict for translated_value based on a string or int value. Value could be 80, or '80' or '80-90'. Will be returned as {'min_port': 80, 'max_port': 80} or {'min_port': 80, 'max_port': 90} :rtype: dict """ _ports = str(port_s...
Return a dict for translated_value based on a string or int value. Value could be 80, or '80' or '80-90'. Will be returned as {'min_port': 80, 'max_port': 80} or {'min_port': 80, 'max_port': 90} :rtype: dict
entailment
def _update_nat_field(self, source_or_dest): """ If the source or destination field of a rule is changed and the rule is a NAT rule, this method will check to see if the changed field maps to a NAT type and modifies the `original_value` field within the NAT dict to reflect the ne...
If the source or destination field of a rule is changed and the rule is a NAT rule, this method will check to see if the changed field maps to a NAT type and modifies the `original_value` field within the NAT dict to reflect the new element reference. It is possible that a NAT rule doesn...
entailment
def _update_field(self, natvalue): """ Update this NATValue if values are different :rtype: bool """ updated = False if natvalue.element and natvalue.element != self.element: self.update(element=natvalue.element) self.pop('ip_descriptor', ...
Update this NATValue if values are different :rtype: bool
entailment
def update_field(self, element_or_ip_address=None, start_port=None, end_port=None, **kw): """ Update the source NAT translation on this rule. You must call `save` or `update` on the rule to make this modification. To update the source target for this NAT rule, update ...
Update the source NAT translation on this rule. You must call `save` or `update` on the rule to make this modification. To update the source target for this NAT rule, update the source field directly using rule.sources.update_field(...). This will automatically update the NAT value. This...
entailment
def translated_value(self): """ The translated value for this NAT type. If this rule does not have a NAT value defined, this will return None. :return: NATValue or None :rtype: NATValue """ if self.typeof in self: return NATValue(self....
The translated value for this NAT type. If this rule does not have a NAT value defined, this will return None. :return: NATValue or None :rtype: NATValue
entailment
def update_field(self, element_or_ip_address=None, original_port=None, translated_port=None, **kw): """ Update the destination NAT translation on this rule. You must call `save` or `update` on the rule to make this modification. The destination field in the NAT rule determin...
Update the destination NAT translation on this rule. You must call `save` or `update` on the rule to make this modification. The destination field in the NAT rule determines which destination is the target of the NAT. To change the target, call the rule.destinations.update_field(...) met...
entailment
def create(self, name, sources=None, destinations=None, services=None, dynamic_src_nat=None, dynamic_src_nat_ports=(1024, 65535), static_src_nat=None, static_dst_nat=None, static_dst_nat_ports=None, is_disabled=False, used_on=None, add_pos=None, after=None, be...
Create a NAT rule. When providing sources/destinations or services, you can provide the element href, network element or services from ``smc.elements``. You can also mix href strings with Element types in these fields. :param str name: name of NAT rule :param list sources: lis...
entailment
def request(self, uri, method='GET', body=None, headers=None, **kwargs): """Implementation of httplib2's Http.request.""" _credential_refresh_attempt = kwargs.pop( '_credential_refresh_attempt', 0) # Make a copy of the headers. They will be modified by the credentia...
Implementation of httplib2's Http.request.
entailment
def connect(self, broker, port=1883, client_id="", clean_session=True): """ Connect to an MQTT broker. This is a pre-requisite step for publish and subscribe keywords. `broker` MQTT broker host `port` broker port (default 1883) `client_id` if not specified, a random id is gene...
Connect to an MQTT broker. This is a pre-requisite step for publish and subscribe keywords. `broker` MQTT broker host `port` broker port (default 1883) `client_id` if not specified, a random id is generated `clean_session` specifies the clean session flag for the connection ...
entailment
def publish(self, topic, message=None, qos=0, retain=False): """ Publish a message to a topic with specified qos and retained flag. It is required that a connection has been established using `Connect` keyword before using this keyword. `topic` topic to which the message will be publish...
Publish a message to a topic with specified qos and retained flag. It is required that a connection has been established using `Connect` keyword before using this keyword. `topic` topic to which the message will be published `message` message payload to publish `qos` qos of th...
entailment
def subscribe(self, topic, qos, timeout=1, limit=1): """ Subscribe to a topic and return a list of message payloads received within the specified time. `topic` topic to subscribe to `qos` quality of service for the subscription `timeout` duration of subscription. Specify 0...
Subscribe to a topic and return a list of message payloads received within the specified time. `topic` topic to subscribe to `qos` quality of service for the subscription `timeout` duration of subscription. Specify 0 to enable background looping (async) `limit` the max nu...
entailment
def listen(self, topic, timeout=1, limit=1): """ Listen to a topic and return a list of message payloads received within the specified time. Requires an async Subscribe to have been called previously. `topic` topic to listen to `timeout` duration to listen `limit` the max ...
Listen to a topic and return a list of message payloads received within the specified time. Requires an async Subscribe to have been called previously. `topic` topic to listen to `timeout` duration to listen `limit` the max number of payloads that will be returned. Specify 0 ...
entailment
def subscribe_and_validate(self, topic, qos, payload, timeout=1): """ Subscribe to a topic and validate that the specified payload is received within timeout. It is required that a connection has been established using `Connect` keyword. The payload can be specified as a python regular e...
Subscribe to a topic and validate that the specified payload is received within timeout. It is required that a connection has been established using `Connect` keyword. The payload can be specified as a python regular expression. If the specified payload is not received within timeout, an...
entailment
def unsubscribe(self, topic): """ Unsubscribe the client from the specified topic. `topic` topic to unsubscribe from Example: | Unsubscribe | test/mqtt_test | """ try: tmp = self._mqttc except AttributeError: logger.info('No MQTT Client ...
Unsubscribe the client from the specified topic. `topic` topic to unsubscribe from Example: | Unsubscribe | test/mqtt_test |
entailment
def disconnect(self): """ Disconnect from MQTT Broker. Example: | Disconnect | """ try: tmp = self._mqttc except AttributeError: logger.info('No MQTT Client instance found so nothing to disconnect from.') return self._disconn...
Disconnect from MQTT Broker. Example: | Disconnect |
entailment
def publish_single(self, topic, payload=None, qos=0, retain=False, hostname="localhost", port=1883, client_id="", keepalive=60, will=None, auth=None, tls=None, protocol=mqtt.MQTTv31): """ Publish a single message and disconnect. This keyword uses the [http://eclipse.org/paho/cli...
Publish a single message and disconnect. This keyword uses the [http://eclipse.org/paho/clients/python/docs/#single|single] function of publish module. `topic` topic to which the message will be published `payload` message payload to publish (default None) `qos` qos of the mes...
entailment
def publish_multiple(self, msgs, hostname="localhost", port=1883, client_id="", keepalive=60, will=None, auth=None, tls=None, protocol=mqtt.MQTTv31): """ Publish multiple messages and disconnect. This keyword uses the [http://eclipse.org/paho/clients/python/docs/#multiple|multip...
Publish multiple messages and disconnect. This keyword uses the [http://eclipse.org/paho/clients/python/docs/#multiple|multiple] function of publish module. `msgs` a list of messages to publish. Each message is either a dict or a tuple. If a dict, it must be of the form: ...
entailment
def user_to_request(handler): '''Add user to request if user logged in''' @wraps(handler) async def decorator(*args): request = _get_request(args) request[cfg.REQUEST_USER_KEY] = await get_cur_user(request) return await handler(*args) return decorator
Add user to request if user logged in
entailment
def add_synonym(self, other): """Every word in a group of synonyms shares the same list.""" self.synonyms.extend(other.synonyms) other.synonyms = self.synonyms
Every word in a group of synonyms shares the same list.
entailment
def find_one_sql(table, filter, fields=None): ''' >>> find_one_sql('tbl', {'foo': 10, 'bar': 'baz'}) ('SELECT * FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10]) >>> find_one_sql('tbl', {'id': 10}, fields=['foo', 'bar']) ('SELECT foo, bar FROM tbl WHERE id=$1', [10]) ''' keys, values = _split_...
>>> find_one_sql('tbl', {'foo': 10, 'bar': 'baz'}) ('SELECT * FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10]) >>> find_one_sql('tbl', {'id': 10}, fields=['foo', 'bar']) ('SELECT foo, bar FROM tbl WHERE id=$1', [10])
entailment
def insert_sql(table, data, returning='id'): ''' >>> insert_sql('tbl', {'foo': 'bar', 'id': 1}) ('INSERT INTO tbl (foo, id) VALUES ($1, $2) RETURNING id', ['bar', 1]) >>> insert_sql('tbl', {'foo': 'bar', 'id': 1}, returning=None) ('INSERT INTO tbl (foo, id) VALUES ($1, $2)', ['bar', 1]) >>> in...
>>> insert_sql('tbl', {'foo': 'bar', 'id': 1}) ('INSERT INTO tbl (foo, id) VALUES ($1, $2) RETURNING id', ['bar', 1]) >>> insert_sql('tbl', {'foo': 'bar', 'id': 1}, returning=None) ('INSERT INTO tbl (foo, id) VALUES ($1, $2)', ['bar', 1]) >>> insert_sql('tbl', {'foo': 'bar', 'id': 1}, returning='pk') ...
entailment
def update_sql(table, filter, updates): ''' >>> update_sql('tbl', {'foo': 'a', 'bar': 1}, {'bar': 2, 'baz': 'b'}) ('UPDATE tbl SET bar=$1, baz=$2 WHERE bar=$3 AND foo=$4', [2, 'b', 1, 'a']) ''' where_keys, where_vals = _split_dict(filter) up_keys, up_vals = _split_dict(updates) changes = _pa...
>>> update_sql('tbl', {'foo': 'a', 'bar': 1}, {'bar': 2, 'baz': 'b'}) ('UPDATE tbl SET bar=$1, baz=$2 WHERE bar=$3 AND foo=$4', [2, 'b', 1, 'a'])
entailment
def delete_sql(table, filter): ''' >>> delete_sql('tbl', {'foo': 10, 'bar': 'baz'}) ('DELETE FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10]) ''' keys, values = _split_dict(filter) where = _pairs(keys) sql = 'DELETE FROM {} WHERE {}'.format(table, where) return sql, values
>>> delete_sql('tbl', {'foo': 10, 'bar': 'baz'}) ('DELETE FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10])
entailment
def _pairs(keys, *, start=1, sep=' AND '): ''' >>> _pairs(['foo', 'bar', 'baz'], sep=', ') 'foo=$1, bar=$2, baz=$3' >>> _pairs(['foo', 'bar', 'baz'], start=2) 'foo=$2 AND bar=$3 AND baz=$4' ''' return sep.join('{}=${}'.format(k, i) for i, k in enumerate(keys, start))
>>> _pairs(['foo', 'bar', 'baz'], sep=', ') 'foo=$1, bar=$2, baz=$3' >>> _pairs(['foo', 'bar', 'baz'], start=2) 'foo=$2 AND bar=$3 AND baz=$4'
entailment
def _split_dict(dic): '''Split dict into sorted keys and values >>> _split_dict({'b': 2, 'a': 1}) (['a', 'b'], [1, 2]) ''' keys = sorted(dic.keys()) return keys, [dic[k] for k in keys]
Split dict into sorted keys and values >>> _split_dict({'b': 2, 'a': 1}) (['a', 'b'], [1, 2])
entailment
def play(seed=None): """Turn the Python prompt into an Adventure game. With optional the `seed` argument the caller can supply an integer to start the Python random number generator at a known state. """ global _game from .game import Game from .prompt import install_words _game = Ga...
Turn the Python prompt into an Adventure game. With optional the `seed` argument the caller can supply an integer to start the Python random number generator at a known state.
entailment
def write(self, more): """Append the Unicode representation of `s` to our output.""" if more: self.output += str(more).upper() self.output += '\n'
Append the Unicode representation of `s` to our output.
entailment
def yesno(self, s, yesno_callback, casual=False): """Ask a question and prepare to receive a yes-or-no answer.""" self.write(s) self.yesno_callback = yesno_callback self.yesno_casual = casual
Ask a question and prepare to receive a yes-or-no answer.
entailment
def start(self): """Start the game.""" # For old-fashioned players, accept five-letter truncations like # "inven" instead of insisting on full words like "inventory". for key, value in list(self.vocabulary.items()): if isinstance(key, str) and len(key) > 5: ...
Start the game.
entailment
def start2(self, yes): """Display instructions if the user wants them.""" if yes: self.write_message(1) self.hints[3].used = True self.lamp_turns = 1000 self.oldloc2 = self.oldloc = self.loc = self.rooms[1] self.dwarves = [ Dwarf(self.rooms[n]) for n ...
Display instructions if the user wants them.
entailment
def do_command(self, words): """Parse and act upon the command in the list of strings `words`.""" self.output = '' self._do_command(words) return self.output
Parse and act upon the command in the list of strings `words`.
entailment
def resume(self, obj): """Returns an Adventure game saved to the given file.""" if isinstance(obj, str): savefile = open(obj, 'rb') else: savefile = obj game = pickle.loads(zlib.decompress(savefile.read())) if savefile is not obj: savefile.clos...
Returns an Adventure game saved to the given file.
entailment
def parse(data, datafile): """Read the Adventure data file and return a ``Data`` object.""" data._last_travel = [0, [0]] # x and verbs used by section 3 while True: section_number = int(datafile.readline()) if not section_number: # no further sections break store = glo...
Read the Adventure data file and return a ``Data`` object.
entailment
def _map_smtp_headers_to_api_parameters(self, email_message): """ Map the values passed in SMTP headers to API-ready 2-item tuples present in HEADERS_MAP header values must be a single string or list or tuple of strings :return: 2-item tuples of the form (api_name, api_values) ...
Map the values passed in SMTP headers to API-ready 2-item tuples present in HEADERS_MAP header values must be a single string or list or tuple of strings :return: 2-item tuples of the form (api_name, api_values)
entailment
def _send(self, email_message): """A helper method that does the actual sending.""" if not email_message.recipients(): return False from_email = sanitize_address(email_message.from_email, email_message.encoding) to_recipients = [sanitize_address(addr, email_message.encoding)...
A helper method that does the actual sending.
entailment
def send_messages(self, email_messages): """Sends one or more EmailMessage objects and returns the number of email messages sent. """ if not email_messages: return num_sent = 0 for message in email_messages: if self._send(message): ...
Sends one or more EmailMessage objects and returns the number of email messages sent.
entailment
def student_view(self, context=None): """ Build the fragment for the default student view """ context = context or {} context.update({ 'display_name': self.display_name, 'image_url': self.image_url, 'thumbnail_url': self.thumbnail_url or self.i...
Build the fragment for the default student view
entailment
def build_fragment( self, template='', context=None, css=None, js=None, js_init=None, ): """ Creates a fragment for display. """ template = 'templates/' + template context = context or {} css = cs...
Creates a fragment for display.
entailment
def _parse_title(file_path): """ Parse a title from a file name """ title = file_path title = title.split('/')[-1] title = '.'.join(title.split('.')[:-1]) title = ' '.join(title.split('-')) title = ' '.join([ word.capitalize() for word in title.split(' ') ]) retur...
Parse a title from a file name
entailment
def _read_files(files): """ Read the contents of a list of files """ file_contents = [ ( _parse_title(file_path), _read_file(file_path), ) for file_path in files ] return file_contents
Read the contents of a list of files
entailment