# Copyright 2013 Nebula Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
"""Object v1 action implementations"""
import logging
import six
from cliff import command
from cliff import lister
from cliff import show
from openstackclient.common import utils
class CreateObject(lister.Lister):
"""Upload object to container"""
log = logging.getLogger(__name__ + '.CreateObject')
def get_parser(self, prog_name):
parser = super(CreateObject, self).get_parser(prog_name)
parser.add_argument(
'container',
metavar='',
help='Container for new object',
)
parser.add_argument(
'objects',
metavar='',
nargs="+",
help='Local filename(s) to upload',
)
return parser
@utils.log_method(log)
def take_action(self, parsed_args):
results = []
for obj in parsed_args.objects:
data = self.app.client_manager.object_store.object_create(
container=parsed_args.container,
object=obj,
)
results.append(data)
columns = ("object", "container", "etag")
return (columns,
(utils.get_dict_properties(
s, columns,
formatters={},
) for s in results))
class DeleteObject(command.Command):
"""Delete object from container"""
log = logging.getLogger(__name__ + '.DeleteObject')
def get_parser(self, prog_name):
parser = super(DeleteObject, self).get_parser(prog_name)
parser.add_argument(
'container',
metavar='',
help='Delete object(s) from ',
)
parser.add_argument(
'objects',
metavar='