# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=too-many-lines

from azure.cli.core.util import sdk_no_wait


def swiftlet_virtual_machine_list(client,
                                  resource_group_name=None):
    if resource_group_name:
        return client.list_by_resource_group(resource_group_name=resource_group_name)
    return client.list_by_subscription()


def swiftlet_virtual_machine_show(client,
                                  resource_group_name,
                                  vm_name):
    return client.get(resource_group_name=resource_group_name,
                      vm_name=vm_name)


def swiftlet_virtual_machine_create(client,
                                    resource_group_name,
                                    vm_name,
                                    location,
                                    swiftlet_bundle_sku,
                                    swiftlet_image_id,
                                    tags=None,
                                    username=None,
                                    ssh_public_key=None,
                                    password=None,
                                    ports=None,
                                    startup_script=None,
                                    no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_create_or_update,
                       resource_group_name=resource_group_name,
                       vm_name=vm_name,
                       tags=tags,
                       location=location,
                       swiftlet_bundle_sku=swiftlet_bundle_sku,
                       swiftlet_image_id=swiftlet_image_id,
                       username=username,
                       ssh_public_key=ssh_public_key,
                       password=password,
                       ports=ports,
                       startup_script=startup_script)


def swiftlet_virtual_machine_update(client,
                                    resource_group_name,
                                    vm_name,
                                    tags=None,
                                    ports=None,
                                    no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_update,
                       resource_group_name=resource_group_name,
                       vm_name=vm_name,
                       tags=tags,
                       ports=ports)


def swiftlet_virtual_machine_delete(client,
                                    resource_group_name,
                                    vm_name,
                                    no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_delete,
                       resource_group_name=resource_group_name,
                       vm_name=vm_name)


def swiftlet_virtual_machine_list_bundle(client,
                                         location):
    return client.list_bundle(location=location)


def swiftlet_virtual_machine_list_image(client,
                                        location):
    return client.list_image(location=location)


def swiftlet_virtual_machine_start(client,
                                   vm_name,
                                   resource_group_name,
                                   no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_start,
                       vm_name=vm_name,
                       resource_group_name=resource_group_name)


def swiftlet_virtual_machine_stop(client,
                                  vm_name,
                                  resource_group_name,
                                  no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_stop,
                       vm_name=vm_name,
                       resource_group_name=resource_group_name)
