databricks-cli/cmd/workspace/genie/genie.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

516 lines
15 KiB
Go
Raw Normal View History

// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package genie
import (
"fmt"
"time"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/databricks-sdk-go/service/dashboards"
"github.com/spf13/cobra"
)
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var cmdOverrides []func(*cobra.Command)
func New() *cobra.Command {
cmd := &cobra.Command{
Use: "genie",
Short: `Genie provides a no-code experience for business users, powered by AI/BI.`,
Long: `Genie provides a no-code experience for business users, powered by AI/BI.
Analysts set up spaces that business users can use to ask questions using
natural language. Genie uses data registered to Unity Catalog and requires at
least CAN USE permission on a Pro or Serverless SQL warehouse. Also,
Databricks Assistant must be enabled.`,
GroupID: "dashboards",
Annotations: map[string]string{
"package": "dashboards",
},
// This service is being previewed; hide from help output.
Hidden: true,
}
// Add methods
cmd.AddCommand(newCreateMessage())
cmd.AddCommand(newExecuteMessageQuery())
cmd.AddCommand(newGetMessage())
cmd.AddCommand(newGetMessageQueryResult())
build(deps): bump github.com/databricks/databricks-sdk-go from 0.57.0 to 0.58.1 (#2357) Bumps [github.com/databricks/databricks-sdk-go](https://github.com/databricks/databricks-sdk-go) from 0.57.0 to 0.58.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/databricks/databricks-sdk-go/releases">github.com/databricks/databricks-sdk-go's releases</a>.</em></p> <blockquote> <h2>v0.58.1</h2> <h3>Internal Changes</h3> <ul> <li>Do not send ForceSendFields as query parameters.</li> </ul> <h2>v0.58.0</h2> <h2>[Release] Release v0.58.0</h2> <h3>New Features and Improvements</h3> <ul> <li>Enable async refreshes for OAuth tokens (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1143">#1143</a>).</li> </ul> <h3>Internal Changes</h3> <ul> <li>Add support for asynchronous data plane token refreshes (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1142">#1142</a>).</li> <li>Introduce new TokenSource interface that takes a <code>context.Context</code> (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1141">#1141</a>).</li> </ul> <h3>API Changes:</h3> <ul> <li>Added <code>GetMessageQueryResultByAttachment</code> method for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#GenieAPI">w.Genie</a> workspace-level service.</li> <li>Added <code>Id</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/apps#App">apps.App</a>.</li> <li>Added <code>LimitConfig</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/billing#UpdateBudgetPolicyRequest">billing.UpdateBudgetPolicyRequest</a>.</li> <li>Added <code>Volumes</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/compute#ClusterLogConf">compute.ClusterLogConf</a>.</li> <li>Removed <code>ReviewState</code>, <code>Reviews</code> and <code>RunnerCollaborators</code> fields for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/cleanrooms#CleanRoomAssetNotebook">cleanrooms.CleanRoomAssetNotebook</a>.</li> </ul> <p>OpenAPI SHA: 99f644e72261ef5ecf8d74db20f4b7a1e09723cc, Date: 2025-02-11</p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/databricks/databricks-sdk-go/blob/main/CHANGELOG.md">github.com/databricks/databricks-sdk-go's changelog</a>.</em></p> <blockquote> <h2>[Release] Release v0.58.1</h2> <h3>Internal Changes</h3> <ul> <li>Do not send ForceSendFields as query parameters.</li> </ul> <h2>[Release] Release v0.58.0</h2> <h3>New Features and Improvements</h3> <ul> <li>Enable async refreshes for OAuth tokens (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1143">#1143</a>).</li> </ul> <h3>Internal Changes</h3> <ul> <li>Add support for asynchronous data plane token refreshes (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1142">#1142</a>).</li> <li>Introduce new TokenSource interface that takes a <code>context.Context</code> (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1141">#1141</a>).</li> </ul> <h3>API Changes:</h3> <ul> <li>Added <code>GetMessageQueryResultByAttachment</code> method for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#GenieAPI">w.Genie</a> workspace-level service.</li> <li>Added <code>Id</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/apps#App">apps.App</a>.</li> <li>Added <code>LimitConfig</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/billing#UpdateBudgetPolicyRequest">billing.UpdateBudgetPolicyRequest</a>.</li> <li>Added <code>Volumes</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/compute#ClusterLogConf">compute.ClusterLogConf</a>.</li> <li>Added .</li> <li>Removed <code>ReviewState</code>, <code>Reviews</code> and <code>RunnerCollaborators</code> fields for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/cleanrooms#CleanRoomAssetNotebook">cleanrooms.CleanRoomAssetNotebook</a>.</li> </ul> <p>OpenAPI SHA: 99f644e72261ef5ecf8d74db20f4b7a1e09723cc, Date: 2025-02-11</p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/967d0632b7676ca14b3dae154dcc2f727f4350c6"><code>967d063</code></a> [Release] Release v0.58.1 (<a href="https://redirect.github.com/databricks/databricks-sdk-go/issues/1146">#1146</a>)</li> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/9dc3c56fb0afb65e8597f205db087fb2c6cca21d"><code>9dc3c56</code></a> [Release] Release v0.58.0 (<a href="https://redirect.github.com/databricks/databricks-sdk-go/issues/1144">#1144</a>)</li> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/8307a4d467368f6a4290cba179a334d1f816ebd6"><code>8307a4d</code></a> [Feature] Enable async refreshes for OAuth tokens (<a href="https://redirect.github.com/databricks/databricks-sdk-go/issues/1143">#1143</a>)</li> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/815cace601ed08e11794d9c20e8c42e6af376f4a"><code>815cace</code></a> [Internal] Add support for asynchronous data plane token refreshes (<a href="https://redirect.github.com/databricks/databricks-sdk-go/issues/1142">#1142</a>)</li> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/3aebd68bf334b94e63974963cd967f836b559a48"><code>3aebd68</code></a> [Internal] Introduce new TokenSource interface that takes a <code>context.Context</code>...</li> <li>See full diff in <a href="https://github.com/databricks/databricks-sdk-go/compare/v0.57.0...v0.58.1">compare view</a></li> </ul> </details> <br /> <details> <summary>Most Recent Ignore Conditions Applied to This Pull Request</summary> | Dependency Name | Ignore Conditions | | --- | --- | | github.com/databricks/databricks-sdk-go | [>= 0.28.a, < 0.29] | </details> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/databricks/databricks-sdk-go&package-manager=go_modules&previous-version=0.57.0&new-version=0.58.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Nester <andrew.nester@databricks.com>
2025-02-25 11:20:29 +00:00
cmd.AddCommand(newGetMessageQueryResultByAttachment())
cmd.AddCommand(newStartConversation())
// Apply optional overrides to this command.
for _, fn := range cmdOverrides {
fn(cmd)
}
return cmd
}
// start create-message command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var createMessageOverrides []func(
*cobra.Command,
*dashboards.GenieCreateConversationMessageRequest,
)
func newCreateMessage() *cobra.Command {
cmd := &cobra.Command{}
var createMessageReq dashboards.GenieCreateConversationMessageRequest
var createMessageJson flags.JsonFlag
var createMessageSkipWait bool
var createMessageTimeout time.Duration
cmd.Flags().BoolVar(&createMessageSkipWait, "no-wait", createMessageSkipWait, `do not wait to reach COMPLETED state`)
cmd.Flags().DurationVar(&createMessageTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach COMPLETED state`)
// TODO: short flags
cmd.Flags().Var(&createMessageJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Use = "create-message SPACE_ID CONVERSATION_ID CONTENT"
cmd.Short = `Create conversation message.`
cmd.Long = `Create conversation message.
Create new message in [conversation](:method:genie/startconversation). The AI
response uses all previously created messages in the conversation to respond.
Arguments:
SPACE_ID: The ID associated with the Genie space where the conversation is started.
CONVERSATION_ID: The ID associated with the conversation.
CONTENT: User message content.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(2)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, provide only SPACE_ID, CONVERSATION_ID as positional arguments. Provide 'content' in your JSON input")
}
return nil
}
check := root.ExactArgs(3)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
diags := createMessageJson.Unmarshal(&createMessageReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
createMessageReq.SpaceId = args[0]
createMessageReq.ConversationId = args[1]
if !cmd.Flags().Changed("json") {
createMessageReq.Content = args[2]
}
wait, err := w.Genie.CreateMessage(ctx, createMessageReq)
if err != nil {
return err
}
if createMessageSkipWait {
return cmdio.Render(ctx, wait.Response)
}
spinner := cmdio.Spinner(ctx)
info, err := wait.OnProgress(func(i *dashboards.GenieMessage) {
status := i.Status
statusMessage := fmt.Sprintf("current status: %s", status)
spinner <- statusMessage
}).GetWithTimeout(createMessageTimeout)
close(spinner)
if err != nil {
return err
}
return cmdio.Render(ctx, info)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range createMessageOverrides {
fn(cmd, &createMessageReq)
}
return cmd
}
// start execute-message-query command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var executeMessageQueryOverrides []func(
*cobra.Command,
*dashboards.GenieExecuteMessageQueryRequest,
)
func newExecuteMessageQuery() *cobra.Command {
cmd := &cobra.Command{}
var executeMessageQueryReq dashboards.GenieExecuteMessageQueryRequest
// TODO: short flags
cmd.Use = "execute-message-query SPACE_ID CONVERSATION_ID MESSAGE_ID"
cmd.Short = `Execute SQL query in a conversation message.`
cmd.Long = `Execute SQL query in a conversation message.
Execute the SQL query in the message.
Arguments:
SPACE_ID: Genie space ID
CONVERSATION_ID: Conversation ID
MESSAGE_ID: Message ID`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(3)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
executeMessageQueryReq.SpaceId = args[0]
executeMessageQueryReq.ConversationId = args[1]
executeMessageQueryReq.MessageId = args[2]
response, err := w.Genie.ExecuteMessageQuery(ctx, executeMessageQueryReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range executeMessageQueryOverrides {
fn(cmd, &executeMessageQueryReq)
}
return cmd
}
// start get-message command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var getMessageOverrides []func(
*cobra.Command,
*dashboards.GenieGetConversationMessageRequest,
)
func newGetMessage() *cobra.Command {
cmd := &cobra.Command{}
var getMessageReq dashboards.GenieGetConversationMessageRequest
// TODO: short flags
cmd.Use = "get-message SPACE_ID CONVERSATION_ID MESSAGE_ID"
cmd.Short = `Get conversation message.`
cmd.Long = `Get conversation message.
Get message from conversation.
Arguments:
SPACE_ID: The ID associated with the Genie space where the target conversation is
located.
CONVERSATION_ID: The ID associated with the target conversation.
MESSAGE_ID: The ID associated with the target message from the identified
conversation.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(3)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
getMessageReq.SpaceId = args[0]
getMessageReq.ConversationId = args[1]
getMessageReq.MessageId = args[2]
response, err := w.Genie.GetMessage(ctx, getMessageReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range getMessageOverrides {
fn(cmd, &getMessageReq)
}
return cmd
}
// start get-message-query-result command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var getMessageQueryResultOverrides []func(
*cobra.Command,
*dashboards.GenieGetMessageQueryResultRequest,
)
func newGetMessageQueryResult() *cobra.Command {
cmd := &cobra.Command{}
var getMessageQueryResultReq dashboards.GenieGetMessageQueryResultRequest
// TODO: short flags
cmd.Use = "get-message-query-result SPACE_ID CONVERSATION_ID MESSAGE_ID"
cmd.Short = `Get conversation message SQL query result.`
cmd.Long = `Get conversation message SQL query result.
Get the result of SQL query if the message has a query attachment. This is
only available if a message has a query attachment and the message status is
EXECUTING_QUERY.
Arguments:
SPACE_ID: Genie space ID
CONVERSATION_ID: Conversation ID
MESSAGE_ID: Message ID`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(3)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
getMessageQueryResultReq.SpaceId = args[0]
getMessageQueryResultReq.ConversationId = args[1]
getMessageQueryResultReq.MessageId = args[2]
response, err := w.Genie.GetMessageQueryResult(ctx, getMessageQueryResultReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range getMessageQueryResultOverrides {
fn(cmd, &getMessageQueryResultReq)
}
return cmd
}
build(deps): bump github.com/databricks/databricks-sdk-go from 0.57.0 to 0.58.1 (#2357) Bumps [github.com/databricks/databricks-sdk-go](https://github.com/databricks/databricks-sdk-go) from 0.57.0 to 0.58.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/databricks/databricks-sdk-go/releases">github.com/databricks/databricks-sdk-go's releases</a>.</em></p> <blockquote> <h2>v0.58.1</h2> <h3>Internal Changes</h3> <ul> <li>Do not send ForceSendFields as query parameters.</li> </ul> <h2>v0.58.0</h2> <h2>[Release] Release v0.58.0</h2> <h3>New Features and Improvements</h3> <ul> <li>Enable async refreshes for OAuth tokens (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1143">#1143</a>).</li> </ul> <h3>Internal Changes</h3> <ul> <li>Add support for asynchronous data plane token refreshes (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1142">#1142</a>).</li> <li>Introduce new TokenSource interface that takes a <code>context.Context</code> (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1141">#1141</a>).</li> </ul> <h3>API Changes:</h3> <ul> <li>Added <code>GetMessageQueryResultByAttachment</code> method for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#GenieAPI">w.Genie</a> workspace-level service.</li> <li>Added <code>Id</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/apps#App">apps.App</a>.</li> <li>Added <code>LimitConfig</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/billing#UpdateBudgetPolicyRequest">billing.UpdateBudgetPolicyRequest</a>.</li> <li>Added <code>Volumes</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/compute#ClusterLogConf">compute.ClusterLogConf</a>.</li> <li>Removed <code>ReviewState</code>, <code>Reviews</code> and <code>RunnerCollaborators</code> fields for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/cleanrooms#CleanRoomAssetNotebook">cleanrooms.CleanRoomAssetNotebook</a>.</li> </ul> <p>OpenAPI SHA: 99f644e72261ef5ecf8d74db20f4b7a1e09723cc, Date: 2025-02-11</p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/databricks/databricks-sdk-go/blob/main/CHANGELOG.md">github.com/databricks/databricks-sdk-go's changelog</a>.</em></p> <blockquote> <h2>[Release] Release v0.58.1</h2> <h3>Internal Changes</h3> <ul> <li>Do not send ForceSendFields as query parameters.</li> </ul> <h2>[Release] Release v0.58.0</h2> <h3>New Features and Improvements</h3> <ul> <li>Enable async refreshes for OAuth tokens (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1143">#1143</a>).</li> </ul> <h3>Internal Changes</h3> <ul> <li>Add support for asynchronous data plane token refreshes (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1142">#1142</a>).</li> <li>Introduce new TokenSource interface that takes a <code>context.Context</code> (<a href="https://redirect.github.com/databricks/databricks-sdk-go/pull/1141">#1141</a>).</li> </ul> <h3>API Changes:</h3> <ul> <li>Added <code>GetMessageQueryResultByAttachment</code> method for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/dashboards#GenieAPI">w.Genie</a> workspace-level service.</li> <li>Added <code>Id</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/apps#App">apps.App</a>.</li> <li>Added <code>LimitConfig</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/billing#UpdateBudgetPolicyRequest">billing.UpdateBudgetPolicyRequest</a>.</li> <li>Added <code>Volumes</code> field for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/compute#ClusterLogConf">compute.ClusterLogConf</a>.</li> <li>Added .</li> <li>Removed <code>ReviewState</code>, <code>Reviews</code> and <code>RunnerCollaborators</code> fields for <a href="https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/cleanrooms#CleanRoomAssetNotebook">cleanrooms.CleanRoomAssetNotebook</a>.</li> </ul> <p>OpenAPI SHA: 99f644e72261ef5ecf8d74db20f4b7a1e09723cc, Date: 2025-02-11</p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/967d0632b7676ca14b3dae154dcc2f727f4350c6"><code>967d063</code></a> [Release] Release v0.58.1 (<a href="https://redirect.github.com/databricks/databricks-sdk-go/issues/1146">#1146</a>)</li> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/9dc3c56fb0afb65e8597f205db087fb2c6cca21d"><code>9dc3c56</code></a> [Release] Release v0.58.0 (<a href="https://redirect.github.com/databricks/databricks-sdk-go/issues/1144">#1144</a>)</li> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/8307a4d467368f6a4290cba179a334d1f816ebd6"><code>8307a4d</code></a> [Feature] Enable async refreshes for OAuth tokens (<a href="https://redirect.github.com/databricks/databricks-sdk-go/issues/1143">#1143</a>)</li> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/815cace601ed08e11794d9c20e8c42e6af376f4a"><code>815cace</code></a> [Internal] Add support for asynchronous data plane token refreshes (<a href="https://redirect.github.com/databricks/databricks-sdk-go/issues/1142">#1142</a>)</li> <li><a href="https://github.com/databricks/databricks-sdk-go/commit/3aebd68bf334b94e63974963cd967f836b559a48"><code>3aebd68</code></a> [Internal] Introduce new TokenSource interface that takes a <code>context.Context</code>...</li> <li>See full diff in <a href="https://github.com/databricks/databricks-sdk-go/compare/v0.57.0...v0.58.1">compare view</a></li> </ul> </details> <br /> <details> <summary>Most Recent Ignore Conditions Applied to This Pull Request</summary> | Dependency Name | Ignore Conditions | | --- | --- | | github.com/databricks/databricks-sdk-go | [>= 0.28.a, < 0.29] | </details> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/databricks/databricks-sdk-go&package-manager=go_modules&previous-version=0.57.0&new-version=0.58.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Nester <andrew.nester@databricks.com>
2025-02-25 11:20:29 +00:00
// start get-message-query-result-by-attachment command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var getMessageQueryResultByAttachmentOverrides []func(
*cobra.Command,
*dashboards.GenieGetQueryResultByAttachmentRequest,
)
func newGetMessageQueryResultByAttachment() *cobra.Command {
cmd := &cobra.Command{}
var getMessageQueryResultByAttachmentReq dashboards.GenieGetQueryResultByAttachmentRequest
// TODO: short flags
cmd.Use = "get-message-query-result-by-attachment SPACE_ID CONVERSATION_ID MESSAGE_ID ATTACHMENT_ID"
cmd.Short = `Get conversation message SQL query result by attachment id.`
cmd.Long = `Get conversation message SQL query result by attachment id.
Get the result of SQL query by attachment id This is only available if a
message has a query attachment and the message status is EXECUTING_QUERY.
Arguments:
SPACE_ID: Genie space ID
CONVERSATION_ID: Conversation ID
MESSAGE_ID: Message ID
ATTACHMENT_ID: Attachment ID`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(4)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
getMessageQueryResultByAttachmentReq.SpaceId = args[0]
getMessageQueryResultByAttachmentReq.ConversationId = args[1]
getMessageQueryResultByAttachmentReq.MessageId = args[2]
getMessageQueryResultByAttachmentReq.AttachmentId = args[3]
response, err := w.Genie.GetMessageQueryResultByAttachment(ctx, getMessageQueryResultByAttachmentReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range getMessageQueryResultByAttachmentOverrides {
fn(cmd, &getMessageQueryResultByAttachmentReq)
}
return cmd
}
// start start-conversation command
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var startConversationOverrides []func(
*cobra.Command,
*dashboards.GenieStartConversationMessageRequest,
)
func newStartConversation() *cobra.Command {
cmd := &cobra.Command{}
var startConversationReq dashboards.GenieStartConversationMessageRequest
var startConversationJson flags.JsonFlag
var startConversationSkipWait bool
var startConversationTimeout time.Duration
cmd.Flags().BoolVar(&startConversationSkipWait, "no-wait", startConversationSkipWait, `do not wait to reach COMPLETED state`)
cmd.Flags().DurationVar(&startConversationTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach COMPLETED state`)
// TODO: short flags
cmd.Flags().Var(&startConversationJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Use = "start-conversation SPACE_ID CONTENT"
cmd.Short = `Start conversation.`
cmd.Long = `Start conversation.
Start a new conversation.
Arguments:
SPACE_ID: The ID associated with the Genie space where you want to start a
conversation.
CONTENT: The text of the message that starts the conversation.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(1)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, provide only SPACE_ID as positional arguments. Provide 'content' in your JSON input")
}
return nil
}
check := root.ExactArgs(2)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
diags := startConversationJson.Unmarshal(&startConversationReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
startConversationReq.SpaceId = args[0]
if !cmd.Flags().Changed("json") {
startConversationReq.Content = args[1]
}
wait, err := w.Genie.StartConversation(ctx, startConversationReq)
if err != nil {
return err
}
if startConversationSkipWait {
return cmdio.Render(ctx, wait.Response)
}
spinner := cmdio.Spinner(ctx)
info, err := wait.OnProgress(func(i *dashboards.GenieMessage) {
status := i.Status
statusMessage := fmt.Sprintf("current status: %s", status)
spinner <- statusMessage
}).GetWithTimeout(startConversationTimeout)
close(spinner)
if err != nil {
return err
}
return cmdio.Render(ctx, info)
}
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
// Apply optional overrides to this command.
for _, fn := range startConversationOverrides {
fn(cmd, &startConversationReq)
}
return cmd
}
// end service Genie