# --------------------------------------------------------------------------
# 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
# pylint: disable=unused-argument

from azure.cli.core.util import sdk_no_wait


def stream_analytics_job_list(client,
                              expand=None,
                              resource_group_name=None):
    if resource_group_name:
        return client.list_by_resource_group(expand=expand,
                                             resource_group_name=resource_group_name)
    return client.list(expand=expand)


def stream_analytics_job_show(client,
                              resource_group_name,
                              job_name,
                              expand=None):
    return client.get(expand=expand,
                      resource_group_name=resource_group_name,
                      job_name=job_name)


def stream_analytics_job_create(client,
                                resource_group_name,
                                job_name,
                                if_match=None,
                                if_none_match=None,
                                tags=None,
                                location=None,
                                identity=None,
                                job_type=None,
                                output_start_mode=None,
                                output_start_time=None,
                                out_of_order_policy=None,
                                output_error_policy=None,
                                order_max_delay=None,
                                arrival_max_delay=None,
                                data_locale=None,
                                compatibility_level=None,
                                inputs=None,
                                transformation=None,
                                outputs=None,
                                functions=None,
                                job_storage_account=None,
                                content_storage_policy=None,
                                id_=None,
                                no_wait=False):
    streaming_job = {}
    if tags is not None:
        streaming_job['tags'] = tags
    if location is not None:
        streaming_job['location'] = location
    if identity is not None:
        streaming_job['identity'] = identity
    if job_type is not None:
        streaming_job['job_type'] = job_type
    if output_start_mode is not None:
        streaming_job['output_start_mode'] = output_start_mode
    if output_start_time is not None:
        streaming_job['output_start_time'] = output_start_time
    if out_of_order_policy is not None:
        streaming_job['events_out_of_order_policy'] = out_of_order_policy
    if output_error_policy is not None:
        streaming_job['output_error_policy'] = output_error_policy
    if order_max_delay is not None:
        streaming_job['events_out_of_order_max_delay_in_seconds'] = order_max_delay
    if arrival_max_delay is not None:
        streaming_job['events_late_arrival_max_delay_in_seconds'] = arrival_max_delay
    if data_locale is not None:
        streaming_job['data_locale'] = data_locale
    if compatibility_level is not None:
        streaming_job['compatibility_level'] = compatibility_level
    if inputs is not None:
        streaming_job['inputs'] = inputs
    if transformation is not None:
        streaming_job['transformation'] = transformation
    if outputs is not None:
        streaming_job['outputs'] = outputs
    if functions is not None:
        streaming_job['functions'] = functions
    if job_storage_account is not None:
        streaming_job['job_storage_account'] = job_storage_account
    if content_storage_policy is not None:
        streaming_job['content_storage_policy'] = content_storage_policy
    streaming_job['cluster'] = {}
    if id_ is not None:
        streaming_job['cluster']['id'] = id_
    if len(streaming_job['cluster']) == 0:
        del streaming_job['cluster']
    streaming_job['sku'] = {}
    streaming_job['sku']['name'] = "Standard"
    if len(streaming_job['sku']) == 0:
        del streaming_job['sku']
    return sdk_no_wait(no_wait,
                       client.begin_create_or_replace,
                       if_match=if_match,
                       if_none_match=if_none_match,
                       resource_group_name=resource_group_name,
                       job_name=job_name,
                       streaming_job=streaming_job)


def stream_analytics_job_update(client,
                                resource_group_name,
                                job_name,
                                if_match=None,
                                tags=None,
                                location=None,
                                identity=None,
                                job_type=None,
                                output_start_mode=None,
                                output_start_time=None,
                                out_of_order_policy=None,
                                output_error_policy=None,
                                order_max_delay=None,
                                arrival_max_delay=None,
                                data_locale=None,
                                compatibility_level=None,
                                inputs=None,
                                transformation=None,
                                outputs=None,
                                functions=None,
                                job_storage_account=None,
                                content_storage_policy=None,
                                id_=None):
    streaming_job = {}
    if tags is not None:
        streaming_job['tags'] = tags
    if location is not None:
        streaming_job['location'] = location
    if identity is not None:
        streaming_job['identity'] = identity
    if job_type is not None:
        streaming_job['job_type'] = job_type
    if output_start_mode is not None:
        streaming_job['output_start_mode'] = output_start_mode
    if output_start_time is not None:
        streaming_job['output_start_time'] = output_start_time
    if out_of_order_policy is not None:
        streaming_job['events_out_of_order_policy'] = out_of_order_policy
    if output_error_policy is not None:
        streaming_job['output_error_policy'] = output_error_policy
    if order_max_delay is not None:
        streaming_job['events_out_of_order_max_delay_in_seconds'] = order_max_delay
    if arrival_max_delay is not None:
        streaming_job['events_late_arrival_max_delay_in_seconds'] = arrival_max_delay
    if data_locale is not None:
        streaming_job['data_locale'] = data_locale
    if compatibility_level is not None:
        streaming_job['compatibility_level'] = compatibility_level
    if inputs is not None:
        streaming_job['inputs'] = inputs
    if transformation is not None:
        streaming_job['transformation'] = transformation
    if outputs is not None:
        streaming_job['outputs'] = outputs
    if functions is not None:
        streaming_job['functions'] = functions
    if job_storage_account is not None:
        streaming_job['job_storage_account'] = job_storage_account
    if content_storage_policy is not None:
        streaming_job['content_storage_policy'] = content_storage_policy
    streaming_job['cluster'] = {}
    if id_ is not None:
        streaming_job['cluster']['id'] = id_
    if len(streaming_job['cluster']) == 0:
        del streaming_job['cluster']
    streaming_job['sku'] = {}
    streaming_job['sku']['name'] = "Standard"
    if len(streaming_job['sku']) == 0:
        del streaming_job['sku']
    return client.update(if_match=if_match,
                         resource_group_name=resource_group_name,
                         job_name=job_name,
                         streaming_job=streaming_job)


def stream_analytics_job_delete(client,
                                resource_group_name,
                                job_name,
                                no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_delete,
                       resource_group_name=resource_group_name,
                       job_name=job_name)


def stream_analytics_job_scale(client,
                               resource_group_name,
                               job_name,
                               streaming_units=None,
                               no_wait=False):
    scale_job_parameters = {}
    if streaming_units is not None:
        scale_job_parameters['streaming_units'] = streaming_units
    return sdk_no_wait(no_wait,
                       client.begin_scale,
                       resource_group_name=resource_group_name,
                       job_name=job_name,
                       scale_job_parameters=scale_job_parameters)


def stream_analytics_job_start(client,
                               resource_group_name,
                               job_name,
                               output_start_mode=None,
                               output_start_time=None,
                               no_wait=False):
    start_job_parameters = {}
    if output_start_mode is not None:
        start_job_parameters['output_start_mode'] = output_start_mode
    if output_start_time is not None:
        start_job_parameters['output_start_time'] = output_start_time
    return sdk_no_wait(no_wait,
                       client.begin_start,
                       resource_group_name=resource_group_name,
                       job_name=job_name,
                       start_job_parameters=start_job_parameters)


def stream_analytics_job_stop(client,
                              resource_group_name,
                              job_name,
                              no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_stop,
                       resource_group_name=resource_group_name,
                       job_name=job_name)


def stream_analytics_input_list(client,
                                resource_group_name,
                                job_name,
                                select=None):
    return client.list_by_streaming_job(select=select,
                                        resource_group_name=resource_group_name,
                                        job_name=job_name)


def stream_analytics_input_show(client,
                                resource_group_name,
                                job_name,
                                input_name):
    return client.get(resource_group_name=resource_group_name,
                      job_name=job_name,
                      input_name=input_name)


def stream_analytics_input_create(client,
                                  resource_group_name,
                                  job_name,
                                  input_name,
                                  if_match=None,
                                  if_none_match=None,
                                  properties=None):
    input = {}
    if properties is not None:
        input['properties'] = properties
    return client.create_or_replace(if_match=if_match,
                                    if_none_match=if_none_match,
                                    resource_group_name=resource_group_name,
                                    job_name=job_name,
                                    input_name=input_name,
                                    input=input)


def stream_analytics_input_update(client,
                                  resource_group_name,
                                  job_name,
                                  input_name,
                                  if_match=None,
                                  properties=None):
    input = {}
    if properties is not None:
        input['properties'] = properties
    return client.update(if_match=if_match,
                         resource_group_name=resource_group_name,
                         job_name=job_name,
                         input_name=input_name,
                         input=input)


def stream_analytics_input_delete(client,
                                  resource_group_name,
                                  job_name,
                                  input_name):
    return client.delete(resource_group_name=resource_group_name,
                         job_name=job_name,
                         input_name=input_name)


def stream_analytics_input_test(client,
                                resource_group_name,
                                job_name,
                                input_name,
                                properties=None,
                                no_wait=False):
    input = {}
    if properties is not None:
        input['properties'] = properties
    return sdk_no_wait(no_wait,
                       client.begin_test,
                       resource_group_name=resource_group_name,
                       job_name=job_name,
                       input_name=input_name,
                       input=input)


def stream_analytics_output_list(client,
                                 resource_group_name,
                                 job_name,
                                 select=None):
    return client.list_by_streaming_job(select=select,
                                        resource_group_name=resource_group_name,
                                        job_name=job_name)


def stream_analytics_output_show(client,
                                 resource_group_name,
                                 job_name,
                                 output_name):
    return client.get(resource_group_name=resource_group_name,
                      job_name=job_name,
                      output_name=output_name)


def stream_analytics_output_create(client,
                                   resource_group_name,
                                   job_name,
                                   output_name,
                                   if_match=None,
                                   if_none_match=None,
                                   datasource=None,
                                   time_window=None,
                                   size_window=None,
                                   serialization=None):
    output = {}
    if datasource is not None:
        output['datasource'] = datasource
    if time_window is not None:
        output['time_window'] = time_window
    if size_window is not None:
        output['size_window'] = size_window
    if serialization is not None:
        output['serialization'] = serialization
    return client.create_or_replace(if_match=if_match,
                                    if_none_match=if_none_match,
                                    resource_group_name=resource_group_name,
                                    job_name=job_name,
                                    output_name=output_name,
                                    output=output)


def stream_analytics_output_update(client,
                                   resource_group_name,
                                   job_name,
                                   output_name,
                                   if_match=None,
                                   datasource=None,
                                   time_window=None,
                                   size_window=None,
                                   serialization=None):
    output = {}
    if datasource is not None:
        output['datasource'] = datasource
    if time_window is not None:
        output['time_window'] = time_window
    if size_window is not None:
        output['size_window'] = size_window
    if serialization is not None:
        output['serialization'] = serialization
    return client.update(if_match=if_match,
                         resource_group_name=resource_group_name,
                         job_name=job_name,
                         output_name=output_name,
                         output=output)


def stream_analytics_output_delete(client,
                                   resource_group_name,
                                   job_name,
                                   output_name):
    return client.delete(resource_group_name=resource_group_name,
                         job_name=job_name,
                         output_name=output_name)


def stream_analytics_output_test(client,
                                 resource_group_name,
                                 job_name,
                                 output_name,
                                 datasource=None,
                                 time_window=None,
                                 size_window=None,
                                 serialization=None,
                                 no_wait=False):
    output = {}
    if datasource is not None:
        output['datasource'] = datasource
    if time_window is not None:
        output['time_window'] = time_window
    if size_window is not None:
        output['size_window'] = size_window
    if serialization is not None:
        output['serialization'] = serialization
    return sdk_no_wait(no_wait,
                       client.begin_test,
                       resource_group_name=resource_group_name,
                       job_name=job_name,
                       output_name=output_name,
                       output=output)


def stream_analytics_transformation_show(client,
                                         resource_group_name,
                                         job_name,
                                         transformation_name):
    return client.get(resource_group_name=resource_group_name,
                      job_name=job_name,
                      transformation_name=transformation_name)


def stream_analytics_transformation_create(client,
                                           resource_group_name,
                                           job_name,
                                           transformation_name,
                                           if_match=None,
                                           if_none_match=None,
                                           streaming_units=None,
                                           valid_streaming_units=None,
                                           saql=None):
    transformation = {}
    if streaming_units is not None:
        transformation['streaming_units'] = streaming_units
    if valid_streaming_units is not None:
        transformation['valid_streaming_units'] = valid_streaming_units
    if saql is not None:
        transformation['query'] = saql
    return client.create_or_replace(if_match=if_match,
                                    if_none_match=if_none_match,
                                    resource_group_name=resource_group_name,
                                    job_name=job_name,
                                    transformation_name=transformation_name,
                                    transformation=transformation)


def stream_analytics_transformation_update(client,
                                           resource_group_name,
                                           job_name,
                                           transformation_name,
                                           if_match=None,
                                           streaming_units=None,
                                           valid_streaming_units=None,
                                           saql=None):
    transformation = {}
    if streaming_units is not None:
        transformation['streaming_units'] = streaming_units
    if valid_streaming_units is not None:
        transformation['valid_streaming_units'] = valid_streaming_units
    if saql is not None:
        transformation['query'] = saql
    return client.update(if_match=if_match,
                         resource_group_name=resource_group_name,
                         job_name=job_name,
                         transformation_name=transformation_name,
                         transformation=transformation)


def stream_analytics_function_list(client,
                                   resource_group_name,
                                   job_name,
                                   select=None):
    return client.list_by_streaming_job(select=select,
                                        resource_group_name=resource_group_name,
                                        job_name=job_name)


def stream_analytics_function_show(client,
                                   resource_group_name,
                                   job_name,
                                   function_name):
    return client.get(resource_group_name=resource_group_name,
                      job_name=job_name,
                      function_name=function_name)


def stream_analytics_function_create(client,
                                     resource_group_name,
                                     job_name,
                                     function_name,
                                     if_match=None,
                                     if_none_match=None,
                                     properties=None):
    function = {}
    if properties is not None:
        function['properties'] = properties
    return client.create_or_replace(if_match=if_match,
                                    if_none_match=if_none_match,
                                    resource_group_name=resource_group_name,
                                    job_name=job_name,
                                    function_name=function_name,
                                    function=function)


def stream_analytics_function_update(client,
                                     resource_group_name,
                                     job_name,
                                     function_name,
                                     if_match=None,
                                     properties=None):
    function = {}
    if properties is not None:
        function['properties'] = properties
    return client.update(if_match=if_match,
                         resource_group_name=resource_group_name,
                         job_name=job_name,
                         function_name=function_name,
                         function=function)


def stream_analytics_function_delete(client,
                                     resource_group_name,
                                     job_name,
                                     function_name):
    return client.delete(resource_group_name=resource_group_name,
                         job_name=job_name,
                         function_name=function_name)


def stream_analytics_function_test(client,
                                   resource_group_name,
                                   job_name,
                                   function_name,
                                   properties=None,
                                   no_wait=False):
    function = {}
    if properties is not None:
        function['properties'] = properties
    return sdk_no_wait(no_wait,
                       client.begin_test,
                       resource_group_name=resource_group_name,
                       job_name=job_name,
                       function_name=function_name,
                       function=function)


def stream_analytics_subscription_inspect(client,
                                          location):
    return client.list_quotas(location=location)


def stream_analytics_cluster_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 stream_analytics_cluster_show(client,
                                  resource_group_name,
                                  cluster_name):
    return client.get(resource_group_name=resource_group_name,
                      cluster_name=cluster_name)


def stream_analytics_cluster_create(client,
                                    resource_group_name,
                                    cluster_name,
                                    if_match=None,
                                    if_none_match=None,
                                    tags=None,
                                    location=None,
                                    sku=None,
                                    no_wait=False):
    cluster = {}
    if tags is not None:
        cluster['tags'] = tags
    if location is not None:
        cluster['location'] = location
    if sku is not None:
        cluster['sku'] = sku
    return sdk_no_wait(no_wait,
                       client.begin_create_or_update,
                       resource_group_name=resource_group_name,
                       cluster_name=cluster_name,
                       if_match=if_match,
                       if_none_match=if_none_match,
                       cluster=cluster)


def stream_analytics_cluster_update(client,
                                    resource_group_name,
                                    cluster_name,
                                    if_match=None,
                                    tags=None,
                                    location=None,
                                    sku=None,
                                    no_wait=False):
    cluster = {}
    if tags is not None:
        cluster['tags'] = tags
    if location is not None:
        cluster['location'] = location
    if sku is not None:
        cluster['sku'] = sku
    return sdk_no_wait(no_wait,
                       client.begin_update,
                       resource_group_name=resource_group_name,
                       cluster_name=cluster_name,
                       if_match=if_match,
                       cluster=cluster)


def stream_analytics_cluster_delete(client,
                                    resource_group_name,
                                    cluster_name,
                                    no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_delete,
                       resource_group_name=resource_group_name,
                       cluster_name=cluster_name)


def stream_analytics_cluster_list_streaming_job(client,
                                                resource_group_name,
                                                cluster_name):
    return client.list_streaming_jobs(resource_group_name=resource_group_name,
                                      cluster_name=cluster_name)


def stream_analytics_private_endpoint_list(client,
                                           resource_group_name,
                                           cluster_name):
    return client.list_by_cluster(resource_group_name=resource_group_name,
                                  cluster_name=cluster_name)


def stream_analytics_private_endpoint_show(client,
                                           resource_group_name,
                                           cluster_name,
                                           private_endpoint_name):
    return client.get(resource_group_name=resource_group_name,
                      cluster_name=cluster_name,
                      private_endpoint_name=private_endpoint_name)


def stream_analytics_private_endpoint_create(client,
                                             resource_group_name,
                                             cluster_name,
                                             private_endpoint_name,
                                             if_match=None,
                                             if_none_match=None,
                                             manual_private_link_service_connections=None):
    private_endpoint = {}
    if manual_private_link_service_connections is not None:
        private_endpoint['manual_private_link_service_connections'] = manual_private_link_service_connections
    return client.create_or_update(resource_group_name=resource_group_name,
                                   cluster_name=cluster_name,
                                   private_endpoint_name=private_endpoint_name,
                                   if_match=if_match,
                                   if_none_match=if_none_match,
                                   private_endpoint=private_endpoint)


def stream_analytics_private_endpoint_delete(client,
                                             resource_group_name,
                                             cluster_name,
                                             private_endpoint_name,
                                             no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_delete,
                       resource_group_name=resource_group_name,
                       cluster_name=cluster_name,
                       private_endpoint_name=private_endpoint_name)
