#!/usr/bin/env python
#
# Copyright (C) 2018 Layered Insight - All Rights Reserved
# Unauthorized copying of this file, via any medium is strictly prohibited
# Proprietary and confidential

from __future__ import print_function
import argparse
import sys
from pprint import pprint
import layint_runtime_api
from layint_runtime_api.rest import ApiException
from vyper import v
from li_utils.envtools import env_setup

env_setup()

# Parse CLI
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", help="Verbose logging", action="store_true")
parser.add_argument("--imageid", help="ID of image", required=True)
args = parser.parse_args()

layint_runtime_api.configuration.api_key['Authorization'] = v.get("api_key")
image_api = layint_runtime_api.ImageApi()
image_api.api_client.host = v.get("api_host")

if args.verbose:
    print("Deleting Image by ID %s on API host %s..." % (args.imageid, v.get("api_host")))
try:
    api_response = image_api.delete_image(args.imageid)
    if args.verbose:
        pprint(api_response)
except ApiException as e:
    print("Exception when calling ImageApi->delete_image: %s" % e)
    sys.exit()

if args.verbose:
    print("Image deleted, ID " + str(args.imageid))
