mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-11 08:28:11 -05:00
feat(source/alloydb, source/cloud-sql-postgres,source/cloud-sql-mysql,source/cloud-sql-mssql): Use project from env for alloydb and cloud sql control plane tools (#1588)
## Description --- This change introduces the `DefaultProject` field for the `alloydb-admin` and `cloud-sql-admin` sources. This field allows the alloydb and cloud sql control plane tools to use the project value from the environment variables (Ex: `ALLOYDB_POSTGRES_PROJECT`) if it is already set instead of asking the user. ## PR Checklist --- > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [x] Make sure to add `!` if this involve a breaking change 🛠️ Fixes: https://github.com/gemini-cli-extensions/alloydb/issues/47 --------- Co-authored-by: Averi Kitsch <akitsch@google.com>
This commit is contained in:
@@ -365,7 +365,7 @@ type ToolsFile struct {
|
||||
// parseEnv replaces environment variables ${ENV_NAME} with their values.
|
||||
// also support ${ENV_NAME:default_value}.
|
||||
func parseEnv(input string) (string, error) {
|
||||
re := regexp.MustCompile(`\$\{(\w+)(:(\w*))?\}`)
|
||||
re := regexp.MustCompile(`\$\{(\w+)(:([^}]*))?\}`)
|
||||
|
||||
var err error
|
||||
output := re.ReplaceAllStringFunc(input, func(match string) string {
|
||||
@@ -376,7 +376,7 @@ func parseEnv(input string) (string, error) {
|
||||
if value, found := os.LookupEnv(variableName); found {
|
||||
return value
|
||||
}
|
||||
if parts[2] != "" {
|
||||
if len(parts) >= 4 && parts[2] != "" {
|
||||
return parts[3]
|
||||
}
|
||||
err = fmt.Errorf("environment variable not found: %q", variableName)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
---
|
||||
title: "AlloyDB Admin"
|
||||
linkTitle: "AlloyDB Admin"
|
||||
title: AlloyDB Admin
|
||||
linkTitle: AlloyDB Admin
|
||||
type: docs
|
||||
weight: 2
|
||||
description: >
|
||||
The "alloydb-admin" source provides a client for the AlloyDB API.
|
||||
aliases:
|
||||
- /resources/sources/alloydb-admin
|
||||
weight: 1
|
||||
description: "The \"alloydb-admin\" source provides a client for the AlloyDB API.\n"
|
||||
aliases: [/resources/sources/alloydb-admin]
|
||||
---
|
||||
|
||||
## About
|
||||
@@ -17,6 +15,7 @@ tools to perform administrative tasks on AlloyDB resources, such as managing
|
||||
clusters, instances, and users.
|
||||
|
||||
Authentication can be handled in two ways:
|
||||
|
||||
1. **Application Default Credentials (ADC):** By default, the source uses ADC
|
||||
to authenticate with the API.
|
||||
2. **Client-side OAuth:** If `useClientOAuth` is set to `true`, the source will
|
||||
@@ -36,7 +35,9 @@ sources:
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
| **field** | **type** | **required** | **description** |
|
||||
|----------------|:--------:|:------------:|------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| -------------- | :------: | :----------: | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| kind | string | true | Must be "alloydb-admin". |
|
||||
| useClientOAuth | boolean | false | If true, the source will use client-side OAuth for authorization. Otherwise, it will use Application Default Credentials. Defaults to `false`. |
|
||||
| defaultProject | string | false | The Google Cloud project ID to use for AlloyDB infrastructure tools. |
|
||||
| useClientOAuth | boolean | false | If true, the source will use client-side OAuth for authorization. Otherwise, it will use Application Default Credentials. Defaults to `false`. |
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
title: "Cloud SQL Admin"
|
||||
title: Cloud SQL Admin
|
||||
type: docs
|
||||
weight: 1
|
||||
description: >
|
||||
A "cloud-sql-admin" source provides a client for the Cloud SQL Admin API.
|
||||
aliases:
|
||||
- /resources/sources/cloud-sql-admin
|
||||
description: "A \"cloud-sql-admin\" source provides a client for the Cloud SQL Admin API.\n"
|
||||
aliases: [/resources/sources/cloud-sql-admin]
|
||||
---
|
||||
|
||||
## About
|
||||
@@ -16,6 +14,7 @@ allows tools to perform administrative tasks on Cloud SQL instances, such as
|
||||
creating users and databases.
|
||||
|
||||
Authentication can be handled in two ways:
|
||||
|
||||
1. **Application Default Credentials (ADC):** By default, the source uses ADC
|
||||
to authenticate with the API.
|
||||
2. **Client-side OAuth:** If `useClientOAuth` is set to `true`, the source will
|
||||
@@ -37,6 +36,7 @@ sources:
|
||||
## Reference
|
||||
|
||||
| **field** | **type** | **required** | **description** |
|
||||
|----------------|:--------:|:------------:|------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| -------------- | :------: | :----------: | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| kind | string | true | Must be "cloud-sql-admin". |
|
||||
| useClientOAuth | boolean | false | If true, the source will use client-side OAuth for authorization. Otherwise, it will use Application Default Credentials. Defaults to `false`. |
|
||||
| defaultProject | string | false | The Google Cloud project ID to use for Cloud SQL infrastructure tools. |
|
||||
| useClientOAuth | boolean | false | If true, the source will use client-side OAuth for authorization. Otherwise, it will use Application Default Credentials. Defaults to `false`. |
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
sources:
|
||||
alloydb-admin-source:
|
||||
kind: alloydb-admin
|
||||
defaultProject: ${ALLOYDB_POSTGRES_PROJECT:}
|
||||
tools:
|
||||
create_cluster:
|
||||
kind: alloydb-create-cluster
|
||||
@@ -30,8 +31,8 @@ tools:
|
||||
kind: alloydb-create-instance
|
||||
source: alloydb-admin-source
|
||||
list_clusters:
|
||||
kind: alloydb-list-clusters
|
||||
source: alloydb-admin-source
|
||||
kind: alloydb-list-clusters
|
||||
source: alloydb-admin-source
|
||||
list_instances:
|
||||
kind: alloydb-list-instances
|
||||
source: alloydb-admin-source
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
sources:
|
||||
cloud-sql-admin-source:
|
||||
kind: cloud-sql-admin
|
||||
defaultProject: ${CLOUD_SQL_MSSQL_PROJECT:}
|
||||
|
||||
tools:
|
||||
create_instance:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
sources:
|
||||
cloud-sql-admin-source:
|
||||
kind: cloud-sql-admin
|
||||
defaultProject: ${CLOUD_SQL_MYSQL_PROJECT:}
|
||||
|
||||
tools:
|
||||
create_instance:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
sources:
|
||||
cloud-sql-admin-source:
|
||||
kind: cloud-sql-admin
|
||||
defaultProject: ${CLOUD_SQL_POSTGRES_PROJECT:}
|
||||
|
||||
tools:
|
||||
create_instance:
|
||||
|
||||
@@ -70,6 +70,7 @@ func newConfig(ctx context.Context, name string, decoder *yaml.Decoder) (sources
|
||||
type Config struct {
|
||||
Name string `yaml:"name" validate:"required"`
|
||||
Kind string `yaml:"kind" validate:"required"`
|
||||
DefaultProject string `yaml:"defaultProject"`
|
||||
UseClientOAuth bool `yaml:"useClientOAuth"`
|
||||
}
|
||||
|
||||
@@ -115,6 +116,7 @@ func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.So
|
||||
Kind: SourceKind,
|
||||
BaseURL: "https://alloydb.googleapis.com",
|
||||
Service: service,
|
||||
DefaultProject: r.DefaultProject,
|
||||
UseClientOAuth: r.UseClientOAuth,
|
||||
}
|
||||
|
||||
@@ -128,6 +130,7 @@ type Source struct {
|
||||
Kind string `yaml:"kind"`
|
||||
BaseURL string
|
||||
Service *alloydbrestapi.Service
|
||||
DefaultProject string
|
||||
UseClientOAuth bool
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ func newConfig(ctx context.Context, name string, decoder *yaml.Decoder) (sources
|
||||
type Config struct {
|
||||
Name string `yaml:"name" validate:"required"`
|
||||
Kind string `yaml:"kind" validate:"required"`
|
||||
DefaultProject string `yaml:"defaultProject"`
|
||||
UseClientOAuth bool `yaml:"useClientOAuth"`
|
||||
}
|
||||
|
||||
@@ -116,6 +117,7 @@ func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.So
|
||||
Kind: SourceKind,
|
||||
BaseURL: "https://sqladmin.googleapis.com",
|
||||
Service: service,
|
||||
DefaultProject: r.DefaultProject,
|
||||
UseClientOAuth: r.UseClientOAuth,
|
||||
}
|
||||
return s, nil
|
||||
@@ -128,6 +130,7 @@ type Source struct {
|
||||
Kind string `yaml:"kind"`
|
||||
BaseURL string
|
||||
Service *sqladmin.Service
|
||||
DefaultProject string
|
||||
UseClientOAuth bool
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `alloydb-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID."),
|
||||
projectParam,
|
||||
tools.NewStringParameterWithDefault("location", "us-central1", "The location to create the cluster in. The default value is us-central1. If quota is exhausted then use other regions."),
|
||||
tools.NewStringParameter("cluster", "A unique ID for the AlloyDB cluster."),
|
||||
tools.NewStringParameter("password", "A secure password for the initial user."),
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `alloydb-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID."),
|
||||
projectParam,
|
||||
tools.NewStringParameter("location", "The location of the cluster (e.g., 'us-central1')."),
|
||||
tools.NewStringParameter("cluster", "The ID of the cluster to create the instance in."),
|
||||
tools.NewStringParameter("instance", "A unique ID for the new AlloyDB instance."),
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `alloydb-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID."),
|
||||
projectParam,
|
||||
tools.NewStringParameter("location", "The location of the cluster (e.g., 'us-central1')."),
|
||||
tools.NewStringParameter("cluster", "The ID of the cluster where the user will be created."),
|
||||
tools.NewStringParameter("user", "The name for the new user. Must be unique within the cluster."),
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `%s`", kind, alloydbadmin.SourceKind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID."),
|
||||
projectParam,
|
||||
tools.NewStringParameter("location", "The location of the cluster (e.g., 'us-central1')."),
|
||||
tools.NewStringParameter("cluster", "The ID of the cluster."),
|
||||
}
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `%s`", kind, alloydbadmin.SourceKind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID."),
|
||||
projectParam,
|
||||
tools.NewStringParameter("location", "The location of the instance (e.g., 'us-central1')."),
|
||||
tools.NewStringParameter("cluster", "The ID of the cluster."),
|
||||
tools.NewStringParameter("instance", "The ID of the instance."),
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `%s`", kind, alloydbadmin.SourceKind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID."),
|
||||
projectParam,
|
||||
tools.NewStringParameter("location", "The location of the cluster (e.g., 'us-central1')."),
|
||||
tools.NewStringParameter("cluster", "The ID of the cluster."),
|
||||
tools.NewStringParameter("user", "The ID of the user."),
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `%s`", kind, alloydbadmin.SourceKind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID to list clusters for.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID to list clusters for."),
|
||||
projectParam,
|
||||
tools.NewStringParameterWithDefault("location", "-", "Optional: The location to list clusters in (e.g., 'us-central1'). Use '-' to list clusters across all locations.(Default: '-')"),
|
||||
}
|
||||
paramManifest := allParameters.Manifest()
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `%s`", kind, alloydbadmin.SourceKind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID to list instances for.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID to list instances for."),
|
||||
projectParam,
|
||||
tools.NewStringParameterWithDefault("location", "-", "Optional: The location of the cluster (e.g., 'us-central1'). Use '-' to get results for all regions.(Default: '-')"),
|
||||
tools.NewStringParameterWithDefault("cluster", "-", "Optional: The ID of the cluster to list instances from. Use '-' to get results for all clusters.(Default: '-')"),
|
||||
}
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `%s`", kind, alloydbadmin.SourceKind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The GCP project ID.")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The GCP project ID."),
|
||||
projectParam,
|
||||
tools.NewStringParameter("location", "The location of the cluster (e.g., 'us-central1')."),
|
||||
tools.NewStringParameter("cluster", "The ID of the cluster to list users from."),
|
||||
}
|
||||
|
||||
@@ -122,8 +122,17 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `%s`", kind, alloydbadmin.SourceKind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("location", "The location ID"),
|
||||
tools.NewStringParameter("operation", "The operation ID"),
|
||||
}
|
||||
|
||||
@@ -69,8 +69,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("instance", "The ID of the instance where the database will be created."),
|
||||
tools.NewStringParameter("name", "The name for the new database. Must be unique within the instance."),
|
||||
}
|
||||
|
||||
@@ -69,8 +69,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("instance", "The ID of the instance where the user will be created."),
|
||||
tools.NewStringParameter("name", "The name for the new user. Must be unique within the instance."),
|
||||
tools.NewStringParameterWithRequired("password", "A secure password for the new user. Not required for IAM users.", false),
|
||||
|
||||
@@ -69,8 +69,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("projectId", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("projectId", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("projectId", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("instanceId", "The instance ID"),
|
||||
}
|
||||
paramManifest := allParameters.Manifest()
|
||||
|
||||
@@ -68,8 +68,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("instance", "The instance ID"),
|
||||
}
|
||||
paramManifest := allParameters.Manifest()
|
||||
|
||||
@@ -68,8 +68,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
}
|
||||
paramManifest := allParameters.Manifest()
|
||||
|
||||
@@ -83,7 +91,7 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
Name: cfg.Name,
|
||||
Kind: kind,
|
||||
AuthRequired: cfg.AuthRequired,
|
||||
source: s,
|
||||
Source: s,
|
||||
AllParams: allParameters,
|
||||
manifest: tools.Manifest{Description: description, Parameters: paramManifest, AuthRequired: cfg.AuthRequired},
|
||||
mcpManifest: mcpManifest,
|
||||
@@ -98,7 +106,7 @@ type Tool struct {
|
||||
AuthRequired []string `yaml:"authRequired"`
|
||||
|
||||
AllParams tools.Parameters `yaml:"allParams"`
|
||||
source *cloudsqladminsrc.Source
|
||||
Source *cloudsqladminsrc.Source
|
||||
manifest tools.Manifest
|
||||
mcpManifest tools.McpManifest
|
||||
}
|
||||
@@ -112,7 +120,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
|
||||
return nil, fmt.Errorf("missing 'project' parameter")
|
||||
}
|
||||
|
||||
service, err := t.source.GetService(ctx, string(accessToken))
|
||||
service, err := t.Source.GetService(ctx, string(accessToken))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -163,5 +171,5 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool {
|
||||
}
|
||||
|
||||
func (t Tool) RequiresClientAuthorization() bool {
|
||||
return t.source.UseClientAuthorization()
|
||||
return t.Source.UseClientAuthorization()
|
||||
}
|
||||
|
||||
@@ -122,8 +122,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("operation", "The operation ID"),
|
||||
}
|
||||
paramManifest := allParameters.Manifest()
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("name", "The name of the instance"),
|
||||
tools.NewStringParameterWithDefault("databaseVersion", "SQLSERVER_2022_STANDARD", "The database version for SQL Server. If not specified, defaults to SQLSERVER_2022_STANDARD."),
|
||||
tools.NewStringParameter("rootPassword", "The root password for the instance"),
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("name", "The name of the instance"),
|
||||
tools.NewStringParameterWithDefault("databaseVersion", "MYSQL_8_4", "The database version for MySQL. If not specified, defaults to the latest available version (e.g., MYSQL_8_4)."),
|
||||
tools.NewStringParameter("rootPassword", "The root password for the instance"),
|
||||
|
||||
@@ -70,8 +70,16 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)
|
||||
return nil, fmt.Errorf("invalid source for %q tool: source kind must be `cloud-sql-admin`", kind)
|
||||
}
|
||||
|
||||
project := s.DefaultProject
|
||||
var projectParam tools.Parameter
|
||||
if project != "" {
|
||||
projectParam = tools.NewStringParameterWithDefault("project", project, "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.")
|
||||
} else {
|
||||
projectParam = tools.NewStringParameter("project", "The project ID")
|
||||
}
|
||||
|
||||
allParameters := tools.Parameters{
|
||||
tools.NewStringParameter("project", "The project ID"),
|
||||
projectParam,
|
||||
tools.NewStringParameter("name", "The name of the instance"),
|
||||
tools.NewStringParameterWithDefault("databaseVersion", "POSTGRES_17", "The database version for Postgres. If not specified, defaults to the latest available version (e.g., POSTGRES_17)."),
|
||||
tools.NewStringParameter("rootPassword", "The root password for the instance"),
|
||||
|
||||
Reference in New Issue
Block a user