mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-11 00:18:17 -05:00
feat: Add AuthRequired to neo4j & dgraph Tools (#434)
neo4j & dgraph Tools are missing the `AuthRequired` fields.
This commit is contained in:
@@ -36,14 +36,15 @@ var _ compatibleSource = &dgraph.Source{}
|
||||
var compatibleSources = [...]string{dgraph.SourceKind}
|
||||
|
||||
type Config struct {
|
||||
Name string `yaml:"name" validate:"required"`
|
||||
Kind string `yaml:"kind" validate:"required"`
|
||||
Source string `yaml:"source" validate:"required"`
|
||||
Description string `yaml:"description" validate:"required"`
|
||||
Statement string `yaml:"statement" validate:"required"`
|
||||
IsQuery bool `yaml:"isQuery"`
|
||||
Timeout string `yaml:"timeout"`
|
||||
Parameters tools.Parameters `yaml:"parameters"`
|
||||
Name string `yaml:"name" validate:"required"`
|
||||
Kind string `yaml:"kind" validate:"required"`
|
||||
Source string `yaml:"source" validate:"required"`
|
||||
Description string `yaml:"description" validate:"required"`
|
||||
Statement string `yaml:"statement" validate:"required"`
|
||||
AuthRequired []string `yaml:"authRequired"`
|
||||
IsQuery bool `yaml:"isQuery"`
|
||||
Timeout string `yaml:"timeout"`
|
||||
Parameters tools.Parameters `yaml:"parameters"`
|
||||
}
|
||||
|
||||
// validate interface
|
||||
@@ -78,6 +79,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
Kind: ToolKind,
|
||||
Parameters: cfg.Parameters,
|
||||
Statement: cfg.Statement,
|
||||
AuthRequired: cfg.AuthRequired,
|
||||
DgraphClient: s.DgraphClient(),
|
||||
IsQuery: cfg.IsQuery,
|
||||
Timeout: cfg.Timeout,
|
||||
|
||||
@@ -42,6 +42,9 @@ func TestParseFromYamlDgraph(t *testing.T) {
|
||||
kind: dgraph-dql
|
||||
source: my-dgraph-instance
|
||||
description: some tool description
|
||||
authRequired:
|
||||
- my-google-auth-service
|
||||
- other-auth-service
|
||||
isQuery: true
|
||||
timeout: 20s
|
||||
statement: |
|
||||
@@ -49,13 +52,14 @@ func TestParseFromYamlDgraph(t *testing.T) {
|
||||
`,
|
||||
want: server.ToolConfigs{
|
||||
"example_tool": dgraph.Config{
|
||||
Name: "example_tool",
|
||||
Kind: dgraph.ToolKind,
|
||||
Source: "my-dgraph-instance",
|
||||
Description: "some tool description",
|
||||
IsQuery: true,
|
||||
Timeout: "20s",
|
||||
Statement: "query {q(func: eq(email, \"example@email.com\")) {email}}\n",
|
||||
Name: "example_tool",
|
||||
Kind: dgraph.ToolKind,
|
||||
Source: "my-dgraph-instance",
|
||||
AuthRequired: []string{"my-google-auth-service", "other-auth-service"},
|
||||
Description: "some tool description",
|
||||
IsQuery: true,
|
||||
Timeout: "20s",
|
||||
Statement: "query {q(func: eq(email, \"example@email.com\")) {email}}\n",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -38,12 +38,13 @@ var _ compatibleSource = &neo4jsc.Source{}
|
||||
var compatibleSources = [...]string{neo4jsc.SourceKind}
|
||||
|
||||
type Config struct {
|
||||
Name string `yaml:"name" validate:"required"`
|
||||
Kind string `yaml:"kind" validate:"required"`
|
||||
Source string `yaml:"source" validate:"required"`
|
||||
Description string `yaml:"description" validate:"required"`
|
||||
Statement string `yaml:"statement" validate:"required"`
|
||||
Parameters tools.Parameters `yaml:"parameters"`
|
||||
Name string `yaml:"name" validate:"required"`
|
||||
Kind string `yaml:"kind" validate:"required"`
|
||||
Source string `yaml:"source" validate:"required"`
|
||||
Description string `yaml:"description" validate:"required"`
|
||||
Statement string `yaml:"statement" validate:"required"`
|
||||
AuthRequired []string `yaml:"authRequired"`
|
||||
Parameters tools.Parameters `yaml:"parameters"`
|
||||
}
|
||||
|
||||
// validate interface
|
||||
@@ -74,14 +75,15 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
|
||||
// finish tool setup
|
||||
t := Tool{
|
||||
Name: cfg.Name,
|
||||
Kind: ToolKind,
|
||||
Parameters: cfg.Parameters,
|
||||
Statement: cfg.Statement,
|
||||
Driver: s.Neo4jDriver(),
|
||||
Database: s.Neo4jDatabase(),
|
||||
manifest: tools.Manifest{Description: cfg.Description, Parameters: cfg.Parameters.Manifest()},
|
||||
mcpManifest: mcpManifest,
|
||||
Name: cfg.Name,
|
||||
Kind: ToolKind,
|
||||
Parameters: cfg.Parameters,
|
||||
Statement: cfg.Statement,
|
||||
AuthRequired: cfg.AuthRequired,
|
||||
Driver: s.Neo4jDriver(),
|
||||
Database: s.Neo4jDatabase(),
|
||||
manifest: tools.Manifest{Description: cfg.Description, Parameters: cfg.Parameters.Manifest()},
|
||||
mcpManifest: mcpManifest,
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ func TestParseFromYamlNeo4j(t *testing.T) {
|
||||
kind: neo4j-cypher
|
||||
source: my-neo4j-instance
|
||||
description: some tool description
|
||||
authRequired:
|
||||
- my-google-auth-service
|
||||
- other-auth-service
|
||||
statement: |
|
||||
MATCH (c:Country) WHERE c.name = $country RETURN c.id as id;
|
||||
parameters:
|
||||
@@ -52,11 +55,12 @@ func TestParseFromYamlNeo4j(t *testing.T) {
|
||||
`,
|
||||
want: server.ToolConfigs{
|
||||
"example_tool": neo4j.Config{
|
||||
Name: "example_tool",
|
||||
Kind: neo4j.ToolKind,
|
||||
Source: "my-neo4j-instance",
|
||||
Description: "some tool description",
|
||||
Statement: "MATCH (c:Country) WHERE c.name = $country RETURN c.id as id;\n",
|
||||
Name: "example_tool",
|
||||
Kind: neo4j.ToolKind,
|
||||
Source: "my-neo4j-instance",
|
||||
Description: "some tool description",
|
||||
AuthRequired: []string{"my-google-auth-service", "other-auth-service"},
|
||||
Statement: "MATCH (c:Country) WHERE c.name = $country RETURN c.id as id;\n",
|
||||
Parameters: []tools.Parameter{
|
||||
tools.NewStringParameter("country", "country parameter description"),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user