# --------------------------------------------------------------------------
# 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 automation_runbook_list(client,
                            resource_group_name,
                            automation_account_name):
    return client.list_by_automation_account(resource_group_name=resource_group_name,
                                             automation_account_name=automation_account_name)


def automation_runbook_show(client,
                            resource_group_name,
                            automation_account_name,
                            runbook_name):
    return client.get(resource_group_name=resource_group_name,
                      automation_account_name=automation_account_name,
                      runbook_name=runbook_name)


def automation_runbook_create(client,
                              resource_group_name,
                              automation_account_name,
                              runbook_name,
                              runbook_type,
                              draft_parameters,
                              name=None,
                              location=None,
                              tags=None,
                              log_verbose=None,
                              log_progress=None,
                              description=None,
                              log_activity_trace=None,
                              publish_content_link_uri=None,
                              publish_content_link_content_hash=None,
                              publish_content_link_version=None,
                              draft_in_edit=None,
                              draft_draft_content_link=None,
                              draft_creation_time=None,
                              draft_last_modified_time=None,
                              draft_output_types=None):
    parameters = {}
    parameters['name'] = name
    parameters['location'] = location
    parameters['tags'] = tags
    parameters['log_verbose'] = log_verbose
    parameters['log_progress'] = log_progress
    parameters['runbook_type'] = runbook_type
    parameters['description'] = description
    parameters['log_activity_trace'] = log_activity_trace
    parameters['publish_content_link'] = {}
    parameters['publish_content_link']['uri'] = publish_content_link_uri
    parameters['publish_content_link']['content_hash'] = publish_content_link_content_hash
    parameters['publish_content_link']['version'] = publish_content_link_version
    parameters['draft'] = {}
    parameters['draft']['in_edit'] = draft_in_edit
    parameters['draft']['draft_content_link'] = draft_draft_content_link
    parameters['draft']['creation_time'] = draft_creation_time
    parameters['draft']['last_modified_time'] = draft_last_modified_time
    parameters['draft']['parameters'] = draft_parameters
    parameters['draft']['output_types'] = draft_output_types
    return client.create_or_update(resource_group_name=resource_group_name,
                                   automation_account_name=automation_account_name,
                                   runbook_name=runbook_name,
                                   parameters=parameters)


def automation_runbook_update(client,
                              resource_group_name,
                              automation_account_name,
                              runbook_name,
                              name=None,
                              location=None,
                              tags=None,
                              description=None,
                              log_verbose=None,
                              log_progress=None,
                              log_activity_trace=None):
    parameters = {}
    parameters['name'] = name
    parameters['location'] = location
    parameters['tags'] = tags
    parameters['description'] = description
    parameters['log_verbose'] = log_verbose
    parameters['log_progress'] = log_progress
    parameters['log_activity_trace'] = log_activity_trace
    return client.update(resource_group_name=resource_group_name,
                         automation_account_name=automation_account_name,
                         runbook_name=runbook_name,
                         parameters=parameters)


def automation_runbook_delete(client,
                              resource_group_name,
                              automation_account_name,
                              runbook_name):
    return client.delete(resource_group_name=resource_group_name,
                         automation_account_name=automation_account_name,
                         runbook_name=runbook_name)


def automation_runbook_publish(client,
                               resource_group_name,
                               automation_account_name,
                               runbook_name,
                               no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_publish,
                       resource_group_name=resource_group_name,
                       automation_account_name=automation_account_name,
                       runbook_name=runbook_name)
