def cli_post(context, path, body=None):
    """
    Performs a POST on the item (account, container, or object).

    See :py:mod:`swiftly.cli.post` for context usage information.

    See :py:class:`CLIPost` for more information.

    :param context: The :py:class:`swiftly.cli.context.CLIContext` to
        use.
    :param path: The path to the item to issue a POST for.
    :param body: The body send along with the POST.
    """
    path = path.lstrip('/') if path else ''
    status, reason, headers, contents = 0, 'Unknown', {}, ''
    with context.client_manager.with_client() as client:
        if not path:
            status, reason, headers, contents = client.post_account(
                headers=context.headers, query=context.query, cdn=context.cdn,
                body=body)
            if status // 100 != 2:
                raise ReturnCode('posting account: %s %s' % (status, reason))
        elif '/' not in path.rstrip('/'):
            path = path.rstrip('/')
            status, reason, headers, contents = client.post_container(
                path, headers=context.headers, query=context.query,
                cdn=context.cdn, body=body)
            if status // 100 != 2:
                raise ReturnCode(
                    'posting container %r: %s %s' % (path, status, reason))
        else:
            status, reason, headers, contents = client.post_object(
                *path.split('/', 1), headers=context.headers,
                query=context.query, cdn=context.cdn, body=body)
            if status // 100 != 2:
                raise ReturnCode(
                    'posting object %r: %s %s' % (path, status, reason))
dataset/ETHPy150Open gholt/swiftly/swiftly/cli/post.py/cli_post/original