output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def license_install(self, license_file):
"""
Install a new license.
:param str license_file: fully qualified path to the
license jar file.
:raises: ActionCommandFailed
:return: None
"""
self.make_request(
method='update',
... | How would you code a function in Python 3 to
install a new license. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns a dictionary containing the visible security groups assigned to VSS container types. | Here you have a function in Python 3, explain what it does
def visible_security_group_mapping(self, filter=None): # @ReservedAssignment
if 'visible_security_group_mapping' not in self.data.links:
raise ResourceNotFound('This entry point is only supported on SMC >= 6.5')
return self... | As a Python code composer, you craft elegant and concise scripts. |
def references_by_element(self, element_href):
"""
Return all references to element specified.
:param str element_href: element reference
:return: list of references where element is used
:rtype: list(dict)
"""
result = self.make_request(
method='crea... | Write a Python 3 function for
returning all references to element specified. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Export elements from SMC. | How would you explain what the following Python 3 function does
def export_elements(self, filename='export_elements.zip', typeof='all'):
valid_types = ['all', 'nw', 'ips', 'sv', 'rb', 'al', 'vpn']
if typeof not in valid_types:
typeof = 'all'
return Task.download(self, 'expor... | You are a Python code analyst, evaluating scripts for potential improvements. |
Import elements into SMC. | Here you have a function in Python 3, explain what it does
def import_elements(self, import_file):
self.make_request(
method='create',
resource='import_elements',
files={
'import_file': open(import_file, 'rb')
}) | As a python code expert, you are capable of creating scripts from specifications. |
def update_protocol_agent(self, protocol_agent):
"""
Update this service to use the specified protocol agent.
After adding the protocol agent to the service you must call
`update` on the element to commit.
:param str,ProtocolAgent protocol_agent: protocol agent element o... | Can you implement a function in Python 3 that
updates this service to use the specified protocol agent. | As a Python code analyst, you investigate and solve complex coding mysteries |
Return the values of a parameter by name as stored on the protocol
agent payload. | Here you have a function in Python 3, explain what it does
def _get_param_values(self, name):
for param in self.data.get('paParameters', []):
for _pa_parameter, values in param.items():
if values.get('name') == name:
return values | As a Python code composer, you craft elegant and concise scripts. |
Returns a list of ProtocolParameter s for each protocol agent in the service. | Can you generate a brief explanation for the following Python 3 code
def parameters(self):
return [type('ProtocolParameter', (SubElement,), {
'data': ElementCache(data=self._get_param_values(param.get('name')))}
)(**param)
for param in self.make_request(resource='pa_parameter... | As a Python code analyst, you investigate and solve complex coding mysteries |
def protocol_parameter(self):
"""
The protocol parameter defined from the base protocol agent. This is a
read-only element that provides some additional context to the parameter
setting.
:rtype: ProtocolParameter
"""
for parameter in self.protocol_agent.p... | Write a Python 3 function for
returning the protocol parameter that is defined from the base protocol agent. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Update the mutable field value. | Here you have a function in Python 3, explain what it does
def _update(self, **kwargs):
if 'value' in kwargs and self.protocol_agent_values.get('value') != \
kwargs.get('value'):
self.protocol_agent_values.update(value=kwargs['value'])
return True
return False | As a Python code composer, you craft elegant and concise scripts. |
def proxy_server(self):
"""
The ProxyServer element referenced in this protocol parameter, if any.
:return: The proxy server element or None if one is not assigned
:rtype: ProxyServer
"""
# TODO: Workaround for SMC 6.4.3 which only provides the inspected service
... | Create a Python 3 function for
returning the ProxyServer element referenced in this protocol parameter or None if no proxy server element is assigned. | As a python code expert, you are capable of creating scripts from specifications. |
Update the protocol agent parameters based on the parameter name. | How would you explain what the following Python 3 function does
def update(self, name, **kwargs):
for value in self.items:
if value.name == name:
return value._update(**kwargs)
return False | As a Python code translator, you convert algorithms and pseudocode into Python. |
def add_access_list(self, accesslist, rank=None):
"""
Add an access list to the match condition. Valid
access list types are IPAccessList (v4 and v6),
IPPrefixList (v4 and v6), AS Path, CommunityAccessList,
ExtendedCommunityAccessList.
"""
self.conditions.append(
... | Can you write a function in Python 3 where it
adds an access list to the match condition. | You are a Python code generator, capable of creating scripts from specifications. |
Adds a metric to this match condition
| Explain what the following Python 3 code does
def add_metric(self, value, rank=None):
self.conditions.append(
dict(metric=value, type='metric', rank=rank)) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Adds a next hop condition. | Make a summary of the following Python 3 code
def add_next_hop(self, access_or_prefix_list, rank=None):
self.conditions.append(dict(
next_hop_ref=access_or_prefix_list.href,
type='next_hop',
rank=rank)) | You are a Python code generator, capable of creating scripts from specifications. |
def add_peer_address(self, ext_bgp_peer_or_fw, rank=None):
"""
Add a peer address. Peer address types are ExternalBGPPeer
or Engine.
:raises ElementNotFound: If element specified does not exist
"""
if ext_bgp_peer_or_fw.typeof == 'external_bgp_peer':
... | Implement a Python 3 function for
adding a peer address to the set of conditions. | You are a Python code architect, reviewing and designing scalable and efficient code |
Removes a condition element using rank. | Make a summary of the following Python 3 code
def remove_condition(self, rank):
self.conditions[:] = [r for r in self.conditions
if r.get('rank') != rank] | You are a Python code generator, capable of creating scripts from specifications. |
Creates a new route map rule. | Can you tell what is the following Python 3 function doing
def create(self, name, action='permit', goto=None, finish=False,
call=None, comment=None, add_pos=None, after=None,
before=None, **match_condition):
"""
Create a route map rule. You can provide match conditions
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Search the RouteMap policy using a search string | Can you generate the documentation for the following Python 3 function
def search_rule(self, search):
return [RouteMapRule(**rule) for rule in self.make_request(
resource='search_rule', params={'filter': search})] | You are a Python code generator, capable of creating scripts from specifications. |
def create(cls, name, certificate):
"""
Create a new external VPN CA for signing internal gateway
certificates.
:param str name: Name of VPN CA
:param str certificate: file name, path or certificate string.
:raises CreateElementFailed: Failed creating cert with r... | Can you write a function in Python 3 where it
creates a VPNCertificateCA object for signing external gateway VPN certificates. | As a Python code analyst, you investigate and solve complex coding mysteries |
def create(cls, name, min_dst_port, max_dst_port=None, min_src_port=None,
max_src_port=None, protocol_agent=None, comment=None):
"""
Create the TCP service
:param str name: name of tcp service
:param int min_dst_port: minimum destination port value
:param int max_... | Write a Python 3 function for
creating the TCP service object with the given properties. | You are a Python code architect, reviewing and designing scalable and efficient code |
Create the IP Service object with the given name protocol_number and comment. | Make a summary of the following Python 3 code
def create(cls, name, protocol_number, protocol_agent=None, comment=None):
json = {'name': name,
'protocol_number': protocol_number,
'protocol_agent_ref': element_resolver(protocol_agent) or None,
'comment': comment}
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def create(cls, name, frame_type='eth2', value1=None, comment=None):
"""
Create an ethernet service
:param str name: name of service
:param str frame_type: ethernet frame type, eth2
:param str value1: hex code representing ethertype field
:param str comment: optional com... | How would you code a function in Python 3 to
create an ethernet service with the specified name | You are a Python code generator, capable of creating scripts from specifications. |
def custom_range(self, start_time, end_time=None):
"""
Provide a custom range for the search query. Start time and end
time are expected to be naive ``datetime`` objects converted to
milliseconds. When submitting the query, it is strongly recommended
to set the timezone matching... | Implement a function in Python 3 to
provide a custom range for the search query. Start time and end time are expected to be naive ``datetime`` objects converted to milliseconds. When submitting the query, it is strongly recommended to set the timezone matching the local client making the query. Example of finding all r... | As a python code expert, you are capable of creating scripts from specifications. |
def pem_as_string(cert):
"""
Only return False if the certificate is a file path. Otherwise it
is a file object or raw string and will need to be fed to the
file open context.
"""
if hasattr(cert, 'read'): # File object - return as is
return cert
cert = cert.encode('utf-8') if isinst... | How would you implement a function in Python 3 that
returns True if the certificate is a PEM - encoded string. | As a Python code analyst, you investigate and solve complex coding mysteries |
def load_cert_chain(chain_file):
"""
Load the certificates from the chain file.
:raises IOError: Failure to read specified file
:raises ValueError: Format issues with chain file or missing entries
:return: list of cert type matches
"""
if hasattr(chain_file, 'read'):
cert_chain... | Create a Python 3 function to
load the certificates from the chain file. | You are a Python code generator, capable of creating scripts from specifications. |
def import_certificate(self, certificate):
"""
Import a valid certificate. Certificate can be either a file path
or a string of the certificate. If string certificate, it must include
the -----BEGIN CERTIFICATE----- string.
:param str certificate_file: fully qualified pa... | How would you code a function in Python 3 to
import a valid certificate. | You are a Python code generator, capable of creating scripts from specifications. |
def import_intermediate_certificate(self, certificate):
"""
Import a valid certificate. Certificate can be either a file path
or a string of the certificate. If string certificate, it must include
the -----BEGIN CERTIFICATE----- string.
:param str certificate: fully qual... | Write a Python 3 script for
importing a valid certificate. | You are a Python code generator, capable of creating scripts from specifications. |
Exports the intermediate certificate. | Explain what the following Python 3 code does
def export_intermediate_certificate(self, filename=None):
result = self.make_request(
CertificateExportError,
raw_result=True,
resource='intermediate_certificate_export')
if filename is not None:
s... | As a Python code composer, you craft elegant and concise scripts. |
def import_private_key(self, private_key):
"""
Import a private key. The private key can be a path to a file
or the key in string format. If in string format, the key must
start with -----BEGIN. Key types supported are PRIVATE RSA KEY
and PRIVATE KEY.
:param str ... | How would you code a function in Python 3 to
import a private key. | You are a Python code analyst, evaluating scripts for potential improvements. |
def get(self, rel):
"""
Get the resource by rel name
:param str rel_name: name of rel
:raises UnsupportedEntryPoint: entry point not found in this version
of the API
"""
for link in self._entry_points:
if link.get('rel') == rel:
... | Write a Python 3 script to
get the resource by name of rel name | As a Python code analyst, you investigate and solve complex coding mysteries |
def on_open(self):
"""
Once the connection is made, start the query off and
start an event loop to wait for a signal to
stop. Results are yielded within receive().
"""
def event_loop():
logger.debug(pformat(self.query.request))
self.send(json.dumps... | Can you write a function in Python 3 where it
calls when the connection is made. | You are a Python code generator, capable of creating scripts from specifications. |
Send a message down the socket. | Here you have a function in Python 3, explain what it does
def send_message(self, message):
if self.connected:
self.send(
json.dumps(message.request)) | As a Python code composer, you craft elegant and concise scripts. |
Load an element from a resource. | Here you have a function in Python 3, explain what it does
def LoadElement(href, only_etag=False):
request = SMCRequest(href=href)
request.exception = FetchElementFailed
result = request.read()
if only_etag:
return result.etag
return ElementCache(
result.json, etag=result.etag) | As a python code expert, you are capable of creating scripts from specifications. |
def ElementCreator(cls, json, **kwargs):
"""
Helper method for creating elements. If the created element type is
a SubElement class type, provide href value as kwargs since that class
type does not have a direct entry point. This is a lazy load that will
provide only the meta for the element. Additi... | Implement a function in Python 3 to
create an element of type cls with meta data. | You are a Python code generator, capable of creating scripts from specifications. |
Factory function for creating an object of type Element when only
is provided. | Explain what the following Python 3 code does
def ElementFactory(href, smcresult=None, raise_exc=None):
if smcresult is None:
smcresult = SMCRequest(href=href).read()
if smcresult.json:
cache = ElementCache(smcresult.json, etag=smcresult.etag)
typeof = lookup_class(cache.type)
in... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def etag(self, href):
"""
ETag can be None if a subset of element json is using
this container, such as the case with Routing.
"""
if self and self._etag is None:
self._etag = LoadElement(href, only_etag=True)
return self._etag | Can you write a function in Python 3 where it
gets the ETag of the resource. | As a python code expert, you are capable of creating scripts from specifications. |
Return the link for the specified resource. | Can you generate the documentation for the following Python 3 function
def get_link(self, rel):
if rel in self.links:
return self.links[rel]
raise ResourceNotFound('Resource requested: %r is not available '
'on this element.' % rel) | You are a Python code architect, reviewing and designing scalable and efficient code |
Get the element by name. Does an exact match by element type. | Given the following Python 3 function, write the documentation
def get(cls, name, raise_exc=True):
element = cls.objects.filter(name, exact_match=True).first() if \
name is not None else None
if not element and raise_exc:
raise ElementNotFound('Cannot find specified element: %s, ... | You are a Python code generator, capable of creating scripts from specifications. |
Update or create an existing element in the specified class. | Can you tell what is the following Python 3 function doing
def update_or_create(cls, filter_key=None, with_status=False, **kwargs):
updated = False
# Providing this flag will return before updating and require the calling
# class to call update if changes were made.
defer_update = kwargs... | You are a Python code analyst, evaluating scripts for potential improvements. |
Add a category to the element. | How would you explain what the following Python 3 function does
def add_category(self, category):
assert isinstance(category, list), 'Category input was expecting list.'
from smc.elements.other import Category
for tag in category:
category = Category(tag)
try:
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def export(self, filename='element.zip'):
"""
Export this element.
Usage::
engine = Engine('myfirewall')
extask = engine.export(filename='fooexport.zip')
while not extask.done():
extask.wait(3)
print("Finished download task: %s" %... | Write a Python 3 script to
export this element. Usage:: engine = Engine('myfirewall') extask = engine.export(filename='fooexport.zip') while not extask.done(): extask.wait(3) print("Finished download task: %s" % extask.message()) print("File downloaded to: %s" % extask.filename) :param str filename: filename to store e... | You are a Python code analyst, evaluating scripts for potential improvements. |
def referenced_by(self):
"""
Show all references for this element. A reference means that this
element is being used, for example, in a policy rule, as a member of
a group, etc.
:return: list referenced elements
:rtype: list(Element)
"""
href = fetch_entr... | Write a Python 3 script to
show all references for this element. | You are a Python code architect, reviewing and designing scalable and efficient code |
def history(self):
"""
.. versionadded:: 0.5.7
Requires SMC version >= 6.3.2
Obtain the history of this element. This will not chronicle every
modification made over time, but instead a current snapshot with
historical information such as when the element was... | How would you code a function in Python 3 to
return a new History object with the current state of this element. | You are a Python code generator, capable of creating scripts from specifications. |
This method is used to create a duplicate of an element. | Explain what the following Python 3 code does
def duplicate(self, name):
dup = self.make_request(
method='update',
raw_result=True,
resource='duplicate',
params={'name': name})
return type(self)(name=name, href=dup.href, type=type(self).typeof) | As a Python code analyst, you investigate and solve complex coding mysteries |
def get(self, location_name):
"""
Get a contact address by location name
:param str location_name: name of location
:return: return contact address element or None
:rtype: ContactAddress
"""
location_ref = location_helper(location_name, search_only=True)
... | Can you create a Python 3 function that
gets a contact address by location name | You are a Python code generator, capable of creating scripts from specifications. |
Update or create a contact address pair. | Explain what the following Python 3 code does
def update_or_create(self, location, contact_addresses, with_status=False,
overwrite_existing=False, **kw):
"""
Update or create a contact address and location pair. If the
location does not exist it will be automatically created. If the
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def contact_addresses(self):
"""
Provides a reference to contact addresses used by this server.
Obtain a reference to manipulate or iterate existing contact
addresses::
>>> from smc.elements.servers import ManagementServer
>>> mgt_server = Manage... | Can you implement a function in Python 3 that
provides a reference to contact addresses used by this server. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Creates a new HTTP Proxy service. | Can you generate a brief explanation for the following Python 3 code
def create(cls, name, address, proxy_port=8080, username=None,
password=None, secondary=None, comment=None):
"""
Create a new HTTP Proxy service. Proxy must define at least
one primary address but can optionally ... | You are a Python code generator, capable of creating scripts from specifications. |
Creates a DNS Server element. | Can you generate the documentation for the following Python 3 function
def create(cls, name, address, time_to_live=20, update_interval=10,
secondary=None, comment=None):
"""
Create a DNS Server element.
:param str name: Name of DNS Server
:param str address: IP ad... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def create(cls, name, address, inspected_service, secondary=None,
balancing_mode='ha', proxy_service='generic', location=None,
comment=None, add_x_forwarded_for=False, trust_host_header=False,
**kw):
"""
Create a Proxy Server element
:param s... | Can you implement a function in Python 3 that
creates a new Generic Proxy Server element. | You are a Python code analyst, evaluating scripts for potential improvements. |
Flush parent cache of the given node. | Here you have a function in Python 3, explain what it does
def flush_parent_cache(node):
if node._parent is None:
node._del_cache()
return
node._del_cache()
flush_parent_cache(node._parent) | You are a Python code analyst, evaluating scripts for potential improvements. |
Returns an Element object from a routing node. | Given the following Python 3 function, write the documentation
def from_meta(node):
# Version SMC < 6.4
if 'related_element_type' not in node.data:
return Element.from_href(
node.data.get('href'))
# SMC Version >= 6.4 - more efficient because it builds the
# element by meta vers... | As a Python code composer, you craft elegant and concise scripts. |
This method returns the routing node of the specified level. | Can you generate the documentation for the following Python 3 function
def route_level(root, level):
def recurse(nodes):
for node in nodes:
if node.level == level:
routing_node.append(node)
else:
recurse(node)
routing_node = []
recurse(root)
... | As a python code expert, you are capable of creating scripts from specifications. |
def gateway_by_type(self, type=None, on_network=None): # @ReservedAssignment
"""
Return gateways for the specified node. You can also
specify type to find only gateways of a specific type.
Valid types are: bgp_peering, netlink, ospfv2_area.
:param RoutingNode self: the routing node to check
... | Can you create a Python 3 function that
returns a list of gateways of a specific type | As a Python code composer, you craft elegant and concise scripts. |
Validate the protocol addresses for the element and return the protocol address. | Make a summary of the following Python 3 code
def _which_ip_protocol(element):
try:
if element.typeof in ('host', 'router'):
return getattr(element, 'address', False), getattr(element, 'ipv6_address', False)
elif element.typeof == 'netlink':
gateway = element.gateway
... | As a Python code composer, you craft elegant and concise scripts. |
def del_invalid_routes(engine, nicids):
"""
Helper method to run through and delete any routes that are tagged
as invalid or to_delete by a list of nicids. Since we could have a
list of routes, iterate from top level engine routing node to avoid
fetch exceptions. Route list should be a list of nicid... | Can you create a Python 3 function that
deletes any invalid routes that are tagged by a list of nicids. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Return the related element type for this element. | Can you generate the documentation for the following Python 3 function
def related_element_type(self):
if 'related_element_type' in self.data:
return self.data.get('related_element_type')
return None if self.dynamic_nicid or (self.nicid and '.' in self.nicid) else \
Element.from_... | As a Python code composer, you craft elegant and concise scripts. |
def as_tree(self, level=0):
"""
Display the routing tree representation in string
format
:rtype: str
"""
ret = '--' * level + repr(self) + '\n'
for routing_node in self:
ret += routing_node.as_tree(level+1)
return ret | Write a Python 3 function that can
display the routing tree representation in string format | As a python code expert, you are capable of creating scripts from specifications. |
Returns the routing configuration for a specific interface by ID. | How would you explain what the following Python 3 function does
def get(self, interface_id):
for interface in self:
if interface.nicid == str(interface_id) or \
interface.dynamic_nicid == str(interface_id):
return interface
raise InterfaceNotFound('Specified i... | As a python code expert, you are capable of creating scripts from specifications. |
def add_traffic_handler(self, netlink, netlink_gw=None, network=None):
"""
Add a traffic handler to a routing node. A traffic handler can be
either a static netlink or a multilink traffic handler. If ``network``
is not specified and the interface has multiple IP addresses, the
t... | Write a Python 3 script to
add a traffic handler to a routing node. | You are a Python code analyst, evaluating scripts for potential improvements. |
def add_ospf_area(self, ospf_area, ospf_interface_setting=None, network=None,
communication_mode='NOT_FORCED', unicast_ref=None):
"""
Add OSPF Area to this routing node.
Communication mode specifies how the interface will interact with the
adjacent OSPF environment... | Create a Python 3 function to
add an OSPF Area to the routing node. | As a Python code analyst, you investigate and solve complex coding mysteries |
Adds a BGP peering to the routing table. | Given the following Python 3 function, write the documentation
def add_bgp_peering(self, bgp_peering, external_bgp_peer=None,
network=None):
"""
Add a BGP configuration to this routing interface.
If the interface has multiple ip addresses, all networks will receive
... | You are a Python code generator, capable of creating scripts from specifications. |
Adds a static route to the routing table. | Can you tell what is the following Python 3 function doing
def add_static_route(self, gateway, destination, network=None):
routing_node_gateway = RoutingNodeGateway(gateway,
destinations=destination)
return self._add_gateway_node('router', routing_node_gateway, network) | As a Python code analyst, you investigate and solve complex coding mysteries |
Adds a dynamic gateway to the routing table. | Can you tell what is the following Python 3 function doing
def add_dynamic_gateway(self, networks):
routing_node_gateway = RoutingNodeGateway(dynamic_classid='gateway',
destinations=networks or [])
return self._add_gateway_node('dynamic_netlink', routing_node_gateway) | You are a Python code generator, capable of creating scripts from specifications. |
Adds a gateway node on a tunnel interface. | Can you generate the documentation for the following Python 3 function
def _add_gateway_node_on_tunnel(self, routing_node_gateway):
modified = False
peering = [next_hop for next_hop in self
if next_hop.routing_node_element == routing_node_gateway.routing_node_element]
if not peering:... | As a Python code composer, you craft elegant and concise scripts. |
Adds a gateway node to the routing tree. | How would you explain what the following Python 3 function does
def _add_gateway_node(self, gw_type, routing_node_gateway, network=None):
if self.level != 'interface':
raise ModificationAborted('You must make this change from the '
'interface routing level. Current node: {}'.format(s... | As a Python code composer, you craft elegant and concise scripts. |
def remove_route_gateway(self, element, network=None):
"""
Remove a route element by href or Element. Use this if you want to
remove a netlink or a routing element such as BGP or OSPF. Removing
is done from within the routing interface context.
::
interface0 ... | Can you create a Python 3 function that
removes a route gateway from the routing table. | You are a Python code generator, capable of creating scripts from specifications. |
def add(self, element):
"""
Add an entry to this antispoofing node level.
Entry can be either href or network elements specified
in :py:class:`smc.elements.network`
::
if0 = engine.antispoofing.get(0)
if0.add(Network('foonet'))
:param Element ele... | Can you create a Python 3 function that
adds an entry to this antispoofing node level. | You are a Python code architect, reviewing and designing scalable and efficient code |
def remove(self, element):
"""
Remove a specific user added element from the antispoofing tables of
a given interface. This will not remove autogenerated or system level
entries.
:param Element element: element to remove
:return: remove element if it exists and r... | Write a Python 3 script for
removing a specific user added element from the antispoofing tables of a given interface. | As a python code expert, you are capable of creating scripts from specifications. |
Add a new policy route to the engine. | Can you generate a brief explanation for the following Python 3 code
def create(self, source, destination, gateway_ip, comment=None):
self.items.append(dict(
source=source, destination=destination,
gateway_ip=gateway_ip, comment=comment)) | You are a Python code generator, capable of creating scripts from specifications. |
Delete a policy route from the engine. | Given the following Python 3 function, write the documentation
def delete(self, **kw):
delete_by = []
for field, val in kw.items():
if val is not None:
delete_by.append(field)
self.items[:] = [route for route in self.items
if not all(... | You are a Python code architect, reviewing and designing scalable and efficient code |
Create the host element with meta data | Here you have a function in Python 3, explain what it does
def create(cls, name, address=None, ipv6_address=None,
secondary=None, comment=None):
"""
Create the host element
:param str name: Name of element
:param str address: ipv4 address of host object (optional if ipv6)... | You are a Python code generator, capable of creating scripts from specifications. |
def add_secondary(self, address, append_lists=False):
"""
Add secondary IP addresses to this host element. If append_list
is True, then add to existing list. Otherwise overwrite.
:param list address: ip addresses to add in IPv4 or IPv6 format
:param bool append_list: add... | Can you write a function in Python 3 where it
adds secondary IP addresses to this host element. | You are a Python code architect, reviewing and designing scalable and efficient code |
def create(cls, name, ip_range, comment=None):
"""
Create an AddressRange element
:param str name: Name of element
:param str iprange: iprange of element
:param str comment: comment (optional)
:raises CreateElementFailed: element creation failed with reason
:retu... | Write a Python 3 script to
create an AddressRange element | You are a Python code generator, capable of creating scripts from specifications. |
Create the network element in the cache | Explain what the following Python 3 code does
def create(cls, name, ipv4_network=None, ipv6_network=None,
comment=None):
"""
Create the network element
:param str name: Name of element
:param str ipv4_network: network cidr (optional if ipv6)
:param str ipv6_networ... | You are a Python code generator, capable of creating scripts from specifications. |
Static method to build and return the proper json for a sub - expression. | Can you generate the documentation for the following Python 3 function
def build_sub_expression(name, ne_ref=None, operator='union'):
ne_ref = [] if ne_ref is None else ne_ref
json = {'name': name,
'ne_ref': ne_ref,
'operator': operator}
return json | You are a Python code generator, capable of creating scripts from specifications. |
Create the Expression
class. | Given the following Python 3 function, write the documentation
def create(cls, name, ne_ref=None, operator='exclusion',
sub_expression=None, comment=None):
"""
Create the expression
:param str name: name of expression
:param list ne_ref: network element references for exp... | As a python code expert, you are capable of creating scripts from specifications. |
Download the IPList from the AAF system. | Can you generate the documentation for the following Python 3 function
def download(self, filename=None, as_type='zip'):
headers = None
if as_type in ['zip', 'txt', 'json']:
if as_type == 'zip':
if filename is None:
raise MissingRequiredInput('Filename mus... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Uploads an IPList to the SMC. | Can you tell what is the following Python 3 function doing
def upload(self, filename=None, json=None, as_type='zip'):
headers = {'content-type': 'multipart/form-data'}
params = None
files = None
if filename:
files = {'ip_addresses': open(filename, 'rb')}
if as_type ==... | You are a Python code architect, reviewing and designing scalable and efficient code |
def update_or_create(cls, append_lists=True, with_status=False, **kwargs):
"""
Update or create an IPList.
:param bool append_lists: append to existing IP List
:param dict kwargs: provide at minimum the name attribute
and optionally match the create constructor value... | Can you implement a function in Python 3 that
updates or create an IPList. | You are a Python code generator, capable of creating scripts from specifications. |
Create an IP List. | Given the following Python 3 function, write the documentation
def create(cls, name, iplist=None, comment=None):
json = {'name': name, 'comment': comment}
result = ElementCreator(cls, json)
if result and iplist is not None:
element = IPList(name)
element.make_request(
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Update or create an alias and its mappings. | Here you have a function in Python 3, explain what it does
def update_or_create(cls, name, engine, translation_values=None, with_status=False):
updated, created = False, False
alias = cls.get(name, raise_exc=False)
if not alias:
alias = cls.create(name)
created = True
... | As a Python code composer, you craft elegant and concise scripts. |
def _from_engine(cls, data, alias_list):
"""
Return an alias for the engine. The data is dict provided
when calling engine.alias_resolving(). The alias list is
the list of aliases pre-fetched from Alias.objects.all().
This will return an Alias element by taking the alias_ref
... | Create a Python 3 function to
return an alias object from the engine. | You are a Python code generator, capable of creating scripts from specifications. |
Resolve this Alias to a specific value. | Given the following Python 3 function, write the documentation
def resolve(self, engine):
if not self.resolved_value:
result = self.make_request(
ElementNotFound,
href=self.get_relation('resolve'),
params={'for': engine})
self.resolved_val... | You are a Python code generator, capable of creating scripts from specifications. |
Fetch the blacklist and return as an instance of Element. | Make a summary of the following Python 3 code
def fetch_as_element(self, **kw):
clone = self.copy()
# Replace all filters with a combined filter
bldata = TextFormat(field_format='name')
# Preserve resolving fields for new filter
if 'resolving' in self.format.data:
blda... | As a Python code analyst, you investigate and solve complex coding mysteries |
def source_ports(self):
"""
Source ports for this blacklist entry. If no ports are specified (i.e. ALL
ports), 'ANY' is returned.
:rtype: str
"""
start_port = self.blacklist.get('BlacklistEntrySourcePort')
if start_port is not None:
return '{}... | Write a Python 3 script for
returning the source ports for this blacklist entry. | You are a Python code analyst, evaluating scripts for potential improvements. |
def dest_ports(self):
"""
Destination ports for this blacklist entry. If no ports are specified,
'ANY' is returned.
:rtype: str
"""
start_port = self.blacklist.get('BlacklistEntryDestinationPort')
if start_port is not None:
return '{}-{}'.form... | Write a Python 3 function that can
return the destination ports for this blacklist entry. | As a Python code composer, you craft elegant and concise scripts. |
def name(self):
"""
Name attribute of rule element
"""
return self._meta.name if self._meta.name else \
'Rule @%s' % self.tag | Write a Python 3 function for
returning the name of the rule element. | You are a Python code analyst, evaluating scripts for potential improvements. |
Move this rule after another rule. | Can you generate the documentation for the following Python 3 function
def move_rule_after(self, other_rule):
self.make_request(
CreateRuleFailed,
href=other_rule.get_relation('add_after'),
method='create',
json=self)
self.delete() | You are a Python code architect, reviewing and designing scalable and efficient code |
def create_rule_section(self, name, add_pos=None, after=None, before=None):
"""
Create a rule section in a Firewall Policy. To specify a specific numbering
position for the rule section, use the `add_pos` field. If no position or
before/after is specified, the rule section will be placed... | How would you code a function in Python 3 to
create a rule section in a Firewall Policy. | You are a Python code generator, capable of creating scripts from specifications. |
def create(self, name, sources=None, destinations=None,
services=None, action='allow', log_options=None,
authentication_options=None, connection_tracking=None,
is_disabled=False, vpn_policy=None, mobile_vpn=False,
add_pos=None, after=None, before=None,
... | Implement a function in Python 3 to
create a new layer 3 firewall rule. | As a Python code composer, you craft elegant and concise scripts. |
Creates an Ethernet rule with the specified parameters. | Make a summary of the following Python 3 code
def create(self, name, sources=None, destinations=None,
services=None, action='allow', is_disabled=False,
logical_interfaces=None, add_pos=None,
after=None, before=None, comment=None):
"""
Create an Ethernet rule
... | As a python code expert, you are capable of creating scripts from specifications. |
Return the severity integer value by it s name. | How would you explain what the following Python 3 function does
def _severity_by_name(name):
for intvalue, sevname in SEVERITY.items():
if name.lower() == sevname:
return intvalue
return 1 | As a Python code analyst, you investigate and solve complex coding mysteries |
A generator that returns the list of SituationParameter objects representing the detection logic for the context. | Can you generate a brief explanation for the following Python 3 code
def situation_parameters(self):
for param in self.data.get('situation_parameters', []):
cache = ElementCache(data=self.make_request(href=param))
yield type('SituationParameter', (SituationParameter,), {
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Yields the parameter values for this inspection situation. This correlate to
the situation_context. | Can you tell what is the following Python 3 function doing
def parameter_values(self):
for param in self.data.get('parameter_values', []):
cache = ElementCache(data=self.make_request(href=param))
name = '{}'.format(cache.type.title()).replace('_', '')
yield type(name, (Situat... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Create an inspection situation. | Can you generate the documentation for the following Python 3 function
def create(cls, name, situation_context, attacker=None, target=None,
severity='information', situation_type=None, description=None,
comment=None):
"""
Create an inspection situation.
:pa... | You are a Python code analyst, evaluating scripts for potential improvements. |
def create_regular_expression(self, regexp):
"""
Create a regular expression for this inspection situation
context. The inspection situation must be using an inspection
context that supports regex.
:param str regexp: regular expression string
:raises CreateElemen... | Can you write a function in Python 3 where it
creates a regular expression for this inspection situation. | As a Python code composer, you craft elegant and concise scripts. |
def download(self, filename=None):
"""
Download snapshot to filename
:param str filename: fully qualified path including filename .zip
:raises EngineCommandFailed: IOError occurred downloading snapshot
:return: None
"""
if not filename:
filename = '{}... | Write a Python 3 script for
downloading the current version of the current snapshot to a file. | You are a Python code analyst, evaluating scripts for potential improvements. |
Uploads policy to specific device. Using wait for finish
returns a TaskOperationPoller that will be executed when the task is finished. | Here you have a function in Python 3, explain what it does
def upload(self, engine, timeout=5, wait_for_finish=False, **kw):
return Task.execute(self, 'upload', params={'filter': engine},
timeout=timeout, wait_for_finish=wait_for_finish, **kw) | As a python code expert, you are capable of creating scripts from specifications. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.