_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q17900 | assure_snapshot | train | def assure_snapshot(fnc):
"""
Converts a snapshot ID passed as the snapshot to a CloudBlockStorageSnapshot
object.
"""
@wraps(fnc)
def _wrapped(self, snapshot, *args, **kwargs):
if not isinstance(snapshot, CloudBlockStorageSnapshot):
# Must be the ID
snapshot = se... | python | {
"resource": ""
} |
q17901 | CloudBlockStorageSnapshot.delete | train | def delete(self):
"""
Adds a check to make sure that the snapshot is able to be deleted.
"""
if self.status not in ("available", "error"):
raise exc.SnapshotNotAvailable("Snapshot must be in 'available' "
"or 'error' status before deleting. Current status:... | python | {
"resource": ""
} |
q17902 | CloudBlockStorageSnapshot.update | train | def update(self, display_name=None, display_description=None):
"""
Update the specified values on this snapshot. You may specify one or
more values to update. If no values are specified as non-None, the call
is a no-op; no exception will be raised.
"""
return self.manager... | python | {
"resource": ""
} |
q17903 | CloudBlockStorageVolume.attach_to_instance | train | def attach_to_instance(self, instance, mountpoint):
"""
Attaches this volume to the cloud server instance at the
specified mountpoint. This requires a call to the cloud servers
API; it cannot be done directly.
"""
instance_id = _resolve_id(instance)
try:
... | python | {
"resource": ""
} |
q17904 | CloudBlockStorageVolume.detach | train | def detach(self):
"""
Detaches this volume from any device it may be attached to. If it
is not attached, nothing happens.
"""
attachments = self.attachments
if not attachments:
# Not attached; no error needed, just return
return
# A volume ... | python | {
"resource": ""
} |
q17905 | CloudBlockStorageVolume.create_snapshot | train | def create_snapshot(self, name=None, description=None, force=False):
"""
Creates a snapshot of this volume, with an optional name and
description.
Normally snapshots will not happen if the volume is attached. To
override this default behavior, pass force=True.
"""
... | python | {
"resource": ""
} |
q17906 | CloudBlockStorageVolume.list_snapshots | train | def list_snapshots(self):
"""
Returns a list of all snapshots of this volume.
"""
return [snap for snap in self.manager.list_snapshots()
if snap.volume_id == self.id] | python | {
"resource": ""
} |
q17907 | CloudBlockStorageManager._create_body | train | def _create_body(self, name, size=None, volume_type=None, description=None,
metadata=None, snapshot_id=None, clone_id=None,
availability_zone=None, image=None):
"""
Used to create the dict required to create a new volume
"""
if not isinstance(size, six.integer_t... | python | {
"resource": ""
} |
q17908 | CloudBlockStorageManager.create | train | def create(self, *args, **kwargs):
"""
Catches errors that may be returned, and raises more informational
exceptions.
"""
try:
return super(CloudBlockStorageManager, self).create(*args,
**kwargs)
except exc.BadRequest as e:
msg ... | python | {
"resource": ""
} |
q17909 | CloudBlockStorageSnapshotManager._create_body | train | def _create_body(self, name, description=None, volume=None, force=False):
"""
Used to create the dict required to create a new snapshot
"""
body = {"snapshot": {
"display_name": name,
"display_description": description,
"volume_id": volume.... | python | {
"resource": ""
} |
q17910 | CloudBlockStorageClient._configure_manager | train | def _configure_manager(self):
"""
Create the manager to handle the instances, and also another
to handle flavors.
"""
self._manager = CloudBlockStorageManager(self,
resource_class=CloudBlockStorageVolume, response_key="volume",
uri_base="volumes")
... | python | {
"resource": ""
} |
q17911 | CloudBlockStorageClient.create_snapshot | train | def create_snapshot(self, volume, name=None, description=None, force=False):
"""
Creates a snapshot of the volume, with an optional name and description.
Normally snapshots will not happen if the volume is attached. To
override this default behavior, pass force=True.
"""
... | python | {
"resource": ""
} |
q17912 | CloudBlockStorageClient.update_snapshot | train | def update_snapshot(self, snapshot, display_name=None,
display_description=None):
"""
Update the specified values on the specified snapshot. You may specify
one or more values to update.
"""
return snapshot.update(display_name=display_name,
display_des... | python | {
"resource": ""
} |
q17913 | assure_check | train | def assure_check(fnc):
"""
Converts an checkID passed as the check to a CloudMonitorCheck object.
"""
@wraps(fnc)
def _wrapped(self, check, *args, **kwargs):
if not isinstance(check, CloudMonitorCheck):
# Must be the ID
check = self._check_manager.get(check)
r... | python | {
"resource": ""
} |
q17914 | assure_entity | train | def assure_entity(fnc):
"""
Converts an entityID passed as the entity to a CloudMonitorEntity object.
"""
@wraps(fnc)
def _wrapped(self, entity, *args, **kwargs):
if not isinstance(entity, CloudMonitorEntity):
# Must be the ID
entity = self._entity_manager.get(entity)... | python | {
"resource": ""
} |
q17915 | CloudMonitorEntity.get_check | train | def get_check(self, check):
"""
Returns an instance of the specified check.
"""
chk = self._check_manager.get(check)
chk.set_entity(self)
return chk | python | {
"resource": ""
} |
q17916 | CloudMonitorEntity.list_checks | train | def list_checks(self, limit=None, marker=None, return_next=False):
"""
Returns a list of the checks defined for this account. By default the
number returned is limited to 100; you can define the number to return
by optionally passing a value for the 'limit' parameter. The value for
... | python | {
"resource": ""
} |
q17917 | CloudMonitorEntity.create_check | train | def create_check(self, label=None, name=None, check_type=None,
disabled=False, metadata=None, details=None,
monitoring_zones_poll=None, timeout=None, period=None,
target_alias=None, target_hostname=None, target_receiver=None,
test_only=False, include_debug=False):
... | python | {
"resource": ""
} |
q17918 | CloudMonitorEntity.create_alarm | train | def create_alarm(self, check, notification_plan, criteria=None,
disabled=False, label=None, name=None, metadata=None):
"""
Creates an alarm that binds the check on this entity with a
notification plan.
"""
return self._alarm_manager.create(check, notification_plan,
... | python | {
"resource": ""
} |
q17919 | CloudMonitorEntity.update_alarm | train | def update_alarm(self, alarm, criteria=None, disabled=False,
label=None, name=None, metadata=None):
"""
Updates an existing alarm on this entity.
"""
return self._alarm_manager.update(alarm, criteria=criteria,
disabled=disabled, label=label, name=name, metadat... | python | {
"resource": ""
} |
q17920 | CloudMonitorEntity.list_alarms | train | def list_alarms(self, limit=None, marker=None, return_next=False):
"""
Returns a list of all the alarms created on this entity.
"""
return self._alarm_manager.list(limit=limit, marker=marker,
return_next=return_next) | python | {
"resource": ""
} |
q17921 | _PaginationManager.list | train | def list(self, limit=None, marker=None, return_next=False):
"""
This is necessary to handle pagination correctly, as the Monitoring
service defines 'marker' differently than most other services. For
monitoring, 'marker' represents the first item in the next page,
whereas other se... | python | {
"resource": ""
} |
q17922 | CloudMonitorNotificationManager.update_notification | train | def update_notification(self, notification, details):
"""
Updates the specified notification with the supplied details.
"""
if isinstance(notification, CloudMonitorNotification):
nid = notification.id
ntyp = notification.type
else:
# Supplied a... | python | {
"resource": ""
} |
q17923 | CloudMonitorNotificationManager.list_types | train | def list_types(self):
"""
Returns a list of all available notification types.
"""
uri = "/notification_types"
resp, resp_body = self.api.method_get(uri)
return [CloudMonitorNotificationType(self, info)
for info in resp_body["values"]] | python | {
"resource": ""
} |
q17924 | CloudMonitorNotificationManager.get_type | train | def get_type(self, notification_type_id):
"""
Returns a CloudMonitorNotificationType object for the given ID.
"""
uri = "/notification_types/%s" % utils.get_id(notification_type_id)
resp, resp_body = self.api.method_get(uri)
return CloudMonitorNotificationType(self, resp_... | python | {
"resource": ""
} |
q17925 | CloudMonitorAlarmManager.create | train | def create(self, check, notification_plan, criteria=None,
disabled=False, label=None, name=None, metadata=None):
"""
Creates an alarm that binds the check on the given entity with a
notification plan.
Note that the 'criteria' parameter, if supplied, should be a string
... | python | {
"resource": ""
} |
q17926 | CloudMonitorCheckManager.create_check | train | def create_check(self, label=None, name=None, check_type=None,
details=None, disabled=False, metadata=None,
monitoring_zones_poll=None, timeout=None, period=None,
target_alias=None, target_hostname=None, target_receiver=None,
test_only=False, include_debug=False):
... | python | {
"resource": ""
} |
q17927 | _EntityFilteringManger.list | train | def list(self, entity=None):
"""
Returns a dictionary of data, optionally filtered for a given entity.
"""
uri = "/%s" % self.uri_base
if entity:
uri = "%s?entityId=%s" % (uri, utils.get_id(entity))
resp, resp_body = self._list(uri, return_raw=True)
re... | python | {
"resource": ""
} |
q17928 | CloudMonitorEntityManager._create_body | train | def _create_body(self, name, label=None, agent=None, ip_addresses=None,
metadata=None):
"""
Used to create the dict required to create various resources. Accepts
either 'label' or 'name' as the keyword parameter for the label
attribute for entities.
"""
label ... | python | {
"resource": ""
} |
q17929 | CloudMonitorEntityManager.update_entity | train | def update_entity(self, entity, agent=None, metadata=None):
"""
Updates the specified entity's values with the supplied parameters.
"""
body = {}
if agent:
body["agent_id"] = utils.get_id(agent)
if metadata:
body["metadata"] = metadata
if b... | python | {
"resource": ""
} |
q17930 | CloudMonitorCheck.get | train | def get(self):
"""Reloads the check with its current values."""
new = self.manager.get(self)
if new:
self._add_details(new._info) | python | {
"resource": ""
} |
q17931 | CloudMonitorCheck.list_metrics | train | def list_metrics(self, limit=None, marker=None, return_next=False):
"""
Returns a list of all the metrics associated with this check.
"""
return self._metrics_manager.list(limit=limit, marker=marker,
return_next=return_next) | python | {
"resource": ""
} |
q17932 | CloudMonitorCheck.create_alarm | train | def create_alarm(self, notification_plan, criteria=None, disabled=False,
label=None, name=None, metadata=None):
"""
Creates an alarm that binds this check with a notification plan.
"""
return self.manager.create_alarm(self.entity, self, notification_plan,
crit... | python | {
"resource": ""
} |
q17933 | CloudMonitorAlarm.get | train | def get(self):
"""
Fetches the current state of the alarm from the API and updates the
object.
"""
new_alarm = self.entity.get_alarm(self)
if new_alarm:
self._add_details(new_alarm._info) | python | {
"resource": ""
} |
q17934 | CloudMonitorClient.list_metrics | train | def list_metrics(self, entity, check, limit=None, marker=None,
return_next=False):
"""
Returns a list of all the metrics associated with the specified check.
"""
return entity.list_metrics(check, limit=limit, marker=marker,
return_next=return_next) | python | {
"resource": ""
} |
q17935 | CloudMonitorClient.create_notification_plan | train | def create_notification_plan(self, label=None, name=None,
critical_state=None, ok_state=None, warning_state=None):
"""
Creates a notification plan to be executed when a monitoring check
triggers an alarm.
"""
return self._notification_plan_manager.create(label=label, ... | python | {
"resource": ""
} |
q17936 | CloudMonitorClient.update_alarm | train | def update_alarm(self, entity, alarm, criteria=None, disabled=False,
label=None, name=None, metadata=None):
"""
Updates an existing alarm on the given entity.
"""
return entity.update_alarm(alarm, criteria=criteria, disabled=disabled,
label=label, name=name, metad... | python | {
"resource": ""
} |
q17937 | CloudMonitorClient.list_alarms | train | def list_alarms(self, entity, limit=None, marker=None, return_next=False):
"""
Returns a list of all the alarms created on the specified entity.
"""
return entity.list_alarms(limit=limit, marker=marker,
return_next=return_next) | python | {
"resource": ""
} |
q17938 | assure_container | train | def assure_container(fnc):
"""
Assures that whether a Container or a name of a container is passed, a
Container object is available.
"""
@wraps(fnc)
def _wrapped(self, container, *args, **kwargs):
if not isinstance(container, Container):
# Must be the name
contain... | python | {
"resource": ""
} |
q17939 | _massage_metakeys | train | def _massage_metakeys(dct, prfx):
"""
Returns a copy of the supplied dictionary, prefixing any keys that do
not begin with the specified prefix accordingly.
"""
lowprefix = prfx.lower()
ret = {}
for k, v in list(dct.items()):
if not k.lower().startswith(lowprefix):
k = "%... | python | {
"resource": ""
} |
q17940 | get_file_size | train | def get_file_size(fileobj):
"""
Returns the size of a file-like object.
"""
currpos = fileobj.tell()
fileobj.seek(0, 2)
total_size = fileobj.tell()
fileobj.seek(currpos)
return total_size | python | {
"resource": ""
} |
q17941 | Container._set_cdn_defaults | train | def _set_cdn_defaults(self):
"""Sets all the CDN-related attributes to default values."""
if self._cdn_enabled is FAULT:
self._cdn_enabled = False
self._cdn_uri = None
self._cdn_ttl = DEFAULT_CDN_TTL
self._cdn_ssl_uri = None
self._cdn_streaming_uri = None
... | python | {
"resource": ""
} |
q17942 | Container._fetch_cdn_data | train | def _fetch_cdn_data(self):
"""Fetches the container's CDN data from the CDN service"""
if self._cdn_enabled is FAULT:
headers = self.manager.fetch_cdn_data(self)
else:
headers = {}
# Set defaults in case not all headers are present.
self._set_cdn_defaults(... | python | {
"resource": ""
} |
q17943 | Container.get_object | train | def get_object(self, item):
"""
Returns a StorageObject matching the specified item. If no such object
exists, a NotFound exception is raised. If 'item' is not a string, that
item is returned unchanged.
"""
if isinstance(item, six.string_types):
item = self.ob... | python | {
"resource": ""
} |
q17944 | Container.store_object | train | def store_object(self, obj_name, data, content_type=None, etag=None,
content_encoding=None, ttl=None, return_none=False,
headers=None, extra_info=None):
"""
Creates a new object in this container, and populates it with the given
data. A StorageObject reference to the uplo... | python | {
"resource": ""
} |
q17945 | Container.upload_file | train | def upload_file(self, file_or_path, obj_name=None, content_type=None,
etag=None, return_none=False, content_encoding=None, ttl=None,
content_length=None, headers=None):
"""
Uploads the specified file to this container. If no name is supplied,
the file's name will be used.... | python | {
"resource": ""
} |
q17946 | Container.delete | train | def delete(self, del_objects=False):
"""
Deletes this Container. If the container contains objects, the
command will fail unless 'del_objects' is passed as True. In that
case, each object will be deleted first, and then the container.
"""
return self.manager.delete(self, ... | python | {
"resource": ""
} |
q17947 | Container.delete_object_in_seconds | train | def delete_object_in_seconds(self, obj, seconds, extra_info=None):
"""
Sets the object in this container to be deleted after the specified
number of seconds.
The 'extra_info' parameter is included for backwards compatibility. It
is no longer used at all, and will not be modified... | python | {
"resource": ""
} |
q17948 | Container.change_object_content_type | train | def change_object_content_type(self, obj, new_ctype, guess=False):
"""
Copies object to itself, but applies a new content-type. The guess
feature requires this container to be CDN-enabled. If not, then the
content-type must be supplied. If using guess with a CDN-enabled
container... | python | {
"resource": ""
} |
q17949 | Container.get_temp_url | train | def get_temp_url(self, obj, seconds, method="GET", key=None, cached=True):
"""
Given a storage object in this container, returns a URL that can be
used to access that object. The URL will expire after `seconds`
seconds.
The only methods supported are GET and PUT. Anything else w... | python | {
"resource": ""
} |
q17950 | ContainerManager.list | train | def list(self, limit=None, marker=None, end_marker=None, prefix=None):
"""
Swift doesn't return listings in the same format as the rest of
OpenStack, so this method has to be overriden.
"""
uri = "/%s" % self.uri_base
qs = utils.dict_to_qs({"marker": marker, "limit": limi... | python | {
"resource": ""
} |
q17951 | ContainerManager.get | train | def get(self, container):
"""
Returns a Container matching the specified container name. If no such
container exists, a NoSuchContainer exception is raised.
"""
name = utils.get_name(container)
uri = "/%s" % name
resp, resp_body = self.api.method_head(uri)
... | python | {
"resource": ""
} |
q17952 | ContainerManager.create | train | def create(self, name, metadata=None, prefix=None, *args, **kwargs):
"""
Creates a new container, and returns a Container object that represents
that contianer. If a container by the same name already exists, no
exception is raised; instead, a reference to that existing container is
... | python | {
"resource": ""
} |
q17953 | ContainerManager.fetch_cdn_data | train | def fetch_cdn_data(self, container):
"""
Returns a dict containing the CDN information for the specified
container. If the container is not CDN-enabled, returns an empty dict.
"""
name = utils.get_name(container)
uri = "/%s" % name
try:
resp, resp_body... | python | {
"resource": ""
} |
q17954 | ContainerManager.get_headers | train | def get_headers(self, container):
"""
Return the headers for the specified container.
"""
uri = "/%s" % utils.get_name(container)
resp, resp_body = self.api.method_head(uri)
return resp.headers | python | {
"resource": ""
} |
q17955 | ContainerManager.get_account_metadata | train | def get_account_metadata(self, prefix=None):
"""
Returns a dictionary containing metadata about the account.
"""
headers = self.get_account_headers()
if prefix is None:
prefix = ACCOUNT_META_PREFIX
low_prefix = prefix.lower()
ret = {}
for hkey,... | python | {
"resource": ""
} |
q17956 | ContainerManager.delete_account_metadata | train | def delete_account_metadata(self, prefix=None):
"""
Removes all metadata matching the specified prefix from the account.
By default, the standard account metadata prefix ('X-Account-Meta-') is
prepended to the header name if it isn't present. For non-standard
headers, you must i... | python | {
"resource": ""
} |
q17957 | ContainerManager.remove_metadata_key | train | def remove_metadata_key(self, container, key):
"""
Removes the specified key from the container's metadata. If the key
does not exist in the metadata, nothing is done.
"""
meta_dict = {key: ""}
return self.set_metadata(container, meta_dict) | python | {
"resource": ""
} |
q17958 | ContainerManager.delete_metadata | train | def delete_metadata(self, container, prefix=None):
"""
Removes all of the container's metadata.
By default, all metadata beginning with the standard container metadata
prefix ('X-Container-Meta-') is removed. If you wish to remove all
metadata beginning with a different prefix, ... | python | {
"resource": ""
} |
q17959 | ContainerManager.get_cdn_metadata | train | def get_cdn_metadata(self, container):
"""
Returns a dictionary containing the CDN metadata for the container. If
the container does not exist, a NotFound exception is raised. If the
container exists, but is not CDN-enabled, a NotCDNEnabled exception is
raised.
"""
... | python | {
"resource": ""
} |
q17960 | ContainerManager.list_public_containers | train | def list_public_containers(self):
"""
Returns a list of the names of all CDN-enabled containers.
"""
resp, resp_body = self.api.cdn_request("", "GET")
return [cont["name"] for cont in resp_body] | python | {
"resource": ""
} |
q17961 | ContainerManager._set_cdn_access | train | def _set_cdn_access(self, container, public, ttl=None):
"""
Enables or disables CDN access for the specified container, and
optionally sets the TTL for the container when enabling access.
"""
headers = {"X-Cdn-Enabled": "%s" % public}
if public and ttl:
header... | python | {
"resource": ""
} |
q17962 | ContainerManager.get_cdn_log_retention | train | def get_cdn_log_retention(self, container):
"""
Returns the status of the setting for CDN log retention for the
specified container.
"""
resp, resp_body = self.api.cdn_request("/%s" %
utils.get_name(container), method="HEAD")
return resp.headers.get("x-log... | python | {
"resource": ""
} |
q17963 | ContainerManager.set_cdn_log_retention | train | def set_cdn_log_retention(self, container, enabled):
"""
Enables or disables whether CDN access logs for the specified container
are collected and stored on Cloud Files.
"""
headers = {"X-Log-Retention": "%s" % enabled}
self.api.cdn_request("/%s" % utils.get_name(containe... | python | {
"resource": ""
} |
q17964 | ContainerManager.get_container_streaming_uri | train | def get_container_streaming_uri(self, container):
"""
Returns the URI for streaming content, or None if CDN is not enabled.
"""
resp, resp_body = self.api.cdn_request("/%s" %
utils.get_name(container), method="HEAD")
return resp.headers.get("x-cdn-streaming-uri") | python | {
"resource": ""
} |
q17965 | ContainerManager.set_web_index_page | train | def set_web_index_page(self, container, page):
"""
Sets the header indicating the index page in a container
when creating a static website.
Note: the container must be CDN-enabled for this to have
any effect.
"""
headers = {"X-Container-Meta-Web-Index": "%s" % pa... | python | {
"resource": ""
} |
q17966 | ContainerManager.list_objects | train | def list_objects(self, container, limit=None, marker=None, prefix=None,
delimiter=None, end_marker=None, full_listing=False):
"""
Return a list of StorageObjects representing the objects in this
container. You can use the marker, end_marker, and limit params to
handle paginat... | python | {
"resource": ""
} |
q17967 | ContainerManager.list_object_names | train | def list_object_names(self, container, marker=None, limit=None, prefix=None,
delimiter=None, end_marker=None, full_listing=False):
"""
Return a list of then names of the objects in this container. You can
use the marker, end_marker, and limit params to handle pagination, and
... | python | {
"resource": ""
} |
q17968 | ContainerManager.change_object_content_type | train | def change_object_content_type(self, container, obj, new_ctype,
guess=False):
"""
Copies object to itself, but applies a new content-type. The guess
feature requires the container to be CDN-enabled. If not, then the
content-type must be supplied. If using guess with a CDN-ena... | python | {
"resource": ""
} |
q17969 | StorageObject.copy | train | def copy(self, new_container, new_obj_name=None, extra_info=None):
"""
Copies this object to the new container, optionally giving it a new
name. If you copy to the same container, you must supply a different
name.
"""
return self.container.copy_object(self, new_container... | python | {
"resource": ""
} |
q17970 | StorageObject.move | train | def move(self, new_container, new_obj_name=None, extra_info=None):
"""
Works just like copy_object, except that this object is deleted after a
successful copy. This means that this storage_object reference will no
longer be valid.
"""
return self.container.move_object(sel... | python | {
"resource": ""
} |
q17971 | StorageObject.get_temp_url | train | def get_temp_url(self, seconds, method="GET"):
"""
Returns a URL that can be used to access this object. The URL will
expire after `seconds` seconds.
The only methods supported are GET and PUT. Anything else will raise
an InvalidTemporaryURLMethod exception.
"""
... | python | {
"resource": ""
} |
q17972 | StorageObjectManager.get | train | def get(self, obj):
"""
Gets the information about the specified object.
This overrides the base behavior, since Swift uses HEAD to get
information, and GET to download the object.
"""
name = utils.get_name(obj)
uri = "/%s/%s" % (self.uri_base, name)
resp... | python | {
"resource": ""
} |
q17973 | StorageObjectManager._upload | train | def _upload(self, obj_name, content, content_type, content_encoding,
content_length, etag, chunked, chunk_size, headers):
"""
Handles the uploading of content, including working around the 5GB
maximum file size.
"""
if content_type is not None:
headers["Co... | python | {
"resource": ""
} |
q17974 | StorageObjectManager._store_object | train | def _store_object(self, obj_name, content, etag=None, chunked=False,
chunk_size=None, headers=None):
"""
Handles the low-level creation of a storage object and the uploading of
the contents of that object.
"""
head_etag = headers.pop("ETag", "")
if chunked:
... | python | {
"resource": ""
} |
q17975 | StorageObjectManager._fetch_chunker | train | def _fetch_chunker(self, uri, chunk_size, size, obj_size):
"""
Returns a generator that returns an object in chunks.
"""
pos = 0
total_bytes = 0
size = size or obj_size
max_size = min(size, obj_size)
while True:
endpos = min(obj_size, pos + chu... | python | {
"resource": ""
} |
q17976 | StorageObjectManager.remove_metadata_key | train | def remove_metadata_key(self, obj, key):
"""
Removes the specified key from the object's metadata. If the key does
not exist in the metadata, nothing is done.
"""
meta_dict = {key: ""}
return self.set_metadata(obj, meta_dict) | python | {
"resource": ""
} |
q17977 | StorageClient._configure_cdn | train | def _configure_cdn(self):
"""
Initialize CDN-related endpoints, if available.
"""
ident = self.identity
cdn_svc = ident.services.get("object_cdn")
if cdn_svc:
ep = cdn_svc.endpoints.get(self.region_name)
if ep:
self.cdn_management_u... | python | {
"resource": ""
} |
q17978 | StorageClient._backwards_aliases | train | def _backwards_aliases(self):
"""
In order to keep this backwards-compatible with previous versions,
alias the old names to the new methods.
"""
self.list_containers = self.list_container_names
self.get_all_containers = self.list
self.get_container = self.get
... | python | {
"resource": ""
} |
q17979 | StorageClient.get | train | def get(self, item):
"""
Returns the container whose name is provided as 'item'. If 'item' is
not a string, the original item is returned unchanged.
"""
if isinstance(item, six.string_types):
item = super(StorageClient, self).get(item)
return item | python | {
"resource": ""
} |
q17980 | StorageClient._configure_manager | train | def _configure_manager(self):
"""
Creates a manager to handle interacting with Containers.
"""
self._manager = ContainerManager(self, resource_class=Container,
response_key="", uri_base="") | python | {
"resource": ""
} |
q17981 | StorageClient.get_account_details | train | def get_account_details(self):
"""
Returns a dictionary containing information about the account.
"""
headers = self._manager.get_account_headers()
acct_prefix = "x-account-"
meta_prefix = ACCOUNT_META_PREFIX.lower()
ret = {}
for hkey, hval in list(headers... | python | {
"resource": ""
} |
q17982 | StorageClient.get_account_info | train | def get_account_info(self):
"""
Returns a tuple for the number of containers and total bytes in the
account.
"""
headers = self._manager.get_account_headers()
return (headers.get("x-account-container-count"),
headers.get("x-account-bytes-used")) | python | {
"resource": ""
} |
q17983 | StorageClient.get_temp_url_key | train | def get_temp_url_key(self, cached=True):
"""
Returns the current TempURL key, or None if it has not been set.
By default the value returned is cached. To force an API call to get
the current value on the server, pass `cached=False`.
"""
meta = self._cached_temp_url_key
... | python | {
"resource": ""
} |
q17984 | StorageClient.set_temp_url_key | train | def set_temp_url_key(self, key=None):
"""
Sets the key for the Temporary URL for the account. It should be a key
that is secret to the owner.
If no key is provided, a UUID value will be generated and used. It can
later be obtained by calling get_temp_url_key().
"""
... | python | {
"resource": ""
} |
q17985 | StorageClient.list | train | def list(self, limit=None, marker=None, end_marker=None, prefix=None):
"""
List the containers in this account, using the parameters to control
the pagination of containers, since by default only the first 10,000
containers are returned.
"""
return self._manager.list(limi... | python | {
"resource": ""
} |
q17986 | StorageClient.list_container_object_names | train | def list_container_object_names(self, container, limit=None, marker=None,
prefix=None, delimiter=None, full_listing=False):
"""
Returns the names of all the objects in the specified container,
optionally limited by the pagination parameters.
"""
return self._manager.l... | python | {
"resource": ""
} |
q17987 | StorageClient.delete_container_metadata | train | def delete_container_metadata(self, container, prefix=None):
"""
Removes all of thethe container's metadata.
By default, all metadata beginning with the standard container metadata
prefix ('X-Container-Meta-') is removed. If you wish to remove all
metadata beginning with a diffe... | python | {
"resource": ""
} |
q17988 | StorageClient.list_container_objects | train | def list_container_objects(self, container, limit=None, marker=None,
prefix=None, delimiter=None, end_marker=None, full_listing=False):
"""
Return a list of StorageObjects representing the objects in the
container. You can use the marker, end_marker, and limit params to
handl... | python | {
"resource": ""
} |
q17989 | StorageClient.store_object | train | def store_object(self, container, obj_name, data, content_type=None,
etag=None, content_encoding=None, ttl=None, return_none=False,
chunk_size=None, headers=None, metadata=None, extra_info=None):
"""
Creates a new object in the specified container, and populates it with
t... | python | {
"resource": ""
} |
q17990 | StorageClient.upload_file | train | def upload_file(self, container, file_or_path, obj_name=None,
content_type=None, etag=None, content_encoding=None, ttl=None,
content_length=None, return_none=False, headers=None,
metadata=None, extra_info=None):
"""
Uploads the specified file to the container. If no n... | python | {
"resource": ""
} |
q17991 | StorageClient.fetch_partial | train | def fetch_partial(self, container, obj, size):
"""
Returns the first 'size' bytes of an object. If the object is smaller
than the specified 'size' value, the entire object is returned.
"""
return self._manager.fetch_partial(container, obj, size) | python | {
"resource": ""
} |
q17992 | StorageClient.upload_folder | train | def upload_folder(self, folder_path, container=None, ignore=None, ttl=None):
"""
Convenience method for uploading an entire folder, including any
sub-folders, to Cloud Files.
All files will be uploaded to objects with the same name as the file.
In the case of nested folders, fil... | python | {
"resource": ""
} |
q17993 | StorageClient._upload_folder_in_background | train | def _upload_folder_in_background(self, folder_path, container, ignore,
upload_key, ttl=None):
"""Runs the folder upload in the background."""
uploader = FolderUploader(folder_path, container, ignore, upload_key,
self, ttl=ttl)
uploader.start() | python | {
"resource": ""
} |
q17994 | StorageClient._sync_folder_to_container | train | def _sync_folder_to_container(self, folder_path, container, prefix, delete,
include_hidden, ignore, ignore_timestamps, object_prefix, verbose):
"""
This is the internal method that is called recursively to handle
nested folder structures.
"""
fnames = os.listdir(folde... | python | {
"resource": ""
} |
q17995 | StorageClient._delete_objects_not_in_list | train | def _delete_objects_not_in_list(self, cont, object_prefix=""):
"""
Finds all the objects in the specified container that are not present
in the self._local_files list, and deletes them.
"""
objnames = set(cont.get_object_names(prefix=object_prefix,
full_listing=Tr... | python | {
"resource": ""
} |
q17996 | StorageClient.bulk_delete | train | def bulk_delete(self, container, object_names, async_=False):
"""
Deletes multiple objects from a container in a single call.
The bulk deletion call does not return until all of the specified
objects have been processed. For large numbers of objects, this can
take quite a while,... | python | {
"resource": ""
} |
q17997 | StorageClient.cdn_request | train | def cdn_request(self, uri, method, *args, **kwargs):
"""
If the service supports CDN, use this method to access CDN-specific
URIs.
"""
if not self.cdn_management_url:
raise exc.NotCDNEnabled("CDN is not enabled for this service.")
cdn_uri = "%s%s" % (self.cdn_... | python | {
"resource": ""
} |
q17998 | FolderUploader.upload_files_in_folder | train | def upload_files_in_folder(self, dirname, fnames):
"""Handles the iteration across files within a folder."""
if utils.match_pattern(dirname, self.ignore):
return False
good_names = (nm for nm in fnames
if not utils.match_pattern(nm, self.ignore))
for fname in ... | python | {
"resource": ""
} |
q17999 | FolderUploader.run | train | def run(self):
"""Starts the uploading thread."""
root_path, folder_name = os.path.split(self.root_folder)
self.root_folder = os.path.join(root_path, folder_name)
for dirname, _, fnames in os.walk(self.root_folder):
self.upload_files_in_folder(dirname, fnames) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.