def delete_object_tags(cls, path, tags, version): if not tags: click.echo("Error: Missing argument \"tags\"", err=True) sys.exit(1) try: root_bucket, relative_path = DataStorage.load_from_uri(path) DataStorage.delete_object_tags(root_bucket.identifier, relative_path, tags, version) except BaseException as e: click.echo(str(e.message), err=True) sys.exit(1)
def set_object_tags(cls, path, tags, version): try: root_bucket, relative_path = DataStorage.load_from_uri(path) updated_tags = DataStorage.set_object_tags(root_bucket.identifier, relative_path, cls.convert_input_pairs_to_json(tags), version) if not updated_tags: raise RuntimeError("Failed to set tags for path '{}'.".format(path)) except BaseException as e: click.echo(str(e.message), err=True) sys.exit(1)
def get_object_tags(cls, path, version): try: root_bucket, relative_path = DataStorage.load_from_uri(path) tags = DataStorage.get_object_tags(root_bucket.identifier, relative_path, version) if not tags: click.echo("No tags available for path '{}'.".format(path)) else: click.echo(cls.create_table(tags)) except BaseException as e: click.echo(str(e.message), err=True) sys.exit(1)
def storage_list(cls, path, show_details, show_versions, recursive, page, show_all): """Lists storage contents """ if path: root_bucket = None original_path = '' try: root_bucket, original_path = DataStorage.load_from_uri(path) except (ConfigNotFoundError, requests.exceptions.RequestException, RuntimeError, ValueError) as error: click.echo('Error: %s' % str(error), err=True) sys.exit(1) if show_versions and not root_bucket.policy.versioning_enabled: click.echo('Error: versioning is not enabled for storage.', err=True) sys.exit(1) if root_bucket is None: click.echo('Storage path "{}" was not found'.format(path), err=True) sys.exit(1) else: relative_path = original_path if original_path != '/' else '' cls.__print_data_storage_contents(root_bucket, relative_path, show_details, recursive, page_size=page, show_versions=show_versions, show_all=show_all) else: # If no argument is specified - list brief details of all buckets cls.__print_data_storage_contents(None, None, show_details, recursive, show_all=show_all)