diff --git a/.nextchanges/bundles/genie_agents.md b/.nextchanges/bundles/genie_agents.md new file mode 100644 index 00000000000..ca5f10a3d89 --- /dev/null +++ b/.nextchanges/bundles/genie_agents.md @@ -0,0 +1 @@ +* Add the `genie_agents` resource for managing AI/BI Genie agents on the direct deployment engine. diff --git a/acceptance/bundle/deployment/bind/genie_agent/databricks.yml b/acceptance/bundle/deployment/bind/genie_agent/databricks.yml new file mode 100644 index 00000000000..ca373223061 --- /dev/null +++ b/acceptance/bundle/deployment/bind/genie_agent/databricks.yml @@ -0,0 +1,14 @@ +bundle: + name: test-bundle + +resources: + genie_agents: + agent1: + genie_agent_id: "01f0a1b2c3d4e5f60718293a4b5c6d7e" + display_name: bound-agent + warehouse_id: test-warehouse-id + definition: + config: + sample_questions: + - id: "01f0a1b2c3d4e5f60718293a4b5c6d7f" + question: What were total sales last month? diff --git a/acceptance/bundle/deployment/bind/genie_agent/out.test.toml b/acceptance/bundle/deployment/bind/genie_agent/out.test.toml new file mode 100644 index 00000000000..a927a5fbc06 --- /dev/null +++ b/acceptance/bundle/deployment/bind/genie_agent/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/deployment/bind/genie_agent/output.txt b/acceptance/bundle/deployment/bind/genie_agent/output.txt new file mode 100644 index 00000000000..ef44e06497c --- /dev/null +++ b/acceptance/bundle/deployment/bind/genie_agent/output.txt @@ -0,0 +1,48 @@ + +>>> [CLI] genie-agents create-genie-agent --json { + "display_name": "bound-agent", + "warehouse_id": "test-warehouse-id", + "definition": { + "config": { + "sample_questions": [ + {"id": "01f0a1b2c3d4e5f60718293a4b5c6d7f", "question": "What were total sales last month?"} + ] + } + } +} --genie-agent-id 01f0a1b2c3d4e5f60718293a4b5c6d7e +{ + "name": "agents/01f0a1b2c3d4e5f60718293a4b5c6d7e", + "display_name": "bound-agent", + "warehouse_id": "test-warehouse-id", + "etag": "1" +} + +>>> [CLI] bundle deployment bind agent1 01f0a1b2c3d4e5f60718293a4b5c6d7e --auto-approve +Successfully bound genie_agent with an id '01f0a1b2c3d4e5f60718293a4b5c6d7e' +Run 'bundle deploy' to deploy changes to your workspace + +>>> [CLI] bundle summary +Name: test-bundle +Target: default +Workspace: + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default +Resources: + Genie Agents: + agent1: + Name: bound-agent + URL: [DATABRICKS_URL]/genie/rooms/01f0a1b2c3d4e5f60718293a4b5c6d7e?w=[WORKSPACE_ID] + +>>> [CLI] bundle deployment unbind agent1 + +>>> [CLI] bundle summary +Name: test-bundle +Target: default +Workspace: + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default +Resources: + Genie Agents: + agent1: + Name: bound-agent + URL: (not deployed) diff --git a/acceptance/bundle/deployment/bind/genie_agent/script b/acceptance/bundle/deployment/bind/genie_agent/script new file mode 100644 index 00000000000..73ae2b63c87 --- /dev/null +++ b/acceptance/bundle/deployment/bind/genie_agent/script @@ -0,0 +1,20 @@ +AGENT="01f0a1b2c3d4e5f60718293a4b5c6d7e" + +# Create the object outside the bundle with the CLI's own create command. +trace $CLI genie-agents create-genie-agent --json '{ + "display_name": "bound-agent", + "warehouse_id": "test-warehouse-id", + "definition": { + "config": { + "sample_questions": [ + {"id": "01f0a1b2c3d4e5f60718293a4b5c6d7f", "question": "What were total sales last month?"} + ] + } + } +}' --genie-agent-id "$AGENT" | agent_fields + +trace $CLI bundle deployment bind agent1 "$AGENT" --auto-approve +trace $CLI bundle summary + +trace $CLI bundle deployment unbind agent1 +trace $CLI bundle summary diff --git a/acceptance/bundle/deployment/bind/genie_agent/script.prepare b/acceptance/bundle/deployment/bind/genie_agent/script.prepare new file mode 100644 index 00000000000..96d3dc77ef2 --- /dev/null +++ b/acceptance/bundle/deployment/bind/genie_agent/script.prepare @@ -0,0 +1,4 @@ +# Project a genie agent read to the fields the test asserts. +agent_fields() { + jq '{name, display_name, warehouse_id, etag}' +} diff --git a/acceptance/bundle/deployment/bind/genie_agent/test.toml b/acceptance/bundle/deployment/bind/genie_agent/test.toml new file mode 100644 index 00000000000..4f5f1962a36 --- /dev/null +++ b/acceptance/bundle/deployment/bind/genie_agent/test.toml @@ -0,0 +1,6 @@ +# Genie agents are managed by the direct deployment engine. +Cloud = false + +Ignore = [ + ".databricks", +] diff --git a/acceptance/bundle/invariant/auto-migrate/test.toml b/acceptance/bundle/invariant/auto-migrate/test.toml index ee0a30ed9da..bc397416e18 100644 --- a/acceptance/bundle/invariant/auto-migrate/test.toml +++ b/acceptance/bundle/invariant/auto-migrate/test.toml @@ -31,6 +31,8 @@ EnvMatrixExclude.no_external_location = ["INPUT_CONFIG=external_location.yml.tmp EnvMatrixExclude.no_uc_trailing_slash = ["INPUT_CONFIG=uc_trailing_slash.yml.tmpl"] # Genie spaces are direct-only too; the terraform deploy that seeds the migration fails for them. EnvMatrixExclude.no_genie_space = ["INPUT_CONFIG=genie_space.yml.tmpl"] +# Genie agents are direct-only too; the terraform deploy that seeds the migration fails for them. +EnvMatrixExclude.no_genie_agent = ["INPUT_CONFIG=genie_agent.yml.tmpl"] # Instance pools are direct-only; the terraform deploy that seeds the migration fails for them. EnvMatrixExclude.no_instance_pool = ["INPUT_CONFIG=instance_pool.yml.tmpl"] # Cluster policies are direct-only; the terraform deploy that seeds the migration fails for them. diff --git a/acceptance/bundle/invariant/configs/genie_agent.yml.tmpl b/acceptance/bundle/invariant/configs/genie_agent.yml.tmpl new file mode 100644 index 00000000000..9de3b1120f2 --- /dev/null +++ b/acceptance/bundle/invariant/configs/genie_agent.yml.tmpl @@ -0,0 +1,20 @@ +bundle: + name: test-bundle-$UNIQUE_NAME + +resources: + genie_agents: + foo: + warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID + display_name: test-genie-agent-$UNIQUE_NAME + description: This is a test genie agent # CAN_REMOVE + definition: + config: + sample_questions: + - id: "01f0a1b2c3d4e5f60718293a4b5c6d7e" + question: What were total sales last month? + data_sources: + tables: + - identifier: main.sales.orders + permissions: + - level: CAN_READ + group_name: users diff --git a/acceptance/bundle/invariant/continue_293/test.toml b/acceptance/bundle/invariant/continue_293/test.toml index 150d61a2c4b..b07e4191632 100644 --- a/acceptance/bundle/invariant/continue_293/test.toml +++ b/acceptance/bundle/invariant/continue_293/test.toml @@ -17,6 +17,9 @@ EnvMatrixExclude.no_vector_search_index = ["INPUT_CONFIG=vector_search_index.yml # genie_spaces resource is not supported on v0.293.0 EnvMatrixExclude.no_genie_space = ["INPUT_CONFIG=genie_space.yml.tmpl"] +# genie_agents resource is not supported on v0.293.0 +EnvMatrixExclude.no_genie_agent = ["INPUT_CONFIG=genie_agent.yml.tmpl"] + # instance_pools resource is not supported on v0.293.0 EnvMatrixExclude.no_instance_pool = ["INPUT_CONFIG=instance_pool.yml.tmpl"] diff --git a/acceptance/bundle/invariant/delete_idempotent/out.test.toml b/acceptance/bundle/invariant/delete_idempotent/out.test.toml index 9de4b5dba9b..ca880de3340 100644 --- a/acceptance/bundle/invariant/delete_idempotent/out.test.toml +++ b/acceptance/bundle/invariant/delete_idempotent/out.test.toml @@ -20,6 +20,7 @@ EnvMatrix.INPUT_CONFIG = [ "external_location.yml.tmpl", "feature.yml.tmpl", "feature_spec.yml.tmpl", + "genie_agent.yml.tmpl", "genie_space.yml.tmpl", "instance_pool.yml.tmpl", "job.yml.tmpl", diff --git a/acceptance/bundle/invariant/destroy_idempotent/out.test.toml b/acceptance/bundle/invariant/destroy_idempotent/out.test.toml index 9de4b5dba9b..ca880de3340 100644 --- a/acceptance/bundle/invariant/destroy_idempotent/out.test.toml +++ b/acceptance/bundle/invariant/destroy_idempotent/out.test.toml @@ -20,6 +20,7 @@ EnvMatrix.INPUT_CONFIG = [ "external_location.yml.tmpl", "feature.yml.tmpl", "feature_spec.yml.tmpl", + "genie_agent.yml.tmpl", "genie_space.yml.tmpl", "instance_pool.yml.tmpl", "job.yml.tmpl", diff --git a/acceptance/bundle/invariant/migrate/test.toml b/acceptance/bundle/invariant/migrate/test.toml index 71e5463fa01..b99138c8c7e 100644 --- a/acceptance/bundle/invariant/migrate/test.toml +++ b/acceptance/bundle/invariant/migrate/test.toml @@ -31,6 +31,8 @@ EnvMatrixExclude.no_external_location = ["INPUT_CONFIG=external_location.yml.tmp EnvMatrixExclude.no_uc_trailing_slash = ["INPUT_CONFIG=uc_trailing_slash.yml.tmpl"] # Genie spaces are direct-only too; the terraform deploy that seeds the migration fails for them. EnvMatrixExclude.no_genie_space = ["INPUT_CONFIG=genie_space.yml.tmpl"] +# Genie agents are direct-only too; the terraform deploy that seeds the migration fails for them. +EnvMatrixExclude.no_genie_agent = ["INPUT_CONFIG=genie_agent.yml.tmpl"] # Instance pools are direct-only; the terraform deploy that seeds the migration fails for them. EnvMatrixExclude.no_instance_pool = ["INPUT_CONFIG=instance_pool.yml.tmpl"] # Cluster policies are direct-only; the terraform deploy that seeds the migration fails for them. diff --git a/acceptance/bundle/invariant/no_drift/out.test.toml b/acceptance/bundle/invariant/no_drift/out.test.toml index a2856e6353d..68487df60f0 100644 --- a/acceptance/bundle/invariant/no_drift/out.test.toml +++ b/acceptance/bundle/invariant/no_drift/out.test.toml @@ -20,6 +20,7 @@ EnvMatrix.INPUT_CONFIG = [ "external_location.yml.tmpl", "feature.yml.tmpl", "feature_spec.yml.tmpl", + "genie_agent.yml.tmpl", "genie_space.yml.tmpl", "instance_pool.yml.tmpl", "job.yml.tmpl", diff --git a/acceptance/bundle/invariant/test.toml b/acceptance/bundle/invariant/test.toml index 1c1abd19348..8b3934caea8 100644 --- a/acceptance/bundle/invariant/test.toml +++ b/acceptance/bundle/invariant/test.toml @@ -34,6 +34,7 @@ EnvMatrix.INPUT_CONFIG = [ "external_location.yml.tmpl", "feature.yml.tmpl", "feature_spec.yml.tmpl", + "genie_agent.yml.tmpl", "genie_space.yml.tmpl", "instance_pool.yml.tmpl", "job.yml.tmpl", @@ -128,6 +129,8 @@ EnvMatrixExclude.no_data_quality_monitor_on_cloud = ["CONFIG_Cloud=true", "INPUT EnvMatrixExclude.no_feature_spec_dms = ["DMS=true", "INPUT_CONFIG=feature_spec.yml.tmpl"] # Same for the "postgres_data_apis." prefix. EnvMatrixExclude.no_postgres_data_api_dms = ["DMS=true", "INPUT_CONFIG=postgres_data_api.yml.tmpl"] +# Same for the "genie_agents." prefix. +EnvMatrixExclude.no_genie_agent_dms = ["DMS=true", "INPUT_CONFIG=genie_agent.yml.tmpl"] [[Server]] Pattern = "DELETE /api/2.1/unity-catalog/tables/{full_name}" diff --git a/acceptance/bundle/refschema/output/genie_agents.txt b/acceptance/bundle/refschema/output/genie_agents.txt new file mode 100644 index 00000000000..55f432ff7de --- /dev/null +++ b/acceptance/bundle/refschema/output/genie_agents.txt @@ -0,0 +1,123 @@ +resources.genie_agents.*.definition *genieagents.GenieAgentDefinition ALL +resources.genie_agents.*.definition.benchmarks *genieagents.GenieAgentBenchmarks ALL +resources.genie_agents.*.definition.benchmarks.questions []genieagents.GenieAgentBenchmarkQuestion ALL +resources.genie_agents.*.definition.benchmarks.questions[*] genieagents.GenieAgentBenchmarkQuestion ALL +resources.genie_agents.*.definition.benchmarks.questions[*].answer []genieagents.GenieAgentBenchmarkAnswer ALL +resources.genie_agents.*.definition.benchmarks.questions[*].answer[*] genieagents.GenieAgentBenchmarkAnswer ALL +resources.genie_agents.*.definition.benchmarks.questions[*].answer[*].content string ALL +resources.genie_agents.*.definition.benchmarks.questions[*].answer[*].format genieagents.GenieAgentBenchmarkAnswerFormat ALL +resources.genie_agents.*.definition.benchmarks.questions[*].evaluation_note string ALL +resources.genie_agents.*.definition.benchmarks.questions[*].id string ALL +resources.genie_agents.*.definition.benchmarks.questions[*].question string ALL +resources.genie_agents.*.definition.config *genieagents.GenieAgentConfig ALL +resources.genie_agents.*.definition.config.sample_questions []genieagents.GenieAgentSampleQuestion ALL +resources.genie_agents.*.definition.config.sample_questions[*] genieagents.GenieAgentSampleQuestion ALL +resources.genie_agents.*.definition.config.sample_questions[*].id string ALL +resources.genie_agents.*.definition.config.sample_questions[*].question string ALL +resources.genie_agents.*.definition.data_sources *genieagents.GenieAgentDataSources ALL +resources.genie_agents.*.definition.data_sources.mcp_connections []genieagents.GenieAgentMcpConnection ALL +resources.genie_agents.*.definition.data_sources.mcp_connections[*] genieagents.GenieAgentMcpConnection ALL +resources.genie_agents.*.definition.data_sources.mcp_connections[*].mcp_connection string ALL +resources.genie_agents.*.definition.data_sources.tables []genieagents.GenieAgentTable ALL +resources.genie_agents.*.definition.data_sources.tables[*] genieagents.GenieAgentTable ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs []genieagents.GenieAgentColumnConfig ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*] genieagents.GenieAgentColumnConfig ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*].column string ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*].description string ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*].display_name string ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*].enable_entity_matching bool ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*].enable_format_assistance bool ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*].exclude bool ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*].synonyms []string ALL +resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*].synonyms[*] string ALL +resources.genie_agents.*.definition.data_sources.tables[*].description string ALL +resources.genie_agents.*.definition.data_sources.tables[*].identifier string ALL +resources.genie_agents.*.definition.data_sources.volumes []genieagents.GenieAgentVolume ALL +resources.genie_agents.*.definition.data_sources.volumes[*] genieagents.GenieAgentVolume ALL +resources.genie_agents.*.definition.data_sources.volumes[*].description string ALL +resources.genie_agents.*.definition.data_sources.volumes[*].path string ALL +resources.genie_agents.*.definition.instructions *genieagents.GenieAgentInstructions ALL +resources.genie_agents.*.definition.instructions.example_question_sqls []genieagents.GenieAgentExampleQuestionSql ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*] genieagents.GenieAgentExampleQuestionSql ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].id string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters []genieagents.GenieAgentSqlParameter ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*] genieagents.GenieAgentSqlParameter ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].default_value *genieagents.GenieAgentSqlParameterDefaultValue ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].default_value.value_range *genieagents.GenieAgentSqlParameterDefaultRange ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].default_value.value_range.max string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].default_value.value_range.min string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].default_value.values []string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].default_value.values[*] string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].description string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].name string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*].type_hint string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].question string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].sql string ALL +resources.genie_agents.*.definition.instructions.example_question_sqls[*].usage_guidance string ALL +resources.genie_agents.*.definition.instructions.join_specs []genieagents.GenieAgentJoinSpec ALL +resources.genie_agents.*.definition.instructions.join_specs[*] genieagents.GenieAgentJoinSpec ALL +resources.genie_agents.*.definition.instructions.join_specs[*].comment string ALL +resources.genie_agents.*.definition.instructions.join_specs[*].id string ALL +resources.genie_agents.*.definition.instructions.join_specs[*].instruction string ALL +resources.genie_agents.*.definition.instructions.join_specs[*].left genieagents.GenieAgentJoinSource ALL +resources.genie_agents.*.definition.instructions.join_specs[*].left.alias string ALL +resources.genie_agents.*.definition.instructions.join_specs[*].left.identifier string ALL +resources.genie_agents.*.definition.instructions.join_specs[*].relationship_type genieagents.GenieAgentJoinRelationshipType ALL +resources.genie_agents.*.definition.instructions.join_specs[*].right genieagents.GenieAgentJoinSource ALL +resources.genie_agents.*.definition.instructions.join_specs[*].right.alias string ALL +resources.genie_agents.*.definition.instructions.join_specs[*].right.identifier string ALL +resources.genie_agents.*.definition.instructions.join_specs[*].sql string ALL +resources.genie_agents.*.definition.instructions.sql_functions []genieagents.GenieAgentSqlFunction ALL +resources.genie_agents.*.definition.instructions.sql_functions[*] genieagents.GenieAgentSqlFunction ALL +resources.genie_agents.*.definition.instructions.sql_functions[*].id string ALL +resources.genie_agents.*.definition.instructions.sql_functions[*].identifier string ALL +resources.genie_agents.*.definition.instructions.sql_snippets *genieagents.GenieAgentSqlSnippets ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions []genieagents.GenieAgentSqlExpression ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*] genieagents.GenieAgentSqlExpression ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*].alias string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*].display_name string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*].id string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*].instruction string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*].sql string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*].synonyms []string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*].synonyms[*] string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.filters []genieagents.GenieAgentSqlFilter ALL +resources.genie_agents.*.definition.instructions.sql_snippets.filters[*] genieagents.GenieAgentSqlFilter ALL +resources.genie_agents.*.definition.instructions.sql_snippets.filters[*].display_name string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.filters[*].id string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.filters[*].instruction string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.filters[*].sql string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.filters[*].synonyms []string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.filters[*].synonyms[*] string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures []genieagents.GenieAgentSqlMeasure ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures[*] genieagents.GenieAgentSqlMeasure ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures[*].alias string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures[*].display_name string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures[*].id string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures[*].instruction string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures[*].sql string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures[*].synonyms []string ALL +resources.genie_agents.*.definition.instructions.sql_snippets.measures[*].synonyms[*] string ALL +resources.genie_agents.*.definition.instructions.text_instructions []genieagents.GenieAgentTextInstruction ALL +resources.genie_agents.*.definition.instructions.text_instructions[*] genieagents.GenieAgentTextInstruction ALL +resources.genie_agents.*.definition.instructions.text_instructions[*].content string ALL +resources.genie_agents.*.definition.instructions.text_instructions[*].id string ALL +resources.genie_agents.*.description string ALL +resources.genie_agents.*.display_name string ALL +resources.genie_agents.*.genie_agent_id string ALL +resources.genie_agents.*.id string INPUT +resources.genie_agents.*.lifecycle resources.Lifecycle INPUT +resources.genie_agents.*.lifecycle.depends_on []resources.DependsOn INPUT +resources.genie_agents.*.lifecycle.depends_on[*] resources.DependsOn INPUT +resources.genie_agents.*.lifecycle.depends_on[*].resource string INPUT +resources.genie_agents.*.lifecycle.prevent_destroy bool INPUT +resources.genie_agents.*.modified_status string INPUT +resources.genie_agents.*.parent_path string ALL +resources.genie_agents.*.url string INPUT +resources.genie_agents.*.warehouse_id string ALL +resources.genie_agents.*.permissions.object_id string ALL +resources.genie_agents.*.permissions[*] dresources.StatePermission ALL +resources.genie_agents.*.permissions[*].group_name string ALL +resources.genie_agents.*.permissions[*].level iam.PermissionLevel ALL +resources.genie_agents.*.permissions[*].service_principal_name string ALL +resources.genie_agents.*.permissions[*].user_name string ALL diff --git a/acceptance/bundle/resources/genie_agents/basic/databricks.yml b/acceptance/bundle/resources/genie_agents/basic/databricks.yml new file mode 100644 index 00000000000..44973c3dbea --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/basic/databricks.yml @@ -0,0 +1,19 @@ +bundle: + name: test-bundle + +resources: + genie_agents: + agent1: + genie_agent_id: "01f0a1b2c3d4e5f60718293a4b5c6d7e" + display_name: my-agent + description: COMMENT1 + warehouse_id: test-warehouse-id + definition: + config: + sample_questions: + - id: "01f0a1b2c3d4e5f60718293a4b5c6d7f" + question: What were total sales last month? + data_sources: + tables: + - identifier: main.sales.orders + description: One row per order, with order date and amount. diff --git a/acceptance/bundle/resources/genie_agents/basic/out.test.toml b/acceptance/bundle/resources/genie_agents/basic/out.test.toml new file mode 100644 index 00000000000..19b5b15d11f --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/basic/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/resources/genie_agents/basic/output.txt b/acceptance/bundle/resources/genie_agents/basic/output.txt new file mode 100644 index 00000000000..4b706794a66 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/basic/output.txt @@ -0,0 +1,280 @@ + +=== Initial summary before deploy + +>>> [CLI] bundle summary -o json +{ + "definition": { + "config": { + "sample_questions": [ + { + "id": "01f0a1b2c3d4e5f60718293a4b5c6d7f", + "question": "What were total sales last month?" + } + ] + }, + "data_sources": { + "tables": [ + { + "description": "One row per order, with order date and amount.", + "identifier": "main.sales.orders" + } + ] + } + }, + "description": "COMMENT1", + "display_name": "my-agent", + "genie_agent_id": "01f0a1b2c3d4e5f60718293a4b5c6d7e", + "modified_status": "created", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/resources", + "warehouse_id": "test-warehouse-id" +} + +=== Verify it does not exist yet + +>>> musterr [CLI] genie-agents get-genie-agent agents/01f0a1b2c3d4e5f60718293a4b5c6d7e +Error: Genie Agent not found + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Created genie_agents.agent1 +Files: 1 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +>>> print_requests.py //genie/agents //workspace/mkdirs +{ + "method": "POST", + "path": "/api/2.0/workspace/mkdirs", + "body": { + "path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state" + } +} +{ + "method": "POST", + "path": "/api/2.0/workspace/mkdirs", + "body": { + "path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal" + } +} +{ + "method": "POST", + "path": "/api/2.0/workspace/mkdirs", + "body": { + "path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files" + } +} +{ + "method": "POST", + "path": "/api/2.0/genie/agents", + "q": { + "genie_agent_id": "01f0a1b2c3d4e5f60718293a4b5c6d7e" + }, + "body": { + "definition": { + "config": { + "sample_questions": [ + { + "id": "01f0a1b2c3d4e5f60718293a4b5c6d7f", + "question": "What were total sales last month?" + } + ] + }, + "data_sources": { + "tables": [ + { + "description": "One row per order, with order date and amount.", + "identifier": "main.sales.orders" + } + ] + } + }, + "description": "COMMENT1", + "display_name": "my-agent", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/resources", + "warehouse_id": "test-warehouse-id" + } +} +{ + "method": "POST", + "path": "/api/2.0/workspace/mkdirs", + "body": { + "path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/resources" + } +} +{ + "method": "POST", + "path": "/api/2.0/genie/agents", + "q": { + "genie_agent_id": "01f0a1b2c3d4e5f60718293a4b5c6d7e" + }, + "body": { + "definition": { + "config": { + "sample_questions": [ + { + "id": "01f0a1b2c3d4e5f60718293a4b5c6d7f", + "question": "What were total sales last month?" + } + ] + }, + "data_sources": { + "tables": [ + { + "description": "One row per order, with order date and amount.", + "identifier": "main.sales.orders" + } + ] + } + }, + "description": "COMMENT1", + "display_name": "my-agent", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/resources", + "warehouse_id": "test-warehouse-id" + } +} + +=== Summary should show the id and the Genie room url + +>>> [CLI] bundle summary -o json +{ + "id": "01f0a1b2c3d4e5f60718293a4b5c6d7e", + "url": "[DATABRICKS_URL]/genie/rooms/01f0a1b2c3d4e5f60718293a4b5c6d7e?w=[WORKSPACE_ID]" +} + +=== Verify deployment + +>>> [CLI] genie-agents get-genie-agent agents/01f0a1b2c3d4e5f60718293a4b5c6d7e +{ + "name": "agents/01f0a1b2c3d4e5f60718293a4b5c6d7e", + "display_name": "my-agent", + "description": "COMMENT1", + "warehouse_id": "test-warehouse-id", + "etag": "1" +} + +=== Update description (should update in place, not recreate) + +>>> update_file.py databricks.yml COMMENT1 COMMENT2 + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Updated genie_agents.agent1 +Files: 1 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged + +>>> print_requests.py //genie/agents +{ + "method": "PATCH", + "path": "/api/2.0/genie/agents/01f0a1b2c3d4e5f60718293a4b5c6d7e", + "q": { + "update_mask": "*" + }, + "body": { + "definition": { + "config": { + "sample_questions": [ + { + "id": "01f0a1b2c3d4e5f60718293a4b5c6d7f", + "question": "What were total sales last month?" + } + ] + }, + "data_sources": { + "tables": [ + { + "description": "One row per order, with order date and amount.", + "identifier": "main.sales.orders" + } + ] + } + }, + "description": "COMMENT2", + "display_name": "my-agent", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/resources", + "warehouse_id": "test-warehouse-id" + } +} + +>>> [CLI] genie-agents get-genie-agent agents/01f0a1b2c3d4e5f60718293a4b5c6d7e +{ + "name": "agents/01f0a1b2c3d4e5f60718293a4b5c6d7e", + "display_name": "my-agent", + "description": "COMMENT2", + "warehouse_id": "test-warehouse-id", + "etag": "1" +} + +=== Change the identity field (should plan a recreate) + +>>> update_file.py databricks.yml 01f0a1b2c3d4e5f60718293a4b5c6d7e 02f0a1b2c3d4e5f60718293a4b5c6d7e + +>>> [CLI] bundle plan +recreate genie_agents.agent1 + +Plan: 1 to add, 0 to change, 1 to delete, 0 unchanged + +>>> [CLI] bundle deploy --auto-approve +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... + +This action will result in the deletion or recreation of the following Genie agents. +The conversation history attached to a deleted agent is permanently lost: + recreate resources.genie_agents.agent1 +Recreated genie_agents.agent1 +Files: 1 uploaded, 0 deleted +Resources: 1 created, 0 changed, 1 deleted, 0 unchanged + +>>> print_requests.py //genie/agents +{ + "method": "DELETE", + "path": "/api/2.0/genie/agents/01f0a1b2c3d4e5f60718293a4b5c6d7e" +} +{ + "method": "POST", + "path": "/api/2.0/genie/agents", + "q": { + "genie_agent_id": "02f0a1b2c3d4e5f60718293a4b5c6d7e" + }, + "body": { + "definition": { + "config": { + "sample_questions": [ + { + "id": "01f0a1b2c3d4e5f60718293a4b5c6d7f", + "question": "What were total sales last month?" + } + ] + }, + "data_sources": { + "tables": [ + { + "description": "One row per order, with order date and amount.", + "identifier": "main.sales.orders" + } + ] + } + }, + "description": "COMMENT2", + "display_name": "my-agent", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/resources", + "warehouse_id": "test-warehouse-id" + } +} + +=== Destroy + +>>> [CLI] bundle destroy --auto-approve +The following resources will be deleted: + delete resources.genie_agents.agent1 + +This action will result in the deletion of the following Genie agents. +The conversation history attached to them is permanently lost: + delete resources.genie_agents.agent1 + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default + +Destroy: 1 deleted + +>>> print_requests.py //genie/agents +{ + "method": "DELETE", + "path": "/api/2.0/genie/agents/02f0a1b2c3d4e5f60718293a4b5c6d7e" +} diff --git a/acceptance/bundle/resources/genie_agents/basic/script b/acceptance/bundle/resources/genie_agents/basic/script new file mode 100644 index 00000000000..41a79d70ebd --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/basic/script @@ -0,0 +1,35 @@ +AGENT="agents/01f0a1b2c3d4e5f60718293a4b5c6d7e" + +title "Initial summary before deploy" +trace $CLI bundle summary -o json | jq .resources.genie_agents.agent1 + +title "Verify it does not exist yet" +trace musterr $CLI genie-agents get-genie-agent "$AGENT" + +trace $CLI bundle deploy +# The default parent_path (the bundle's resource folder) does not exist on a +# first deploy: the create 404s, the adapter mkdirs and retries. +trace print_requests.py //genie/agents //workspace/mkdirs + +title "Summary should show the id and the Genie room url" +trace $CLI bundle summary -o json | jq ".resources.genie_agents.agent1 | {id, url}" + +title "Verify deployment" +trace $CLI genie-agents get-genie-agent "$AGENT" | agent_fields + +title "Update description (should update in place, not recreate)" +trace update_file.py databricks.yml COMMENT1 COMMENT2 +trace $CLI bundle deploy +trace print_requests.py //genie/agents +trace $CLI genie-agents get-genie-agent "$AGENT" | agent_fields + +title "Change the identity field (should plan a recreate)" +trace update_file.py databricks.yml 01f0a1b2c3d4e5f60718293a4b5c6d7e 02f0a1b2c3d4e5f60718293a4b5c6d7e +trace $CLI bundle plan + +trace $CLI bundle deploy --auto-approve +trace print_requests.py //genie/agents + +title "Destroy" +trace $CLI bundle destroy --auto-approve +trace print_requests.py //genie/agents diff --git a/acceptance/bundle/resources/genie_agents/basic/test.toml b/acceptance/bundle/resources/genie_agents/basic/test.toml new file mode 100644 index 00000000000..116f2013783 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/basic/test.toml @@ -0,0 +1,7 @@ +# Local only: this test inspects the recorded request stream (print_requests), +# which has no equivalent against a real workspace. +Cloud = false + +Ignore = [ + ".databricks", +] diff --git a/acceptance/bundle/resources/genie_agents/lifecycle/databricks.yml.tmpl b/acceptance/bundle/resources/genie_agents/lifecycle/databricks.yml.tmpl new file mode 100644 index 00000000000..36fa6e5b3ac --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/lifecycle/databricks.yml.tmpl @@ -0,0 +1,17 @@ +bundle: + name: deploy-genie-agent-test-$UNIQUE_NAME + +resources: + genie_agents: + agent: + display_name: test_agent_$UNIQUE_NAME + description: "Agent grounded in sales tables" + warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID + definition: + config: + sample_questions: + - id: "01f0a1b2c3d4e5f60718293a4b5c6d7e" + question: What were total sales last month? + data_sources: + tables: + - identifier: main.sales.orders diff --git a/acceptance/bundle/resources/genie_agents/lifecycle/out.test.toml b/acceptance/bundle/resources/genie_agents/lifecycle/out.test.toml new file mode 100644 index 00000000000..f68b4a89c36 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/lifecycle/out.test.toml @@ -0,0 +1,2 @@ +Cloud = true +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/resources/genie_agents/lifecycle/output.txt b/acceptance/bundle/resources/genie_agents/lifecycle/output.txt new file mode 100644 index 00000000000..15f92edf306 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/lifecycle/output.txt @@ -0,0 +1,52 @@ + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-genie-agent-test-[UNIQUE_NAME]/default/files... +Created genie_agents.agent +Files: 2 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +>>> [CLI] genie-agents get-genie-agent agents/[AGENT_ID] +{ + "name": "agents/[AGENT_ID]", + "display_name": "test_agent_[UNIQUE_NAME]", + "description": "Agent grounded in sales tables", + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "etag": "1" +} + +>>> [CLI] bundle plan +Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged + +=== Update description in place + +>>> update_file.py databricks.yml Agent grounded in sales tables Agent grounded in sales tables, updated + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-genie-agent-test-[UNIQUE_NAME]/default/files... +Updated genie_agents.agent +Files: 1 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged + +>>> [CLI] genie-agents get-genie-agent agents/[AGENT_ID] +{ + "name": "agents/[AGENT_ID]", + "display_name": "test_agent_[UNIQUE_NAME]", + "description": "Agent grounded in sales tables, updated", + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "etag": "1" +} + +>>> [CLI] bundle plan +Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged + +>>> [CLI] bundle destroy --auto-approve +The following resources will be deleted: + delete resources.genie_agents.agent + +This action will result in the deletion of the following Genie agents. +The conversation history attached to them is permanently lost: + delete resources.genie_agents.agent + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-genie-agent-test-[UNIQUE_NAME]/default + +Destroy: 1 deleted diff --git a/acceptance/bundle/resources/genie_agents/lifecycle/script b/acceptance/bundle/resources/genie_agents/lifecycle/script new file mode 100644 index 00000000000..e67adbb3910 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/lifecycle/script @@ -0,0 +1,25 @@ +envsubst < databricks.yml.tmpl > databricks.yml + +cleanup() { + trace $CLI bundle destroy --auto-approve +} +trap cleanup EXIT + +trace $CLI bundle deploy + +# The server assigns the id; read it from state and register the [AGENT_ID] +# replacement so the golden does not pin the random value. +AGENT=$(read_id.py agent) + +trace $CLI genie-agents get-genie-agent "agents/$AGENT" | agent_fields + +# Verify there is no drift right after deploy. Text plan (not -o json) keeps the +# output identical between the mock and a real workspace. +trace $CLI bundle plan + +title "Update description in place" +trace update_file.py databricks.yml "Agent grounded in sales tables" "Agent grounded in sales tables, updated" +trace $CLI bundle deploy +trace $CLI genie-agents get-genie-agent "agents/$AGENT" | agent_fields + +trace $CLI bundle plan diff --git a/acceptance/bundle/resources/genie_agents/lifecycle/test.toml b/acceptance/bundle/resources/genie_agents/lifecycle/test.toml new file mode 100644 index 00000000000..8abb5e502eb --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/lifecycle/test.toml @@ -0,0 +1,9 @@ +# Genie agent lifecycle, also runs against a real workspace. The cloud run +# needs the Genie Agents preview enabled on the test workspaces; locally the +# fake server covers the same flow. +RecordRequests = false + +Ignore = [ + "databricks.yml", + ".databricks", +] diff --git a/acceptance/bundle/resources/genie_agents/remote-delete/databricks.yml b/acceptance/bundle/resources/genie_agents/remote-delete/databricks.yml new file mode 100644 index 00000000000..1bff6d9b2ce --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/remote-delete/databricks.yml @@ -0,0 +1,14 @@ +bundle: + name: test-bundle + +resources: + genie_agents: + agent1: + genie_agent_id: "01f0a1b2c3d4e5f60718293a4b5c6d7e" + display_name: my-agent + warehouse_id: test-warehouse-id + definition: + config: + sample_questions: + - id: "01f0a1b2c3d4e5f60718293a4b5c6d7f" + question: What were total sales last month? diff --git a/acceptance/bundle/resources/genie_agents/remote-delete/out.test.toml b/acceptance/bundle/resources/genie_agents/remote-delete/out.test.toml new file mode 100644 index 00000000000..19b5b15d11f --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/remote-delete/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/resources/genie_agents/remote-delete/output.txt b/acceptance/bundle/resources/genie_agents/remote-delete/output.txt new file mode 100644 index 00000000000..35811a847af --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/remote-delete/output.txt @@ -0,0 +1,22 @@ + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Created genie_agents.agent1 +Files: 1 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +=== Delete the resource out of band + +>>> [CLI] genie-agents delete-genie-agent agents/01f0a1b2c3d4e5f60718293a4b5c6d7e + +=== Plan should detect the resource is gone and re-create it + +>>> [CLI] bundle plan +create genie_agents.agent1 + +Plan: 1 to add, 0 to change, 0 to delete, 0 unchanged + +>>> [CLI] bundle destroy --auto-approve +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default + +Destroy: 0 deleted diff --git a/acceptance/bundle/resources/genie_agents/remote-delete/script b/acceptance/bundle/resources/genie_agents/remote-delete/script new file mode 100644 index 00000000000..f1790035ec6 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/remote-delete/script @@ -0,0 +1,9 @@ +trace $CLI bundle deploy + +title "Delete the resource out of band" +trace $CLI genie-agents delete-genie-agent agents/01f0a1b2c3d4e5f60718293a4b5c6d7e + +title "Plan should detect the resource is gone and re-create it" +trace $CLI bundle plan + +trace $CLI bundle destroy --auto-approve diff --git a/acceptance/bundle/resources/genie_agents/remote-delete/test.toml b/acceptance/bundle/resources/genie_agents/remote-delete/test.toml new file mode 100644 index 00000000000..ba894313d70 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/remote-delete/test.toml @@ -0,0 +1,9 @@ +# Local only: simulates an out-of-band delete with a fixed resource id, so it +# can't run against a real workspace. +Cloud = false + +RecordRequests = false + +Ignore = [ + ".databricks", +] diff --git a/acceptance/bundle/resources/genie_agents/script.prepare b/acceptance/bundle/resources/genie_agents/script.prepare new file mode 100644 index 00000000000..2d9bd50f07f --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/script.prepare @@ -0,0 +1,4 @@ +# Project a genie agent read to the fields the test asserts. +agent_fields() { + jq '{name, display_name, description, warehouse_id, etag}' +} diff --git a/acceptance/bundle/resources/genie_agents/test.toml b/acceptance/bundle/resources/genie_agents/test.toml new file mode 100644 index 00000000000..03326ae69c0 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/test.toml @@ -0,0 +1,7 @@ +# Genie agents are managed by the direct deployment engine. +Cloud = true + +# Deployment history has no "genie_agents." resource-key prefix, so enabling +# deployment history warns on every deploy. See dmsResourceTypes in +# libs/testserver/bundledeployments.go, which mirrors the service's allowlist. +EnvMatrixExclude.no_genie_agent_dms = ["DMS=true"] diff --git a/acceptance/bundle/resources/genie_agents/without-definition/databricks.yml.tmpl b/acceptance/bundle/resources/genie_agents/without-definition/databricks.yml.tmpl new file mode 100644 index 00000000000..f000e589e76 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/without-definition/databricks.yml.tmpl @@ -0,0 +1,8 @@ +bundle: + name: genie-agent-no-definition-$UNIQUE_NAME + +resources: + genie_agents: + agent: + display_name: test_agent_$UNIQUE_NAME + warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID diff --git a/acceptance/bundle/resources/genie_agents/without-definition/out.test.toml b/acceptance/bundle/resources/genie_agents/without-definition/out.test.toml new file mode 100644 index 00000000000..19b5b15d11f --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/without-definition/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/resources/genie_agents/without-definition/output.txt b/acceptance/bundle/resources/genie_agents/without-definition/output.txt new file mode 100644 index 00000000000..7c21fc74292 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/without-definition/output.txt @@ -0,0 +1,13 @@ + +>>> [CLI] bundle validate +Warning: required field "definition" is not set + at resources.genie_agents.agent + in databricks.yml:7:7 + +Name: genie-agent-no-definition-[UNIQUE_NAME] +Target: default +Workspace: + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/genie-agent-no-definition-[UNIQUE_NAME]/default + +Found 1 warning diff --git a/acceptance/bundle/resources/genie_agents/without-definition/script b/acceptance/bundle/resources/genie_agents/without-definition/script new file mode 100644 index 00000000000..cfe2ad15929 --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/without-definition/script @@ -0,0 +1,3 @@ +envsubst < databricks.yml.tmpl > databricks.yml + +trace $CLI bundle validate diff --git a/acceptance/bundle/resources/genie_agents/without-definition/test.toml b/acceptance/bundle/resources/genie_agents/without-definition/test.toml new file mode 100644 index 00000000000..1cf5e80e38c --- /dev/null +++ b/acceptance/bundle/resources/genie_agents/without-definition/test.toml @@ -0,0 +1,8 @@ +# Local only: shows the required-field warning; nothing is deployed. +Cloud = false + +RecordRequests = false + +Ignore = [ + ".databricks", +] diff --git a/acceptance/experimental/open/output.txt b/acceptance/experimental/open/output.txt index 09747c5baa0..bae64d7caac 100644 --- a/acceptance/experimental/open/output.txt +++ b/acceptance/experimental/open/output.txt @@ -12,7 +12,7 @@ === unknown resource type >>> [CLI] experimental open --url unknown 123 -Error: unknown resource type "unknown", must be one of: alerts, apps, catalogs, cluster_policies, clusters, dashboards, database_catalogs, database_instances, experiments, feature_specs, features, genie_spaces, instance_pools, jobs, mcp_services, model_provider_services, model_services, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, secrets, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses +Error: unknown resource type "unknown", must be one of: alerts, apps, catalogs, cluster_policies, clusters, dashboards, database_catalogs, database_instances, experiments, feature_specs, features, genie_agents, genie_spaces, instance_pools, jobs, mcp_services, model_provider_services, model_services, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, secrets, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses === test auto-completion handler @@ -28,6 +28,7 @@ database_instances experiments feature_specs features +genie_agents genie_spaces instance_pools jobs diff --git a/bundle/config/mutator/resourcemutator/apply_bundle_permissions.go b/bundle/config/mutator/resourcemutator/apply_bundle_permissions.go index 15493ae9d15..c050f77a7a5 100644 --- a/bundle/config/mutator/resourcemutator/apply_bundle_permissions.go +++ b/bundle/config/mutator/resourcemutator/apply_bundle_permissions.go @@ -52,6 +52,10 @@ var ( permissions.CAN_MANAGE: "CAN_MANAGE", permissions.CAN_VIEW: "CAN_READ", }, + "genie_agents": { + permissions.CAN_MANAGE: "CAN_MANAGE", + permissions.CAN_VIEW: "CAN_READ", + }, "apps": { permissions.CAN_MANAGE: "CAN_MANAGE", permissions.CAN_VIEW: "CAN_USE", diff --git a/bundle/config/mutator/resourcemutator/apply_presets.go b/bundle/config/mutator/resourcemutator/apply_presets.go index d808daf82fb..08761609fb6 100644 --- a/bundle/config/mutator/resourcemutator/apply_presets.go +++ b/bundle/config/mutator/resourcemutator/apply_presets.go @@ -286,6 +286,14 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos genieSpace.Title = prefix + genieSpace.Title } + // Genie Agents: Prefix + for _, genieAgent := range r.GenieAgents { + if genieAgent == nil { + continue + } + genieAgent.DisplayName = prefix + genieAgent.DisplayName + } + // Apps: No presets // Alerts: Prefix, TriggerPauseStatus diff --git a/bundle/config/mutator/resourcemutator/apply_target_mode_test.go b/bundle/config/mutator/resourcemutator/apply_target_mode_test.go index 30a2d8d427c..813bfe33c60 100644 --- a/bundle/config/mutator/resourcemutator/apply_target_mode_test.go +++ b/bundle/config/mutator/resourcemutator/apply_target_mode_test.go @@ -207,6 +207,13 @@ func mockBundle(mode config.Mode) *bundle.Bundle { }, }, }, + GenieAgents: map[string]*resources.GenieAgent{ + "genieagent1": { + GenieAgentConfig: resources.GenieAgentConfig{ + DisplayName: "genieagent1", + }, + }, + }, Apps: map[string]*resources.App{ "app1": { App: apps.App{ @@ -458,6 +465,9 @@ func TestProcessTargetModeDevelopment(t *testing.T) { // Genie Spaces assert.Equal(t, "[dev lennart] geniespace1", b.Config.Resources.GenieSpaces["geniespace1"].Title) + // Genie Agents + assert.Equal(t, "[dev lennart] genieagent1", b.Config.Resources.GenieAgents["genieagent1"].DisplayName) + // Alert 1: has schedule without pause status set - should be paused assert.Equal(t, "[dev lennart] alert1", b.Config.Resources.Alerts["alert1"].DisplayName) assert.Equal(t, sql.SchedulePauseStatusPaused, b.Config.Resources.Alerts["alert1"].Schedule.PauseStatus) diff --git a/bundle/config/mutator/resourcemutator/resource_mutator.go b/bundle/config/mutator/resourcemutator/resource_mutator.go index e00444cc773..16fb6555fdf 100644 --- a/bundle/config/mutator/resourcemutator/resource_mutator.go +++ b/bundle/config/mutator/resourcemutator/resource_mutator.go @@ -53,6 +53,7 @@ func applyInitializeMutators(ctx context.Context, b *bundle.Bundle) { {"resources.dashboards.*.parent_path", b.Config.Workspace.ResourcePath}, {"resources.dashboards.*.embed_credentials", false}, {"resources.genie_spaces.*.parent_path", b.Config.Workspace.ResourcePath}, + {"resources.genie_agents.*.parent_path", b.Config.Workspace.ResourcePath}, {"resources.volumes.*.volume_type", "MANAGED"}, {"resources.alerts.*.parent_path", b.Config.Workspace.ResourcePath}, diff --git a/bundle/config/mutator/resourcemutator/run_as_test.go b/bundle/config/mutator/resourcemutator/run_as_test.go index 6979407c4ec..7a2ad3a72e8 100644 --- a/bundle/config/mutator/resourcemutator/run_as_test.go +++ b/bundle/config/mutator/resourcemutator/run_as_test.go @@ -51,6 +51,7 @@ func allResourceTypes(t *testing.T) []string { "external_locations", "feature_specs", "features", + "genie_agents", "genie_spaces", "instance_pools", "internal_immutable_snapshots", @@ -211,6 +212,7 @@ var allowList = []string{ "experiments", "feature_specs", "features", + "genie_agents", "genie_spaces", "instance_pools", "job_runs", diff --git a/bundle/config/resources.go b/bundle/config/resources.go index b2c968a2b07..0ac8e78b468 100644 --- a/bundle/config/resources.go +++ b/bundle/config/resources.go @@ -35,6 +35,7 @@ type Resources struct { Clusters map[string]*resources.Cluster `json:"clusters,omitempty"` Dashboards map[string]*resources.Dashboard `json:"dashboards,omitempty"` GenieSpaces map[string]*resources.GenieSpace `json:"genie_spaces,omitempty"` + GenieAgents map[string]*resources.GenieAgent `json:"genie_agents,omitempty"` Apps map[string]*resources.App `json:"apps,omitempty"` SecretScopes map[string]*resources.SecretScope `json:"secret_scopes,omitempty"` Alerts map[string]*resources.Alert `json:"alerts,omitempty"` @@ -135,6 +136,7 @@ func (r *Resources) AllResources() []ResourceGroup { collectResourceMap(descriptions["clusters"], r.Clusters), collectResourceMap(descriptions["dashboards"], r.Dashboards), collectResourceMap(descriptions["genie_spaces"], r.GenieSpaces), + collectResourceMap(descriptions["genie_agents"], r.GenieAgents), collectResourceMap(descriptions["volumes"], r.Volumes), collectResourceMap(descriptions["apps"], r.Apps), collectResourceMap(descriptions["alerts"], r.Alerts), @@ -246,6 +248,7 @@ func SupportedResources() map[string]resources.ResourceDescription { "clusters": (&resources.Cluster{}).ResourceDescription(), "dashboards": (&resources.Dashboard{}).ResourceDescription(), "genie_spaces": (&resources.GenieSpace{}).ResourceDescription(), + "genie_agents": (&resources.GenieAgent{}).ResourceDescription(), "volumes": (&resources.Volume{}).ResourceDescription(), "apps": (&resources.App{}).ResourceDescription(), "secret_scopes": (&resources.SecretScope{}).ResourceDescription(), diff --git a/bundle/config/resources/genie_agent.go b/bundle/config/resources/genie_agent.go new file mode 100644 index 00000000000..f0b9bb034db --- /dev/null +++ b/bundle/config/resources/genie_agent.go @@ -0,0 +1,111 @@ +package resources + +import ( + "context" + "net/url" + + "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/workspaceurls" + "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/databricks-sdk-go/marshal" + "github.com/databricks/databricks-sdk-go/service/genieagents" +) + +// GenieAgentConfig is the bundle-authored state for a Genie Agent. +// +// It mirrors ResourceMcpService: the SDK models the create input `genie_agent_id` +// as a URL parameter (`json:"-"`) outside the GenieAgent body and derives the +// resource `name` (`agents/{genie_agent_id}`) server-side, so we expose a flat +// struct with the identity plus the mutable body. The server-derived `name`, +// `etag`, timestamps and `effective_parent_path` stay out of the config type; +// the engine tracks the bare `genie_agent_id` as the resource id. +type GenieAgentConfig struct { + // Client-specified ID for the agent: 32 lowercase hexadecimal characters + // (a UUID without dashes), not all zeros. Assigned by the server if + // omitted. Immutable: changing it recreates the resource. + GenieAgentId string `json:"genie_agent_id,omitempty"` + // Display name of the Genie Agent. Must be unique within its folder. The + // maximum length is 63 characters. + DisplayName string `json:"display_name"` + // Description of the Genie Agent. The maximum length is 4,096 characters. + Description string `json:"description,omitempty"` + // Warehouse associated with the Genie Agent. + WarehouseId string `json:"warehouse_id"` + // The workspace folder to create the Genie Agent in. If omitted, the + // caller's home folder is used. On update, setting it moves the agent and + // clearing it does not. + ParentPath string `json:"parent_path,omitempty"` + // The definition of the Genie Agent: its sample questions, data sources, + // instructions, and benchmarks. Must set at least one field. Replaced as a + // whole on update. + Definition *genieagents.GenieAgentDefinition `json:"definition"` + + ForceSendFields []string `json:"-" url:"-"` +} + +func (c *GenieAgentConfig) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, c) +} + +func (c GenieAgentConfig) MarshalJSON() ([]byte, error) { + return marshal.Marshal(c) +} + +// GenieAgent is a Genie Agent resource (the AI/BI Genie assistant surface). +// It manages the same backend object as the older genie_spaces resource, so +// declaring the same object under both resource types is unsupported. +type GenieAgent struct { + BaseResource + ID string `json:"id,omitempty" bundle:"readonly"` + GenieAgentConfig + + Permissions []Permission `json:"permissions,omitempty"` +} + +func (r *GenieAgent) UnmarshalJSON(b []byte) error { + return marshal.Unmarshal(b, r) +} + +func (r GenieAgent) MarshalJSON() ([]byte, error) { + return marshal.Marshal(r) +} + +func (*GenieAgent) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { + // The engine tracks the id as the bare genie_agent_id; the API addresses + // the resource by its full name. + _, err := w.GenieAgents.GetGenieAgent(ctx, genieagents.GetGenieAgentRequest{ + Name: "agents/" + id, + }) + if err != nil { + if apierr.IsMissing(err) { + log.Debugf(ctx, "genie agent %s does not exist", id) + return false, nil + } + return false, err + } + return true, nil +} + +func (*GenieAgent) ResourceDescription() ResourceDescription { + return ResourceDescription{ + SingularName: "genie_agent", + PluralName: "genie_agents", + SingularTitle: "Genie Agent", + PluralTitle: "Genie Agents", + } +} + +func (r *GenieAgent) InitializeURL(baseURL url.URL) { + if r.ID == "" { + return + } + + // Agents and spaces are the same backend object, so an agent's UI page is + // the same Genie room page a space uses. + r.URL = workspaceurls.ResourceURL(baseURL, "genie_agents", r.ID) +} + +func (r *GenieAgent) GetName() string { + return r.DisplayName +} diff --git a/bundle/config/resources_test.go b/bundle/config/resources_test.go index 67603159775..e28d1e98665 100644 --- a/bundle/config/resources_test.go +++ b/bundle/config/resources_test.go @@ -226,6 +226,9 @@ func TestResourcesBindSupport(t *testing.T) { GenieSpaces: map[string]*resources.GenieSpace{ "my_genie_space": {}, }, + GenieAgents: map[string]*resources.GenieAgent{ + "my_genie_agent": {}, + }, Volumes: map[string]*resources.Volume{ "my_volume": { CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{}, @@ -446,6 +449,7 @@ func TestResourcesBindSupport(t *testing.T) { m.GetMockClusterPoliciesAPI().EXPECT().GetByPolicyId(mock.Anything, mock.Anything).Return(nil, nil) m.GetMockLakeviewAPI().EXPECT().Get(mock.Anything, mock.Anything).Return(nil, nil) m.GetMockGenieAPI().EXPECT().GetSpace(mock.Anything, mock.Anything).Return(nil, nil) + m.GetMockGenieAgentsAPI().EXPECT().GetGenieAgent(mock.Anything, mock.Anything).Return(nil, nil) m.GetMockVolumesAPI().EXPECT().Read(mock.Anything, mock.Anything).Return(nil, nil) m.GetMockAppsAPI().EXPECT().GetByName(mock.Anything, mock.Anything).Return(nil, nil) m.GetMockAlertsV2API().EXPECT().GetAlertById(mock.Anything, mock.Anything).Return(nil, nil) diff --git a/bundle/direct/dresources/all.go b/bundle/direct/dresources/all.go index 0bc31f6642d..c71c8052684 100644 --- a/bundle/direct/dresources/all.go +++ b/bundle/direct/dresources/all.go @@ -38,6 +38,7 @@ var SupportedResources = map[string]any{ "registered_models": (*ResourceRegisteredModel)(nil), "dashboards": (*ResourceDashboard)(nil), "genie_spaces": (*ResourceGenieSpace)(nil), + "genie_agents": (*ResourceGenieAgent)(nil), "secret_scopes": (*ResourceSecretScope)(nil), "model_serving_endpoints": (*ResourceModelServingEndpoint)(nil), "model_services": (*ResourceModelService)(nil), @@ -67,6 +68,7 @@ var SupportedResources = map[string]any{ "model_serving_endpoints.permissions": (*ResourcePermissions)(nil), "dashboards.permissions": (*ResourcePermissions)(nil), "genie_spaces.permissions": (*ResourcePermissions)(nil), + "genie_agents.permissions": (*ResourcePermissions)(nil), "vector_search_endpoints.permissions": (*ResourcePermissions)(nil), "instance_pools.permissions": (*ResourcePermissions)(nil), diff --git a/bundle/direct/dresources/all_test.go b/bundle/direct/dresources/all_test.go index f80fda21d14..2981b9bdc8f 100644 --- a/bundle/direct/dresources/all_test.go +++ b/bundle/direct/dresources/all_test.go @@ -29,6 +29,7 @@ import ( "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/databricks/databricks-sdk-go/service/database" "github.com/databricks/databricks-sdk-go/service/dataquality" + "github.com/databricks/databricks-sdk-go/service/genieagents" "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/databricks/databricks-sdk-go/service/ml" "github.com/databricks/databricks-sdk-go/service/pipelines" @@ -336,6 +337,31 @@ var testConfig map[string]any = map[string]any{ SerializedSpace: "{}", }, + "genie_agents": &resources.GenieAgent{ + GenieAgentId: "01f0a1b2c3d4e5f60718293a4b5c6d7e", + DisplayName: "my-genie-agent", + Description: "Test genie agent", + WarehouseId: "test-warehouse-id", + ParentPath: "/Workspace/Users/user@example.com", + Definition: &genieagents.GenieAgentDefinition{ + Config: &genieagents.GenieAgentConfig{ + SampleQuestions: []genieagents.GenieAgentSampleQuestion{ + {Id: "01f0a1b2c3d4e5f60718293a4b5c6d7e", Question: "What were total sales?"}, + }, + }, + DataSources: &genieagents.GenieAgentDataSources{ + Tables: []genieagents.GenieAgentTable{ + {Identifier: "main.sales.orders", Description: "Orders table"}, + }, + }, + Instructions: &genieagents.GenieAgentInstructions{ + TextInstructions: []genieagents.GenieAgentTextInstruction{ + {Id: "01f0a1b2c3d4e5f60718293a4b5c6d7f", Content: "Report revenue as the sum of order_amount."}, + }, + }, + }, + }, + "vector_search_endpoints": &resources.VectorSearchEndpoint{ Name: "my-endpoint", EndpointType: vectorsearch.EndpointTypeStandard, @@ -639,6 +665,33 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, + "genie_agents.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + resp, err := client.GenieAgents.CreateGenieAgent(ctx, genieagents.CreateGenieAgentRequest{ + GenieAgent: genieagents.GenieAgent{ + DisplayName: "genie-agent-permissions", + WarehouseId: "test-warehouse-id", + Definition: genieagents.GenieAgentDefinition{ + Config: &genieagents.GenieAgentConfig{ + SampleQuestions: []genieagents.GenieAgentSampleQuestion{ + {Id: "01f0a1b2c3d4e5f60718293a4b5c6d7e", Question: "What were total sales?"}, + }, + }, + }, + }, + }) + if err != nil { + return nil, err + } + + return &PermissionsState{ + ObjectID: "/genie/" + strings.TrimPrefix(resp.Name, "agents/"), + EmbeddedSlice: []StatePermission{{ + Level: "CAN_MANAGE", + UserName: "user@example.com", + }}, + }, nil + }, + "model_serving_endpoints.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { waiter, err := client.ServingEndpoints.Create(ctx, serving.CreateServingEndpoint{ Name: "endpoint-permissions", diff --git a/bundle/direct/dresources/apitypes.generated.yml b/bundle/direct/dresources/apitypes.generated.yml index fb16c02facf..192325a8a13 100644 --- a/bundle/direct/dresources/apitypes.generated.yml +++ b/bundle/direct/dresources/apitypes.generated.yml @@ -26,6 +26,8 @@ feature_specs: ml.FeatureSpec features: ml.Feature +genie_agents: genieagents.CreateGenieAgentRequest + genie_spaces: dashboards.GenieUpdateSpaceRequest instance_pools: compute.CreateInstancePool diff --git a/bundle/direct/dresources/apitypes.yml b/bundle/direct/dresources/apitypes.yml index 7832c70e58f..26a519ae822 100644 --- a/bundle/direct/dresources/apitypes.yml +++ b/bundle/direct/dresources/apitypes.yml @@ -13,6 +13,15 @@ genie_spaces: dashboards.GenieSpace mcp_services: catalog.McpService +# The heuristic picks CreateGenieAgentRequest because the config's identity +# field genie_agent_id exists only on the create request, and the field-overlap +# score weights that rare field name heavily. Pin the resource type: the +# generated rules describe the read shape, and GenieAgent is what GET returns. +# If the API carried the create-time genie_agent_id input on the resource +# message itself, the resource type would win the overlap and this pin could be +# dropped. +genie_agents: genieagents.GenieAgent + model_provider_services: catalog.ModelProviderService model_services: catalog.ModelService diff --git a/bundle/direct/dresources/configs/genie_agents.yml b/bundle/direct/dresources/configs/genie_agents.yml new file mode 100644 index 00000000000..6bbc649b648 --- /dev/null +++ b/bundle/direct/dresources/configs/genie_agents.yml @@ -0,0 +1,6 @@ +provided_id_fields: + # genie_agent_id is the leaf of the server-derived resource name + # (agents/{genie_agent_id}), which is what the resource is fetched by. It is + # server-assigned when omitted on create; a local change recreates. + - field: genie_agent_id + reason: id_field diff --git a/bundle/direct/dresources/genie_agent.go b/bundle/direct/dresources/genie_agent.go new file mode 100644 index 00000000000..37896de2a91 --- /dev/null +++ b/bundle/direct/dresources/genie_agent.go @@ -0,0 +1,164 @@ +package dresources + +import ( + "context" + "fmt" + "strings" + + "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/common/types/fieldmask" + "github.com/databricks/databricks-sdk-go/service/genieagents" +) + +// ResourceGenieAgent manages Genie Agents (the AI/BI Genie assistant surface). +// It mirrors ResourceGenieSpace, which manages the same backend object through +// the older Genie Spaces API; declaring the same object under both resource +// types is unsupported. Bind of an object created through either surface works, +// since both address it by the same id. +// +// API: https://docs.databricks.com/api/workspace/genieagents +// Terraform: databricks_genie_agent +// +// Identity: the engine tracks the bare genie_agent_id; the API addresses the +// resource by its full name (agents/{genie_agent_id}). genie_agent_id is +// optional on create (server-assigned when omitted) and immutable, so a local +// change recreates. +const genieAgentNamePrefix = "agents/" + +type ResourceGenieAgent struct { + client *databricks.WorkspaceClient +} + +func (*ResourceGenieAgent) New(client *databricks.WorkspaceClient) *ResourceGenieAgent { + return &ResourceGenieAgent{client: client} +} + +func (*ResourceGenieAgent) PrepareState(input *resources.GenieAgent) *resources.GenieAgentConfig { + return &input.GenieAgentConfig +} + +// genieAgentBody builds the GenieAgent write payload from the bundle config. +// `name` is server-derived and the create/update paths carry the id, so it is +// never sent; the remaining fields are output-only and stay zero. +func genieAgentBody(config *resources.GenieAgentConfig) genieagents.GenieAgent { + body := genieagents.GenieAgent{ + DisplayName: config.DisplayName, + Description: config.Description, + WarehouseId: config.WarehouseId, + ParentPath: config.ParentPath, + + // A nil config definition marshals as the zero value, which the API + // rejects (the definition must set at least one field). + Definition: genieagents.GenieAgentDefinition{ + Benchmarks: nil, + Config: nil, + DataSources: nil, + Instructions: nil, + }, + + // Output-only fields; `name` is carried by the request path. + Name: "", + Etag: "", + CreateTime: nil, + UpdateTime: nil, + EffectiveParentPath: "", + ForceSendFields: nil, + } + if config.Definition != nil { + body.Definition = *config.Definition + } + return body +} + +// responseToGenieAgentConfig converts a returned GenieAgent into the bundle +// state. The server-derived name, etag, timestamps and effective_parent_path +// have no config counterpart and are dropped here. +func responseToGenieAgentConfig(agent *genieagents.GenieAgent) *resources.GenieAgentConfig { + definition := agent.Definition + return &resources.GenieAgentConfig{ + GenieAgentId: strings.TrimPrefix(agent.Name, genieAgentNamePrefix), + DisplayName: agent.DisplayName, + Description: agent.Description, + Definition: &definition, + WarehouseId: agent.WarehouseId, + ParentPath: agent.ParentPath, + ForceSendFields: nil, + } +} + +func (r *ResourceGenieAgent) DoRead(ctx context.Context, id string) (*resources.GenieAgentConfig, error) { + agent, err := r.client.GenieAgents.GetGenieAgent(ctx, genieagents.GetGenieAgentRequest{ + Name: genieAgentNamePrefix + id, + }) + if err != nil { + return nil, err + } + return responseToGenieAgentConfig(agent), nil +} + +// DoCreate deliberately issues up to three SDK calls — create, mkdirs, create — +// an exception to the one-SDK-call-per-DoCreate rule in +// bundle/direct/dresources/README.md. The default parent_path is the bundle's +// workspace resource folder (workspace.resource_path), which does not exist on +// a first deploy, so create retries once after mkdirs. ResourceGenieSpace.DoCreate +// handles the same condition the same way; isMissingGenieParentPathError +// recognises the two shapes the Genie backend uses for a missing folder. That +// the Agents API surfaces one of those shapes is confirmed by the lifecycle +// test's cloud run. +func (r *ResourceGenieAgent) DoCreate(ctx context.Context, config *resources.GenieAgentConfig) (string, *resources.GenieAgentConfig, error) { + req := genieagents.CreateGenieAgentRequest{ + GenieAgent: genieAgentBody(config), + GenieAgentId: config.GenieAgentId, + ForceSendFields: nil, + } + + resp, err := r.client.GenieAgents.CreateGenieAgent(ctx, req) + if err != nil && isMissingGenieParentPathError(err) { + err = r.client.Workspace.MkdirsByPath(ctx, config.ParentPath) + if err != nil { + return "", nil, fmt.Errorf("failed to create parent directory: %w", err) + } + resp, err = r.client.GenieAgents.CreateGenieAgent(ctx, req) + } + if err != nil { + return "", nil, err + } + + return strings.TrimPrefix(resp.Name, genieAgentNamePrefix), responseToGenieAgentConfig(resp), nil +} + +// DoUpdate sends update_mask "*": the API documents that the wildcard replaces +// every updatable field (display_name, description, warehouse_id, definition, +// parent_path), taking each field's value from the body even when unset there, +// so removing a field from config clears it. definition is replaced as a whole; +// paths within it are not supported. The lifecycle acceptance test exercises +// this mask against a real workspace. +// +// Etag is intentionally left empty (here and in DoDelete): it guards concurrent +// definition edits, which a serial bundle deploy does not have. Drift is +// detected on read by comparing the full config against the GET response, +// matching ResourceMcpService. +func (r *ResourceGenieAgent) DoUpdate(ctx context.Context, id string, config *resources.GenieAgentConfig, _ *PlanEntry) (*resources.GenieAgentConfig, error) { + resp, err := r.client.GenieAgents.UpdateGenieAgent(ctx, genieagents.UpdateGenieAgentRequest{ + GenieAgent: genieAgentBody(config), + Name: genieAgentNamePrefix + id, + UpdateMask: fieldmask.FieldMask{Paths: []string{"*"}}, + Etag: "", + ForceSendFields: nil, + }) + if err != nil { + return nil, err + } + return responseToGenieAgentConfig(resp), nil +} + +func (r *ResourceGenieAgent) DoDelete(ctx context.Context, id string, _ *resources.GenieAgentConfig) error { + // Delete moves the agent to trash; NOT_FOUND afterwards means it is gone + // (the trash is not readable through this API). + return r.client.GenieAgents.DeleteGenieAgent(ctx, genieagents.DeleteGenieAgentRequest{ + Name: genieAgentNamePrefix + id, + Etag: "", + ForceSendFields: nil, + }) +} diff --git a/bundle/direct/dresources/permissions.go b/bundle/direct/dresources/permissions.go index 7f2eb0dbf04..e9657822218 100644 --- a/bundle/direct/dresources/permissions.go +++ b/bundle/direct/dresources/permissions.go @@ -21,6 +21,7 @@ var permissionResourceToObjectType = map[string]string{ "instance_pools": "/instance-pools/", "dashboards": "/dashboards/", "genie_spaces": "/genie/", + "genie_agents": "/genie/", "database_instances": "/database-instances/", "postgres_projects": "/database-projects/", "jobs": "/jobs/", diff --git a/bundle/internal/annotation/preview.go b/bundle/internal/annotation/preview.go index 33392256e48..b6b68f14f5f 100644 --- a/bundle/internal/annotation/preview.go +++ b/bundle/internal/annotation/preview.go @@ -27,6 +27,7 @@ func PreviewTag(stage clijson.LaunchStage) string { // fully-qualified Go type paths (PkgPath + "." + Name), matching getPath in // bundle/internal/schema. var launchStageOverrides = map[string]clijson.LaunchStage{ + "github.com/databricks/cli/bundle/config/resources.GenieAgent": clijson.LaunchStagePrivatePreview, // The Genie Agents API is at Private Preview. "github.com/databricks/cli/bundle/config/resources.PostgresBranch": clijson.LaunchStagePublicBeta, "github.com/databricks/cli/bundle/config/resources.PostgresCatalog": clijson.LaunchStagePublicBeta, "github.com/databricks/cli/bundle/config/resources.PostgresDataApi": clijson.LaunchStagePrivatePreview, // The Data API is at Private Preview, below its siblings' Beta. diff --git a/bundle/internal/schema/annotations.yml b/bundle/internal/schema/annotations.yml index db3cc5585e3..1bec75bb7a4 100644 --- a/bundle/internal/schema/annotations.yml +++ b/bundle/internal/schema/annotations.yml @@ -993,6 +993,48 @@ resources: "time_window": "description": |- PLACEHOLDER + "genie_agents": + "description": |- + The Genie agent definitions for the bundle, where each key is the name of the agent. + "$fields": + "definition": + "description": |- + The definition of the Genie Agent: its sample questions, data sources, instructions, and benchmarks. Must set at least one field. Replaced as a whole on update. + "description": + "description": |- + Description of the Genie Agent. The maximum length is 4,096 characters. + "display_name": + "description": |- + Display name of the Genie Agent. Must be unique within its folder. The maximum length is 63 characters. + "genie_agent_id": + "description": |- + Client-specified ID for the agent: 32 lowercase hexadecimal characters (a UUID without dashes), not all zeros. Assigned by the server if omitted. Immutable: changing this field recreates the resource. + "lifecycle": + "description": |- + Settings that control the deployment lifecycle of the resource, such as preventing it from being destroyed. + "parent_path": + "description": |- + Workspace folder in which to create the Genie Agent. If omitted, the caller's home folder is used. On update, setting it moves the agent and clearing it does not. + "permissions": + "description": |- + The permissions to apply to this resource. + "markdown_description": |- + A Sequence of permissions to apply to this resource, where each item grants a permission `level` to a single `user_name`, `group_name`, or `service_principal_name`. A principal cannot be set in both a resource's `permissions` and the top-level `permissions` mapping. + + See [\_](/dev-tools/bundles/settings.md#permissions) and [\_](/dev-tools/bundles/permissions.md). + "markdown_examples": |- + ```yaml + permissions: + - level: CAN_VIEW + group_name: test-group + - level: CAN_MANAGE + user_name: someone@example.com + - level: CAN_RUN + service_principal_name: 123456-abcdef + ``` + "warehouse_id": + "description": |- + ID of the SQL warehouse used by this Genie Agent. "genie_spaces": "description": |- PLACEHOLDER diff --git a/bundle/internal/validation/generated/enum_fields.go b/bundle/internal/validation/generated/enum_fields.go index 879c5f475d7..8a29bd6de04 100644 --- a/bundle/internal/validation/generated/enum_fields.go +++ b/bundle/internal/validation/generated/enum_fields.go @@ -87,6 +87,10 @@ var EnumFields = map[string][]string{ "resources.features.*.source.request_source.flat_schema.fields[*].data_type": {"BINARY", "BOOLEAN", "DATE", "DECIMAL", "DOUBLE", "FLOAT", "INTEGER", "LONG", "SHORT", "STRING", "TIMESTAMP"}, "resources.features.*.source.sdp_source.pipeline_state": {"ERROR", "PENDING", "RESOLVED"}, + "resources.genie_agents.*.definition.benchmarks.questions[*].answer[*].format": {"GENIE_AGENT_BENCHMARK_ANSWER_FORMAT_SQL"}, + "resources.genie_agents.*.definition.instructions.join_specs[*].relationship_type": {"GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_MANY_TO_MANY", "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_MANY_TO_ONE", "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_ONE_TO_MANY", "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_ONE_TO_ONE"}, + "resources.genie_agents.*.permissions[*].level": {"CAN_ATTACH_TO", "CAN_BIND", "CAN_CREATE", "CAN_CREATE_APP", "CAN_EDIT", "CAN_EDIT_METADATA", "CAN_MANAGE", "CAN_MANAGE_PRODUCTION_VERSIONS", "CAN_MANAGE_RUN", "CAN_MANAGE_STAGING_VERSIONS", "CAN_MONITOR", "CAN_MONITOR_ONLY", "CAN_QUERY", "CAN_READ", "CAN_RESTART", "CAN_RUN", "CAN_USE", "CAN_VIEW", "CAN_VIEW_METADATA", "IS_OWNER"}, + "resources.genie_spaces.*.permissions[*].level": {"CAN_ATTACH_TO", "CAN_BIND", "CAN_CREATE", "CAN_CREATE_APP", "CAN_EDIT", "CAN_EDIT_METADATA", "CAN_MANAGE", "CAN_MANAGE_PRODUCTION_VERSIONS", "CAN_MANAGE_RUN", "CAN_MANAGE_STAGING_VERSIONS", "CAN_MONITOR", "CAN_MONITOR_ONLY", "CAN_QUERY", "CAN_READ", "CAN_RESTART", "CAN_RUN", "CAN_USE", "CAN_VIEW", "CAN_VIEW_METADATA", "IS_OWNER"}, "resources.instance_pools.*.aws_attributes.availability": {"ON_DEMAND", "SPOT"}, diff --git a/bundle/internal/validation/generated/required_fields.go b/bundle/internal/validation/generated/required_fields.go index 78b761f02d7..826553c5ad3 100644 --- a/bundle/internal/validation/generated/required_fields.go +++ b/bundle/internal/validation/generated/required_fields.go @@ -152,6 +152,27 @@ var RequiredFields = map[string][]string{ "resources.features.*.time_window.tumbling": {"window_duration"}, "resources.features.*.timeseries_column": {"name"}, + "resources.genie_agents.*": {"display_name", "warehouse_id", "definition"}, + "resources.genie_agents.*.definition.benchmarks.questions[*]": {"id", "question"}, + "resources.genie_agents.*.definition.benchmarks.questions[*].answer[*]": {"content", "format"}, + "resources.genie_agents.*.definition.config.sample_questions[*]": {"id", "question"}, + "resources.genie_agents.*.definition.data_sources.mcp_connections[*]": {"mcp_connection"}, + "resources.genie_agents.*.definition.data_sources.tables[*]": {"identifier"}, + "resources.genie_agents.*.definition.data_sources.tables[*].column_configs[*]": {"column"}, + "resources.genie_agents.*.definition.data_sources.volumes[*]": {"path"}, + "resources.genie_agents.*.definition.instructions.example_question_sqls[*]": {"id", "question", "sql"}, + "resources.genie_agents.*.definition.instructions.example_question_sqls[*].parameters[*]": {"name"}, + "resources.genie_agents.*.definition.instructions.join_specs[*]": {"id", "left", "right", "sql"}, + "resources.genie_agents.*.definition.instructions.join_specs[*].left": {"identifier"}, + "resources.genie_agents.*.definition.instructions.join_specs[*].right": {"identifier"}, + "resources.genie_agents.*.definition.instructions.sql_functions[*]": {"id", "identifier"}, + "resources.genie_agents.*.definition.instructions.sql_snippets.expressions[*]": {"id", "sql"}, + "resources.genie_agents.*.definition.instructions.sql_snippets.filters[*]": {"id", "sql"}, + "resources.genie_agents.*.definition.instructions.sql_snippets.measures[*]": {"id", "sql"}, + "resources.genie_agents.*.definition.instructions.text_instructions[*]": {"content", "id"}, + "resources.genie_agents.*.lifecycle.depends_on[*]": {"resource"}, + "resources.genie_agents.*.permissions[*]": {"level"}, + "resources.genie_spaces.*.lifecycle.depends_on[*]": {"resource"}, "resources.genie_spaces.*.permissions[*]": {"level"}, diff --git a/bundle/phases/deploy.go b/bundle/phases/deploy.go index 1f6831281ea..6eb4d01248f 100644 --- a/bundle/phases/deploy.go +++ b/bundle/phases/deploy.go @@ -40,6 +40,7 @@ var deployApprovalGroups = []approvalGroup{ {group: "postgres_databases", message: deleteOrRecreatePostgresDatabaseMessage}, {group: "vector_search_indexes", message: deleteOrRecreateVectorSearchIndexMessage}, {group: "genie_spaces", message: deleteOrRecreateGenieSpaceMessage}, + {group: "genie_agents", message: deleteOrRecreateGenieAgentMessage}, {group: "materialization_sets", message: deleteOrRecreateMaterializationSetMessage}, {group: "features", message: deleteOrRecreateFeatureMessage}, {group: "feature_specs", message: deleteOrRecreateFeatureSpecMessage}, diff --git a/bundle/phases/destroy.go b/bundle/phases/destroy.go index c5d2de0980f..ba4ab4b9192 100644 --- a/bundle/phases/destroy.go +++ b/bundle/phases/destroy.go @@ -50,6 +50,7 @@ var destroyApprovalGroups = []approvalGroup{ {group: "postgres_databases", message: deletePostgresDatabaseMessage}, {group: "vector_search_indexes", message: deleteVectorSearchIndexMessage}, {group: "genie_spaces", message: deleteGenieSpaceMessage}, + {group: "genie_agents", message: deleteGenieAgentMessage}, {group: "features", message: deleteFeatureMessage}, {group: "feature_specs", message: deleteFeatureSpecMessage}, } diff --git a/bundle/phases/messages.go b/bundle/phases/messages.go index 535d8086b59..616f0ae5c12 100644 --- a/bundle/phases/messages.go +++ b/bundle/phases/messages.go @@ -50,6 +50,10 @@ index drops all upserted vectors. Both can be expensive to rebuild:` This action will result in the deletion or recreation of the following Genie spaces. The conversation history attached to a deleted space is permanently lost:` + deleteOrRecreateGenieAgentMessage = ` +This action will result in the deletion or recreation of the following Genie agents. +The conversation history attached to a deleted agent is permanently lost:` + deleteOrRecreateMaterializationSetMessage = ` This action will result in the deletion or recreation of the following materialization sets. Every materialized feature in a recreated set is dropped and recomputed from scratch, including @@ -117,6 +121,9 @@ For Direct Access indexes, all upserted vectors are permanently lost:` deleteGenieSpaceMessage = `This action will result in the deletion of the following Genie spaces. The conversation history attached to them is permanently lost:` + deleteGenieAgentMessage = `This action will result in the deletion of the following Genie agents. +The conversation history attached to them is permanently lost:` + deleteFeatureMessage = `This action will result in the deletion of the following Feature Views. Deleting a Feature View that a FeatureSpec serves is not blocked, and leaves the FeatureSpec stale:` diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index 14fcb5e83ad..564c15792ec 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -1234,6 +1234,61 @@ } ] }, + "resources.GenieAgent": { + "oneOf": [ + { + "type": "object", + "description": "[Private Preview]", + "properties": { + "definition": { + "description": "The definition of the Genie Agent: its sample questions, data sources, instructions, and benchmarks. Must set at least one field. Replaced as a whole on update.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentDefinition" + }, + "description": { + "description": "Description of the Genie Agent. The maximum length is 4,096 characters.", + "$ref": "#/$defs/string" + }, + "display_name": { + "description": "Display name of the Genie Agent. Must be unique within its folder. The maximum length is 63 characters.", + "$ref": "#/$defs/string" + }, + "genie_agent_id": { + "description": "Client-specified ID for the agent: 32 lowercase hexadecimal characters (a UUID without dashes), not all zeros. Assigned by the server if omitted. Immutable: changing this field recreates the resource.", + "$ref": "#/$defs/string" + }, + "lifecycle": { + "description": "Settings that control the deployment lifecycle of the resource, such as preventing it from being destroyed.", + "$ref": "#/$defs/github.com/databricks/cli/bundle/config/resources.Lifecycle" + }, + "parent_path": { + "description": "Workspace folder in which to create the Genie Agent. If omitted, the caller's home folder is used. On update, setting it moves the agent and clearing it does not.", + "$ref": "#/$defs/string" + }, + "permissions": { + "description": "The permissions to apply to this resource.", + "$ref": "#/$defs/slice/github.com/databricks/cli/bundle/config/resources.Permission", + "markdownDescription": "A Sequence of permissions to apply to this resource, where each item grants a permission `level` to a single `user_name`, `group_name`, or `service_principal_name`. A principal cannot be set in both a resource's `permissions` and the top-level `permissions` mapping.\n\nSee [permissions](https://docs.databricks.com/dev-tools/bundles/settings.html#permissions) and [link](https://docs.databricks.com/dev-tools/bundles/permissions.html)." + }, + "warehouse_id": { + "description": "ID of the SQL warehouse used by this Genie Agent.", + "$ref": "#/$defs/string" + } + }, + "additionalProperties": false, + "required": [ + "display_name", + "warehouse_id", + "definition" + ], + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, "resources.GenieSpace": { "oneOf": [ { @@ -4425,6 +4480,10 @@ "$ref": "#/$defs/map/github.com/databricks/cli/bundle/config/resources.Feature", "markdownDescription": "The feature definitions for the bundle, where each key is the name of the feature." }, + "genie_agents": { + "description": "The Genie agent definitions for the bundle, where each key is the name of the agent.", + "$ref": "#/$defs/map/github.com/databricks/cli/bundle/config/resources.GenieAgent" + }, "genie_spaces": { "$ref": "#/$defs/map/github.com/databricks/cli/bundle/config/resources.GenieSpace" }, @@ -9840,24 +9899,954 @@ } ] }, - "dataquality.NotificationSettings": { + "dataquality.NotificationSettings": { + "oneOf": [ + { + "type": "object", + "description": "Settings for sending notifications on the data quality monitoring.", + "properties": { + "on_failure": { + "description": "Destinations to send notifications on failure/timeout.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/dataquality.NotificationDestination", + "x-databricks-launch-stage": "GA" + }, + "on_unhealthy_table": { + "description": "Recipients to notify when anomaly detection finds unhealthy tables in the schema. Each\nrecipient gets one notification per important unhealthy table. Only supported on schema\nmonitors, via `anomaly_detection_config`.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/dataquality.NotificationDestination", + "x-databricks-launch-stage": "GA" + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "dataquality.SnapshotConfig": { + "oneOf": [ + { + "type": "object", + "description": "Snapshot analysis configuration.", + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "dataquality.TimeSeriesConfig": { + "oneOf": [ + { + "type": "object", + "description": "Time series analysis configuration.", + "properties": { + "granularities": { + "description": "List of granularities to use when aggregating data into time windows based on their timestamp.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/dataquality.AggregationGranularity", + "x-databricks-launch-stage": "GA" + }, + "timestamp_column": { + "description": "Column for the timestamp.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "GA" + } + }, + "additionalProperties": false, + "required": [ + "granularities", + "timestamp_column" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentBenchmarkAnswer": { + "oneOf": [ + { + "type": "object", + "description": "The expected answer to a benchmark question.", + "properties": { + "content": { + "description": "[Private Preview] The answer.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "format": { + "description": "[Private Preview] The format of the answer.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentBenchmarkAnswerFormat", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "content", + "format" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentBenchmarkAnswerFormat": { + "oneOf": [ + { + "type": "string", + "description": "The format of a benchmark answer.", + "enum": [ + "GENIE_AGENT_BENCHMARK_ANSWER_FORMAT_SQL" + ], + "enumDescriptions": [ + "[Private Preview]" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentBenchmarkQuestion": { + "oneOf": [ + { + "type": "object", + "description": "A benchmark question with its expected answer.", + "properties": { + "answer": { + "description": "[Private Preview] The expected answer. At most one answer is supported; omit it when the question has no\nexpected answer.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentBenchmarkAnswer", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "evaluation_note": { + "description": "[Private Preview] Notes on how to evaluate answers to the question.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "id": { + "description": "[Private Preview] Identifier of the question: 32 lowercase hexadecimal characters, unique within the Genie\nAgent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "question": { + "description": "[Private Preview] The question.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "id", + "question" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentBenchmarks": { + "oneOf": [ + { + "type": "object", + "description": "Benchmarks for evaluating a Genie Agent.", + "properties": { + "questions": { + "description": "[Private Preview] The benchmark questions, sorted by `id` in descending order.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentBenchmarkQuestion", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentColumnConfig": { + "oneOf": [ + { + "type": "object", + "description": "Settings for one column of a table or metric view.", + "properties": { + "column": { + "description": "[Private Preview] The name of the column. Must exist in the table or metric view.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "description": { + "description": "[Private Preview] Description of the column, overriding its Unity Catalog comment.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "display_name": { + "description": "[Private Preview] Display name of the column in the Genie Agent. Accepted only where column display names are\nenabled for the workspace.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "enable_entity_matching": { + "description": "[Private Preview] Whether the Genie Agent indexes the column's values to match them in questions.", + "$ref": "#/$defs/bool", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "enable_format_assistance": { + "description": "[Private Preview] Whether the Genie Agent samples example values from the column to learn its format.", + "$ref": "#/$defs/bool", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "exclude": { + "description": "[Private Preview] Whether the column is hidden from the Genie Agent.", + "$ref": "#/$defs/bool", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "synonyms": { + "description": "[Private Preview] Synonyms for the column name.", + "$ref": "#/$defs/slice/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "column" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentConfig": { + "oneOf": [ + { + "type": "object", + "description": "General settings of a Genie Agent. The warehouse, display name, and description are separate\nfields of the Genie Agent.", + "properties": { + "sample_questions": { + "description": "[Private Preview] Sample questions shown to users of the Genie Agent, sorted by `id`.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSampleQuestion", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentDataSources": { + "oneOf": [ + { + "type": "object", + "description": "The data a Genie Agent can access.", + "properties": { + "mcp_connections": { + "description": "[Private Preview] Unity Catalog MCP connections, sorted by `mcp_connection`.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentMcpConnection", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "tables": { + "description": "[Private Preview] Unity Catalog tables, views, and metric views, in the order they were added.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentTable", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "volumes": { + "description": "[Private Preview] Unity Catalog volumes, in the order they were added.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentVolume", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentDefinition": { + "oneOf": [ + { + "type": "object", + "description": "The definition of a Genie Agent.", + "properties": { + "benchmarks": { + "description": "[Private Preview] Benchmarks for evaluating the quality of the Genie Agent's answers.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentBenchmarks", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "config": { + "description": "[Private Preview] General settings of the Genie Agent.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentConfig", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "data_sources": { + "description": "[Private Preview] The data the Genie Agent can access.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentDataSources", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "instructions": { + "description": "[Private Preview] Instructions and SQL that guide how the Genie Agent answers questions.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentInstructions", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentExampleQuestionSql": { + "oneOf": [ + { + "type": "object", + "description": "An example question paired with the SQL that answers it.", + "properties": { + "id": { + "description": "[Private Preview] Identifier of the example: 32 lowercase hexadecimal characters, unique within the Genie Agent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "parameters": { + "description": "[Private Preview] Parameters used in the SQL, in the order given.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlParameter", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "question": { + "description": "[Private Preview] The question.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "sql": { + "description": "[Private Preview] The SQL that answers the question.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "usage_guidance": { + "description": "[Private Preview] Guidance on when to use this example.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "id", + "question", + "sql" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentInstructions": { + "oneOf": [ + { + "type": "object", + "description": "Instructions and SQL that guide how a Genie Agent answers questions.", + "properties": { + "example_question_sqls": { + "description": "[Private Preview] Example questions paired with the SQL that answers them.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentExampleQuestionSql", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "join_specs": { + "description": "[Private Preview] Predefined joins between tables or metric views.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentJoinSpec", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "sql_functions": { + "description": "[Private Preview] Unity Catalog SQL functions the generated SQL may call.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlFunction", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "sql_snippets": { + "description": "[Private Preview] Reusable SQL filters, expressions, and measures.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlSnippets", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "text_instructions": { + "description": "[Private Preview] General text instructions. At most one text instruction is supported.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentTextInstruction", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentJoinRelationshipType": { + "oneOf": [ + { + "type": "string", + "description": "How the rows of the two sides of a join relate.", + "enum": [ + "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_MANY_TO_ONE", + "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_ONE_TO_MANY", + "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_ONE_TO_ONE", + "GENIE_AGENT_JOIN_RELATIONSHIP_TYPE_MANY_TO_MANY" + ], + "enumDescriptions": [ + "[Private Preview]", + "[Private Preview]", + "[Private Preview]", + "[Private Preview]" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentJoinSource": { + "oneOf": [ + { + "type": "object", + "description": "One side of a join.", + "properties": { + "alias": { + "description": "[Private Preview] The alias the join condition uses for this side.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "identifier": { + "description": "[Private Preview] The full three-level name of the table or metric view.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "identifier" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentJoinSpec": { + "oneOf": [ + { + "type": "object", + "description": "A predefined join between two tables or metric views.", + "properties": { + "comment": { + "description": "[Private Preview] Description of the join's purpose.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "id": { + "description": "[Private Preview] Identifier of the join: 32 lowercase hexadecimal characters, unique within the Genie Agent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "instruction": { + "description": "[Private Preview] Guidance on when to use the join.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "left": { + "description": "[Private Preview] The left side of the join.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentJoinSource", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "relationship_type": { + "description": "[Private Preview] How the rows of the two sides relate.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentJoinRelationshipType", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "right": { + "description": "[Private Preview] The right side of the join.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentJoinSource", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "sql": { + "description": "[Private Preview] The join condition, for example `orders.customer_id = customers.id`.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "id", + "left", + "right", + "sql" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentMcpConnection": { + "oneOf": [ + { + "type": "object", + "description": "A Unity Catalog MCP connection the Genie Agent can use.", + "properties": { + "mcp_connection": { + "description": "[Private Preview] The name of the Unity Catalog connection, for example `system.ai.google_calendar`.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "mcp_connection" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSampleQuestion": { + "oneOf": [ + { + "type": "object", + "description": "A sample question shown to users of the Genie Agent.", + "properties": { + "id": { + "description": "[Private Preview] Identifier of the sample question: 32 lowercase hexadecimal characters, unique within the\nGenie Agent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "question": { + "description": "[Private Preview] The text of the question.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "id", + "question" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlExpression": { + "oneOf": [ + { + "type": "object", + "description": "A reusable non-aggregated SQL expression (dimension).", + "properties": { + "alias": { + "description": "[Private Preview] The alias the Genie Agent uses for the expression in generated SQL.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "display_name": { + "description": "[Private Preview] Display name of the expression.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "id": { + "description": "[Private Preview] Identifier of the expression: 32 lowercase hexadecimal characters, unique within the Genie\nAgent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "instruction": { + "description": "[Private Preview] Guidance on when to use the expression.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "sql": { + "description": "[Private Preview] The SQL of the expression.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "synonyms": { + "description": "[Private Preview] Synonyms for the expression.", + "$ref": "#/$defs/slice/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "id", + "sql" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlFilter": { + "oneOf": [ + { + "type": "object", + "description": "A reusable SQL filter.", + "properties": { + "display_name": { + "description": "[Private Preview] Display name of the filter.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "id": { + "description": "[Private Preview] Identifier of the filter: 32 lowercase hexadecimal characters, unique within the Genie Agent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "instruction": { + "description": "[Private Preview] Guidance on when to use the filter.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "sql": { + "description": "[Private Preview] The SQL of the filter.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "synonyms": { + "description": "[Private Preview] Synonyms for the filter.", + "$ref": "#/$defs/slice/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "id", + "sql" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlFunction": { + "oneOf": [ + { + "type": "object", + "description": "A Unity Catalog SQL function the generated SQL may call.", + "properties": { + "id": { + "description": "[Private Preview] Identifier of the entry: 32 lowercase hexadecimal characters, unique within the Genie Agent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "identifier": { + "description": "[Private Preview] The full three-level name of the function, for example `catalog.schema.function`.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "id", + "identifier" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlMeasure": { + "oneOf": [ + { + "type": "object", + "description": "A reusable aggregated SQL measure.", + "properties": { + "alias": { + "description": "[Private Preview] The alias the Genie Agent uses for the measure in generated SQL.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "display_name": { + "description": "[Private Preview] Display name of the measure.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "id": { + "description": "[Private Preview] Identifier of the measure: 32 lowercase hexadecimal characters, unique within the Genie Agent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "instruction": { + "description": "[Private Preview] Guidance on when to use the measure.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "sql": { + "description": "[Private Preview] The SQL of the measure.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "synonyms": { + "description": "[Private Preview] Synonyms for the measure.", + "$ref": "#/$defs/slice/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "id", + "sql" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlParameter": { + "oneOf": [ + { + "type": "object", + "description": "A parameter of a parameterized SQL example.", + "properties": { + "default_value": { + "description": "[Private Preview] The parameter's default value.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlParameterDefaultValue", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "description": { + "description": "[Private Preview] Description of the parameter.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "name": { + "description": "[Private Preview] The name of the parameter in the SQL.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "type_hint": { + "description": "[Private Preview] The parameter's data type, for example `STRING` or `INTEGER`.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "name" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlParameterDefaultRange": { + "oneOf": [ + { + "type": "object", + "description": "A range of default values for a SQL parameter.", + "properties": { + "max": { + "description": "[Private Preview] The upper end of the range.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "min": { + "description": "[Private Preview] The lower end of the range.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlParameterDefaultValue": { + "oneOf": [ + { + "type": "object", + "description": "The default value of a SQL parameter: a list of values or a range.", + "properties": { + "value_range": { + "description": "[Private Preview] The default range.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlParameterDefaultRange", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "values": { + "description": "[Private Preview] The default values. A single default is a one-element list.", + "$ref": "#/$defs/slice/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlSnippets": { + "oneOf": [ + { + "type": "object", + "description": "Reusable SQL snippets.", + "properties": { + "expressions": { + "description": "[Private Preview] Non-aggregated expressions (dimensions), such as `price * units`.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlExpression", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "filters": { + "description": "[Private Preview] Filters, such as `state = 'CA'`.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlFilter", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "measures": { + "description": "[Private Preview] Aggregated measures, such as `SUM(price * units)`.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlMeasure", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentTable": { "oneOf": [ { "type": "object", - "description": "Settings for sending notifications on the data quality monitoring.", + "description": "A Unity Catalog table, view, or metric view the Genie Agent can access.", "properties": { - "on_failure": { - "description": "Destinations to send notifications on failure/timeout.", - "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/dataquality.NotificationDestination", - "x-databricks-launch-stage": "GA" + "column_configs": { + "description": "[Private Preview] Column settings for the table, sorted by `column`.", + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentColumnConfig", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true }, - "on_unhealthy_table": { - "description": "Recipients to notify when anomaly detection finds unhealthy tables in the schema. Each\nrecipient gets one notification per important unhealthy table. Only supported on schema\nmonitors, via `anomaly_detection_config`.", - "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/dataquality.NotificationDestination", - "x-databricks-launch-stage": "GA" + "description": { + "description": "[Private Preview] Description of the table.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "identifier": { + "description": "[Private Preview] The full three-level name, for example `catalog.schema.table`.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true } }, - "additionalProperties": false + "additionalProperties": false, + "required": [ + "identifier" + ] }, { "type": "string", @@ -9865,12 +10854,30 @@ } ] }, - "dataquality.SnapshotConfig": { + "genieagents.GenieAgentTextInstruction": { "oneOf": [ { "type": "object", - "description": "Snapshot analysis configuration.", - "additionalProperties": false + "description": "A general text instruction for the Genie Agent.", + "properties": { + "content": { + "description": "[Private Preview] The text of the instruction.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + }, + "id": { + "description": "[Private Preview] Identifier of the instruction: 32 lowercase hexadecimal characters, unique within the Genie\nAgent.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true + } + }, + "additionalProperties": false, + "required": [ + "content", + "id" + ] }, { "type": "string", @@ -9878,27 +10885,28 @@ } ] }, - "dataquality.TimeSeriesConfig": { + "genieagents.GenieAgentVolume": { "oneOf": [ { "type": "object", - "description": "Time series analysis configuration.", + "description": "A Unity Catalog volume the Genie Agent can access.", "properties": { - "granularities": { - "description": "List of granularities to use when aggregating data into time windows based on their timestamp.", - "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/dataquality.AggregationGranularity", - "x-databricks-launch-stage": "GA" + "description": { + "description": "[Private Preview] Description of the volume.", + "$ref": "#/$defs/string", + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true }, - "timestamp_column": { - "description": "Column for the timestamp.", + "path": { + "description": "[Private Preview] The volume path, for example `/Volumes/catalog/schema/volume`. May name a directory or file\nwithin the volume.", "$ref": "#/$defs/string", - "x-databricks-launch-stage": "GA" + "x-databricks-launch-stage": "PRIVATE_PREVIEW", + "doNotSuggest": true } }, "additionalProperties": false, "required": [ - "granularities", - "timestamp_column" + "path" ] }, { @@ -22106,6 +23114,20 @@ } ] }, + "resources.GenieAgent": { + "oneOf": [ + { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/github.com/databricks/cli/bundle/config/resources.GenieAgent" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, "resources.GenieSpace": { "oneOf": [ { @@ -23145,6 +24167,216 @@ } ] }, + "genieagents.GenieAgentBenchmarkAnswer": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentBenchmarkAnswer" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentBenchmarkQuestion": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentBenchmarkQuestion" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentColumnConfig": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentColumnConfig" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentExampleQuestionSql": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentExampleQuestionSql" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentJoinSpec": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentJoinSpec" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentMcpConnection": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentMcpConnection" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSampleQuestion": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSampleQuestion" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlExpression": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlExpression" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlFilter": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlFilter" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlFunction": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlFunction" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlMeasure": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlMeasure" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentSqlParameter": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentSqlParameter" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentTable": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentTable" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentTextInstruction": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentTextInstruction" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "genieagents.GenieAgentVolume": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/genieagents.GenieAgentVolume" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, "jobs.AiClassifyFunctionLabel": { "oneOf": [ { diff --git a/bundle/statemgmt/state_load_test.go b/bundle/statemgmt/state_load_test.go index ac1c272d013..c418a86598b 100644 --- a/bundle/statemgmt/state_load_test.go +++ b/bundle/statemgmt/state_load_test.go @@ -49,6 +49,7 @@ func TestStateToBundleEmptyLocalResources(t *testing.T) { "resources.clusters.test_cluster": {ID: "1"}, "resources.dashboards.test_dashboard": {ID: "1"}, "resources.genie_spaces.test_genie_space": {ID: "1"}, + "resources.genie_agents.test_genie_agent": {ID: "1"}, "resources.apps.test_app": {ID: "app1"}, "resources.secret_scopes.test_secret_scope": {ID: "secret_scope1"}, "resources.sql_warehouses.test_sql_warehouse": {ID: "1"}, @@ -119,6 +120,9 @@ func TestStateToBundleEmptyLocalResources(t *testing.T) { assert.Equal(t, "1", config.Resources.GenieSpaces["test_genie_space"].ID) assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.GenieSpaces["test_genie_space"].ModifiedStatus) + assert.Equal(t, "1", config.Resources.GenieAgents["test_genie_agent"].ID) + assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.GenieAgents["test_genie_agent"].ModifiedStatus) + assert.Equal(t, "app1", config.Resources.Apps["test_app"].ID) assert.Empty(t, config.Resources.Apps["test_app"].Name) assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.Apps["test_app"].ModifiedStatus) @@ -323,6 +327,13 @@ func TestStateToBundleEmptyRemoteResources(t *testing.T) { }, }, }, + GenieAgents: map[string]*resources.GenieAgent{ + "test_genie_agent": { + GenieAgentConfig: resources.GenieAgentConfig{ + DisplayName: "test_genie_agent", + }, + }, + }, Apps: map[string]*resources.App{ "test_app": { App: apps.App{ @@ -557,6 +568,9 @@ func TestStateToBundleEmptyRemoteResources(t *testing.T) { assert.Empty(t, config.Resources.GenieSpaces["test_genie_space"].ID) assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.GenieSpaces["test_genie_space"].ModifiedStatus) + assert.Empty(t, config.Resources.GenieAgents["test_genie_agent"].ID) + assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.GenieAgents["test_genie_agent"].ModifiedStatus) + assert.Empty(t, config.Resources.Apps["test_app"].Name) assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.Apps["test_app"].ModifiedStatus) @@ -846,6 +860,18 @@ func TestStateToBundleModifiedResources(t *testing.T) { }, }, }, + GenieAgents: map[string]*resources.GenieAgent{ + "test_genie_agent": { + GenieAgentConfig: resources.GenieAgentConfig{ + DisplayName: "test_genie_agent", + }, + }, + "test_genie_agent_new": { + GenieAgentConfig: resources.GenieAgentConfig{ + DisplayName: "test_genie_agent_new", + }, + }, + }, Apps: map[string]*resources.App{ "test_app": { App: apps.App{ @@ -1182,6 +1208,8 @@ func TestStateToBundleModifiedResources(t *testing.T) { "resources.dashboards.test_dashboard_old": {ID: "2"}, "resources.genie_spaces.test_genie_space": {ID: "1"}, "resources.genie_spaces.test_genie_space_old": {ID: "2"}, + "resources.genie_agents.test_genie_agent": {ID: "1"}, + "resources.genie_agents.test_genie_agent_old": {ID: "2"}, "resources.apps.test_app": {ID: "test_app"}, "resources.apps.test_app_old": {ID: "test_app_old"}, "resources.secret_scopes.test_secret_scope": {ID: "test_secret_scope"}, @@ -1338,6 +1366,13 @@ func TestStateToBundleModifiedResources(t *testing.T) { assert.Empty(t, config.Resources.GenieSpaces["test_genie_space_new"].ID) assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.GenieSpaces["test_genie_space_new"].ModifiedStatus) + assert.Equal(t, "1", config.Resources.GenieAgents["test_genie_agent"].ID) + assert.Empty(t, config.Resources.GenieAgents["test_genie_agent"].ModifiedStatus) + assert.Equal(t, "2", config.Resources.GenieAgents["test_genie_agent_old"].ID) + assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.GenieAgents["test_genie_agent_old"].ModifiedStatus) + assert.Empty(t, config.Resources.GenieAgents["test_genie_agent_new"].ID) + assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.GenieAgents["test_genie_agent_new"].ModifiedStatus) + assert.Equal(t, "test_app", config.Resources.Apps["test_app"].Name) assert.Empty(t, config.Resources.Apps["test_app"].ModifiedStatus) assert.Equal(t, "test_app_old", config.Resources.Apps["test_app_old"].ID) diff --git a/cmd/experimental/workspace_open_test.go b/cmd/experimental/workspace_open_test.go index dd62f40177a..0c4d917a7b3 100644 --- a/cmd/experimental/workspace_open_test.go +++ b/cmd/experimental/workspace_open_test.go @@ -69,7 +69,7 @@ func TestBuildWorkspaceURLFragmentBasedResources(t *testing.T) { func TestBuildWorkspaceURLUnknownResourceType(t *testing.T) { _, err := workspaceurls.BuildResourceURL("https://myworkspace.databricks.com", "unknown", "123", "") assert.ErrorContains(t, err, "unknown resource type \"unknown\"") - assert.ErrorContains(t, err, "alerts, apps, catalogs, cluster_policies, clusters, dashboards, database_catalogs, database_instances, experiments, feature_specs, features, genie_spaces, instance_pools, jobs, mcp_services, model_provider_services, model_services, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, secrets, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses") + assert.ErrorContains(t, err, "alerts, apps, catalogs, cluster_policies, clusters, dashboards, database_catalogs, database_instances, experiments, feature_specs, features, genie_agents, genie_spaces, instance_pools, jobs, mcp_services, model_provider_services, model_services, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, secrets, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses") } func TestBuildWorkspaceURLHostWithTrailingSlash(t *testing.T) { @@ -120,6 +120,7 @@ func TestWorkspaceOpenCommandCompletion(t *testing.T) { "experiments", "feature_specs", "features", + "genie_agents", "genie_spaces", "instance_pools", "jobs", @@ -156,7 +157,7 @@ func TestWorkspaceOpenCommandCompletionSecondArg(t *testing.T) { func TestWorkspaceOpenCommandHelpText(t *testing.T) { cmd := newWorkspaceOpenCommand() - assert.Contains(t, cmd.Long, "Supported resource types: alerts, apps, catalogs, cluster_policies, clusters, dashboards, database_catalogs, database_instances, experiments, feature_specs, features, genie_spaces, instance_pools, jobs, mcp_services, model_provider_services, model_services, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, secrets, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses.") + assert.Contains(t, cmd.Long, "Supported resource types: alerts, apps, catalogs, cluster_policies, clusters, dashboards, database_catalogs, database_instances, experiments, feature_specs, features, genie_agents, genie_spaces, instance_pools, jobs, mcp_services, model_provider_services, model_services, model_serving_endpoints, models, notebooks, pipelines, postgres_catalogs, postgres_synced_tables, quality_monitors, queries, registered_models, schemas, secrets, synced_database_tables, vector_search_endpoints, vector_search_indexes, volumes, warehouses.") assert.Contains(t, cmd.Long, "databricks experimental open jobs 123456789") assert.Contains(t, cmd.Long, "databricks experimental open notebooks /Users/user@example.com/my-notebook") assert.Contains(t, cmd.Long, "databricks experimental open registered_models catalog.schema.my_model") diff --git a/libs/testserver/fake_workspace.go b/libs/testserver/fake_workspace.go index 5e8068b6d02..beec4ab1128 100644 --- a/libs/testserver/fake_workspace.go +++ b/libs/testserver/fake_workspace.go @@ -23,6 +23,7 @@ import ( "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/databricks/databricks-sdk-go/service/database" "github.com/databricks/databricks-sdk-go/service/dataquality" + "github.com/databricks/databricks-sdk-go/service/genieagents" "github.com/databricks/databricks-sdk-go/service/postgres" "github.com/databricks/cli/libs/structs/structtag" @@ -232,6 +233,7 @@ type FakeWorkspace struct { Dashboards *EventualMap[string, *fakeDashboard] PublishedDashboards map[string]dashboards.PublishedDashboard GenieSpaces map[string]dashboards.GenieSpace + GenieAgents map[string]genieagents.GenieAgent SqlWarehouses map[string]sql.GetWarehouseResponse Alerts map[string]sql.AlertV2 PurgedAlertIDs map[string]bool @@ -553,6 +555,7 @@ func NewFakeWorkspace(url, token string) *FakeWorkspace { Dashboards: NewEventualMap[string, *fakeDashboard](eventualConsistency), PublishedDashboards: map[string]dashboards.PublishedDashboard{}, GenieSpaces: map[string]dashboards.GenieSpace{}, + GenieAgents: map[string]genieagents.GenieAgent{}, SqlWarehouses: map[string]sql.GetWarehouseResponse{ TestDefaultWarehouseId: { Id: TestDefaultWarehouseId, diff --git a/libs/testserver/genie_agents.go b/libs/testserver/genie_agents.go new file mode 100644 index 00000000000..d85c8bd4439 --- /dev/null +++ b/libs/testserver/genie_agents.go @@ -0,0 +1,162 @@ +package testserver + +import ( + "encoding/json" + "time" + + sdktime "github.com/databricks/databricks-sdk-go/common/types/time" + "github.com/databricks/databricks-sdk-go/service/genieagents" +) + +func (s *FakeWorkspace) GenieAgentCreate(req Request) Response { + defer s.LockUnlock()() + + var body genieagents.GenieAgent + if err := json.Unmarshal(req.Body, &body); err != nil { + return genieAgentInvalidRequest(err) + } + + // The client may pin the id via the genie_agent_id query parameter; the + // server assigns one otherwise. ALREADY_EXISTS when the id is in use. + agentId := req.URL.Query().Get("genie_agent_id") + if agentId == "" { + agentId, _ = generateGenieSpaceId() + } + if _, ok := s.GenieAgents[agentId]; ok { + return Response{ + StatusCode: 409, + Body: map[string]string{ + "error_code": "ALREADY_EXISTS", + "message": "Genie Agent " + agentId + " already exists", + }, + } + } + + // Default to the caller's home folder when parent_path is omitted, + // matching the documented behavior and GenieSpaceCreate. + parentPath := body.ParentPath + if parentPath == "" { + parentPath = "/Users/" + s.CurrentUser().UserName + } + + // An explicitly submitted parent_path must exist as a workspace folder; the + // CLI's default is the bundle's resource folder, which its mkdirs retry + // creates. The home folder default needs no check. + if body.ParentPath != "" { + if _, ok := s.directories[parentPath]; !ok { + return Response{ + StatusCode: 404, + Body: map[string]string{ + "error_code": "RESOURCE_DOES_NOT_EXIST", + "message": "Parent folder " + parentPath + " does not exist", + }, + } + } + } + + agent := body + agent.Name = "agents/" + agentId + agent.ParentPath = parentPath + agent.EffectiveParentPath = parentPath + agent.CreateTime = sdktime.New(time.Now()) + agent.UpdateTime = sdktime.New(time.Now()) + agent.Etag = "1" + + s.GenieAgents[agentId] = agent + + return Response{ + Body: agent, + } +} + +func (s *FakeWorkspace) GenieAgentGet(req Request) Response { + defer s.LockUnlock()() + + agent, resp := s.getGenieAgent(req.Vars["genie_agent_id"]) + if resp != nil { + return *resp + } + + return Response{ + Body: agent, + } +} + +func (s *FakeWorkspace) GenieAgentUpdate(req Request) Response { + defer s.LockUnlock()() + + agent, resp := s.getGenieAgent(req.Vars["genie_agent_id"]) + if resp != nil { + return *resp + } + + var body genieagents.GenieAgent + if err := json.Unmarshal(req.Body, &body); err != nil { + return genieAgentInvalidRequest(err) + } + + // update_mask "*" replaces every updatable field with the body's value and + // keeps the server-assigned ones. Setting parent_path moves the agent; + // clearing it does not (the stored folder is untouched, only the field is + // cleared, matching the update_mask contract). + agent.DisplayName = body.DisplayName + agent.Description = body.Description + agent.Definition = body.Definition + agent.WarehouseId = body.WarehouseId + agent.ParentPath = body.ParentPath + if body.ParentPath != "" { + agent.EffectiveParentPath = body.ParentPath + } + agent.UpdateTime = sdktime.New(time.Now()) + + s.GenieAgents[req.Vars["genie_agent_id"]] = agent + + return Response{ + Body: agent, + } +} + +func (s *FakeWorkspace) GenieAgentDelete(req Request) Response { + defer s.LockUnlock()() + + agentId := req.Vars["genie_agent_id"] + if _, ok := s.GenieAgents[agentId]; !ok { + return genieAgentNotFound() + } + + delete(s.GenieAgents, agentId) + + return Response{ + StatusCode: 200, + } +} + +// getGenieAgent returns a copy of the stored agent, or a 404 response. +func (s *FakeWorkspace) getGenieAgent(agentId string) (genieagents.GenieAgent, *Response) { + agent, ok := s.GenieAgents[agentId] + if !ok { + resp := genieAgentNotFound() + return genieagents.GenieAgent{}, &resp + } + return agent, nil +} + +func genieAgentNotFound() Response { + return Response{ + StatusCode: 404, + Body: map[string]string{ + "error_code": "RESOURCE_DOES_NOT_EXIST", + "message": "Genie Agent not found", + }, + } +} + +func genieAgentInvalidRequest(err error) Response { + return Response{ + StatusCode: 400, + Body: map[string]string{ + "error_code": "INVALID_PARAMETER_VALUE", + "message": "Invalid request body: " + err.Error(), + }, + } +} diff --git a/libs/testserver/handlers.go b/libs/testserver/handlers.go index 20aac63e2b7..2ed4110d356 100644 --- a/libs/testserver/handlers.go +++ b/libs/testserver/handlers.go @@ -666,6 +666,20 @@ func AddDefaultHandlers(server *Server) { return req.Workspace.GenieSpaceTrash(req) }) + // Genie Agents: + server.Handle("GET", "/api/2.0/genie/agents/{genie_agent_id}", func(req Request) any { + return req.Workspace.GenieAgentGet(req) + }) + server.Handle("POST", "/api/2.0/genie/agents", func(req Request) any { + return req.Workspace.GenieAgentCreate(req) + }) + server.Handle("PATCH", "/api/2.0/genie/agents/{genie_agent_id}", func(req Request) any { + return req.Workspace.GenieAgentUpdate(req) + }) + server.Handle("DELETE", "/api/2.0/genie/agents/{genie_agent_id}", func(req Request) any { + return req.Workspace.GenieAgentDelete(req) + }) + // Pipelines: server.Handle("GET", "/api/2.0/pipelines/{pipeline_id}", func(req Request) any { diff --git a/libs/workspaceurls/urls.go b/libs/workspaceurls/urls.go index 2773cb792d8..b8593e5ef20 100644 --- a/libs/workspaceurls/urls.go +++ b/libs/workspaceurls/urls.go @@ -21,6 +21,7 @@ var resourceURLPatterns = map[string]string{ "features": "explore/data/features/%s", "feature_specs": "explore/data/functions/%s", "genie_spaces": "genie/rooms/%s", + "genie_agents": "genie/rooms/%s", "jobs": "jobs/%s", "mcp_services": "explore/data/mcp-services/%s", "models": "ml/models/%s",