From 3a5a25fe981817ba0e550d39d6e9863fa1539588 Mon Sep 17 00:00:00 2001 From: Joel Wright Date: Thu, 3 Mar 2016 17:22:33 +0000 Subject: Add new doc structure and contents for swiftclient As a result of the Hackathon we have produced a new documentation structure for the python-swiftclient. This patch introduces the new structure and adds the required content. The intention is to document the CLI, the SwiftService and Connection API. Importantly, we also provide guidance on important considerations when using a swift object store, such as which aspect of the python-swiftclient to use for various use cases, common authentication patterns and some useful examples. Co-Authored-By: Alexandra Settle Co-Authored-By: Mohit Motiani Co-Authored-By: Hisashi Osanai Change-Id: I9eb41f8e9137efa66cead67dc264a76a3c03fbda --- examples/delete.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 examples/delete.py (limited to 'examples/delete.py') diff --git a/examples/delete.py b/examples/delete.py new file mode 100644 index 0000000..6979d9e --- /dev/null +++ b/examples/delete.py @@ -0,0 +1,34 @@ +import logging + +from swiftclient.service import SwiftService +from sys import argv + + +logging.basicConfig(level=logging.ERROR) +logging.getLogger("requests").setLevel(logging.CRITICAL) +logging.getLogger("swiftclient").setLevel(logging.CRITICAL) +logger = logging.getLogger(__name__) + +_opts = {'object_dd_threads': 20} +container = argv[1] +objects = argv[2:] +with SwiftService(options=_opts) as swift: + del_iter = swift.delete(container=container, objects=objects) + for del_res in del_iter: + c = del_res.get('container', '') + o = del_res.get('object', '') + a = del_res.get('attempts') + if del_res['success'] and not del_res['action'] == 'bulk_delete': + rd = del_res.get('response_dict') + if rd is not None: + t = dict(rd.get('headers', {})) + if t: + print( + 'Successfully deleted {0}/{1} in {2} attempts ' + '(transaction id: {3})'.format(c, o, a, t) + ) + else: + print( + 'Successfully deleted {0}/{1} in {2} ' + 'attempts'.format(c, o, a) + ) -- cgit v1.2.1