References¶
swiftsc.client module.
-
class
swiftsc.client.
Client
(auth_uri=None, uri=None, username=None, password=None, token=None, tenant_name=None, verify=True, timeout=5.0)¶ Bases:
object
The
Client
object.This provides REST connection including tempauth or KeyStone Auth.:
>>> from swiftsc import Client >>> client = Client(auth_uri='https://swift.example.org/auth/v1.0', ... username='swiftuser', password='passw0rd')
Parameters: - auth_uri (str) – tempauth URL or KeyStone URL
- uri (str) – Storage URL (required token)
- username (str) – tempauth or KeyStone username
- password (str) – tempauth or KeyStone password
- token (str) – Auth token
- tenant_name (str) – KeyStone tenant name
-
class
swiftsc.client.
Container
(obj)¶ Bases:
swiftsc.client._CRUD
Swift container resources.
>>> client.containers.list().json() [{'bytes': 1403088360, 'count': 5, 'name': 'container-a'}, {'bytes': 393429510, 'count': 11, 'name': 'container-b'}, {'bytes': 410389320, 'count': 11, 'name': 'container-c'}, ... {'bytes': 9690876040, 'count': 57, 'name': 'container-x'}]
-
change_timeout
(timeout)¶ Change timeout.
Change timeout to other than “5.0”
-
container
(container_name)¶ Set container name and create instances.
The instance has the attributes of
Container
, as follows.- objects:
Object
Parameters: container_name (str) – container name - objects:
-
create
(**kwargs)¶ Create or replace resource.
Return type: requests.Response Returns: Response of metadata single resource. Parameters: **kwargs – parameters
-
delete
(obj_id)¶ Delete resource.
Return type: requests.Response Returns: Response of deleting a single resource. Parameters: obj_id (str) – resource id (or resource name)
-
detail
(obj_id=None)¶ Show/Get a single resource.
Return type: requests.Response Returns: Response of detail single resource. Parameters: obj_id (str) – resource id (or resource name)
-
list
()¶ List collection of resources.
Return type: requests.Response Returns: Response of list collection.
-
no_verify
()¶ Ignore SSL Cert Verification.
Change
verify
toFalse
.
-
show_metadata
(obj_id=None)¶ Show metadata.
Return type: requests.Response Returns: Response of metadata single resource. Parameters: obj_id (str) – resource id (or resource name)
-
update_metadata
(obj_id, **kwargs)¶ Create, Update (or delete) metadata.
Return type: requests.Response
Returns: Response of updating a single resource.
Parameters: - obj_id (str) – resource id (or resource name)
- **kwargs –
keyword arguments of method
-
-
class
swiftsc.client.
Object
(obj)¶ Bases:
swiftsc.client._CRUD
Objects resources.
>>> client.containers.container('container-a') >>> client.containers.objects.list().json() [{'bytes': 0, 'content_type': 'application/octet-stream', 'hash': 'd41d8cd98f00b204e9800998ecf8427e', 'last_modified': '2015-03-05T07:57:17.450440', 'name': 'test'}, {'bytes': 225280, 'content_type': 'application/x-tar', 'hash': '9aa58f7a3fca9853c26a048eda407c71', 'last_modified': '2013-07-18T09:56:30.989920', 'name': 'test.tgz'}, {'bytes': 22, 'content_type': 'text/plain', 'hash': '4cc6982f37c06ec4eb378e916cfbd289', 'last_modified': '2015-03-05T09:34:42.935400', 'name': 'test2'}]
-
change_timeout
(timeout)¶ Change timeout.
Change timeout to other than “5.0”
-
copy
(src_object_name, dest_object_name)¶ Copy object.
Return type: requests.Response Returns: Response of copy object
-
create
(**kwargs)¶ Create object.
Parameters: **kwargs – parameters for creating object
Return type: requests.Response Returns: Response of create object
-
delete
(obj_id)¶ Delete resource.
Return type: requests.Response Returns: Response of deleting a single resource. Parameters: obj_id (str) – resource id (or resource name)
-
detail
(obj_id=None)¶ Show/Get a single resource.
Return type: requests.Response Returns: Response of detail single resource. Parameters: obj_id (str) – resource id (or resource name)
-
list
()¶ List collection of resources.
Return type: requests.Response Returns: Response of list collection.
-
no_verify
()¶ Ignore SSL Cert Verification.
Change
verify
toFalse
.
-
object
(object_name)¶ Set object name.
Parameters: object_name (str) – object name
-
show_metadata
(obj_id=None)¶ Show metadata.
Return type: requests.Response Returns: Response of metadata single resource. Parameters: obj_id (str) – resource id (or resource name)
-
update_metadata
(obj_id, **kwargs)¶ Create, Update (or delete) metadata.
Return type: requests.Response
Returns: Response of updating a single resource.
Parameters: - obj_id (str) – resource id (or resource name)
- **kwargs –
keyword arguments of method
-
swiftsc utility module.
-
swiftsc.utils.
check_mimetype
(filepath)¶ Check mimetype of file.
Return type: str Returns: mimetype Parameters: filepath (str) – target filename path
-
swiftsc.utils.
check_mimetype_buffer
(fileobj)¶ Check mimetype of file.
Return type: str Returns: mimetype Parameters: fileobj – target filename path
-
swiftsc.utils.
retrieve_info_from_buffer
(file_object)¶ Check mimetype of file object.
Return type: tuple Returns: mimetype, content length, data Parameters: file_object – target file object