Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/sources/looker/looker.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"time"

geminidataanalytics "cloud.google.com/go/geminidataanalytics/apiv1beta"
geminidataanalytics "cloud.google.com/go/geminidataanalytics/apiv1"
"github.com/goccy/go-yaml"
"github.com/googleapis/mcp-toolbox/internal/sources"
"github.com/googleapis/mcp-toolbox/internal/util"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
const resourceType string = "bigquery-conversational-analytics"

func getGDAURLFormat() string {
return util.GetGDAEndpoint() + "/v1beta/projects/%s/locations/%s:chat"
return util.GetGDAEndpoint() + "/v1/projects/%s/locations/%s:chat"
}

const instructions = `**INSTRUCTIONS - FOLLOW THESE RULES:**
Expand Down Expand Up @@ -101,11 +101,9 @@ type Options struct {
}
type InlineContext struct {
DatasourceReferences DatasourceReferences `json:"datasourceReferences"`
Options Options `json:"options"`
}

type CAPayload struct {
Project string `json:"project"`
Messages []Message `json:"messages"`
InlineContext InlineContext `json:"inlineContext"`
ClientIdEnum string `json:"clientIdEnum"`
Expand Down Expand Up @@ -220,13 +218,11 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par
}

payload := CAPayload{
Project: fmt.Sprintf("projects/%s", projectID),
Messages: []Message{{UserMessage: UserMessage{Text: finalQueryText}}},
InlineContext: InlineContext{
DatasourceReferences: DatasourceReferences{
BQ: BQDatasource{TableReferences: tableRefs},
},
Options: Options{Chart: ChartOptions{Image: ImageOptions{NoImage: map[string]any{}}}},
},
ClientIdEnum: util.GDAClientID,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ type DataAgentContext struct {
}

type CAPayload struct {
Project string `json:"project"`
Messages []Message `json:"messages"`
DataAgentContext DataAgentContext `json:"dataAgentContext"`
ClientIdEnum string `json:"clientIdEnum"`
Expand Down Expand Up @@ -196,7 +195,7 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par

// Construct URL, headers, and payload
projectID := source.GetProjectID()
caURL := fmt.Sprintf("%s/v1beta/projects/%s/locations/%s:chat", util.GetGDAEndpoint(), projectID, t.Cfg.Location)
caURL := fmt.Sprintf("%s/v1/projects/%s/locations/%s:chat", util.GetGDAEndpoint(), projectID, t.Cfg.Location)

headers := map[string]string{
"Content-Type": "application/json",
Expand All @@ -206,7 +205,6 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par
dataAgentName := fmt.Sprintf("projects/%s/locations/%s/dataAgents/%s", projectID, t.Cfg.Location, dataAgentId)

payload := CAPayload{
Project: fmt.Sprintf("projects/%s", projectID),
Messages: []Message{{UserMessage: UserMessage{Text: userQuery}}},
DataAgentContext: DataAgentContext{
DataAgent: dataAgentName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par

// Construct URL
projectID := source.GetProjectID()
caURL := fmt.Sprintf("%s/v1beta/projects/%s/locations/%s/dataAgents/%s", util.GetGDAEndpoint(), projectID, t.Cfg.Location, url.PathEscape(dataAgentId))
caURL := fmt.Sprintf("%s/v1/projects/%s/locations/%s/dataAgents/%s", util.GetGDAEndpoint(), projectID, t.Cfg.Location, url.PathEscape(dataAgentId))

req, err := http.NewRequest("GET", caURL, nil)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par

// Construct URL
projectID := source.GetProjectID()
caURL := fmt.Sprintf("%s/v1beta/projects/%s/locations/%s/dataAgents:listAccessible", util.GetGDAEndpoint(), projectID, t.Cfg.Location)
caURL := fmt.Sprintf("%s/v1/projects/%s/locations/%s/dataAgents:listAccessible", util.GetGDAEndpoint(), projectID, t.Cfg.Location)

req, err := http.NewRequest("GET", caURL, nil)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ type LookerExploreReference struct {
}
type LookerExploreReferences struct {
ExploreReferences []LookerExploreReference `json:"exploreReferences"`
Credentials Credentials `json:"credentials,omitzero"`
}
type SecretBased struct {
ClientId string `json:"clientId"`
Expand Down Expand Up @@ -116,11 +115,11 @@ type ConversationOptions struct {
type InlineContext struct {
SystemInstruction string `json:"systemInstruction"`
DatasourceReferences DatasourceReferences `json:"datasourceReferences"`
Options ConversationOptions `json:"options"`
}
type CAPayload struct {
Messages []Message `json:"messages"`
InlineContext InlineContext `json:"inlineContext"`
Credentials *Credentials `json:"credentials,omitempty"`
ClientIdEnum string `json:"clientIdEnum"`
}

Expand Down Expand Up @@ -249,15 +248,12 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par

lers := LookerExploreReferences{
ExploreReferences: ler,
Credentials: Credentials{
OAuth: oauth_creds,
},
}

// Construct URL, headers, and payload
projectID := source.GoogleCloudProject()
location := source.GoogleCloudLocation()
caURL := fmt.Sprintf("%s/v1beta/projects/%s/locations/%s:chat", util.GetGDAEndpoint(), url.PathEscape(projectID), url.PathEscape(location))
caURL := fmt.Sprintf("%s/v1/projects/%s/locations/%s:chat", util.GetGDAEndpoint(), url.PathEscape(projectID), url.PathEscape(location))

headers := map[string]string{
"Content-Type": "application/json",
Expand All @@ -271,7 +267,9 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par
DatasourceReferences: DatasourceReferences{
Looker: lers,
},
Options: ConversationOptions{Chart: ChartOptions{Image: ImageOptions{NoImage: map[string]any{}}}},
},
Credentials: &Credentials{
OAuth: oauth_creds,
},
ClientIdEnum: util.GDAClientID,
}
Expand Down
6 changes: 3 additions & 3 deletions tests/cloudgda/cloud_gda_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func setupDataAgent(t *testing.T, ctx context.Context, projectID, datasetID, tab

dataAgentId := "test" + strings.ReplaceAll(uuid.New().String(), "-", "")
parent := fmt.Sprintf("projects/%s/locations/global", projectID)
url := fmt.Sprintf("%s/v1beta/%s/dataAgents?dataAgentId=%s", util.GetGDAEndpoint(), parent, dataAgentId)
url := fmt.Sprintf("%s/v1/%s/dataAgents?dataAgentId=%s", util.GetGDAEndpoint(), parent, dataAgentId)

requestBody := map[string]any{
"displayName": dataAgentDisplayName,
Expand Down Expand Up @@ -402,7 +402,7 @@ func setupDataAgent(t *testing.T, ctx context.Context, projectID, datasetID, tab
case <-timeout:
t.Fatalf("timed out waiting for data agent creation")
case <-ticker.C:
opUrl := fmt.Sprintf("%s/v1beta/%s", util.GetGDAEndpoint(), opName)
opUrl := fmt.Sprintf("%s/v1/%s", util.GetGDAEndpoint(), opName)
opReq, _ := http.NewRequestWithContext(ctx, http.MethodGet, opUrl, nil)
opResp, err := client.Do(opReq)
if err != nil {
Expand All @@ -429,7 +429,7 @@ func setupDataAgent(t *testing.T, ctx context.Context, projectID, datasetID, tab

teardown := func(t *testing.T) {
agentName := fmt.Sprintf("%s/dataAgents/%s", parent, dataAgentId)
deleteUrl := fmt.Sprintf("%s/v1beta/%s", util.GetGDAEndpoint(), agentName)
deleteUrl := fmt.Sprintf("%s/v1/%s", util.GetGDAEndpoint(), agentName)
delReq, _ := http.NewRequest(http.MethodDelete, deleteUrl, nil)
delResp, err := client.Do(delReq)
if err != nil {
Expand Down
Loading