_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q19700 | SummonerApiV4.by_account | train | def by_account(self, region, encrypted_account_id):
"""
Get a summoner by account ID.
:param string region: The region to execute this request on
:param string encrypted_account_id: The account ID.
:returns: SummonerDTO: represents a summoner
"""
u... | python | {
"resource": ""
} |
q19701 | SummonerApiV4.by_name | train | def by_name(self, region, summoner_name):
"""
Get a summoner by summoner name
:param string region: The region to execute this request on
:param string summoner_name: Summoner Name
:returns: SummonerDTO: represents a summoner
"""
url, query = Summon... | python | {
"resource": ""
} |
q19702 | SummonerApiV4.by_puuid | train | def by_puuid(self, region, encrypted_puuid):
"""
Get a summoner by PUUID.
:param string region: The region to execute this request on
:param string encrypted_puuid: PUUID
:returns: SummonerDTO: represents a summoner
"""
url, query = SummonerApiV4Urls.... | python | {
"resource": ""
} |
q19703 | SummonerApiV4.by_id | train | def by_id(self, region, encrypted_summoner_id):
"""
Get a summoner by summoner ID.
:param string region: The region to execute this request on
:param string encrypted_summoner_id: Summoner ID
:returns: SummonerDTO: represents a summoner
"""
... | python | {
"resource": ""
} |
q19704 | SpectatorApiV4.featured_games | train | def featured_games(self, region):
"""
Get list of featured games.
:param string region: The region to execute this request on
:returns: FeaturedGames
"""
url, query = SpectatorApiV4Urls.featured_games(region=region)
return self._raw_request(self.featured_games._... | python | {
"resource": ""
} |
q19705 | ThirdPartyCodeApiV4.by_summoner | train | def by_summoner(self, region, encrypted_summoner_id):
"""
FOR KR SUMMONERS, A 404 WILL ALWAYS BE RETURNED.
Valid codes must be no longer than 256 characters and only use
valid characters: 0-9, a-z, A-Z, and -
:param string region: the region to execute this re... | python | {
"resource": ""
} |
q19706 | NamedEndpoint._raw_request | train | def _raw_request(self, method_name, region, url, query_params):
"""
Sends a request through the BaseApi instance provided, injecting the provided endpoint_name
into the method call, so the caller doesn't have to.
:param string method_name: The name of the calling method
:param ... | python | {
"resource": ""
} |
q19707 | LeagueApiV4.challenger_by_queue | train | def challenger_by_queue(self, region, queue):
"""
Get the challenger league for a given queue.
:param string region: the region to execute this request on
:param string queue: the queue to get the challenger players for
:returns: LeagueListDTO
"""
url, quer... | python | {
"resource": ""
} |
q19708 | LeagueApiV4.masters_by_queue | train | def masters_by_queue(self, region, queue):
"""
Get the master league for a given queue.
:param string region: the region to execute this request on
:param string queue: the queue to get the master players for
:returns: LeagueListDTO
"""
url, query = LeagueA... | python | {
"resource": ""
} |
q19709 | LeagueApiV4.by_id | train | def by_id(self, region, league_id):
"""
Get league with given ID, including inactive entries
:param string region: the region to execute this request on
:param string league_id: the league ID to query
:returns: LeagueListDTO
"""
url, query = LeagueApiV4... | python | {
"resource": ""
} |
q19710 | LeagueApiV4.entries | train | def entries(self, region, queue, tier, division):
"""
Get all the league entries
:param string region: the region to execute this request on
:param string queue: the queue to query, i.e. RANKED_SOLO_5x5
:param string tier: the tier to query, i.e. DIAMOND
:param ... | python | {
"resource": ""
} |
q19711 | ChampionApiV3.rotations | train | def rotations(self, region):
"""
Returns champion rotations, including free-to-play and low-level free-to-play rotations.
:returns: ChampionInfo
"""
url, query = ChampionApiV3Urls.rotations(region=region)
return self._raw_request(self.rotations.__name__, region, url, que... | python | {
"resource": ""
} |
q19712 | Response.get_body | train | def get_body(self):
'''Get the response Body
:returns Body: A Body object containing the response.
'''
if self._body is None:
resp = self._dispatcher._dispatch(self.request)
self._body = self._create_body(resp)
return self._body | python | {
"resource": ""
} |
q19713 | Response.cancel | train | def cancel(self):
'''Cancel any request.'''
if self._body:
self._body._cancel = True
else:
self._cancel = True | python | {
"resource": ""
} |
q19714 | Body.last_modified | train | def last_modified(self):
'''Read the last-modified header as a datetime, if present.'''
lm = self.response.headers.get('last-modified', None)
return datetime.strptime(lm, '%a, %d %b %Y %H:%M:%S GMT') if lm \
else None | python | {
"resource": ""
} |
q19715 | Paged.iter | train | def iter(self, pages=None):
'''Get an iterator of pages.
:param int pages: optional limit to number of pages
:return: iter of this and subsequent pages
'''
i = self._pages()
if pages is not None:
i = itertools.islice(i, pages)
return i | python | {
"resource": ""
} |
q19716 | Paged.json_encode | train | def json_encode(self, out, limit=None, sort_keys=False, indent=None):
'''Encode the results of this paged response as JSON writing to the
provided file-like `out` object. This function will iteratively read
as many pages as present, streaming the contents out as JSON.
:param file-like o... | python | {
"resource": ""
} |
q19717 | Paged.items_iter | train | def items_iter(self, limit):
'''Get an iterator of the 'items' in each page. Instead of a feature
collection from each page, the iterator yields the features.
:param int limit: The number of 'items' to limit to.
:return: iter of items in page
'''
pages = (page.get() for... | python | {
"resource": ""
} |
q19718 | create | train | def create(client, mosaic=False, **kw):
'''Create a Downloader with the provided client.
:param mosaic bool: If True, the Downloader will fetch mosaic quads.
:returns: :py:Class:`planet.api.downloader.Downloader`
'''
if mosaic:
return _MosaicDownloader(client, **kw)
else:
return... | python | {
"resource": ""
} |
q19719 | quick_search | train | def quick_search(limit, pretty, sort, **kw):
'''Execute a quick search.'''
req = search_req_from_opts(**kw)
cl = clientv1()
page_size = min(limit, 250)
echo_json_response(call_and_wrap(
cl.quick_search, req, page_size=page_size, sort=sort
), pretty, limit) | python | {
"resource": ""
} |
q19720 | create_search | train | def create_search(pretty, **kw):
'''Create a saved search'''
req = search_req_from_opts(**kw)
cl = clientv1()
echo_json_response(call_and_wrap(cl.create_search, req), pretty) | python | {
"resource": ""
} |
q19721 | saved_search | train | def saved_search(search_id, sort, pretty, limit):
'''Execute a saved search'''
sid = read(search_id)
cl = clientv1()
page_size = min(limit, 250)
echo_json_response(call_and_wrap(
cl.saved_search, sid, page_size=page_size, sort=sort
), limit=limit, pretty=pretty) | python | {
"resource": ""
} |
q19722 | download | train | def download(asset_type, dest, limit, sort, search_id, dry_run, activate_only,
quiet, **kw):
'''Activate and download'''
cl = clientv1()
page_size = min(limit or 250, 250)
asset_type = list(chain.from_iterable(asset_type))
# even though we're using functionality from click.Path, this wa... | python | {
"resource": ""
} |
q19723 | search_mosaics | train | def search_mosaics(name, bbox, rbox, limit, pretty):
'''Get quad IDs and information for a mosaic'''
bbox = bbox or rbox
cl = clientv1()
mosaic, = cl.get_mosaic_by_name(name).items_iter(1)
response = call_and_wrap(cl.get_quads, mosaic, bbox)
echo_json_response(response, pretty, limit) | python | {
"resource": ""
} |
q19724 | mosaic_info | train | def mosaic_info(name, pretty):
'''Get information for a specific mosaic'''
cl = clientv1()
echo_json_response(call_and_wrap(cl.get_mosaic_by_name, name), pretty) | python | {
"resource": ""
} |
q19725 | quad_info | train | def quad_info(name, quad, pretty):
'''Get information for a specific mosaic quad'''
cl = clientv1()
mosaic, = cl.get_mosaic_by_name(name).items_iter(1)
echo_json_response(call_and_wrap(cl.get_quad_by_id, mosaic, quad), pretty) | python | {
"resource": ""
} |
q19726 | quad_contributions | train | def quad_contributions(name, quad, pretty):
'''Get contributing scenes for a mosaic quad'''
cl = clientv1()
mosaic, = cl.get_mosaic_by_name(name).items_iter(1)
quad = cl.get_quad_by_id(mosaic, quad).get()
response = call_and_wrap(cl.get_quad_contributions, quad)
echo_json_response(response, pret... | python | {
"resource": ""
} |
q19727 | download_quads | train | def download_quads(name, bbox, rbox, quiet, dest, limit):
'''Download quads from a mosaic'''
bbox = bbox or rbox
cl = clientv1()
dl = downloader.create(cl, mosaic=True)
output = downloader_output(dl, disable_ansi=quiet)
output.start()
try:
mosaic, = cl.get_mosaic_by_name(name).items... | python | {
"resource": ""
} |
q19728 | configure_logging | train | def configure_logging(verbosity):
'''configure logging via verbosity level of between 0 and 2 corresponding
to log levels warning, info and debug respectfully.'''
log_level = max(logging.DEBUG, logging.WARNING - logging.DEBUG*verbosity)
logging.basicConfig(
stream=sys.stderr, level=log_level,
... | python | {
"resource": ""
} |
q19729 | cli | train | def cli(context, verbose, api_key, base_url, workers):
'''Planet API Client'''
configure_logging(verbose)
client_params.clear()
client_params['api_key'] = api_key
client_params['workers'] = workers
if base_url:
client_params['base_url'] = base_url | python | {
"resource": ""
} |
q19730 | help | train | def help(context, command):
'''Get command help'''
if command:
cmd = cli.commands.get(command, None)
if cmd:
context.info_name = command
click.echo(cmd.get_help(context))
else:
raise click.ClickException('no command: %s' % command)
else:
cl... | python | {
"resource": ""
} |
q19731 | geometry_from_json | train | def geometry_from_json(obj):
'''try to find a geometry in the provided JSON object'''
obj_type = obj.get('type', None)
if not obj_type:
return None
if obj_type == 'FeatureCollection':
features = obj.get('features', [])
if len(features):
obj = obj['features'][0]
... | python | {
"resource": ""
} |
q19732 | check_status | train | def check_status(response):
'''check the status of the response and if needed raise an APIException'''
status = response.status_code
if status < 300:
return
exception = {
400: exceptions.BadQuery,
401: exceptions.InvalidAPIKey,
403: exceptions.NoPermission,
404: e... | python | {
"resource": ""
} |
q19733 | get_filename | train | def get_filename(response):
"""Derive a filename from the given response.
>>> import requests
>>> from planet.api import utils
>>> response = requests.Response()
>>> response.headers = {
... 'date': 'Thu, 14 Feb 2019 16:13:26 GMT',
... 'last-modified': 'Wed, 22 Nov 2017 17:22:31 GMT... | python | {
"resource": ""
} |
q19734 | get_filename_from_headers | train | def get_filename_from_headers(headers):
"""Get a filename from the Content-Disposition header, if available.
>>> from planet.api import utils
>>> headers = {
... 'date': 'Thu, 14 Feb 2019 16:13:26 GMT',
... 'last-modified': 'Wed, 22 Nov 2017 17:22:31 GMT',
... 'accept-ranges': 'byte... | python | {
"resource": ""
} |
q19735 | get_filename_from_url | train | def get_filename_from_url(url):
"""Get a filename from a URL.
>>> from planet.api import utils
>>> urls = [
... 'https://planet.com/',
... 'https://planet.com/path/to/',
... 'https://planet.com/path/to/example.tif',
... 'https://planet.com/path/to/example.tif?foo=f6f1&bar=ba... | python | {
"resource": ""
} |
q19736 | get_random_filename | train | def get_random_filename(content_type=None):
"""Get a pseudo-random, Planet-looking filename.
>>> from planet.api import utils
>>> print(utils.get_random_filename()) #doctest:+SKIP
planet-61FPnh7K
>>> print(utils.get_random_filename('image/tiff')) #doctest:+SKIP
planet-V8ELYxy5.tif
>>>
... | python | {
"resource": ""
} |
q19737 | write_to_file | train | def write_to_file(directory=None, callback=None, overwrite=True):
'''Create a callback handler for asynchronous Body handling.
If provided, the callback will be invoked as described in
:py:meth:`planet.api.models.Body.write`. In addition, if the download
is skipped because the destination exists, the c... | python | {
"resource": ""
} |
q19738 | probably_wkt | train | def probably_wkt(text):
'''Quick check to determine if the provided text looks like WKT'''
valid = False
valid_types = set([
'POINT', 'LINESTRING', 'POLYGON', 'MULTIPOINT',
'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION',
])
matched = re.match(r'(\w+)\s*\([^)]+\)', text.strip... | python | {
"resource": ""
} |
q19739 | probably_geojson | train | def probably_geojson(input):
'''A quick check to see if this input looks like GeoJSON. If not a dict
JSON-like object, attempt to parse input as JSON. If the resulting object
has a type property that looks like GeoJSON, return that object or None'''
valid = False
if not isinstance(input, dict):
... | python | {
"resource": ""
} |
q19740 | ClientV1.quick_search | train | def quick_search(self, request, **kw):
'''Execute a quick search with the specified request.
:param request: see :ref:`api-search-request`
:param **kw: See Options below
:returns: :py:class:`planet.api.models.Items`
:raises planet.api.exceptions.APIException: On API error.
... | python | {
"resource": ""
} |
q19741 | ClientV1.saved_search | train | def saved_search(self, sid, **kw):
'''Execute a saved search by search id.
:param sid string: The id of the search
:returns: :py:class:`planet.api.models.Items`
:raises planet.api.exceptions.APIException: On API error.
:Options:
* page_size (int): Size of response page... | python | {
"resource": ""
} |
q19742 | ClientV1.get_searches | train | def get_searches(self, quick=False, saved=True):
'''Get searches listing.
:param quick bool: Include quick searches (default False)
:param quick saved: Include saved searches (default True)
:returns: :py:class:`planet.api.models.Searches`
:raises planet.api.exceptions.APIExcepti... | python | {
"resource": ""
} |
q19743 | ClientV1.stats | train | def stats(self, request):
'''Get stats for the provided request.
:param request dict: A search request that also contains the 'interval'
property.
:returns: :py:class:`planet.api.models.JSON`
:raises planet.api.exceptions.APIException: On API error.
... | python | {
"resource": ""
} |
q19744 | ClientV1.activate | train | def activate(self, asset):
'''Request activation of the specified asset representation.
Asset representations are obtained from :py:meth:`get_assets`.
:param request dict: An asset representation from the API.
:returns: :py:class:`planet.api.models.Body` with no response content
... | python | {
"resource": ""
} |
q19745 | ClientV1.download | train | def download(self, asset, callback=None):
'''Download the specified asset. If provided, the callback will be
invoked asynchronously. Otherwise it is up to the caller to handle the
response Body.
:param asset dict: An asset representation from the API
:param callback: An optional... | python | {
"resource": ""
} |
q19746 | ClientV1.get_item | train | def get_item(self, item_type, id):
'''Get the an item response for the given item_type and id
:param item_type str: A valid item-type
:param id str: The id of the item
:returns: :py:Class:`planet.api.models.JSON`
:raises planet.api.exceptions.APIException: On API error.
... | python | {
"resource": ""
} |
q19747 | ClientV1.get_assets_by_id | train | def get_assets_by_id(self, item_type, id):
'''Get an item's asset response for the given item_type and id
:param item_type str: A valid item-type
:param id str: The id of the item
:returns: :py:Class:`planet.api.models.JSON`
:raises planet.api.exceptions.APIException: On API err... | python | {
"resource": ""
} |
q19748 | ClientV1.get_mosaics | train | def get_mosaics(self):
'''Get information for all mosaics accessible by the current user.
:returns: :py:Class:`planet.api.models.Mosaics`
'''
url = self._url('basemaps/v1/mosaics')
return self._get(url, models.Mosaics).get_body() | python | {
"resource": ""
} |
q19749 | ClientV1.get_mosaic_by_name | train | def get_mosaic_by_name(self, name):
'''Get the API representation of a mosaic by name.
:param name str: The name of the mosaic
:returns: :py:Class:`planet.api.models.Mosaics`
:raises planet.api.exceptions.APIException: On API error.
'''
params = {'name__is': name}
... | python | {
"resource": ""
} |
q19750 | ClientV1.get_quads | train | def get_quads(self, mosaic, bbox=None):
'''Search for quads from a mosaic that are inside the specified
bounding box. Will yield all quads if no bounding box is specified.
:param mosaic dict: A mosaic representation from the API
:param bbox tuple: A lon_min, lat_min, lon_max, lat_max a... | python | {
"resource": ""
} |
q19751 | ClientV1.get_quad_by_id | train | def get_quad_by_id(self, mosaic, quad_id):
'''Get a quad response for a specific mosaic and quad.
:param mosaic dict: A mosaic representation from the API
:param quad_id str: A quad id (typically <xcoord>-<ycoord>)
:returns: :py:Class:`planet.api.models.JSON`
:raises planet.api.... | python | {
"resource": ""
} |
q19752 | ClientV1.download_quad | train | def download_quad(self, quad, callback=None):
'''Download the specified mosaic quad. If provided, the callback will
be invoked asynchronously. Otherwise it is up to the caller to handle
the response Body.
:param asset dict: A mosaic quad representation from the API
:param callb... | python | {
"resource": ""
} |
q19753 | and_filter_from_opts | train | def and_filter_from_opts(opts):
'''build an AND filter from the provided opts dict as passed to a command
from the filter_options decorator. Assumes all dict values are lists of
filter dict constructs.'''
return filters.and_filter(*list(chain.from_iterable([
o for o in opts.values() if o]
))... | python | {
"resource": ""
} |
q19754 | read | train | def read(value, split=False):
'''Get the value of an option interpreting as a file implicitly or
explicitly and falling back to the value if not explicitly specified.
If the value is '@name', then a file must exist with name and the returned
value will be the contents of that file. If the value is '@-' ... | python | {
"resource": ""
} |
q19755 | build_search_request | train | def build_search_request(filter_like, item_types, name=None, interval=None):
'''Build a data-api search request body for the specified item_types.
If 'filter_like' is a request, item_types will be merged and, if name or
interval is provided, will replace any existing values.
:param dict filter_like: a ... | python | {
"resource": ""
} |
q19756 | date_range | train | def date_range(field_name, **kwargs):
'''Build a DateRangeFilter.
Predicate arguments accept a value str that in ISO-8601 format or a value
that has a `isoformat` callable that returns an ISO-8601 str.
:raises: ValueError if predicate value does not parse
>>> date_range('acquired', gt='2017') == ... | python | {
"resource": ""
} |
q19757 | Vrfs.get | train | def get(self, value):
"""Returns the VRF configuration as a resource dict.
Args:
value (string): The vrf name to retrieve from the
running configuration.
Returns:
A Python dict object containing the VRF attributes as
key/value pairs.
... | python | {
"resource": ""
} |
q19758 | Vrfs._parse_rd | train | def _parse_rd(self, config):
""" _parse_rd scans the provided configuration block and extracts
the vrf rd. The return dict is intended to be merged into the response
dict.
Args:
config (str): The vrf configuration block from the nodes running
configuration
... | python | {
"resource": ""
} |
q19759 | Vrfs._parse_description | train | def _parse_description(self, config):
""" _parse_description scans the provided configuration block and
extracts the vrf description value. The return dict is intended to
be merged into the response dict.
Args:
config (str): The vrf configuration block from the nodes
... | python | {
"resource": ""
} |
q19760 | Vrfs.getall | train | def getall(self):
"""Returns a dict object of all VRFs in the running-config
Returns:
A dict object of VRF attributes
"""
vrfs_re = re.compile(r'(?<=^vrf definition\s)(\w+)', re.M)
response = dict()
for vrf in vrfs_re.findall(self.config):
respo... | python | {
"resource": ""
} |
q19761 | Vrfs.create | train | def create(self, vrf_name, rd=None):
""" Creates a new VRF resource
Note: A valid RD has the following format admin_ID:local_assignment.
The admin_ID can be an AS number or globally assigned IPv4 address.
The local_assignment can be an integer between 0-65,535 if the
... | python | {
"resource": ""
} |
q19762 | Vrfs.configure_vrf | train | def configure_vrf(self, vrf_name, commands):
""" Configures the specified VRF using commands
Args:
vrf_name (str): The VRF name to configure
commands: The list of commands to configure
Returns:
True if the commands completed successfully
"""
... | python | {
"resource": ""
} |
q19763 | Vrfs.set_description | train | def set_description(self, vrf_name, description=None, default=False,
disable=False):
""" Configures the VRF description
Args:
vrf_name (str): The VRF name to configure
description(str): The string to set the vrf description to
default (bool): ... | python | {
"resource": ""
} |
q19764 | Vrfs.set_ipv4_routing | train | def set_ipv4_routing(self, vrf_name, default=False, disable=False):
""" Configures ipv4 routing for the vrf
Args:
vrf_name (str): The VRF name to configure
default (bool): Configures ipv4 routing for the vrf value to
default if this value is true
disa... | python | {
"resource": ""
} |
q19765 | Vrfs.set_interface | train | def set_interface(self, vrf_name, interface, default=False, disable=False):
""" Adds a VRF to an interface
Notes:
Requires interface to be in routed mode. Must apply ip address
after VRF has been applied. This feature can also be accessed
through the interfaces api.
... | python | {
"resource": ""
} |
q19766 | Vrrp.get | train | def get(self, name):
"""Get the vrrp configurations for a single node interface
Args:
name (string): The name of the interface for which vrrp
configurations will be retrieved.
Returns:
A dictionary containing the vrrp configurations on the interface.
... | python | {
"resource": ""
} |
q19767 | Vrrp.getall | train | def getall(self):
"""Get the vrrp configurations for all interfaces on a node
Returns:
A dictionary containing the vrrp configurations on the node,
keyed by interface.
"""
vrrps = dict()
# Find the available interfaces
interfaces = re.findall(r'... | python | {
"resource": ""
} |
q19768 | Vrrp.create | train | def create(self, interface, vrid, **kwargs):
"""Creates a vrrp instance from an interface
Note:
This method will attempt to create a vrrp in the node's
operational config. If the vrrp already exists on the
interface, then this method will set the properties of
... | python | {
"resource": ""
} |
q19769 | Vrrp.delete | train | def delete(self, interface, vrid):
"""Deletes a vrrp instance from an interface
Note:
This method will attempt to delete the vrrp from the node's
operational config. If the vrrp does not exist on the
interface then this method will not perform any changes
... | python | {
"resource": ""
} |
q19770 | Vrrp.default | train | def default(self, interface, vrid):
"""Defaults a vrrp instance from an interface
Note:
This method will attempt to default the vrrp on the node's
operational config. Default results in the deletion of the
specified vrrp . If the vrrp does not exist on the
... | python | {
"resource": ""
} |
q19771 | Vrrp.set_enable | train | def set_enable(self, name, vrid, value=False, run=True):
"""Set the enable property of the vrrp
Args:
name (string): The interface to configure.
vrid (integer): The vrid number for the vrrp to be managed.
value (boolean): True to enable the vrrp, False to disable.
... | python | {
"resource": ""
} |
q19772 | Vrrp.set_secondary_ips | train | def set_secondary_ips(self, name, vrid, secondary_ips, run=True):
"""Configure the secondary_ip property of the vrrp
Notes:
set_secondary_ips takes a list of secondary ip addresses
which are to be set on the virtal router. An empty list will
remove any existing secon... | python | {
"resource": ""
} |
q19773 | Vrrp.set_mac_addr_adv_interval | train | def set_mac_addr_adv_interval(self, name, vrid, value=None, disable=False,
default=False, run=True):
"""Set the mac_addr_adv_interval property of the vrrp
Args:
name (string): The interface to configure.
vrid (integer): The vrid number for the v... | python | {
"resource": ""
} |
q19774 | Vrrp.set_bfd_ip | train | def set_bfd_ip(self, name, vrid, value=None, disable=False,
default=False, run=True):
"""Set the bfd_ip property of the vrrp
Args:
name (string): The interface to configure.
vrid (integer): The vrid number for the vrrp to be managed.
value (string)... | python | {
"resource": ""
} |
q19775 | Vrrp.vrconf_format | train | def vrconf_format(self, vrconfig):
"""Formats a vrrp configuration dictionary to match the
information as presented from the get and getall methods.
vrrp configuration dictionaries passed to the create
method may contain data for setting properties which results
in a default valu... | python | {
"resource": ""
} |
q19776 | prefixlen_to_mask | train | def prefixlen_to_mask(prefixlen):
"""Converts a prefix length to a dotted decimal subnet mask
Args:
prefixlen (str): The prefix length value to convert
Returns:
str: The subt mask as a dotted decimal string
"""
prefixlen = prefixlen or '32'
addr = '0.0.0.0/%s' % prefixlen
r... | python | {
"resource": ""
} |
q19777 | Acls.getall | train | def getall(self):
"""Returns all ACLs in a dict object.
Returns:
A Python dictionary object containing all ACL
configuration indexed by ACL name::
{
"<ACL1 name>": {...},
"<ACL2 name>": {...}
}
"""... | python | {
"resource": ""
} |
q19778 | Mlag.get | train | def get(self):
"""Returns the Mlag configuration as a resource dict
Returns:
dict: A dict ojbect containing the Mlag resource attributes.
"""
resource = dict()
resource.update(self._parse_config())
resource.update(self._parse_interfaces())
return res... | python | {
"resource": ""
} |
q19779 | Mlag._parse_config | train | def _parse_config(self):
"""Parses the mlag global configuration
Returns:
dict: A dict object that is intended to be merged into the
resource dict
"""
config = self.get_block('mlag configuration')
cfg = dict()
cfg.update(self._parse_domain_id(... | python | {
"resource": ""
} |
q19780 | Mlag._parse_domain_id | train | def _parse_domain_id(self, config):
"""Scans the config block and parses the domain-id value
Args:
config (str): The config block to scan
Returns:
dict: A dict object that is intended to be merged into the
resource dict
"""
match = re.sea... | python | {
"resource": ""
} |
q19781 | Mlag._parse_local_interface | train | def _parse_local_interface(self, config):
"""Scans the config block and parses the local-interface value
Args:
config (str): The config block to scan
Returns:
dict: A dict object that is intended to be merged into the
resource dict
"""
ma... | python | {
"resource": ""
} |
q19782 | Mlag._parse_peer_address | train | def _parse_peer_address(self, config):
"""Scans the config block and parses the peer-address value
Args:
config (str): The config block to scan
Returns:
dict: A dict object that is intended to be merged into the
resource dict
"""
match = ... | python | {
"resource": ""
} |
q19783 | Mlag._parse_peer_link | train | def _parse_peer_link(self, config):
"""Scans the config block and parses the peer-link value
Args:
config (str): The config block to scan
Returns:
dict: A dict object that is intended to be merged into the
resource dict
"""
match = re.sea... | python | {
"resource": ""
} |
q19784 | Mlag._parse_interfaces | train | def _parse_interfaces(self):
"""Scans the global config and returns the configured interfaces
Returns:
dict: A dict object that is intended to be merged into the
resource dict.
"""
interfaces = dict()
names = re.findall(r'^interface (Po.+)$', self.con... | python | {
"resource": ""
} |
q19785 | Mlag.set_domain_id | train | def set_domain_id(self, value=None, default=False, disable=False):
"""Configures the mlag domain-id value
Args:
value (str): The value to configure the domain-id
default (bool): Configures the domain-id using the default keyword
disable (bool): Negates the domain-id ... | python | {
"resource": ""
} |
q19786 | Mlag.set_local_interface | train | def set_local_interface(self, value=None, default=False, disable=False):
"""Configures the mlag local-interface value
Args:
value (str): The value to configure the local-interface
default (bool): Configures the local-interface using the
default keyword
... | python | {
"resource": ""
} |
q19787 | Mlag.set_peer_address | train | def set_peer_address(self, value=None, default=False, disable=False):
"""Configures the mlag peer-address value
Args:
value (str): The value to configure the peer-address
default (bool): Configures the peer-address using the
default keyword
disable (b... | python | {
"resource": ""
} |
q19788 | Mlag.set_peer_link | train | def set_peer_link(self, value=None, default=False, disable=False):
"""Configures the mlag peer-link value
Args:
value (str): The value to configure the peer-link
default (bool): Configures the peer-link using the
default keyword
disable (bool): Negate... | python | {
"resource": ""
} |
q19789 | Mlag.set_shutdown | train | def set_shutdown(self, default=False, disable=True):
"""Configures the mlag shutdown value
Default setting for set_shutdown is disable=True, meaning
'no shutdown'. Setting both default and disable to False will
effectively enable shutdown.
Args:
default (bool): Conf... | python | {
"resource": ""
} |
q19790 | Mlag.set_mlag_id | train | def set_mlag_id(self, name, value=None, default=False, disable=False):
"""Configures the interface mlag value for the specified interface
Args:
name (str): The interface to configure. Valid values for the
name arg include Port-Channel*
value (str): The mlag iden... | python | {
"resource": ""
} |
q19791 | Bgp.get | train | def get(self):
"""Returns the bgp routing configuration as a dict object
"""
config = self.get_block('^router bgp .*')
if not config:
return None
response = dict()
response.update(self._parse_bgp_as(config))
response.update(self._parse_router_id(confi... | python | {
"resource": ""
} |
q19792 | Ospf.get | train | def get(self, vrf=None):
"""Returns the OSPF routing configuration
Args:
vrf (str): VRF name to return OSPF routing config for
Returns:
dict:
keys: router_id (int): OSPF router-id
vrf (str): VRF of the OSPF proce... | python | {
"resource": ""
} |
q19793 | Ospf._parse_ospf_process_id | train | def _parse_ospf_process_id(self, config):
"""Parses config file for the OSPF proc ID
Args:
config(str): Running configuration
Returns:
dict: key: ospf_process_id (int)
"""
match = re.search(r'^router ospf (\d+)', config)
return dict(o... | python | {
"resource": ""
} |
q19794 | Ospf._parse_vrf | train | def _parse_vrf(self, config):
"""Parses config file for the OSPF vrf name
Args:
config(str): Running configuration
Returns:
dict: key: ospf_vrf (str)
"""
match = re.search(r'^router ospf \d+ vrf (\w+)', config)
if match:
r... | python | {
"resource": ""
} |
q19795 | Ospf._parse_networks | train | def _parse_networks(self, config):
"""Parses config file for the networks advertised
by the OSPF process
Args:
config(str): Running configuration
Returns:
list: dict:
keys: network (str)
netm... | python | {
"resource": ""
} |
q19796 | Ospf._parse_redistribution | train | def _parse_redistribution(self, config):
"""Parses config file for the OSPF router ID
Args:
config (str): Running configuration
Returns:
list: dict:
keys: protocol (str)
route-map (optional) (str)
... | python | {
"resource": ""
} |
q19797 | Ospf.delete | train | def delete(self):
"""Removes the entire ospf process from the running configuration
Args:
None
Returns:
bool: True if the command completed succssfully
"""
config = self.get()
if not config:
return True
command = 'n... | python | {
"resource": ""
} |
q19798 | Ospf.create | train | def create(self, ospf_process_id, vrf=None):
"""Creates a OSPF process in the specified VRF or the default VRF.
Args:
ospf_process_id (str): The OSPF process Id value
vrf (str): The VRF to apply this OSPF process to
Returns:
bool: True if th... | python | {
"resource": ""
} |
q19799 | Ospf.configure_ospf | train | def configure_ospf(self, cmd):
"""Allows for a list of OSPF subcommands to be configured"
Args:
cmd: (list or str): Subcommand to be entered
Returns:
bool: True if all the commands completed successfully
"""
config = self.get()
cmds = ... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.