output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def update_or_create(self, location, contact_address, with_status=False, **kw):
"""
Update an existing contact address or create if the location does
not exist.
:param str location: name of the location, the location will be added
if it doesn't exist
:param s... | Can you write a function in Python 3 where it
updates an existing contact address or create if it doesn t exist. | You are a Python code analyst, evaluating scripts for potential improvements. |
Get will return a list of interface references based on the given interface id and IP address. | Given the following Python 3 function, write the documentation
def get(self, interface_id, interface_ip=None):
interfaces = []
for interface in iter(self):
if interface.interface_id == str(interface_id):
if interface_ip:
if interface.interface_ip == interf... | As a python code expert, you are capable of creating scripts from specifications. |
Change a VLAN id in a NIC. | Given the following Python 3 function, write the documentation
def change_vlan_id(self, vlan_id):
first, _ = self.nicid.split('.')
self.update(nicid='{}.{}'.format(first, str(vlan_id))) | As a Python code analyst, you investigate and solve complex coding mysteries |
def vlan_id(self):
"""
VLAN ID for this interface, if any
:return: VLAN identifier
:rtype: str
"""
nicid = self.nicid
if nicid:
v = nicid.split('.')
if len(v) > 1:
return nicid.split('.')[1] | Write a Python 3 script to
return the VLAN ID for this interface | As a python code expert, you are capable of creating scripts from specifications. |
def create(cls, interface_id, logical_interface_ref,
second_interface_id=None, zone_ref=None, **kwargs):
"""
:param str interface_id: two interfaces, i.e. '1-2', '4-5', '7-10', etc
:param str logical_ref: logical interface reference
:param str zone_ref: reference to zone, set... | Can you create a Python 3 function that
creates a new pair of neccesary related resources. | You are a Python code generator, capable of creating scripts from specifications. |
Change a VLAN id for an inline interface. | Can you generate the documentation for the following Python 3 function
def change_vlan_id(self, vlan_id):
first, second = self.nicid.split('-')
firstintf = first.split('.')[0]
secondintf = second.split('.')[0]
newvlan = str(vlan_id).split('-')
self.update(nicid='{}.{}-{}.{}'.form... | As a Python code analyst, you investigate and solve complex coding mysteries |
Change the inline interface ID. | How would you explain what the following Python 3 function does
def change_interface_id(self, newid):
try:
newleft, newright = newid.split('-')
except ValueError:
raise EngineCommandFailed('You must provide two parts when changing '
'the interface ID on an inline ... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def vlan_id(self):
"""
VLAN ID for this interface, if any
:return: VLAN identifier
:rtype: str
"""
nicids = self.nicid.split('-')
if nicids:
u = []
for vlan in nicids:
if vlan.split('.')[-1] not in u:
... | Write a Python 3 script for
returning the VLAN ID for this interface. | As a python code expert, you are capable of creating scripts from specifications. |
Create a new entry in the nationale cache. | Can you tell what is the following Python 3 function doing
def create(cls, interface_id, logical_interface_ref, **kw):
data = {'inspect_unspecified_vlans': True,
'logical_interface_ref': logical_interface_ref,
'nicid': str(interface_id)}
if 'reset_interface_nicid... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def create(cls, interface_id, address, network_value,
nodeid=1, **kwargs):
"""
:param int interface_id: interface id
:param str address: ip address of the interface
:param str network_value: network/netmask, i.e. x.x.x.x/24
:param int nodeid: for clusters, used to ... | Can you create a Python 3 function that
creates a new instance of the class based on the parameters passed in. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Creates a new DHCP
object. | Can you generate the documentation for the following Python 3 function
def create(cls, interface_id, address=None, network_value=None,
nodeid=1, **kw):
"""
:param int interface_id: interface id
:param str address: address of this interface
:param str network_value: network... | As a Python code analyst, you investigate and solve complex coding mysteries |
def create(cls, address, ospf_area=None, **kwargs):
"""
Create a loopback interface. Uses parent constructor
:rtype: LoopbackClusterInterface
"""
return super(LoopbackClusterInterface, cls).create(
address=address,
network_value='{}/32'.format(add... | Create a Python 3 function to
create a loopback interface. Uses parent constructor. | As a Python code composer, you craft elegant and concise scripts. |
Delete a loopback cluster virtual interface from this engine. | Here you have a function in Python 3, explain what it does
def delete(self):
self._engine.data[self.typeof] = \
[loopback for loopback in self._engine.data.get(self.typeof, [])
if loopback.get('address') != self.address]
self._engine.update() | You are a Python code analyst, evaluating scripts for potential improvements. |
Adds a new entry to the cluster virtual loopback. This enables the loopback to float between cluster members. | How would you explain what the following Python 3 function does
def add_cvi_loopback(self, address, ospf_area=None, **kw):
lb = self.create(address, ospf_area, **kw)
if self.typeof in self._engine.data:
self._engine.data[self.typeof].append(lb.data)
else:
self._en... | You are a Python code analyst, evaluating scripts for potential improvements. |
def add_single(self, address, rank=1, nodeid=1, ospf_area=None, **kwargs):
"""
Add a single loopback interface to this engine. This is used
for single or virtual FW engines.
:param str address: ip address for loopback
:param int nodeid: nodeid to apply. Default to 1 for ... | Write a Python 3 function that can
add a single loopback interface to this engine. This is used to create a single loopback interface for virtual FW engines. | You are a Python code analyst, evaluating scripts for potential improvements. |
Delete a loopback interface from this engine. | Can you tell what is the following Python 3 function doing
def delete(self):
nodes = []
for node in self._engine.nodes:
node.data[self.typeof] = \
[lb for lb in node.loopback_node_dedicated_interface
if lb.get('rank') != self.rank]
nodes.append({n... | You are a Python code architect, reviewing and designing scalable and efficient code |
def create(cls, name, address, base_dn, bind_user_id=None, bind_password=None,
port=389, protocol='ldap', tls_profile=None, tls_identity=None,
domain_controller=None, supported_method=None, timeout=10, max_search_result=0,
page_size=0, internet_auth_service_enabled=False, **kwargs):
"""
... | Implement a function in Python 3 to
create an instance of the object containing the name of the server element and address. | You are a Python code generator, capable of creating scripts from specifications. |
def update_or_create(cls, with_status=False, **kwargs):
"""
Update or create active directory configuration.
:param dict kwargs: kwargs to satisfy the `create` constructor arguments
if the element doesn't exist or attributes to change
:raises CreateElementFailed: fai... | How would you implement a function in Python 3 that
updates or create an active directory server element. | You are a Python code architect, reviewing and designing scalable and efficient code |
Create an Access List Entry. | Can you generate the documentation for the following Python 3 function
def create(cls, name, entries=None, comment=None, **kw):
access_list_entry = []
if entries:
for entry in entries:
access_list_entry.append(
{'{}_entry'.format(cls.typeof): entry})
... | As a python code expert, you are capable of creating scripts from specifications. |
Add an entry to an AccessList. | Explain what the following Python 3 code does
def add_entry(self, **kw):
self.data.setdefault('entries', []).append(
{'{}_entry'.format(self.typeof): kw}) | As a Python code composer, you craft elegant and concise scripts. |
def remove_entry(self, **field_value):
"""
Remove an AccessList entry by field specified. Use the supported
arguments for the inheriting class for keyword arguments.
:raises UpdateElementFailed: failed to modify with reason
:return: None
"""
field, value = next(i... | Implement a Python 3 function for
removing an AccessList entry by field specified. | As a Python code composer, you craft elegant and concise scripts. |
Update or create the Access List. | Can you generate a brief explanation for the following Python 3 code
def update_or_create(cls, with_status=False, overwrite_existing=False, **kw):
created = False
modified = False
try:
element = cls.get(kw.get('name'))
except ElementNotFound:
element = cls.create(... | You are a Python code architect, reviewing and designing scalable and efficient code |
Updates the status of this task and returns a new Task object. | Can you generate the documentation for the following Python 3 function
def update_status(self):
task = self.make_request(
TaskRunFailed,
href=self.href)
return Task(task) | As a Python code composer, you craft elegant and concise scripts. |
def execute(self, resource, **kw):
"""
Execute the task and return a TaskOperationPoller.
:rtype: TaskOperationPoller
"""
params = kw.pop('params', {})
json = kw.pop('json', None)
task = self.make_request(
TaskRunFailed,
method='cr... | Implement a Python 3 function for
executing the task and return a TaskOperationPoller. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def download(self, resource, filename, **kw):
"""
Start and return a Download Task
:rtype: DownloadTask(TaskOperationPoller)
"""
params = kw.pop('params', {})
task = self.make_request(
TaskRunFailed,
method='create',
resource=r... | Implement a function in Python 3 to
start and return a Download Task | You are a Python code generator, capable of creating scripts from specifications. |
Add a callback to run after the task completes. | How would you explain what the following Python 3 function does
def add_done_callback(self, callback):
if self._done is None or self._done.is_set():
raise ValueError('Task has already finished')
if callable(callback):
self.callbacks.append(callback) | You are a Python code generator, capable of creating scripts from specifications. |
Blocking wait for task status. | How would you explain what the following Python 3 function does
def wait(self, timeout=None):
if self._thread is None:
return
self._thread.join(timeout=timeout) | You are a Python code generator, capable of creating scripts from specifications. |
Wait a specified amount of time and return the last message from the task | Make a summary of the following Python 3 code
def last_message(self, timeout=5):
if self._thread is not None:
self._thread.join(timeout=timeout)
return self._task.last_message | You are a Python code analyst, evaluating scripts for potential improvements. |
def stop(self):
"""
Stop the running task
"""
if self._thread is not None and self._thread.isAlive():
self._done.set() | Create a Python 3 function for
stopping the running task. | As a python code expert, you are capable of creating scripts from specifications. |
def create(cls, name, granted_element=None):
"""
Create a new ACL
:param str name: Name of ACL
:param list granted_elements: Elements to grant access to. Can be
engines, policies or other acl's.
:type granted_elements: list(str,Element)
:raises Create... | Create a Python 3 function for
creating a new ACL object. | As a Python code analyst, you investigate and solve complex coding mysteries |
Adds a list of elements to the set of permissions that this ACL can grant access to. | Can you tell what is the following Python 3 function doing
def add_permission(self, elements):
elements = element_resolver(elements)
self.data['granted_element'].extend(elements)
self.update() | You are a Python code generator, capable of creating scripts from specifications. |
Removes the specified elements from the set of granted elements to this ACL. | Can you generate a brief explanation for the following Python 3 code
def remove_permission(self, elements):
elements = element_resolver(elements)
for element in elements:
if element in self.granted_element:
self.data['granted_element'].remove(element)
self.update() | You are a Python code architect, reviewing and designing scalable and efficient code |
Create a permission.
:param list granted_elements: Elements for this permission. Can
be engines, policies or ACLs
:type granted_elements: list(str,Element)
:param str,Role role: role for this permission
:param str,Element domain: domain to apply (default: Shared Doma... | Explain what the following Python 3 code does
def create(cls, elements, role, domain=None):
if not domain:
domain = AdminDomain('Shared Domain')
return Permission(
granted_elements=elements, role_ref=role, granted_domain_ref=domain) | You are a Python code architect, reviewing and designing scalable and efficient code |
Save content to file. Used by node initial contact but
can be used anywhere. | Make a summary of the following Python 3 code
def save_to_file(filename, content):
import os.path
path = os.path.abspath(filename)
with open(path, "w") as text_file:
text_file.write("{}".format(content)) | You are a Python code architect, reviewing and designing scalable and efficient code |
Element resolver takes either a single class instance or a list of elements to resolve the href. If do_raise is True an exception is raised. | Given the following Python 3 function, write the documentation
def element_resolver(elements, do_raise=True):
if isinstance(elements, list):
e = []
for element in elements:
try:
e.append(element.href)
except AttributeError:
e.append(element)
... | As a Python code composer, you craft elegant and concise scripts. |
def merge_dicts(dict1, dict2, append_lists=False):
"""
Merge the second dict into the first
Not intended to merge list of dicts.
:param append_lists: If true, instead of clobbering a list with the
new value, append all of the new values onto the original list.
"""
for key in dict2:
... | Write a Python 3 script for
merging the second dict into the first dict. | You are a Python code analyst, evaluating scripts for potential improvements. |
Helper function to convert unicode strings to bytes for the
output stream | Here you have a function in Python 3, explain what it does
def unicode_to_bytes(s, encoding='utf-8', errors='replace'):
return s if isinstance(s, str) else s.encode(encoding, errors) | As a python code expert, you are capable of creating scripts from specifications. |
def create_collection(href, cls):
"""
This collection type inserts a ``create`` method into the collection.
This will proxy to the sub elements create method while restricting
access to other attributes that wouldn't be initialized yet.
.. py:method:: create(...)
Create method is inser... | Implement a Python 3 function for
creating a new base class containing a sub - element collection. | You are a Python code architect, reviewing and designing scalable and efficient code |
A utility method to create a new rule collection. | Here you have a function in Python 3, explain what it does
def rule_collection(href, cls):
instance = cls(href=href)
meth = getattr(instance, 'create')
return type(
cls.__name__, (SubElementCollection,), {
'create': meth,
'create_rule_section': instance.create_rule_section})... | You are a Python code analyst, evaluating scripts for potential improvements. |
Strip the metachars from the given value. | Can you generate the documentation for the following Python 3 function
def _strip_metachars(val):
ignore_metachar = r'(.+)([/-].+)'
match = re.search(ignore_metachar, str(val))
if match:
left_half = match.group(1)
return left_half
return val | You are a Python code architect, reviewing and designing scalable and efficient code |
def get(self, index):
"""
Get the element by index. If index is out of bounds for
the internal list, None is returned. Indexes cannot be
negative.
:param int index: retrieve element by positive index in list
:rtype: SubElement or None
"""
if self ... | How would you implement a function in Python 3 that
gets the element by index in the internal list. | You are a Python code generator, capable of creating scripts from specifications. |
Returns the first element that contains the given value. | Can you generate the documentation for the following Python 3 function
def get_contains(self, value, case_sensitive=True):
for element in self:
if not case_sensitive:
if value.lower() in element.name.lower():
return element
elif value in element.name:
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_all_contains(self, value, case_sensitive=True):
"""
A partial match on the name field. Does an `in` comparsion to
elements by the meta `name` field.
Returns all elements that match the specified value.
.. seealso:: :meth:`get_contains` for returning only a single... | Can you implement a function in Python 3 that
returns all elements that contain the specified value. | You are a Python code generator, capable of creating scripts from specifications. |
def _clone(self, **kwargs):
"""
Create a clone of this collection. The only param in the
initial collection is the filter context. Each chainable
filter is added to the clone and returned to preserve
previous iterators and their returned elements.
:return: :class... | Write a Python 3 function for
creating a clone of this collection. | You are a Python code analyst, evaluating scripts for potential improvements. |
def filter(self, *filter, **kw): # @ReservedAssignment
"""
Filter results for specific element type.
keyword arguments can be used to specify a match against the
elements attribute directly. It's important to note that if the
search filter contains a / or -, the SMC... | How would you code a function in Python 3 to
filter the list of elements for specific element type. | You are a Python code analyst, evaluating scripts for potential improvements. |
def batch(self, num):
"""
Iterator returning results in batches. When making more general queries
that might have larger results, specify a batch result that should be
returned with each iteration.
:param int num: number of results per iteration
:return: iterator... | How would you code a function in Python 3 to
return an iterator that returns num results per iteration. | You are a Python code analyst, evaluating scripts for potential improvements. |
def first(self):
"""
Returns the first object matched or None if there is no
matching object.
::
>>> iterator = Host.objects.iterator()
>>> c = iterator.filter('kali')
>>> if c.exists():
>>> print(c.count())
... | Write a Python 3 script for
returning the first object in the collection. | As a Python code composer, you craft elegant and concise scripts. |
Returns the last object in the list or None if there is no matching object. | How would you explain what the following Python 3 function does
def last(self):
if len(self):
self._params.update(limit=1)
if 'filter' not in self._params:
return list(self)[-1]
else: # Filter may not return results
result = list(self)
... | As a Python code composer, you craft elegant and concise scripts. |
Return an iterator from the collection manager. | Can you generate the documentation for the following Python 3 function
def iterator(self, **kwargs):
cls_name = '{0}Collection'.format(self._cls.__name__)
collection_cls = type(str(cls_name), (ElementCollection,), {})
params = {'filter_context': self._cls.typeof}
params.update(kwargs)
... | As a python code expert, you are capable of creating scripts from specifications. |
This method provides an entry point for element types to search. | Given the following Python 3 function, write the documentation
def entry_point(self, entry_point):
if len(entry_point.split(',')) == 1:
self._params.update(
href=self._resource.get(entry_point))
return self
else:
self._params.update(
fi... | You are a Python code generator, capable of creating scripts from specifications. |
Provide a context filter to search. | Given the following Python 3 function, write the documentation
def context_filter(self, context):
if context in CONTEXTS:
self._params.update(filter_context=context)
return self
raise InvalidSearchFilter(
'Context filter %r was invalid. Available filters: %s' %
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Return unused user - created elements. | Explain what the following Python 3 code does
def unused(self):
self._params.update(
href=self._resource.get('search_unused'))
return self | As a python code expert, you are capable of creating scripts from specifications. |
Return duplicate user - created elements. | Here you have a function in Python 3, explain what it does
def duplicates(self):
self._params.update(
href=self._resource.get('search_duplicate'))
return self | As a Python code analyst, you investigate and solve complex coding mysteries |
def object_types():
"""
Show all available 'entry points' available for searching. An entry
point defines a uri that provides unfiltered access to all elements
of the entry point type.
:return: list of entry points by name
:rtype: list(str)
"""
# Return a... | Can you implement a function in Python 3 that
shows all available entry points available for searching. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Fetch the results and return as a Connection element. | How would you explain what the following Python 3 function does
def fetch_as_element(self, **kw):
clone = self.copy()
clone.format.field_format('id')
for custom_field in ['field_ids', 'field_names']:
clone.format.data.pop(custom_field, None)
for list_of_results in clone.fetc... | As a python code expert, you are capable of creating scripts from specifications. |
def create_ospf_area_with_message_digest_auth():
"""
If you require message-digest authentication for your OSPFArea, you must
create an OSPF key chain configuration.
"""
OSPFKeyChain.create(name='secure-keychain',
key_chain_entry=[{'key': 'fookey',
... | How would you code a function in Python 3 to
create an OSPFArea with message - digest authentication for your OSPFArea. | You are a Python code analyst, evaluating scripts for potential improvements. |
def create_ospf_profile():
"""
An OSPF Profile contains administrative distance and redistribution settings. An
OSPF Profile is applied at the engine level.
When creating an OSPF Profile, you must reference a OSPFDomainSetting.
An OSPFDomainSetting holds the settings of the area border router (AB... | Can you write a function in Python 3 where it
creates an OSPF Profile and OSPF Domain Setting. | You are a Python code generator, capable of creating scripts from specifications. |
Set the timezone on the audit records. | Given the following Python 3 function, write the documentation
def timezone(self, tz):
self.data['resolving'].update(
timezone=tz,
time_show_zone=True) | As a Python code analyst, you investigate and solve complex coding mysteries |
def set_resolving(self, **kw):
"""
Certain log fields can be individually resolved. Use this
method to set these fields. Valid keyword arguments:
:param str timezone: string value to set timezone for audits
:param bool time_show_zone: show the time zone in the audit.
... | Can you create a Python 3 function that
sets resolving log fields. | As a python code expert, you are capable of creating scripts from specifications. |
Execute the query and return by batches. | Can you generate a brief explanation for the following Python 3 code
def fetch_raw(self):
for results in super(LogQuery, self).execute():
if 'records' in results and results['records']:
yield results['records'] | You are a Python code generator, capable of creating scripts from specifications. |
Fetch a batch of logs and return using the specified formatter. | Can you tell what is the following Python 3 function doing
def fetch_batch(self, formatter=TableFormat):
clone = self.copy()
clone.update_query(type='stored')
if not clone.fetch_size or clone.fetch_size <= 0:
clone.request['fetch'].update(quantity=200)
fmt = formatte... | As a Python code analyst, you investigate and solve complex coding mysteries |
def fetch_live(self, formatter=TableFormat):
"""
View logs in real-time. If previous filters were already set on
this query, they will be preserved on the original instance (this
method forces ``fetch_type='current'``).
:param formatter: Formatter type for data represent... | Implement a function in Python 3 to
return a generator of formatted results for all live log entries in real - time. | As a Python code composer, you craft elegant and concise scripts. |
def create(cls, name, vss_def=None):
"""
Create a VSS Container. This maps to the Service Manager
within NSX.
vss_def is optional and has the following definition:
{"isc_ovf_appliance_model": 'virtual',
"isc_ovf_appliance_version": '',
"isc_ip_addr... | How would you code a function in Python 3 to
create a new VSS Container. | You are a Python code generator, capable of creating scripts from specifications. |
def nodes(self):
"""
Return the nodes for this VSS Container
:rtype: SubElementCollection(VSSContainerNode)
"""
resource = sub_collection(
self.get_relation('vss_container_node'),
VSSContainerNode)
resource._load_from_engine(self, 'nodes... | Implement a function in Python 3 to
return the nodes for this VSS Container | As a Python code analyst, you investigate and solve complex coding mysteries |
Return all virtual contexts for this VSS Container. | Explain what the following Python 3 code does
def vss_contexts(self):
result = self.make_request(
href=fetch_entry_point('visible_virtual_engine_mapping'),
params={'filter': self.name})
if result.get('mapping', []):
return [Element.from_href(ve)
for ve... | You are a Python code architect, reviewing and designing scalable and efficient code |
def remove_security_group(self, name):
"""
Remove a security group from container
"""
for group in self.security_groups:
if group.isc_name == name:
group.delete() | How would you implement a function in Python 3 that
removes a security group from the container | As a Python code analyst, you investigate and solve complex coding mysteries |
Creates a new security group. | Given the following Python 3 function, write the documentation
def add_security_group(self, name, isc_id, comment=None):
return SecurityGroup.create(
name=name,
isc_id=isc_id,
vss_container=self,
comment=comment) | You are a Python code analyst, evaluating scripts for potential improvements. |
def add_context(self, isc_name, isc_policy_id, isc_traffic_tag):
"""
Create the VSS Context within the VSSContainer
:param str isc_name: ISC name, possibly append policy name??
:param str isc_policy_id: Policy ID in SMC (the 'key' attribute)
:param str isc_traffic_tag: NSX group... | Can you write a function in Python 3 where it
creates the VSS Context within the VSSContainer | You are a Python code analyst, evaluating scripts for potential improvements. |
Create a new VSS node. | Can you generate the documentation for the following Python 3 function
def create(cls, name, vss_container, vss_node_def,
comment=None):
"""
Create VSS node. This is the engines dvFilter management
interface within the NSX agent.
.. seealso:: `~.isc_settings` for ... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Create the VSS Context within the VSS Container. | Explain what the following Python 3 code does
def create(cls, isc_name, isc_policy_id, isc_traffic_tag, vss_container):
container = element_resolver(vss_container)
return ElementCreator(cls,
href=container + '/vss_context',
json = {
'vc_isc': {
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def remove_from_master_node(self, wait_for_finish=False, timeout=20, **kw):
"""
Remove this VSS Context from it's parent VSS Container.
This is required before calling VSSContext.delete(). It preps
the engine for removal.
:param bool wait_for_finish: wait for the task to... | Create a Python 3 function to
remove this VSS Context from the master node. | As a python code expert, you are capable of creating scripts from specifications. |
def create(cls, name, isc_id, vss_container, comment=None):
"""
Create a new security group.
Find a security group::
SecurityGroup.objects.filter(name)
.. note:: The isc_id (securitygroup-10, etc) represents the
internal NSX reference fo... | How would you implement a function in Python 3 that
creates a new security group. | You are a Python code generator, capable of creating scripts from specifications. |
def create(cls, name, gateway, network, input_speed=None,
output_speed=None, domain_server_address=None,
provider_name=None, probe_address=None,
standby_mode_period=3600, standby_mode_timeout=30,
active_mode_period=5, active_mode_timeout=1, comment=None):
... | Create a Python 3 function for
creating a new StaticNetlink with the given parameters. | As a Python code analyst, you investigate and solve complex coding mysteries |
def update_or_create(cls, with_status=False, **kwargs):
"""
Update or create static netlink. DNS entry differences are not
resolved, instead any entries provided will be the final state
for this netlink. If the intent is to add/remove DNS entries
you can use the :meth:`~domain_se... | Can you write a function in Python 3 where it
updates or create a static netlink. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Creates a new Dynamic Netlink element. | Can you tell what is the following Python 3 function doing
def create(cls, name, input_speed=None, learn_dns_automatically=True,
output_speed=None, provider_name=None, probe_address=None,
standby_mode_period=3600, standby_mode_timeout=30,
active_mode_period=5, active_mode_ti... | You are a Python code generator, capable of creating scripts from specifications. |
Creates a new multilink configuration. | Explain what the following Python 3 code does
def create(cls, name, multilink_members, multilink_method='rtt', retries=2,
timeout=3600, comment=None):
"""
Create a new multilink configuration. Multilink requires at least
one netlink for operation, although 2 or more are recommened... | You are a Python code architect, reviewing and designing scalable and efficient code |
Create a new multilink with a list of netlinks. | Can you tell what is the following Python 3 function doing
def create_with_netlinks(cls, name, netlinks, **kwargs):
multilink_members = []
for member in netlinks:
m = {'ip_range': member.get('ip_range', '0.0.0.0'),
'netlink_role': member.get('netlink_role', 'active')}
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Create a new multilink member in the local cache. | Explain what the following Python 3 code does
def create(cls, netlink, ip_range=None, netlink_role='active'):
member_def = dict(
netlink_ref=netlink.href,
netlink_role=netlink_role,
ip_range=ip_range if netlink.typeof == 'netlink' else '0.0.0.0')
if netlink.typeof == ... | As a Python code analyst, you investigate and solve complex coding mysteries |
def create(cls, name, tls_version, use_only_subject_alt_name=False,
accept_wildcard=False, check_revocation=True, tls_cryptography_suites=None,
crl_delay=0, ocsp_delay=0, ignore_network_issues=False,
tls_trusted_ca_ref=None, comment=None):
"""
Create a TLS Profile. By default the... | How would you implement a function in Python 3 that
creates a new NIST profile with the specified name and TLS version. | You are a Python code analyst, evaluating scripts for potential improvements. |
Create a TLS CA. | How would you explain what the following Python 3 function does
def create(cls, name, certificate):
json = {'name': name,
'certificate': certificate if pem_as_string(certificate) else \
load_cert_chain(certificate)[0][1].decode('utf-8')}
return ElementCreator... | You are a Python code architect, reviewing and designing scalable and efficient code |
Creates a new CSR for the specified key. | Can you generate a brief explanation for the following Python 3 code
def create_csr(cls, name, common_name, public_key_algorithm='rsa',
signature_algorithm='rsa_sha_512', key_length=4096):
"""
Create a certificate signing request.
:param str name: name of TLS Server Cred... | You are a Python code analyst, evaluating scripts for potential improvements. |
def create_self_signed(cls, name, common_name, public_key_algorithm='rsa',
signature_algorithm='rsa_sha_512', key_length=4096):
"""
Create a self signed certificate. This is a convenience method that
first calls :meth:`~create_csr`, then calls :meth:`~self_sign` on the
return... | How would you code a function in Python 3 to
create a self signed certificate. | You are a Python code architect, reviewing and designing scalable and efficient code |
Imports a signed certificate and private key to SMC and optionally a intermediate certificate. | Here you have a function in Python 3, explain what it does
def import_signed(cls, name, certificate, private_key, intermediate=None):
tls = TLSServerCredential.create(name)
try:
tls.import_certificate(certificate)
tls.import_private_key(private_key)
if intermediate is... | As a python code expert, you are capable of creating scripts from specifications. |
Imports the server certificate and intermediate and optionally private key from a certificate chain file. | How would you explain what the following Python 3 function does
def import_from_chain(cls, name, certificate_file, private_key=None):
contents = load_cert_chain(certificate_file)
for pem in list(contents):
if b'PRIVATE KEY' in pem[0]:
private_key = pem[1]
cont... | You are a Python code generator, capable of creating scripts from specifications. |
def import_signed(cls, name, certificate, private_key):
"""
Import a signed certificate and private key as a client protection CA.
This is a shortcut method to the 3 step process:
* Create CA with name
* Import certificate
* Import private ke... | Can you implement a function in Python 3 that
imports a signed certificate and private key as a client protection CA. | As a Python code composer, you craft elegant and concise scripts. |
def create_self_signed(cls, name, prefix, password, public_key_algorithm='rsa',
life_time=365, key_length=2048):
"""
Create a self signed client protection CA. To prevent browser warnings during
decryption, you must trust the signing certificate in the client browsers.
... | How would you code a function in Python 3 to
create a new self signed client protection CA. | You are a Python code generator, capable of creating scripts from specifications. |
Updates the format for this query.
| Can you generate the documentation for the following Python 3 function
def update_format(self, format):
self.format = format
self.request.update(format=self.format.data) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Adds an IN filter to the list of filters that will be used to find a match for the given values. | How would you explain what the following Python 3 function does
def add_in_filter(self, *values):
filt = InFilter(*values)
self.update_filter(filt)
return filt | As a Python code composer, you craft elegant and concise scripts. |
Adds an AND filter to the filter list. | Here you have a function in Python 3, explain what it does
def add_and_filter(self, *values):
filt = AndFilter(*values)
self.update_filter(filt)
return filt | As a Python code analyst, you investigate and solve complex coding mysteries |
Adds an OR filter to the list of values. | Explain what the following Python 3 code does
def add_or_filter(self, *values):
filt = OrFilter(*values)
self.update_filter(filt)
return filt | As a Python code translator, you convert algorithms and pseudocode into Python. |
Adds a NOT filter to the list of filters. Typically this filter is used in the case of a list of values that are not present in the list of entries. | Can you generate the documentation for the following Python 3 function
def add_not_filter(self, *value):
filt = NotFilter(*value)
self.update_filter(filt)
return filt | As a Python code translator, you convert algorithms and pseudocode into Python. |
Adds a DefinedFilter expression to the query. | Can you tell what is the following Python 3 function doing
def add_defined_filter(self, *value):
filt = DefinedFilter(*value)
self.update_filter(filt)
return filt | As a Python code analyst, you investigate and solve complex coding mysteries |
This function returns the log field details based on the LogField constant IDs. | How would you explain what the following Python 3 function does
def resolve_field_ids(ids, **kw):
request = {
'fetch': {'quantity': 0},
'format': {
'type': 'detailed',
'field_ids': ids},
'query': {}
}
query = Query(**kw)
... | As a Python code composer, you craft elegant and concise scripts. |
Get a list of all of the default fields for this query type. | Can you tell what is the following Python 3 function doing
def _get_field_schema(self):
self.update_format(DetailedFormat())
for fields in self.execute():
if 'fields' in fields:
return fields['fields'] | As a python code expert, you are capable of creating scripts from specifications. |
def execute(self):
"""
Execute the query with optional timeout. The response to the execute
query is the raw payload received from the websocket and will contain
multiple dict keys and values. It is more common to call query.fetch_XXX
which will filter the return result based on ... | Write a Python 3 script for
executing the query with optional timeout. | As a python code expert, you are capable of creating scripts from specifications. |
def fetch_raw(self, **kw):
"""
Fetch the records for this query. This fetch type will return the
results in raw dict format. It is possible to limit the number of
receives on the socket that return results before exiting by providing
max_recv.
This fetch should b... | Write a Python 3 script for
fetching the records for this query. This method will return the records for the current query in raw dict format. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def fetch_batch(self, formatter=TableFormat, **kw):
"""
Fetch and return in the specified format. Output format is a formatter
class in :py:mod:`smc_monitoring.models.formatters`. This fetch type will
be a single shot fetch unless providing max_recv keyword with a value
greater t... | Implement a function in Python 3 to
fetch and return in the specified format. | You are a Python code generator, capable of creating scripts from specifications. |
Fetch a live stream query. This is the equivalent of selecting
the Play option for monitoring fields within the SMC UI. | Can you generate a brief explanation for the following Python 3 code
def fetch_live(self, formatter=TableFormat):
fmt = formatter(self)
for results in self.execute():
if 'records' in results and results['records'].get('added'):
yield fmt.formatted(results['records']['added']) | As a python code expert, you are capable of creating scripts from specifications. |
This function is used to fetch the metadata of a specific element by name. | Can you generate a brief explanation for the following Python 3 code
def fetch_meta_by_name(name, filter_context=None, exact_match=True):
result = SMCRequest(
params={'filter': name,
'filter_context': filter_context,
'exact_match': exact_match}).read()
if not result.... | As a Python code composer, you craft elegant and concise scripts. |
def blacklist(self, src, dst, duration=3600, **kw):
"""
Add blacklist to all defined engines.
Use the cidr netmask at the end of src and dst, such as:
1.1.1.1/32, etc.
:param src: source of the entry
:param dst: destination of blacklist entry
:raises ActionComman... | Can you implement a function in Python 3 that
adds a blacklist entry to all engines that support the source and destination entries. | 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.