# --------------------------------------------------------------------------
# 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 confluent_terms_list(client):
    return client.list()


def confluent_organization_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 confluent_organization_show(client,
                                resource_group_name,
                                organization_name):
    return client.get(resource_group_name=resource_group_name,
                      organization_name=organization_name)


def confluent_organization_create(client,
                                  resource_group_name,
                                  organization_name,
                                  tags=None,
                                  location=None,
                                  publisher_id=None,
                                  offer_id=None,
                                  plan_id=None,
                                  plan_name=None,
                                  term_unit=None,
                                  no_wait=False):
    body = {}
    body['tags'] = tags
    body['location'] = location
    body['offer_detail'] = {}
    body['offer_detail']['publisher_id'] = publisher_id
    body['offer_detail']['id'] = offer_id
    body['offer_detail']['plan_id'] = plan_id
    body['offer_detail']['plan_name'] = plan_name
    body['offer_detail']['term_unit'] = term_unit
    return sdk_no_wait(no_wait,
                       client.begin_create,
                       resource_group_name=resource_group_name,
                       organization_name=organization_name,
                       body=body)


def confluent_organization_update(client,
                                  resource_group_name,
                                  organization_name,
                                  tags=None):
    body = {}
    body['tags'] = tags
    return client.update(resource_group_name=resource_group_name,
                         organization_name=organization_name,
                         body=body)


def confluent_organization_delete(client,
                                  resource_group_name,
                                  organization_name,
                                  no_wait=False):
    return sdk_no_wait(no_wait,
                       client.begin_delete,
                       resource_group_name=resource_group_name,
                       organization_name=organization_name)
