# coding: utf-8
# Copyright (c) 2016, 2026, Oracle and/or its affiliates.  All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
# NOTE: This class is auto generated by OracleSDKGenerator. DO NOT EDIT. API Version: 20260325

from __future__ import print_function
import click
import oci  # noqa: F401
import six  # noqa: F401
import sys  # noqa: F401
from oci_cli import cli_constants  # noqa: F401
from oci_cli import cli_util
from oci_cli import json_skeleton_utils
from oci_cli import custom_types  # noqa: F401
from oci_cli.aliasing import CommandGroupWithAlias
from services.generative_ai_data.src.oci_cli_generative_ai_data.generated import generative_ai_data_service_cli


@click.command(cli_util.override('generate_sql_from_nl_job.generate_sql_from_nl_job_root_group.command_name', 'generate-sql-from-nl-job'), cls=CommandGroupWithAlias, help=cli_util.override('generate_sql_from_nl_job.generate_sql_from_nl_job_root_group.help', """A description of the ReferenceService API. in progress"""), short_help=cli_util.override('generate_sql_from_nl_job.generate_sql_from_nl_job_root_group.short_help', """Generative AI Service NL2SQL API"""))
@cli_util.help_option_group
def generate_sql_from_nl_job_root_group():
    pass


@click.command(cli_util.override('generate_sql_from_nl_job.generate_sql_from_nl_job_group.command_name', 'generate-sql-from-nl-job'), cls=CommandGroupWithAlias, help="""Object representing to GenerateSqlFromNlJob. ocidEntityType: generativeaiGenerateSqlFromNlJob adLocality: regional""")
@cli_util.help_option_group
def generate_sql_from_nl_job_group():
    pass


generative_ai_data_service_cli.generative_ai_data_service_group.add_command(generate_sql_from_nl_job_root_group)
generate_sql_from_nl_job_root_group.add_command(generate_sql_from_nl_job_group)


@generate_sql_from_nl_job_group.command(name=cli_util.override('generate_sql_from_nl_job.generate_sql_from_nl.command_name', 'generate-sql-from-nl'), help=u"""Generates a SQL query from a natural language input for the specified SemanticStore. \n[Command Reference](generateSqlFromNl)""")
@cli_util.option('--input-natural-language-query', required=True, help=u"""A user-provided query or instruction written in plain, conversational language. This input is intended to capture the user's intent, question, or command without requiring technical syntax or structured formatting. The query should clearly express what the user wants to know or accomplish, allowing the system to interpret and respond appropriately.""")
@cli_util.option('--semantic-store-id', required=True, help=u"""The OCID of the semantic store""")
@cli_util.option('--description', help=u"""An optional description of the GenerateSqlFromNlJob.""")
@cli_util.option('--display-name', help=u"""A user-friendly display name. It does not have to be unique and can be modified. Avoid entering confidential information.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'generative_ai_data', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'generative_ai_data', 'class': 'dict(str, dict(str, object))'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'generative_ai_data', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'generative_ai_data', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'generative_ai_data', 'class': 'GenerateSqlFromNlJob'})
@cli_util.wrap_exceptions
def generate_sql_from_nl(ctx, from_json, input_natural_language_query, semantic_store_id, description, display_name, freeform_tags, defined_tags, if_match):

    if isinstance(semantic_store_id, six.string_types) and len(semantic_store_id.strip()) == 0:
        raise click.UsageError('Parameter --semantic-store-id cannot be whitespace or empty string')

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['inputNaturalLanguageQuery'] = input_natural_language_query

    if description is not None:
        _details['description'] = description

    if display_name is not None:
        _details['displayName'] = display_name

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    client = cli_util.build_client('generative_ai_data', 'generate_sql_from_nl_job', ctx)
    result = client.generate_sql_from_nl(
        semantic_store_id=semantic_store_id,
        generate_sql_from_nl_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
