_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q18000 | option_chooser | train | def option_chooser(options, attr=None):
"""Given an iterable, enumerate its contents for a user to choose from.
If the optional `attr` is not None, that attribute in each iterated
object will be printed.
This function will exit the program if the user chooses the escape option.
"""
for num, opt... | python | {
"resource": ""
} |
q18001 | assure_queue | train | def assure_queue(fnc):
"""
Converts a queue ID or name passed as the 'queue' parameter to a Queue
object.
"""
@wraps(fnc)
def _wrapped(self, queue, *args, **kwargs):
if not isinstance(queue, Queue):
# Must be the ID
queue = self._manager.get(queue)
return ... | python | {
"resource": ""
} |
q18002 | Queue.list | train | def list(self, include_claimed=False, echo=False, marker=None, limit=None):
"""
Returns a list of messages for this queue.
By default only unclaimed messages are returned; if you want claimed
messages included, pass `include_claimed=True`. Also, the requester's
own messages are ... | python | {
"resource": ""
} |
q18003 | Queue.list_by_claim | train | def list_by_claim(self, claim):
"""
Returns a list of all the messages from this queue that have been
claimed by the specified claim. The claim can be either a claim ID or a
QueueClaim object.
"""
if not isinstance(claim, QueueClaim):
claim = self._claim_manag... | python | {
"resource": ""
} |
q18004 | QueueMessage._add_details | train | def _add_details(self, info):
"""
The 'id' and 'claim_id' attributes are not supplied directly, but
included as part of the 'href' value.
"""
super(QueueMessage, self)._add_details(info)
if self.href is None:
return
parsed = urllib.parse.urlparse(self.... | python | {
"resource": ""
} |
q18005 | QueueClaim._add_details | train | def _add_details(self, info):
"""
The 'id' attribute is not supplied directly, but included as part of
the 'href' value. Also, convert the dicts for messages into
QueueMessage objects.
"""
msg_dicts = info.pop("messages", [])
super(QueueClaim, self)._add_details(i... | python | {
"resource": ""
} |
q18006 | QueueMessageManager._iterate_list | train | def _iterate_list(self, include_claimed, echo, marker, limit):
"""
Recursive method to work around the hard limit of 10 items per call.
"""
ret = []
if limit is None:
this_limit = MSG_LIMIT
else:
this_limit = min(MSG_LIMIT, limit)
limit... | python | {
"resource": ""
} |
q18007 | QueueMessageManager.delete | train | def delete(self, msg, claim_id=None):
"""
Deletes the specified message from its queue. If the message has been
claimed, the ID of that claim must be passed as the 'claim_id'
parameter.
"""
msg_id = utils.get_id(msg)
if claim_id:
uri = "/%s/%s?claim_id... | python | {
"resource": ""
} |
q18008 | QueueMessageManager.list_by_ids | train | def list_by_ids(self, ids):
"""
If you wish to retrieve a list of messages from this queue and know the
IDs of those messages, you can pass in a list of those IDs, and only
the matching messages will be returned. This avoids pulling down all
the messages in a queue and filtering ... | python | {
"resource": ""
} |
q18009 | QueueMessageManager.delete_by_ids | train | def delete_by_ids(self, ids):
"""
Deletes the messages whose IDs are passed in from this queue.
"""
ids = utils.coerce_to_list(ids)
uri = "/%s?ids=%s" % (self.uri_base, ",".join(ids))
return self.api.method_delete(uri) | python | {
"resource": ""
} |
q18010 | QueueManager.get | train | def get(self, id_):
"""
Need to customize, since Queues are not returned with normal response
bodies.
"""
if self.api.queue_exists(id_):
return Queue(self, {"queue": {"name": id_, "id_": id_}}, key="queue")
raise exc.NotFound("The queue '%s' does not exist." %... | python | {
"resource": ""
} |
q18011 | QueueManager.get_stats | train | def get_stats(self, queue):
"""
Returns the message stats for the specified queue.
"""
uri = "/%s/%s/stats" % (self.uri_base, utils.get_id(queue))
resp, resp_body = self.api.method_get(uri)
return resp_body.get("messages") | python | {
"resource": ""
} |
q18012 | QueueManager.get_metadata | train | def get_metadata(self, queue):
"""
Returns the metadata for the specified queue.
"""
uri = "/%s/%s/metadata" % (self.uri_base, utils.get_id(queue))
resp, resp_body = self.api.method_get(uri)
return resp_body | python | {
"resource": ""
} |
q18013 | QueueClient._add_custom_headers | train | def _add_custom_headers(self, dct):
"""
Add the Client-ID header required by Cloud Queues
"""
if self.client_id is None:
self.client_id = os.environ.get("CLOUD_QUEUES_ID")
if self.client_id:
dct["Client-ID"] = self.client_id | python | {
"resource": ""
} |
q18014 | QueueClient._api_request | train | def _api_request(self, uri, method, **kwargs):
"""
Any request that involves messages must define the client ID. This
handles all failures due to lack of client ID and raises the
appropriate exception.
"""
try:
return super(QueueClient, self)._api_request(uri,... | python | {
"resource": ""
} |
q18015 | QueueClient.queue_exists | train | def queue_exists(self, name):
"""
Returns True or False, depending on the existence of the named queue.
"""
try:
queue = self._manager.head(name)
return True
except exc.NotFound:
return False | python | {
"resource": ""
} |
q18016 | QueueClient.list_messages | train | def list_messages(self, queue, include_claimed=False, echo=False,
marker=None, limit=None):
"""
Returns a list of messages for the specified queue.
By default only unclaimed messages are returned; if you want claimed
messages included, pass `include_claimed=True`. Also, the ... | python | {
"resource": ""
} |
q18017 | QueueClient.claim_messages | train | def claim_messages(self, queue, ttl, grace, count=None):
"""
Claims up to `count` unclaimed messages from the specified queue. If
count is not specified, the default is to claim 10 messages.
The `ttl` parameter specifies how long the server should wait before
releasing the claim... | python | {
"resource": ""
} |
q18018 | CloudCDNClient.list_services | train | def list_services(self, limit=None, marker=None):
"""List CDN services."""
return self._services_manager.list(limit=limit, marker=marker) | python | {
"resource": ""
} |
q18019 | CloudCDNClient.create_service | train | def create_service(self, name, flavor_id, domains, origins,
restrictions=None, caching=None):
"""Create a new CDN service.
Arguments:
name: The name of the service.
flavor_id: The ID of the flavor to use for this service.
domains: A list of dictionaries, e... | python | {
"resource": ""
} |
q18020 | CloudCDNClient.delete_assets | train | def delete_assets(self, service_id, url=None, all=False):
"""Delete CDN assets
Arguments:
service_id: The ID of the service to delete from.
url: The URL at which to delete assets
all: When True, delete all assets associated with the service_id.
You cannot specifiy both ... | python | {
"resource": ""
} |
q18021 | ServiceCatalog.url_for | train | def url_for(self, attr=None, filter_value=None,
service_type=None, endpoint_type="publicURL",
service_name=None, volume_service_name=None):
"""Fetches the public URL from the given service for
a particular endpoint attribute. If none given, returns
the first. See tests fo... | python | {
"resource": ""
} |
q18022 | CloudLoadBalancer._add_details | train | def _add_details(self, info):
"""Override the base behavior to add Nodes, VirtualIPs, etc."""
for (key, val) in six.iteritems(info):
if key == "nodes":
val = [Node(parent=self, **nd) for nd in val]
elif key == "sessionPersistence":
val = val['persi... | python | {
"resource": ""
} |
q18023 | CloudLoadBalancer.set_metadata_for_node | train | def set_metadata_for_node(self, node, metadata):
"""
Sets the metadata for the specified node to the supplied dictionary
of values. Any existing metadata is cleared.
"""
return self.manager.set_metadata(self, metadata, node=node) | python | {
"resource": ""
} |
q18024 | CloudLoadBalancer.update_metadata_for_node | train | def update_metadata_for_node(self, node, metadata):
"""
Updates the existing metadata for the specified node with
the supplied dictionary.
"""
return self.manager.update_metadata(self, metadata, node=node) | python | {
"resource": ""
} |
q18025 | CloudLoadBalancerManager._create_body | train | def _create_body(self, name, port=None, protocol=None, nodes=None,
virtual_ips=None, algorithm=None, halfClosed=None, accessList=None,
connectionLogging=None, connectionThrottle=None, healthMonitor=None,
metadata=None, timeout=None, sessionPersistence=None,
httpsRedirect=... | python | {
"resource": ""
} |
q18026 | CloudLoadBalancerManager.add_nodes | train | def add_nodes(self, lb, nodes):
"""Adds the list of nodes to the specified load balancer."""
if not isinstance(nodes, (list, tuple)):
nodes = [nodes]
node_dicts = [nd.to_dict() for nd in nodes]
resp, body = self.api.method_post("/loadbalancers/%s/nodes" % lb.id,
... | python | {
"resource": ""
} |
q18027 | CloudLoadBalancerManager.delete_node | train | def delete_node(self, loadbalancer, node):
"""Removes the node from its load balancer."""
lb = node.parent
if not lb:
raise exc.UnattachedNode("No parent Load Balancer for this node "
"could be determined.")
resp, body = self.api.method_delete("/loadbalanc... | python | {
"resource": ""
} |
q18028 | CloudLoadBalancerManager.add_virtualip | train | def add_virtualip(self, lb, vip):
"""Adds the VirtualIP to the specified load balancer."""
resp, body = self.api.method_post("/loadbalancers/%s/virtualips" % lb.id,
body=vip.to_dict())
return resp, body | python | {
"resource": ""
} |
q18029 | CloudLoadBalancerManager.delete_virtualip | train | def delete_virtualip(self, loadbalancer, vip):
"""Deletes the VirtualIP from its load balancer."""
lb = vip.parent
if not lb:
raise exc.UnattachedVirtualIP("No parent Load Balancer for this "
"VirtualIP could be determined.")
resp, body = self.api.method_d... | python | {
"resource": ""
} |
q18030 | CloudLoadBalancerManager.add_access_list | train | def add_access_list(self, loadbalancer, access_list):
"""
Adds the access list provided to the load balancer.
The 'access_list' should be a list of dicts in the following format:
[{"address": "192.0.43.10", "type": "DENY"},
{"address": "192.0.43.11", "type": "ALLOW"},
... | python | {
"resource": ""
} |
q18031 | CloudLoadBalancerManager.delete_access_list | train | def delete_access_list(self, loadbalancer):
"""
Removes the access list from this load balancer.
"""
uri = "/loadbalancers/%s/accesslist" % utils.get_id(loadbalancer)
resp, body = self.api.method_delete(uri)
return body | python | {
"resource": ""
} |
q18032 | CloudLoadBalancerManager.get_health_monitor | train | def get_health_monitor(self, loadbalancer):
"""
Returns a dict representing the health monitor for the load
balancer. If no monitor has been configured, returns an
empty dict.
"""
uri = "/loadbalancers/%s/healthmonitor" % utils.get_id(loadbalancer)
resp, body = se... | python | {
"resource": ""
} |
q18033 | CloudLoadBalancerManager.add_connection_throttle | train | def add_connection_throttle(self, loadbalancer, maxConnectionRate=None,
maxConnections=None, minConnections=None, rateInterval=None):
"""
Creates or updates the connection throttling information for the load
balancer. When first creating the connection throttle, all 4 parameters
... | python | {
"resource": ""
} |
q18034 | CloudLoadBalancerManager.get_ssl_termination | train | def get_ssl_termination(self, loadbalancer):
"""
Returns a dict representing the SSL termination configuration
for the load balancer. If SSL termination has not been configured,
returns an empty dict.
"""
uri = "/loadbalancers/%s/ssltermination" % utils.get_id(loadbalance... | python | {
"resource": ""
} |
q18035 | CloudLoadBalancerManager.get_metadata | train | def get_metadata(self, loadbalancer, node=None, raw=False):
"""
Returns the current metadata for the load balancer. If 'node' is
provided, returns the current metadata for that node.
"""
if node:
uri = "/loadbalancers/%s/nodes/%s/metadata" % (
util... | python | {
"resource": ""
} |
q18036 | CloudLoadBalancerManager.set_metadata | train | def set_metadata(self, loadbalancer, metadata, node=None):
"""
Sets the metadata for the load balancer to the supplied dictionary
of values. Any existing metadata is cleared. If 'node' is provided,
the metadata for that node is set instead of for the load balancer.
"""
# ... | python | {
"resource": ""
} |
q18037 | CloudLoadBalancerManager.update_metadata | train | def update_metadata(self, loadbalancer, metadata, node=None):
"""
Updates the existing metadata with the supplied dictionary. If
'node' is supplied, the metadata for that node is updated instead
of for the load balancer.
"""
# Get the existing metadata
md = self.g... | python | {
"resource": ""
} |
q18038 | CloudLoadBalancerManager.delete_metadata | train | def delete_metadata(self, loadbalancer, keys=None, node=None):
"""
Deletes metadata items specified by the 'keys' parameter. If no value
for 'keys' is provided, all metadata is deleted. If 'node' is supplied,
the metadata for that node is deleted instead of the load balancer.
"""... | python | {
"resource": ""
} |
q18039 | CloudLoadBalancerManager.set_error_page | train | def set_error_page(self, loadbalancer, html):
"""
A single custom error page may be added per account load balancer
with an HTTP protocol. Page updates will override existing content.
If a custom error page is deleted, or the load balancer is changed
to a non-HTTP protocol, the d... | python | {
"resource": ""
} |
q18040 | CloudLoadBalancerManager.get_session_persistence | train | def get_session_persistence(self, loadbalancer):
"""
Returns the session persistence setting for the given load balancer.
"""
uri = "/loadbalancers/%s/sessionpersistence" % utils.get_id(loadbalancer)
resp, body = self.api.method_get(uri)
ret = body["sessionPersistence"].g... | python | {
"resource": ""
} |
q18041 | CloudLoadBalancerManager.set_session_persistence | train | def set_session_persistence(self, loadbalancer, val):
"""
Sets the session persistence for the given load balancer.
"""
val = val.upper()
uri = "/loadbalancers/%s/sessionpersistence" % utils.get_id(loadbalancer)
req_body = {"sessionPersistence": {
"persist... | python | {
"resource": ""
} |
q18042 | CloudLoadBalancerManager.get_connection_logging | train | def get_connection_logging(self, loadbalancer):
"""
Returns the connection logging setting for the given load balancer.
"""
uri = "/loadbalancers/%s/connectionlogging" % utils.get_id(loadbalancer)
resp, body = self.api.method_get(uri)
ret = body.get("connectionLogging", {... | python | {
"resource": ""
} |
q18043 | CloudLoadBalancerManager.set_connection_logging | train | def set_connection_logging(self, loadbalancer, val):
"""
Sets the connection logging for the given load balancer.
"""
uri = "/loadbalancers/%s/connectionlogging" % utils.get_id(loadbalancer)
val = str(val).lower()
req_body = {"connectionLogging": {
"enable... | python | {
"resource": ""
} |
q18044 | CloudLoadBalancerManager._get_lb | train | def _get_lb(self, lb_or_id):
"""
Accepts either a loadbalancer or the ID of a loadbalancer, and returns
the CloudLoadBalancer instance.
"""
if isinstance(lb_or_id, CloudLoadBalancer):
ret = lb_or_id
else:
ret = self.get(lb_or_id)
return ret | python | {
"resource": ""
} |
q18045 | Node.to_dict | train | def to_dict(self):
"""Convert this Node to a dict representation for passing to the API."""
return {"address": self.address,
"port": self.port,
"condition": self.condition,
"type": self.type,
"id": self.id,
} | python | {
"resource": ""
} |
q18046 | Node.update | train | def update(self):
"""
Pushes any local changes to the object up to the actual load
balancer node.
"""
diff = self._diff()
if not diff:
# Nothing to do!
return
self.parent.update_node(self, diff) | python | {
"resource": ""
} |
q18047 | Node.get_device | train | def get_device(self):
"""
Returns a reference to the device that is represented by this node.
Returns None if no such device can be determined.
"""
addr = self.address
servers = [server for server in pyrax.cloudservers.list()
if addr in server.networks.get... | python | {
"resource": ""
} |
q18048 | VirtualIP.to_dict | train | def to_dict(self):
"""
Convert this VirtualIP to a dict representation for passing
to the API.
"""
if self.id:
return {"id": self.id}
return {"type": self.type, "ipVersion": self.ip_version} | python | {
"resource": ""
} |
q18049 | CloudLoadBalancerClient.allowed_domains | train | def allowed_domains(self):
"""
This property lists the allowed domains for a load balancer.
The allowed domains are restrictions set for the allowed domain names
used for adding load balancer nodes. In order to submit a domain name
as an address for the load balancer node to add... | python | {
"resource": ""
} |
q18050 | CloudLoadBalancerClient.algorithms | train | def algorithms(self):
"""
Returns a list of available load balancing algorithms.
"""
if self._algorithms is None:
uri = "/loadbalancers/algorithms"
resp, body = self.method_get(uri)
self._algorithms = [alg["name"] for alg in body["algorithms"]]
... | python | {
"resource": ""
} |
q18051 | CloudLoadBalancerClient.protocols | train | def protocols(self):
"""
Returns a list of available load balancing protocols.
"""
if self._protocols is None:
uri = "/loadbalancers/protocols"
resp, body = self.method_get(uri)
self._protocols = [proto["name"] for proto in body["protocols"]]
r... | python | {
"resource": ""
} |
q18052 | safe_int | train | def safe_int(val, allow_zero=True):
"""
This function converts the six.moves.input values to integers. It handles
invalid entries, and optionally forbids values of zero.
"""
try:
ret = int(val)
except ValueError:
print("Sorry, '%s' is not a valid integer." % val)
return F... | python | {
"resource": ""
} |
q18053 | from_response | train | def from_response(response, body):
"""
Return an instance of a ClientException or subclass
based on an httplib2 response.
Usage::
resp, body = http.request(...)
if resp.status_code != 200:
raise exception_from_response(resp, body)
"""
if isinstance(response, dict):
... | python | {
"resource": ""
} |
q18054 | assure_image | train | def assure_image(fnc):
"""
Converts a image ID passed as the 'image' parameter to a image object.
"""
@wraps(fnc)
def _wrapped(self, img, *args, **kwargs):
if not isinstance(img, Image):
# Must be the ID
img = self._manager.get(img)
return fnc(self, img, *args... | python | {
"resource": ""
} |
q18055 | ImageManager.list_all | train | def list_all(self, name=None, visibility=None, member_status=None,
owner=None, tag=None, status=None, size_min=None, size_max=None,
sort_key=None, sort_dir=None):
"""
Returns all of the images in one call, rather than in paginated batches.
"""
def strip_version(u... | python | {
"resource": ""
} |
q18056 | ImageManager.update_image_member | train | def update_image_member(self, img_id, status):
"""
Updates the image whose ID is given with the status specified. This
must be called by the user whose project_id is in the members for the
image. If called by the owner of the image, an InvalidImageMember
exception will be raised.... | python | {
"resource": ""
} |
q18057 | ImageMemberManager.create | train | def create(self, name, *args, **kwargs):
"""
Need to wrap the default call to handle exceptions.
"""
try:
return super(ImageMemberManager, self).create(name, *args, **kwargs)
except Exception as e:
if e.http_status == 403:
raise exc.Unshara... | python | {
"resource": ""
} |
q18058 | ImageTasksManager.create | train | def create(self, name, *args, **kwargs):
"""
Standard task creation, but first check for the existence of the
containers, and raise an exception if they don't exist.
"""
cont = kwargs.get("cont")
if cont:
# Verify that it exists. If it doesn't, a NoSuchContain... | python | {
"resource": ""
} |
q18059 | JSONSchemaManager.images | train | def images(self):
"""
Returns a json-schema document that represents an image members entity,
which is a container of image member entities.
"""
uri = "/%s/images" % self.uri_base
resp, resp_body = self.api.method_get(uri)
return resp_body | python | {
"resource": ""
} |
q18060 | JSONSchemaManager.image | train | def image(self):
"""
Returns a json-schema document that represents a single image entity.
"""
uri = "/%s/image" % self.uri_base
resp, resp_body = self.api.method_get(uri)
return resp_body | python | {
"resource": ""
} |
q18061 | JSONSchemaManager.image_tasks | train | def image_tasks(self):
"""
Returns a json-schema document that represents a container of tasks
entities.
"""
uri = "/%s/tasks" % self.uri_base
resp, resp_body = self.api.method_get(uri)
return resp_body | python | {
"resource": ""
} |
q18062 | JSONSchemaManager.image_task | train | def image_task(self):
"""
Returns a json-schema document that represents an task entity.
"""
uri = "/%s/task" % self.uri_base
resp, resp_body = self.api.method_get(uri)
return resp_body | python | {
"resource": ""
} |
q18063 | ImageClient.export_task | train | def export_task(self, img, cont):
"""
Creates a task to export the specified image to the swift container
named in the 'cont' parameter. If the container does not exist, a
NoSuchContainer exception is raised.
The 'img' parameter can be either an Image object or the ID of an
... | python | {
"resource": ""
} |
q18064 | ImageClient.import_task | train | def import_task(self, img, cont, img_format=None, img_name=None):
"""
Creates a task to import the specified image from the swift container
named in the 'cont' parameter. The new image will be named the same as
the object in the container unless you specify a value for the
'img_n... | python | {
"resource": ""
} |
q18065 | set_setting | train | def set_setting(key, val, env=None):
"""
Changes the value of the specified key in the current environment, or in
another environment if specified.
"""
return settings.set(key, val, env=env) | python | {
"resource": ""
} |
q18066 | create_context | train | def create_context(id_type=None, env=None, username=None, password=None,
tenant_id=None, tenant_name=None, api_key=None, verify_ssl=None):
"""
Returns an instance of the specified identity class, or if none is
specified, an instance of the current setting for 'identity_class'.
You may optionall... | python | {
"resource": ""
} |
q18067 | _create_identity | train | def _create_identity(id_type=None, username=None, password=None, tenant_id=None,
tenant_name=None, api_key=None, verify_ssl=None,
return_context=False):
"""
Creates an instance of the current identity_class and assigns it to the
module-level name 'identity' by default. If 'return_con... | python | {
"resource": ""
} |
q18068 | _assure_identity | train | def _assure_identity(fnc):
"""Ensures that the 'identity' attribute is not None."""
def _wrapped(*args, **kwargs):
if identity is None:
_create_identity()
return fnc(*args, **kwargs)
return _wrapped | python | {
"resource": ""
} |
q18069 | _require_auth | train | def _require_auth(fnc):
"""Authentication decorator."""
@wraps(fnc)
@_assure_identity
def _wrapped(*args, **kwargs):
if not identity.authenticated:
msg = "Authentication required before calling '%s'." % fnc.__name__
raise exc.NotAuthenticated(msg)
return fnc(*args... | python | {
"resource": ""
} |
q18070 | _safe_region | train | def _safe_region(region=None, context=None):
"""Value to use when no region is specified."""
ret = region or settings.get("region")
context = context or identity
if not ret:
# Nothing specified; get the default from the identity object.
if not context:
_create_identity()
... | python | {
"resource": ""
} |
q18071 | auth_with_token | train | def auth_with_token(token, tenant_id=None, tenant_name=None, region=None):
"""
If you already have a valid token and either a tenant ID or name, you can
call this to configure the identity and available services.
"""
global regions, services
identity.auth_with_token(token, tenant_id=tenant_id,
... | python | {
"resource": ""
} |
q18072 | set_credentials | train | def set_credentials(username, api_key=None, password=None, region=None,
tenant_id=None, authenticate=True):
"""
Set the credentials directly, and then try to authenticate.
If the region is passed, it will authenticate against the proper endpoint
for that region, and set the default region for c... | python | {
"resource": ""
} |
q18073 | keyring_auth | train | def keyring_auth(username=None, region=None, authenticate=True):
"""
Use the password stored within the keyring to authenticate. If a username
is supplied, that name is used; otherwise, the keyring_username value
from the config file is used.
If there is no username defined, or if the keyring modul... | python | {
"resource": ""
} |
q18074 | clear_credentials | train | def clear_credentials():
"""De-authenticate by clearing all the names back to None."""
global identity, regions, services, cloudservers, cloudfiles, cloud_cdn
global cloud_loadbalancers, cloud_databases, cloud_blockstorage, cloud_dns
global cloud_networks, cloud_monitoring, autoscale, images, queues
... | python | {
"resource": ""
} |
q18075 | connect_to_services | train | def connect_to_services(region=None):
"""Establishes authenticated connections to the various cloud APIs."""
global cloudservers, cloudfiles, cloud_loadbalancers, cloud_databases
global cloud_blockstorage, cloud_dns, cloud_networks, cloud_monitoring
global autoscale, images, queues, cloud_cdn
clouds... | python | {
"resource": ""
} |
q18076 | _get_service_endpoint | train | def _get_service_endpoint(context, svc, region=None, public=True):
"""
Parses the services dict to get the proper endpoint for the given service.
"""
region = _safe_region(region)
# If a specific context is passed, use that. Otherwise, use the global
# identity reference.
context = context o... | python | {
"resource": ""
} |
q18077 | connect_to_cloudservers | train | def connect_to_cloudservers(region=None, context=None, verify_ssl=None, **kwargs):
"""Creates a client for working with cloud servers."""
context = context or identity
_cs_auth_plugin.discover_auth_systems()
id_type = get_setting("identity_type")
if id_type != "keystone":
auth_plugin = _cs_a... | python | {
"resource": ""
} |
q18078 | connect_to_cloud_cdn | train | def connect_to_cloud_cdn(region=None):
"""Creates a client for working with cloud loadbalancers."""
global default_region
# (nicholaskuechler/keekz) 2017-11-30 - Not a very elegant solution...
# Cloud CDN only exists in 2 regions: DFW and LON
# But this isn't playing nicely with the identity service... | python | {
"resource": ""
} |
q18079 | connect_to_images | train | def connect_to_images(region=None, public=True):
"""Creates a client for working with Images."""
return _create_client(ep_name="image", region=region, public=public) | python | {
"resource": ""
} |
q18080 | connect_to_queues | train | def connect_to_queues(region=None, public=True):
"""Creates a client for working with Queues."""
return _create_client(ep_name="queues", region=region, public=public) | python | {
"resource": ""
} |
q18081 | Settings.get | train | def get(self, key, env=None):
"""
Returns the config setting for the specified environment. If no
environment is specified, the value for the current environment is
returned. If an unknown key or environment is passed, None is returned.
"""
if env is None:
env... | python | {
"resource": ""
} |
q18082 | Settings.set | train | def set(self, key, val, env=None):
"""
Changes the value for the setting specified by 'key' to the new value.
By default this will change the current environment, but you can change
values in other environments by passing the name of that environment as
the 'env' parameter.
... | python | {
"resource": ""
} |
q18083 | Settings.read_config | train | def read_config(self, config_file):
"""
Parses the specified configuration file and stores the values. Raises
an InvalidConfigurationFile exception if the file is not well-formed.
"""
cfg = ConfigParser.SafeConfigParser()
try:
cfg.read(config_file)
exc... | python | {
"resource": ""
} |
q18084 | CloudDNSRecord.update | train | def update(self, data=None, priority=None, ttl=None, comment=None):
"""
Modifies this record.
"""
return self.manager.update_record(self.domain_id, self, data=data,
priority=priority, ttl=ttl, comment=comment) | python | {
"resource": ""
} |
q18085 | CloudDNSDomain.delete | train | def delete(self, delete_subdomains=False):
"""
Deletes this domain and all of its resource records. If this domain has
subdomains, each subdomain will now become a root domain. If you wish to
also delete any subdomains, pass True to 'delete_subdomains'.
"""
self.manager.d... | python | {
"resource": ""
} |
q18086 | CloudDNSDomain.list_subdomains | train | def list_subdomains(self, limit=None, offset=None):
"""
Returns a list of all subdomains for this domain.
"""
return self.manager.list_subdomains(self, limit=limit, offset=offset) | python | {
"resource": ""
} |
q18087 | CloudDNSDomain.list_records | train | def list_records(self, limit=None, offset=None):
"""
Returns a list of all records configured for this domain.
"""
return self.manager.list_records(self, limit=limit, offset=offset) | python | {
"resource": ""
} |
q18088 | CloudDNSDomain.search_records | train | def search_records(self, record_type, name=None, data=None):
"""
Returns a list of all records configured for this domain that match
the supplied search criteria.
"""
return self.manager.search_records(self, record_type=record_type,
name=name, data=data) | python | {
"resource": ""
} |
q18089 | CloudDNSDomain.update_record | train | def update_record(self, record, data=None, priority=None,
ttl=None, comment=None):
"""
Modifies an existing record for this domain.
"""
return self.manager.update_record(self, record, data=data,
priority=priority, ttl=ttl, comment=comment) | python | {
"resource": ""
} |
q18090 | CloudDNSManager._create_body | train | def _create_body(self, name, emailAddress, ttl=3600, comment=None,
subdomains=None, records=None):
"""
Creates the appropriate dict for creating a new domain.
"""
if subdomains is None:
subdomains = []
if records is None:
records = []
b... | python | {
"resource": ""
} |
q18091 | CloudDNSManager._reset_paging | train | def _reset_paging(self, service, body=None):
"""
Resets the internal attributes when there is no current paging request.
"""
if service == "all":
for svc in self._paging.keys():
svc_dct = self._paging[svc]
svc_dct["next_uri"] = svc_dct["prev_ur... | python | {
"resource": ""
} |
q18092 | CloudDNSManager.list | train | def list(self, limit=None, offset=None):
"""Gets a list of all domains, or optionally a page of domains."""
uri = "/%s%s" % (self.uri_base, self._get_pagination_qs(limit, offset))
return self._list(uri) | python | {
"resource": ""
} |
q18093 | CloudDNSManager.list_previous_page | train | def list_previous_page(self):
"""
When paging through results, this will return the previous page, using
the same limit. If there are no more results, a NoMoreResults exception
will be raised.
"""
uri = self._paging.get("domain", {}).get("prev_uri")
if uri is None... | python | {
"resource": ""
} |
q18094 | CloudDNSManager.list_next_page | train | def list_next_page(self):
"""
When paging through results, this will return the next page, using the
same limit. If there are no more results, a NoMoreResults exception
will be raised.
"""
uri = self._paging.get("domain", {}).get("next_uri")
if uri is None:
... | python | {
"resource": ""
} |
q18095 | CloudDNSManager._retry_get | train | def _retry_get(self, uri):
"""
Handles GET calls to the Cloud DNS API in order to retry on empty
body responses.
"""
for i in six.moves.range(DEFAULT_RETRY):
resp, body = self.api.method_get(uri)
if body:
return resp, body
# Tried t... | python | {
"resource": ""
} |
q18096 | CloudDNSManager._process_async_error | train | def _process_async_error(self, resp_body, error_class):
"""
The DNS API does not return a consistent format for their error
messages. This abstracts out the differences in order to present
a single unified message in the exception to be raised.
"""
def _fmt_error(err):
... | python | {
"resource": ""
} |
q18097 | CloudDNSManager.delete | train | def delete(self, domain, delete_subdomains=False):
"""
Deletes the specified domain and all of its resource records. If the
domain has subdomains, each subdomain will now become a root domain. If
you wish to also delete any subdomains, pass True to 'delete_subdomains'.
"""
... | python | {
"resource": ""
} |
q18098 | CloudDNSManager.list_subdomains | train | def list_subdomains(self, domain, limit=None, offset=None):
"""
Returns a list of all subdomains of the specified domain.
"""
# The commented-out uri is the official API, but it is
# horribly slow.
# uri = "/domains/%s/subdomains" % utils.get_id(domain)
uri = "/dom... | python | {
"resource": ""
} |
q18099 | CloudDNSManager.list_subdomains_previous_page | train | def list_subdomains_previous_page(self):
"""
When paging through subdomain results, this will return the previous
page, using the same limit. If there are no more results, a
NoMoreResults exception will be raised.
"""
uri = self._paging.get("subdomain", {}).get("prev_uri"... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.