from ... pyaz_utils import _call_az

def show(name, resource_group):
    '''
    Get the details for an instance pool.

    Required Parameters:
    - name -- Instance Pool Name
    - resource_group -- Name of resource group. You can configure the default group using `az configure --defaults group=<name>`
    '''
    return _call_az("az sql instance-pool show", locals())


def list(resource_group=None):
    '''
    List available instance pools.

    Optional Parameters:
    - resource_group -- Name of resource group. You can configure the default group using `az configure --defaults group=<name>`
    '''
    return _call_az("az sql instance-pool list", locals())


def update(name, resource_group, add=None, force_string=None, remove=None, set=None, tags=None):
    '''
    Update an instance pool.

    Required Parameters:
    - name -- Instance Pool Name
    - resource_group -- Name of resource group. You can configure the default group using `az configure --defaults group=<name>`

    Optional Parameters:
    - add -- Add an object to a list of objects by specifying a path and key value pairs.  Example: --add property.listProperty <key=value, string or JSON string>
    - force_string -- When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.
    - remove -- Remove a property or an element from a list.  Example: --remove property.list <indexToRemove> OR --remove propertyToRemove
    - set -- Update an object by specifying a property path and value to set.  Example: --set property1.property2=<value>
    - tags -- space-separated tags: key[=value] [key[=value] ...]. Use '' to clear existing tags.
    '''
    return _call_az("az sql instance-pool update", locals())


def delete(name, resource_group, no_wait=None, yes=None):
    '''
    Delete an instance pool.

    Required Parameters:
    - name -- Instance Pool Name
    - resource_group -- Name of resource group. You can configure the default group using `az configure --defaults group=<name>`

    Optional Parameters:
    - no_wait -- Do not wait for the long-running operation to finish.
    - yes -- Do not prompt for confirmation.
    '''
    return _call_az("az sql instance-pool delete", locals())


def create(capacity, family, location, name, resource_group, subnet, tier, license_type=None, no_wait=None, tags=None, vnet_name=None):
    '''
    Create an instance pool.

    Required Parameters:
    - capacity -- Capacity of the instance pool in vcores.
    - family -- The compute generation component of the sku. Allowed value: Gen5
    - location -- Location. Values from: `az account list-locations`. You can configure the default location using `az configure --defaults location=<location>`.
    - name -- Instance Pool Name
    - resource_group -- Name of resource group. You can configure the default group using `az configure --defaults group=<name>`
    - subnet -- Name or ID of the subnet that allows access to an Instance Pool. If subnet name is provided, --vnet-name must be provided.
    - tier -- The edition component of the sku. Allowed value: GeneralPurpose.

    Optional Parameters:
    - license_type -- The license type to apply for this instance pool.
    - no_wait -- Do not wait for the long-running operation to finish.
    - tags -- space-separated tags: key[=value] [key[=value] ...]. Use '' to clear existing tags.
    - vnet_name -- The virtual network name
    '''
    return _call_az("az sql instance-pool create", locals())


def wait(name, resource_group, created=None, custom=None, deleted=None, exists=None, interval=None, timeout=None, updated=None):
    '''
    Wait for an instance pool to reach a desired state.

    Required Parameters:
    - name -- Instance Pool Name
    - resource_group -- Name of resource group. You can configure the default group using `az configure --defaults group=<name>`

    Optional Parameters:
    - created -- wait until created with 'provisioningState' at 'Succeeded'
    - custom -- Wait until the condition satisfies a custom JMESPath query. E.g. provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']
    - deleted -- wait until deleted
    - exists -- wait until the resource exists
    - interval -- polling interval in seconds
    - timeout -- maximum wait in seconds
    - updated -- wait until updated with provisioningState at 'Succeeded'
    '''
    return _call_az("az sql instance-pool wait", locals())

