From 57b0cae8ce865fa76cac154dc0264f6ea80e8312 Mon Sep 17 00:00:00 2001 From: "CodeGlide-[bot]" Date: Mon, 11 Aug 2025 23:41:36 +0000 Subject: [PATCH] feat: codeglide Auto-generated MCP server code Triggered by: @vmunjuluru --- swagger-doc/MCP/McpServer/go/README.md | 208 +++++++++++ swagger-doc/MCP/McpServer/go/config/config.go | 48 +++ swagger-doc/MCP/McpServer/go/go.mod | 17 + swagger-doc/MCP/McpServer/go/go.sum | 39 +++ swagger-doc/MCP/McpServer/go/main.go | 145 ++++++++ swagger-doc/MCP/McpServer/go/models/models.go | 330 ++++++++++++++++++ swagger-doc/MCP/McpServer/go/registry.go | 23 ++ ...cts_locations_instances_applyparameters.go | 117 +++++++ ...che_projects_locations_instances_create.go | 137 ++++++++ ...cache_projects_locations_instances_list.go | 113 ++++++ ...ache_projects_locations_instances_patch.go | 137 ++++++++ ...cations_instances_reschedulemaintenance.go | 117 +++++++ ...ts_locations_instances_updateparameters.go | 117 +++++++ .../memcache_projects_locations_list.go | 109 ++++++ ...he_projects_locations_operations_cancel.go | 115 ++++++ ...he_projects_locations_operations_delete.go | 97 +++++ ...cache_projects_locations_operations_get.go | 97 +++++ ...ache_projects_locations_operations_list.go | 109 ++++++ 18 files changed, 2075 insertions(+) create mode 100644 swagger-doc/MCP/McpServer/go/README.md create mode 100644 swagger-doc/MCP/McpServer/go/config/config.go create mode 100644 swagger-doc/MCP/McpServer/go/go.mod create mode 100644 swagger-doc/MCP/McpServer/go/go.sum create mode 100644 swagger-doc/MCP/McpServer/go/main.go create mode 100644 swagger-doc/MCP/McpServer/go/models/models.go create mode 100644 swagger-doc/MCP/McpServer/go/registry.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_applyparameters.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_create.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_list.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_patch.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_reschedulemaintenance.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_updateparameters.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_list.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_cancel.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_delete.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_get.go create mode 100644 swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_list.go diff --git a/swagger-doc/MCP/McpServer/go/README.md b/swagger-doc/MCP/McpServer/go/README.md new file mode 100644 index 0000000..354572f --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/README.md @@ -0,0 +1,208 @@ +# Cloud Memorystore for Memcached API MCP Server + +This MCP (Model Content Protocol) server provides access to Cloud Memorystore for Memcached API API functionality through HTTP, HTTPS, and STDIO transport modes. + +## Features + +- transport mode support (HTTP and STDIO) +- Dynamic configuration through HTTP headers +- Automatic tool generation from API documentation + +## Building the Project + +1. Ensure you have Go 1.24.6 or later installed +2. Clone the repository +3. Build the project: + +```bash +go build -o mcp-server +``` + +## Running the Server + +The server can run in three modes based on the **TRANSPORT** environment variable: + +### HTTP Mode + +To run in HTTP mode, set the transport environment variable to "http" or "HTTP": + +```bash +export TRANSPORT="http" # or "HTTP" or "HTTPS" +export PORT="8181" # required +``` + +Run the server: +```bash +./mcp-server +``` + +#### Required Environment Variables for HTTP Mode: +- `TRANSPORT`: Set to "HTTP" **(Required)** +- `PORT`: Server port **(Required)** + +#### Configuration through HTTP Headers: +In HTTP mode, API configuration is provided via HTTP headers for each request: +- `API_BASE_URL`: **(Required)** Base URL for the API +- `BEARER_TOKEN`: Bearer token for authentication +- `API_KEY`: API key for authentication +- `BASIC_AUTH`: Basic authentication credentials + +Cursor mcp.json settings: + +{ + "mcpServers": { + "your-mcp-server-http": { + "url": "http://:/mcp", + "headers": { + "API_BASE_URL": "https://your-api-base-url", + "BEARER_TOKEN": "your-bearer-token" + } + } + } +} + +The server will start on the configured port with the following endpoints: +- `/mcp`: HTTP endpoint for MCP communication (requires API_BASE_URL header) +- `/`: Health check endpoint + +**Note**: At least one authentication header (BEARER_TOKEN, API_KEY, or BASIC_AUTH) should be provided unless the API explicitly doesn't require authentication. + +### HTTPS Mode + +To run in HTTPS mode, set the transport environment variable to "https" or "HTTPS": + +```bash +export TRANSPORT="https" # or "HTTPS" +export PORT="8443" # required +export CERT_FILE="./certs/cert.pem" # required +export KEY_FILE="./certs/key.pem" # required +``` + +Run the server: +```bash +./mcp-server +``` + +#### Required Environment Variables for HTTPS Mode: +- `TRANSPORT`: Set to "HTTPS" **(Required)** +- `PORT`: Server port **(Required)** +- `CERT_FILE`: Path to SSL certificate file **(Required)** +- `KEY_FILE`: Path to SSL private key file **(Required)** + +#### Configuration through HTTP Headers: +In HTTPS mode, API configuration is provided via HTTP headers for each request: +- `API_BASE_URL`: **(Required)** Base URL for the API +- `BEARER_TOKEN`: Bearer token for authentication +- `API_KEY`: API key for authentication +- `BASIC_AUTH`: Basic authentication credentials + +Cursor mcp.json settings: + +{ + "mcpServers": { + "your-mcp-server-https": { + "url": "https://:/mcp", + "headers": { + "API_BASE_URL": "https://your-api-base-url", + "BEARER_TOKEN": "your-bearer-token" + } + } + } +} + +The server will start on the configured port with the following endpoints: +- `/mcp`: HTTPS endpoint for MCP communication (requires API_BASE_URL header) +- `/`: Health check endpoint + +**Note**: At least one authentication header (BEARER_TOKEN, API_KEY, or BASIC_AUTH) should be provided unless the API explicitly doesn't require authentication. + +``` + +### STDIO Mode + +To run in STDIO mode, either set the transport environment variable to "stdio" or leave it unset (default): + +```bash +export TRANSPORT="stdio" # or leave unset for default +export API_BASE_URL="https://your-api-base-url" +export BEARER_TOKEN="your-bearer-token" +``` + +Run the server: +```bash +./mcp-server +``` + +#### Required Environment Variables for STDIO Mode: +- `TRANSPORT`: Set to "stdio" or leave unset (default) +- `API_BASE_URL`: Base URL for the API **(Required)** +- `BEARER_TOKEN`: Bearer token for authentication +- `API_KEY`: API key for authentication +- `BASIC_AUTH`: Basic authentication credentials + +**Note**: At least one authentication environment variable (BEARER_TOKEN, API_KEY, or BASIC_AUTH) should be provided unless the API explicitly doesn't require authentication. + +Cursor mcp.json settings: + +{ + "mcpServers": { + "your-mcp-server-stdio": { + "command": "/", + "env": { + "API_BASE_URL": "", + "BEARER_TOKEN": "" + } + } + } +} + +## Environment Variable Case Sensitivity + +The server supports both uppercase and lowercase transport environment variables: +- `TRANSPORT` (uppercase) - checked first +- `transport` (lowercase) - fallback if uppercase not set + +Valid values: "http", "HTTP", "https", "HTTPS", "stdio", or unset (defaults to STDIO) + +## Authentication + +### HTTP Mode +Authentication is provided through HTTP headers on each request: +- `BEARER_TOKEN`: Bearer token +- `API_KEY`: API key +- `BASIC_AUTH`: Basic authentication + +### STDIO Mode +Authentication is provided through environment variables: +- `BEARER_TOKEN`: Bearer token +- `API_KEY`: API key +- `BASIC_AUTH`: Basic authentication + +## Health Check + +When running in HTTP mode, you can check server health at the root endpoint (`/`). +Expected response: `{"status":"ok"}` + +## Transport Modes Summary + +### HTTP Mode (TRANSPORT=http or TRANSPORT=HTTP) +- Uses streamable HTTP server +- Configuration provided via HTTP headers for each request +- Requires API_BASE_URL header for each request +- Endpoint: `/mcp` +- Port configured via PORT environment variable (defaults to 8080) + +### HTTPS Mode (TRANSPORT=https or TRANSPORT=HTTPS) +- Uses streamable HTTPS server with SSL/TLS encryption +- Configuration provided via HTTP headers for each request +- Requires API_BASE_URL header for each request +- Endpoint: `/mcp` +- Port configured via PORT environment variable (defaults to 8443) +- **Requires SSL certificate and private key files (CERT_FILE and KEY_FILE)** + +### STDIO Mode (TRANSPORT=stdio or unset) +- Uses standard input/output for communication +- Configuration through environment variables only +- Requires API_BASE_URL environment variable +- Suitable for command-line usage + diff --git a/swagger-doc/MCP/McpServer/go/config/config.go b/swagger-doc/MCP/McpServer/go/config/config.go new file mode 100644 index 0000000..d8fc813 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/config/config.go @@ -0,0 +1,48 @@ +package config + +import ( + "fmt" + "os" +) + +type APIConfig struct { + BaseURL string + BearerToken string // For OAuth2/Bearer authentication + APIKey string // For API key authentication + BasicAuth string // For basic authentication + Port string // For server port configuration +} + +func LoadAPIConfig() (*APIConfig, error) { + // Check port environment variable (both uppercase and lowercase) + port := os.Getenv("PORT") + if port == "" { + port = os.Getenv("port") + } + + baseURL := os.Getenv("API_BASE_URL") + + // Check transport environment variable (both uppercase and lowercase) + transport := os.Getenv("TRANSPORT") + if transport == "" { + transport = os.Getenv("transport") + } + + // For STDIO mode (transport is not "http"/"HTTP"/"https"/"HTTPS"), API_BASE_URL is required from environment + if transport != "http" && transport != "HTTP" && transport != "https" && transport != "HTTPS" && baseURL == "" { + return nil, fmt.Errorf("API_BASE_URL environment variable not set") + } + + // For HTTP/HTTPS mode (transport is "http"/"HTTP"/"https"/"HTTPS"), API_BASE_URL comes from headers + // so we don't require it from environment variables + + return &APIConfig{ + BaseURL: baseURL, + BearerToken: os.Getenv("BEARER_TOKEN"), + APIKey: os.Getenv("API_KEY"), + BasicAuth: os.Getenv("BASIC_AUTH"), + Port: port, + }, nil +} + + diff --git a/swagger-doc/MCP/McpServer/go/go.mod b/swagger-doc/MCP/McpServer/go/go.mod new file mode 100644 index 0000000..511e7a9 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/go.mod @@ -0,0 +1,17 @@ +module github.com/cloud-memorystore-for-memcached-api/mcp-server + +go 1.24.4 + +require github.com/mark3labs/mcp-go v0.37.0 + +require ( + github.com/bahlo/generic-list-go v0.2.0 // indirect + github.com/buger/jsonparser v1.1.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/invopop/jsonschema v0.13.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/spf13/cast v1.7.1 // indirect + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect + github.com/yosida95/uritemplate/v3 v3.0.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/swagger-doc/MCP/McpServer/go/go.sum b/swagger-doc/MCP/McpServer/go/go.sum new file mode 100644 index 0000000..6a2363e --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/go.sum @@ -0,0 +1,39 @@ +github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= +github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= +github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E= +github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mark3labs/mcp-go v0.37.0 h1:BywvZLPRT6Zx6mMG/MJfxLSZQkTGIcJSEGKsvr4DsoQ= +github.com/mark3labs/mcp-go v0.37.0/go.mod h1:T7tUa2jO6MavG+3P25Oy/jR7iCeJPHImCZHRymCn39g= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= +github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= +github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= +github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= +github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/swagger-doc/MCP/McpServer/go/main.go b/swagger-doc/MCP/McpServer/go/main.go new file mode 100644 index 0000000..8e8eeb8 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/main.go @@ -0,0 +1,145 @@ +package main + +import ( + "context" + "log" + "net" + "net/http" + "os" + "os/signal" + "syscall" + "time" + + "github.com/mark3labs/mcp-go/server" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" +) + +func main() { + cfg, err := config.LoadAPIConfig() + if err != nil { + log.Fatalf("Failed to load config: %v", err) + } + + // Check transport environment variable (both uppercase and lowercase) + transport := os.Getenv("TRANSPORT") + if transport == "" { + transport = os.Getenv("transport") + } + sigChan := make(chan os.Signal, 1) + signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) + + // HTTP/HTTPS Mode - if transport is "http", "HTTP", "https", or "HTTPS" + if transport == "http" || transport == "HTTP" || transport == "https" || transport == "HTTPS" { + port := cfg.Port + if port == "" { + log.Fatalf("PORT environment variable is required for HTTP/HTTPS mode. Please set PORT environment variable.") + } + + // Determine if HTTPS mode and normalize transport + isHTTPS := transport == "https" || transport == "HTTPS" + if isHTTPS { + transport = "HTTPS" + } else { + transport = "HTTP" + } + + log.Printf("Running in %s mode on port %s", transport, port) + + mux := http.NewServeMux() + mux.HandleFunc("/mcp", func(w http.ResponseWriter, r *http.Request) { + // Read headers for dynamic config + apiCfg := &config.APIConfig{ + BaseURL: r.Header.Get("API_BASE_URL"), + BearerToken: r.Header.Get("BEARER_TOKEN"), + APIKey: r.Header.Get("API_KEY"), + BasicAuth: r.Header.Get("BASIC_AUTH"), + } + + if apiCfg.BaseURL == "" { + http.Error(w, "Missing API_BASE_URL header", http.StatusBadRequest) + return + } + + log.Printf("Incoming HTTP request - BaseURL: %s", apiCfg.BaseURL) + + // Create MCP server for this request + mcpSrv := createMCPServer(apiCfg, transport) + handler := server.NewStreamableHTTPServer(mcpSrv, server.WithHTTPContextFunc( + func(ctx context.Context, req *http.Request) context.Context { + return context.WithValue(ctx, "apiConfig", apiCfg) + }, + )) + + handler.ServeHTTP(w, r) + }) + + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.Write([]byte(`{"status":"ok"}`)) + }) + + addr := net.JoinHostPort("0.0.0.0", port) + httpServer := &http.Server{Addr: addr, Handler: mux} + + go func() { + // Check if HTTPS mode + if isHTTPS { + certFile := os.Getenv("CERT_FILE") + keyFile := os.Getenv("KEY_FILE") + + if certFile == "" || keyFile == "" { + log.Fatalf("CERT_FILE and KEY_FILE environment variables are required for HTTPS mode") + } + + log.Printf("Starting HTTPS server on %s", addr) + if err := httpServer.ListenAndServeTLS(certFile, keyFile); err != http.ErrServerClosed { + log.Fatalf("HTTPS server error: %v", err) + } + } else { + log.Printf("Starting HTTP server on %s", addr) + if err := httpServer.ListenAndServe(); err != http.ErrServerClosed { + log.Fatalf("HTTP server error: %v", err) + } + } + }() + + <-sigChan + log.Println("Shutdown signal received") + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + if err := httpServer.Shutdown(ctx); err != nil { + log.Printf("Shutdown error: %v", err) + } else { + log.Println("HTTP server shutdown complete") + } + return + } + + // STDIO Mode - default when no transport or transport is "stdio" + log.Println("Running in STDIO mode") + mcp := createMCPServer(cfg, "STDIO") + go func() { + if err := server.ServeStdio(mcp); err != nil { + log.Fatalf("STDIO error: %v", err) + } + }() + <-sigChan + log.Println("Received shutdown signal. Exiting STDIO mode.") +} + +func createMCPServer(cfg *config.APIConfig, mode string) *server.MCPServer { + mcp := server.NewMCPServer("Cloud Memorystore for Memcached API", "v1", + server.WithToolCapabilities(true), + server.WithRecovery(), + ) + + tools := GetAll(cfg) + log.Printf("Loaded %d tools for %s mode", len(tools), mode) + + for _, tool := range tools { + mcp.AddTool(tool.Definition, tool.Handler) + } + + return mcp +} \ No newline at end of file diff --git a/swagger-doc/MCP/McpServer/go/models/models.go b/swagger-doc/MCP/McpServer/go/models/models.go new file mode 100644 index 0000000..413a506 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/models/models.go @@ -0,0 +1,330 @@ +package models + +import ( + "context" + "github.com/mark3labs/mcp-go/mcp" +) + +type Tool struct { + Definition mcp.Tool + Handler func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) +} + +// GoogleCloudSaasacceleratorManagementProvidersV1ProvisionedResource represents the GoogleCloudSaasacceleratorManagementProvidersV1ProvisionedResource schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1ProvisionedResource struct { + Resourcetype string `json:"resourceType,omitempty"` // Type of the resource. This can be either a GCP resource or a custom one (e.g. another cloud provider's VM). For GCP compute resources use singular form of the names listed in GCP compute API documentation (https://cloud.google.com/compute/docs/reference/rest/v1/), prefixed with 'compute-', for example: 'compute-instance', 'compute-disk', 'compute-autoscaler'. + Resourceurl string `json:"resourceUrl,omitempty"` // URL identifying the resource, e.g. "https://www.googleapis.com/compute/v1/projects/...)". +} + +// MemcacheParameters represents the MemcacheParameters schema from the OpenAPI specification +type MemcacheParameters struct { + Id string `json:"id,omitempty"` // Output only. The unique ID associated with this set of parameters. Users can use this id to determine if the parameters associated with the instance differ from the parameters associated with the nodes. A discrepancy between parameter ids can inform users that they may need to take action to apply parameters on nodes. + Params map[string]interface{} `json:"params,omitempty"` // User defined set of parameters to use in the memcached process. +} + +// GoogleCloudSaasacceleratorManagementProvidersV1Instance represents the GoogleCloudSaasacceleratorManagementProvidersV1Instance schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1Instance struct { + Tenantprojectid string `json:"tenantProjectId,omitempty"` // Output only. ID of the associated GCP tenant project. See go/get-instance-metadata. + Updatetime string `json:"updateTime,omitempty"` // Output only. Timestamp when the resource was last modified. + Createtime string `json:"createTime,omitempty"` // Output only. Timestamp when the resource was created. + Maintenanceschedules map[string]interface{} `json:"maintenanceSchedules,omitempty"` // The MaintenanceSchedule contains the scheduling information of published maintenance schedule with same key as software_versions. + Maintenancesettings GoogleCloudSaasacceleratorManagementProvidersV1MaintenanceSettings `json:"maintenanceSettings,omitempty"` // Maintenance settings associated with instance. Allows service producers and end users to assign settings that controls maintenance on this instance. + Labels map[string]interface{} `json:"labels,omitempty"` // Optional. Resource labels to represent user provided metadata. Each label is a key-value pair, where both the key and the value are arbitrary strings provided by the user. + Softwareversions map[string]interface{} `json:"softwareVersions,omitempty"` // Software versions that are used to deploy this instance. This can be mutated by rollout services. + Producermetadata map[string]interface{} `json:"producerMetadata,omitempty"` // Output only. Custom string attributes used primarily to expose producer-specific information in monitoring dashboards. See go/get-instance-metadata. + Slminstancetemplate string `json:"slmInstanceTemplate,omitempty"` // Link to the SLM instance template. Only populated when updating SLM instances via SSA's Actuation service adaptor. Service producers with custom control plane (e.g. Cloud SQL) doesn't need to populate this field. Instead they should use software_versions. + Consumerdefinedname string `json:"consumerDefinedName,omitempty"` // consumer_defined_name is the name of the instance set by the service consumers. Generally this is different from the `name` field which reperesents the system-assigned id of the instance which the service consumers do not recognize. This is a required field for tenants onboarding to Maintenance Window notifications (go/slm-rollout-maintenance-policies#prerequisites). + Instancetype string `json:"instanceType,omitempty"` // Optional. The instance_type of this instance of format: projects/{project_number}/locations/{location_id}/instanceTypes/{instance_type_id}. Instance Type represents a high-level tier or SKU of the service that this instance belong to. When enabled(eg: Maintenance Rollout), Rollout uses 'instance_type' along with 'software_versions' to determine whether instance needs an update or not. + Name string `json:"name,omitempty"` // Unique name of the resource. It uses the form: `projects/{project_number}/locations/{location_id}/instances/{instance_id}` Note: This name is passed, stored and logged across the rollout system. So use of consumer project_id or any other consumer PII in the name is strongly discouraged for wipeout (go/wipeout) compliance. See go/elysium/project_ids#storage-guidance for more details. + Notificationparameters map[string]interface{} `json:"notificationParameters,omitempty"` // Optional. notification_parameter are information that service producers may like to include that is not relevant to Rollout. This parameter will only be passed to Gamma and Cloud Logging for notification/logging purpose. + Slometadata GoogleCloudSaasacceleratorManagementProvidersV1SloMetadata `json:"sloMetadata,omitempty"` // SloMetadata contains resources required for proper SLO classification of the instance. + Maintenancepolicynames map[string]interface{} `json:"maintenancePolicyNames,omitempty"` // Optional. The MaintenancePolicies that have been attached to the instance. The key must be of the type name of the oneof policy name defined in MaintenancePolicy, and the referenced policy must define the same policy type. For details, please refer to go/cloud-saas-mw-ug. Should not be set if maintenance_settings.maintenance_policies is set. + Provisionedresources []GoogleCloudSaasacceleratorManagementProvidersV1ProvisionedResource `json:"provisionedResources,omitempty"` // Output only. The list of data plane resources provisioned for this instance, e.g. compute VMs. See go/get-instance-metadata. + State string `json:"state,omitempty"` // Output only. Current lifecycle state of the resource (e.g. if it's being created or ready to use). +} + +// MaintenancePolicy represents the MaintenancePolicy schema from the OpenAPI specification +type MaintenancePolicy struct { + Labels map[string]interface{} `json:"labels,omitempty"` // Optional. Resource labels to represent user provided metadata. Each label is a key-value pair, where both the key and the value are arbitrary strings provided by the user. + Name string `json:"name,omitempty"` // Required. MaintenancePolicy name using the form: `projects/{project_id}/locations/{location_id}/maintenancePolicies/{maintenance_policy_id}` where {project_id} refers to a GCP consumer project ID, {location_id} refers to a GCP region/zone, {maintenance_policy_id} must be 1-63 characters long and match the regular expression `[a-z0-9]([-a-z0-9]*[a-z0-9])?`. + State string `json:"state,omitempty"` // Optional. The state of the policy. + Updatepolicy UpdatePolicy `json:"updatePolicy,omitempty"` // Maintenance policy applicable to instance updates. + Updatetime string `json:"updateTime,omitempty"` // Output only. The time when the resource was updated. + Createtime string `json:"createTime,omitempty"` // Output only. The time when the resource was created. + Description string `json:"description,omitempty"` // Optional. Description of what this policy is for. Create/Update methods return INVALID_ARGUMENT if the length is greater than 512. +} + +// NodeConfig represents the NodeConfig schema from the OpenAPI specification +type NodeConfig struct { + Cpucount int `json:"cpuCount,omitempty"` // Required. Number of cpus per Memcached node. + Memorysizemb int `json:"memorySizeMb,omitempty"` // Required. Memory size in MiB for each Memcached node. +} + +// Schedule represents the Schedule schema from the OpenAPI specification +type Schedule struct { + Day string `json:"day,omitempty"` // Allows to define schedule that runs specified day of the week. + Duration string `json:"duration,omitempty"` // Output only. Duration of the time window, set by service producer. + Starttime TimeOfDay `json:"startTime,omitempty"` // Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`. +} + +// WeeklyCycle represents the WeeklyCycle schema from the OpenAPI specification +type WeeklyCycle struct { + Schedule []Schedule `json:"schedule,omitempty"` // User can specify multiple windows in a week. Minimum of 1 window. +} + +// ZoneMetadata represents the ZoneMetadata schema from the OpenAPI specification +type ZoneMetadata struct { +} + +// Date represents the Date schema from the OpenAPI specification +type Date struct { + Year int `json:"year,omitempty"` // Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. + Day int `json:"day,omitempty"` // Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant. + Month int `json:"month,omitempty"` // Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. +} + +// WeeklyMaintenanceWindow represents the WeeklyMaintenanceWindow schema from the OpenAPI specification +type WeeklyMaintenanceWindow struct { + Day string `json:"day,omitempty"` // Required. Allows to define schedule that runs specified day of the week. + Duration string `json:"duration,omitempty"` // Required. Duration of the time window. + Starttime TimeOfDay `json:"startTime,omitempty"` // Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`. +} + +// GoogleCloudSaasacceleratorManagementProvidersV1NotificationParameter represents the GoogleCloudSaasacceleratorManagementProvidersV1NotificationParameter schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1NotificationParameter struct { + Values []string `json:"values,omitempty"` // Optional. Array of string values. e.g. instance's replica information. +} + +// DailyCycle represents the DailyCycle schema from the OpenAPI specification +type DailyCycle struct { + Duration string `json:"duration,omitempty"` // Output only. Duration of the time window, set by service producer. + Starttime TimeOfDay `json:"startTime,omitempty"` // Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`. +} + +// Node represents the Node schema from the OpenAPI specification +type Node struct { + Zone string `json:"zone,omitempty"` // Output only. Location (GCP Zone) for the Memcached node. + Host string `json:"host,omitempty"` // Output only. Hostname or IP address of the Memcached node used by the clients to connect to the Memcached server on this node. + Nodeid string `json:"nodeId,omitempty"` // Output only. Identifier of the Memcached node. The node id does not include project or location like the Memcached instance name. + Parameters MemcacheParameters `json:"parameters,omitempty"` + Port int `json:"port,omitempty"` // Output only. The port number of the Memcached server on this node. + State string `json:"state,omitempty"` // Output only. Current state of the Memcached node. +} + +// RescheduleMaintenanceRequest represents the RescheduleMaintenanceRequest schema from the OpenAPI specification +type RescheduleMaintenanceRequest struct { + Scheduletime string `json:"scheduleTime,omitempty"` // Timestamp when the maintenance shall be rescheduled to if reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for example `2012-11-15T16:19:00.094Z`. + Rescheduletype string `json:"rescheduleType,omitempty"` // Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. +} + +// LocationMetadata represents the LocationMetadata schema from the OpenAPI specification +type LocationMetadata struct { + Availablezones map[string]interface{} `json:"availableZones,omitempty"` // Output only. The set of available zones in the location. The map is keyed by the lowercase ID of each zone, as defined by GCE. These keys can be specified in the `zones` field when creating a Memcached instance. +} + +// MaintenanceWindow represents the MaintenanceWindow schema from the OpenAPI specification +type MaintenanceWindow struct { + Dailycycle DailyCycle `json:"dailyCycle,omitempty"` // Time window specified for daily operations. + Weeklycycle WeeklyCycle `json:"weeklyCycle,omitempty"` // Time window specified for weekly operations. +} + +// DenyMaintenancePeriod represents the DenyMaintenancePeriod schema from the OpenAPI specification +type DenyMaintenancePeriod struct { + Startdate Date `json:"startDate,omitempty"` // Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp + Time TimeOfDay `json:"time,omitempty"` // Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`. + Enddate Date `json:"endDate,omitempty"` // Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp +} + +// Instance represents the Instance schema from the OpenAPI specification +type Instance struct { + State string `json:"state,omitempty"` // Output only. The state of this Memcached instance. + Zones []string `json:"zones,omitempty"` // Zones in which Memcached nodes should be provisioned. Memcached nodes will be equally distributed across these zones. If not provided, the service will by default create nodes in all zones in the region for the instance. + Labels map[string]interface{} `json:"labels,omitempty"` // Resource labels to represent user-provided metadata. Refer to cloud documentation on labels for more details. https://cloud.google.com/compute/docs/labeling-resources + Nodeconfig NodeConfig `json:"nodeConfig,omitempty"` // Configuration for a Memcached Node. + Createtime string `json:"createTime,omitempty"` // Output only. The time the instance was created. + Updatetime string `json:"updateTime,omitempty"` // Output only. The time the instance was updated. + Authorizednetwork string `json:"authorizedNetwork,omitempty"` // The full name of the Google Compute Engine [network](/compute/docs/networks-and-firewalls#networks) to which the instance is connected. If left unspecified, the `default` network will be used. + Discoveryendpoint string `json:"discoveryEndpoint,omitempty"` // Output only. Endpoint for the Discovery API. + Maintenanceschedule MaintenanceSchedule `json:"maintenanceSchedule,omitempty"` // Upcoming maintenance schedule. + Memcacheversion string `json:"memcacheVersion,omitempty"` // The major version of Memcached software. If not provided, latest supported version will be used. Currently the latest supported major version is `MEMCACHE_1_5`. The minor version will be automatically determined by our system based on the latest supported minor version. + Instancemessages []InstanceMessage `json:"instanceMessages,omitempty"` // List of messages that describe the current state of the Memcached instance. + Displayname string `json:"displayName,omitempty"` // User provided name for the instance, which is only used for display purposes. Cannot be more than 80 characters. + Memcachenodes []Node `json:"memcacheNodes,omitempty"` // Output only. List of Memcached nodes. Refer to Node message for more details. + Nodecount int `json:"nodeCount,omitempty"` // Required. Number of nodes in the Memcached instance. + Name string `json:"name,omitempty"` // Required. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` Note: Memcached instances are managed and addressed at the regional level so `location_id` here refers to a Google Cloud region; however, users may choose which zones Memcached nodes should be provisioned in within an instance. Refer to zones field for more details. + Maintenancepolicy GoogleCloudMemcacheV1MaintenancePolicy `json:"maintenancePolicy,omitempty"` // Maintenance policy per instance. + Memcachefullversion string `json:"memcacheFullVersion,omitempty"` // Output only. The full version of memcached server running on this instance. System automatically determines the full memcached version for an instance based on the input MemcacheVersion. The full version format will be "memcached-1.5.16". + Parameters MemcacheParameters `json:"parameters,omitempty"` +} + +// Empty represents the Empty schema from the OpenAPI specification +type Empty struct { +} + +// GoogleCloudSaasacceleratorManagementProvidersV1SloMetadata represents the GoogleCloudSaasacceleratorManagementProvidersV1SloMetadata schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1SloMetadata struct { + Nodes []GoogleCloudSaasacceleratorManagementProvidersV1NodeSloMetadata `json:"nodes,omitempty"` // Optional. List of nodes. Some producers need to use per-node metadata to calculate SLO. This field allows such producers to publish per-node SLO meta data, which will be consumed by SSA Eligibility Exporter and published in the form of per node metric to Monarch. + Perslieligibility GoogleCloudSaasacceleratorManagementProvidersV1PerSliSloEligibility `json:"perSliEligibility,omitempty"` // PerSliSloEligibility is a mapping from an SLI name to eligibility. + Tier string `json:"tier,omitempty"` // Name of the SLO tier the Instance belongs to. This name will be expected to match the tiers specified in the service SLO configuration. Field is mandatory and must not be empty. +} + +// ListLocationsResponse represents the ListLocationsResponse schema from the OpenAPI specification +type ListLocationsResponse struct { + Nextpagetoken string `json:"nextPageToken,omitempty"` // The standard List next-page token. + Locations []Location `json:"locations,omitempty"` // A list of locations that matches the specified filter in the request. +} + +// GoogleCloudMemcacheV1MaintenancePolicy represents the GoogleCloudMemcacheV1MaintenancePolicy schema from the OpenAPI specification +type GoogleCloudMemcacheV1MaintenancePolicy struct { + Updatetime string `json:"updateTime,omitempty"` // Output only. The time when the policy was updated. + Weeklymaintenancewindow []WeeklyMaintenanceWindow `json:"weeklyMaintenanceWindow,omitempty"` // Required. Maintenance window that is applied to resources covered by this policy. Minimum 1. For the current version, the maximum number of weekly_maintenance_windows is expected to be one. + Createtime string `json:"createTime,omitempty"` // Output only. The time when the policy was created. + Description string `json:"description,omitempty"` // Description of what this policy is for. Create/Update methods return INVALID_ARGUMENT if the length is greater than 512. +} + +// OperationMetadata represents the OperationMetadata schema from the OpenAPI specification +type OperationMetadata struct { + Createtime string `json:"createTime,omitempty"` // Output only. Time when the operation was created. + Endtime string `json:"endTime,omitempty"` // Output only. Time when the operation finished running. + Statusdetail string `json:"statusDetail,omitempty"` // Output only. Human-readable status of the operation, if any. + Target string `json:"target,omitempty"` // Output only. Server-defined resource path for the target of the operation. + Verb string `json:"verb,omitempty"` // Output only. Name of the verb executed by the operation. + Apiversion string `json:"apiVersion,omitempty"` // Output only. API version used to start the operation. + Cancelrequested bool `json:"cancelRequested,omitempty"` // Output only. Identifies whether the user has requested cancellation of the operation. Operations that have successfully been cancelled have Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`. +} + +// GoogleCloudSaasacceleratorManagementProvidersV1NodeSloMetadata represents the GoogleCloudSaasacceleratorManagementProvidersV1NodeSloMetadata schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1NodeSloMetadata struct { + Location string `json:"location,omitempty"` // The location of the node, if different from instance location. + Nodeid string `json:"nodeId,omitempty"` // The id of the node. This should be equal to SaasInstanceNode.node_id. + Perslieligibility GoogleCloudSaasacceleratorManagementProvidersV1PerSliSloEligibility `json:"perSliEligibility,omitempty"` // PerSliSloEligibility is a mapping from an SLI name to eligibility. +} + +// Status represents the Status schema from the OpenAPI specification +type Status struct { + Details []map[string]interface{} `json:"details,omitempty"` // A list of messages that carry the error details. There is a common set of message types for APIs to use. + Message string `json:"message,omitempty"` // A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. + Code int `json:"code,omitempty"` // The status code, which should be an enum value of google.rpc.Code. +} + +// Operation represents the Operation schema from the OpenAPI specification +type Operation struct { + Done bool `json:"done,omitempty"` // If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. + ErrorField Status `json:"error,omitempty"` // The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). + Metadata map[string]interface{} `json:"metadata,omitempty"` // Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. + Name string `json:"name,omitempty"` // The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. + Response map[string]interface{} `json:"response,omitempty"` // The normal response of the operation in case of success. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. +} + +// UpdateParametersRequest represents the UpdateParametersRequest schema from the OpenAPI specification +type UpdateParametersRequest struct { + Updatemask string `json:"updateMask,omitempty"` // Required. Mask of fields to update. + Parameters MemcacheParameters `json:"parameters,omitempty"` +} + +// TimeOfDay represents the TimeOfDay schema from the OpenAPI specification +type TimeOfDay struct { + Hours int `json:"hours,omitempty"` // Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time. + Minutes int `json:"minutes,omitempty"` // Minutes of hour of day. Must be from 0 to 59. + Nanos int `json:"nanos,omitempty"` // Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999. + Seconds int `json:"seconds,omitempty"` // Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds. +} + +// ListInstancesResponse represents the ListInstancesResponse schema from the OpenAPI specification +type ListInstancesResponse struct { + Instances []Instance `json:"instances,omitempty"` // A list of Memcached instances in the project in the specified location, or across all locations. If the `location_id` in the parent field of the request is "-", all regions available to the project are queried, and the results aggregated. + Nextpagetoken string `json:"nextPageToken,omitempty"` // Token to retrieve the next page of results, or empty if there are no more results in the list. + Unreachable []string `json:"unreachable,omitempty"` // Locations that could not be reached. +} + +// UpdatePolicy represents the UpdatePolicy schema from the OpenAPI specification +type UpdatePolicy struct { + Denymaintenanceperiods []DenyMaintenancePeriod `json:"denyMaintenancePeriods,omitempty"` // Deny Maintenance Period that is applied to resource to indicate when maintenance is forbidden. User can specify zero or more non-overlapping deny periods. Maximum number of deny_maintenance_periods expected is one. + Window MaintenanceWindow `json:"window,omitempty"` // MaintenanceWindow definition. + Channel string `json:"channel,omitempty"` // Optional. Relative scheduling channel applied to resource. +} + +// GoogleCloudSaasacceleratorManagementProvidersV1MaintenanceSchedule represents the GoogleCloudSaasacceleratorManagementProvidersV1MaintenanceSchedule schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1MaintenanceSchedule struct { + Rolloutmanagementpolicy string `json:"rolloutManagementPolicy,omitempty"` // The rollout management policy this maintenance schedule is associated with. When doing reschedule update request, the reschedule should be against this given policy. + Scheduledeadlinetime string `json:"scheduleDeadlineTime,omitempty"` // schedule_deadline_time is the time deadline any schedule start time cannot go beyond, including reschedule. It's normally the initial schedule start time plus maintenance window length (1 day or 1 week). Maintenance cannot be scheduled to start beyond this deadline. + Starttime string `json:"startTime,omitempty"` // The scheduled start time for the maintenance. + Canreschedule bool `json:"canReschedule,omitempty"` // This field is deprecated, and will be always set to true since reschedule can happen multiple times now. This field should not be removed until all service producers remove this for their customers. + Endtime string `json:"endTime,omitempty"` // The scheduled end time for the maintenance. +} + +// MaintenanceSchedule represents the MaintenanceSchedule schema from the OpenAPI specification +type MaintenanceSchedule struct { + Endtime string `json:"endTime,omitempty"` // Output only. The end time of any upcoming scheduled maintenance for this instance. + Scheduledeadlinetime string `json:"scheduleDeadlineTime,omitempty"` // Output only. The deadline that the maintenance schedule start time can not go beyond, including reschedule. + Starttime string `json:"startTime,omitempty"` // Output only. The start time of any upcoming scheduled maintenance for this instance. +} + +// CancelOperationRequest represents the CancelOperationRequest schema from the OpenAPI specification +type CancelOperationRequest struct { +} + +// Location represents the Location schema from the OpenAPI specification +type Location struct { + Displayname string `json:"displayName,omitempty"` // The friendly name for this location, typically a nearby city name. For example, "Tokyo". + Labels map[string]interface{} `json:"labels,omitempty"` // Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"} + Locationid string `json:"locationId,omitempty"` // The canonical id for this location. For example: `"us-east1"`. + Metadata map[string]interface{} `json:"metadata,omitempty"` // Service-specific metadata. For example the available capacity at the given location. + Name string `json:"name,omitempty"` // Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"` +} + +// GoogleCloudSaasacceleratorManagementProvidersV1MaintenanceSettings represents the GoogleCloudSaasacceleratorManagementProvidersV1MaintenanceSettings schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1MaintenanceSettings struct { + Maintenancepolicies map[string]interface{} `json:"maintenancePolicies,omitempty"` // Optional. The MaintenancePolicies that have been attached to the instance. The key must be of the type name of the oneof policy name defined in MaintenancePolicy, and the embedded policy must define the same policy type. For details, please refer to go/cloud-saas-mw-ug. Should not be set if maintenance_policy_names is set. If only the name is needed, then only populate MaintenancePolicy.name. + Exclude bool `json:"exclude,omitempty"` // Optional. Exclude instance from maintenance. When true, rollout service will not attempt maintenance on the instance. Rollout service will include the instance in reported rollout progress as not attempted. + Isrollback bool `json:"isRollback,omitempty"` // Optional. If the update call is triggered from rollback, set the value as true. +} + +// ApplyParametersRequest represents the ApplyParametersRequest schema from the OpenAPI specification +type ApplyParametersRequest struct { + Applyall bool `json:"applyAll,omitempty"` // Whether to apply instance-level parameter group to all nodes. If set to true, users are restricted from specifying individual nodes, and `ApplyParameters` updates all nodes within the instance. + Nodeids []string `json:"nodeIds,omitempty"` // Nodes to which the instance-level parameter group is applied. +} + +// GoogleCloudMemcacheV1ZoneMetadata represents the GoogleCloudMemcacheV1ZoneMetadata schema from the OpenAPI specification +type GoogleCloudMemcacheV1ZoneMetadata struct { +} + +// GoogleCloudMemcacheV1LocationMetadata represents the GoogleCloudMemcacheV1LocationMetadata schema from the OpenAPI specification +type GoogleCloudMemcacheV1LocationMetadata struct { + Availablezones map[string]interface{} `json:"availableZones,omitempty"` // Output only. The set of available zones in the location. The map is keyed by the lowercase ID of each zone, as defined by GCE. These keys can be specified in the `zones` field when creating a Memcached instance. +} + +// GoogleCloudMemcacheV1OperationMetadata represents the GoogleCloudMemcacheV1OperationMetadata schema from the OpenAPI specification +type GoogleCloudMemcacheV1OperationMetadata struct { + Apiversion string `json:"apiVersion,omitempty"` // Output only. API version used to start the operation. + Cancelrequested bool `json:"cancelRequested,omitempty"` // Output only. Identifies whether the user has requested cancellation of the operation. Operations that have successfully been cancelled have Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`. + Createtime string `json:"createTime,omitempty"` // Output only. Time when the operation was created. + Endtime string `json:"endTime,omitempty"` // Output only. Time when the operation finished running. + Statusdetail string `json:"statusDetail,omitempty"` // Output only. Human-readable status of the operation, if any. + Target string `json:"target,omitempty"` // Output only. Server-defined resource path for the target of the operation. + Verb string `json:"verb,omitempty"` // Output only. Name of the verb executed by the operation. +} + +// GoogleCloudSaasacceleratorManagementProvidersV1SloEligibility represents the GoogleCloudSaasacceleratorManagementProvidersV1SloEligibility schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1SloEligibility struct { + Eligible bool `json:"eligible,omitempty"` // Whether an instance is eligible or ineligible. + Reason string `json:"reason,omitempty"` // User-defined reason for the current value of instance eligibility. Usually, this can be directly mapped to the internal state. An empty reason is allowed. +} + +// GoogleCloudSaasacceleratorManagementProvidersV1PerSliSloEligibility represents the GoogleCloudSaasacceleratorManagementProvidersV1PerSliSloEligibility schema from the OpenAPI specification +type GoogleCloudSaasacceleratorManagementProvidersV1PerSliSloEligibility struct { + Eligibilities map[string]interface{} `json:"eligibilities,omitempty"` // An entry in the eligibilities map specifies an eligibility for a particular SLI for the given instance. The SLI key in the name must be a valid SLI name specified in the Eligibility Exporter binary flags otherwise an error will be emitted by Eligibility Exporter and the oncaller will be alerted. If an SLI has been defined in the binary flags but the eligibilities map does not contain it, the corresponding SLI time series will not be emitted by the Eligibility Exporter. This ensures a smooth rollout and compatibility between the data produced by different versions of the Eligibility Exporters. If eligibilities map contains a key for an SLI which has not been declared in the binary flags, there will be an error message emitted in the Eligibility Exporter log and the metric for the SLI in question will not be emitted. +} + +// InstanceMessage represents the InstanceMessage schema from the OpenAPI specification +type InstanceMessage struct { + Code string `json:"code,omitempty"` // A code that correspond to one type of user-facing message. + Message string `json:"message,omitempty"` // Message on memcached instance which will be exposed to users. +} + +// ListOperationsResponse represents the ListOperationsResponse schema from the OpenAPI specification +type ListOperationsResponse struct { + Nextpagetoken string `json:"nextPageToken,omitempty"` // The standard List next-page token. + Operations []Operation `json:"operations,omitempty"` // A list of operations that matches the specified filter in the request. +} diff --git a/swagger-doc/MCP/McpServer/go/registry.go b/swagger-doc/MCP/McpServer/go/registry.go new file mode 100644 index 0000000..62ad208 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/registry.go @@ -0,0 +1,23 @@ +package main + +import ( + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + tools_projects "github.com/cloud-memorystore-for-memcached-api/mcp-server/tools/projects" +) + +func GetAll(cfg *config.APIConfig) []models.Tool { + return []models.Tool{ + tools_projects.CreateMemcache_projects_locations_instances_listTool(cfg), + tools_projects.CreateMemcache_projects_locations_instances_createTool(cfg), + tools_projects.CreateMemcache_projects_locations_instances_reschedulemaintenanceTool(cfg), + tools_projects.CreateMemcache_projects_locations_operations_deleteTool(cfg), + tools_projects.CreateMemcache_projects_locations_operations_getTool(cfg), + tools_projects.CreateMemcache_projects_locations_instances_patchTool(cfg), + tools_projects.CreateMemcache_projects_locations_listTool(cfg), + tools_projects.CreateMemcache_projects_locations_operations_listTool(cfg), + tools_projects.CreateMemcache_projects_locations_instances_applyparametersTool(cfg), + tools_projects.CreateMemcache_projects_locations_operations_cancelTool(cfg), + tools_projects.CreateMemcache_projects_locations_instances_updateparametersTool(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_applyparameters.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_applyparameters.go new file mode 100644 index 0000000..e8017ca --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_applyparameters.go @@ -0,0 +1,117 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "bytes" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_instances_applyparametersHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + nameVal, ok := args["name"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: name"), nil + } + name, ok := nameVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: name"), nil + } + queryParams := make([]string, 0) + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + // Create properly typed request body using the generated schema + var requestBody models.ApplyParametersRequest + + // Optimized: Single marshal/unmarshal with JSON tags handling field mapping + if argsJSON, err := json.Marshal(args); err == nil { + if err := json.Unmarshal(argsJSON, &requestBody); err != nil { + return mcp.NewToolResultError(fmt.Sprintf("Failed to convert arguments to request type: %v", err)), nil + } + } else { + return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil + } + + bodyBytes, err := json.Marshal(requestBody) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to encode request body", err), nil + } + url := fmt.Sprintf("%s/v1/%s:applyParameters%s", cfg.BaseURL, name, queryString) + req, err := http.NewRequest("POST", url, bytes.NewBuffer(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.Operation + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_instances_applyparametersTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("post_v1_name:applyParameters", + mcp.WithDescription("`ApplyParameters` restarts the set of specified nodes in order to update them to the current set of parameters for the Memcached Instance."), + mcp.WithString("name", mcp.Required(), mcp.Description("Required. Resource name of the Memcached instance for which parameter group updates should be applied.")), + mcp.WithBoolean("applyAll", mcp.Description("Input parameter: Whether to apply instance-level parameter group to all nodes. If set to true, users are restricted from specifying individual nodes, and `ApplyParameters` updates all nodes within the instance.")), + mcp.WithArray("nodeIds", mcp.Description("Input parameter: Nodes to which the instance-level parameter group is applied.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_instances_applyparametersHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_create.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_create.go new file mode 100644 index 0000000..877c5c1 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_create.go @@ -0,0 +1,137 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "bytes" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_instances_createHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + parentVal, ok := args["parent"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: parent"), nil + } + parent, ok := parentVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: parent"), nil + } + queryParams := make([]string, 0) + if val, ok := args["instanceId"]; ok { + queryParams = append(queryParams, fmt.Sprintf("instanceId=%v", val)) + } + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + // Create properly typed request body using the generated schema + var requestBody models.Instance + + // Optimized: Single marshal/unmarshal with JSON tags handling field mapping + if argsJSON, err := json.Marshal(args); err == nil { + if err := json.Unmarshal(argsJSON, &requestBody); err != nil { + return mcp.NewToolResultError(fmt.Sprintf("Failed to convert arguments to request type: %v", err)), nil + } + } else { + return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil + } + + bodyBytes, err := json.Marshal(requestBody) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to encode request body", err), nil + } + url := fmt.Sprintf("%s/v1/%s/instances%s", cfg.BaseURL, parent, queryString) + req, err := http.NewRequest("POST", url, bytes.NewBuffer(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.Operation + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_instances_createTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("post_v1_parent_instances", + mcp.WithDescription("Creates a new Instance in a given location."), + mcp.WithString("parent", mcp.Required(), mcp.Description("Required. The resource name of the instance location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region")), + mcp.WithString("instanceId", mcp.Description("Required. The logical name of the Memcached instance in the user project with the following restrictions: * Must contain only lowercase letters, numbers, and hyphens. * Must start with a letter. * Must be between 1-40 characters. * Must end with a number or a letter. * Must be unique within the user project / location. If any of the above are not met, the API raises an invalid argument error.")), + mcp.WithArray("instanceMessages", mcp.Description("Input parameter: List of messages that describe the current state of the Memcached instance.")), + mcp.WithString("displayName", mcp.Description("Input parameter: User provided name for the instance, which is only used for display purposes. Cannot be more than 80 characters.")), + mcp.WithArray("memcacheNodes", mcp.Description("Input parameter: Output only. List of Memcached nodes. Refer to Node message for more details.")), + mcp.WithNumber("nodeCount", mcp.Description("Input parameter: Required. Number of nodes in the Memcached instance.")), + mcp.WithString("name", mcp.Description("Input parameter: Required. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` Note: Memcached instances are managed and addressed at the regional level so `location_id` here refers to a Google Cloud region; however, users may choose which zones Memcached nodes should be provisioned in within an instance. Refer to zones field for more details.")), + mcp.WithObject("maintenancePolicy", mcp.Description("Input parameter: Maintenance policy per instance.")), + mcp.WithString("memcacheFullVersion", mcp.Description("Input parameter: Output only. The full version of memcached server running on this instance. System automatically determines the full memcached version for an instance based on the input MemcacheVersion. The full version format will be \"memcached-1.5.16\".")), + mcp.WithObject("parameters", mcp.Description("")), + mcp.WithString("state", mcp.Description("Input parameter: Output only. The state of this Memcached instance.")), + mcp.WithArray("zones", mcp.Description("Input parameter: Zones in which Memcached nodes should be provisioned. Memcached nodes will be equally distributed across these zones. If not provided, the service will by default create nodes in all zones in the region for the instance.")), + mcp.WithObject("labels", mcp.Description("Input parameter: Resource labels to represent user-provided metadata. Refer to cloud documentation on labels for more details. https://cloud.google.com/compute/docs/labeling-resources")), + mcp.WithObject("nodeConfig", mcp.Description("Input parameter: Configuration for a Memcached Node.")), + mcp.WithString("createTime", mcp.Description("Input parameter: Output only. The time the instance was created.")), + mcp.WithString("updateTime", mcp.Description("Input parameter: Output only. The time the instance was updated.")), + mcp.WithString("authorizedNetwork", mcp.Description("Input parameter: The full name of the Google Compute Engine [network](/compute/docs/networks-and-firewalls#networks) to which the instance is connected. If left unspecified, the `default` network will be used.")), + mcp.WithString("discoveryEndpoint", mcp.Description("Input parameter: Output only. Endpoint for the Discovery API.")), + mcp.WithObject("maintenanceSchedule", mcp.Description("Input parameter: Upcoming maintenance schedule.")), + mcp.WithString("memcacheVersion", mcp.Description("Input parameter: The major version of Memcached software. If not provided, latest supported version will be used. Currently the latest supported major version is `MEMCACHE_1_5`. The minor version will be automatically determined by our system based on the latest supported minor version.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_instances_createHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_list.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_list.go new file mode 100644 index 0000000..d992dec --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_list.go @@ -0,0 +1,113 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_instances_listHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + parentVal, ok := args["parent"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: parent"), nil + } + parent, ok := parentVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: parent"), nil + } + queryParams := make([]string, 0) + if val, ok := args["filter"]; ok { + queryParams = append(queryParams, fmt.Sprintf("filter=%v", val)) + } + if val, ok := args["orderBy"]; ok { + queryParams = append(queryParams, fmt.Sprintf("orderBy=%v", val)) + } + if val, ok := args["pageSize"]; ok { + queryParams = append(queryParams, fmt.Sprintf("pageSize=%v", val)) + } + if val, ok := args["pageToken"]; ok { + queryParams = append(queryParams, fmt.Sprintf("pageToken=%v", val)) + } + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + url := fmt.Sprintf("%s/v1/%s/instances%s", cfg.BaseURL, parent, queryString) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.ListInstancesResponse + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_instances_listTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("get_v1_parent_instances", + mcp.WithDescription("Lists Instances in a given location."), + mcp.WithString("parent", mcp.Required(), mcp.Description("Required. The resource name of the instance location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region")), + mcp.WithString("filter", mcp.Description("List filter. For example, exclude all Memcached instances with name as my-instance by specifying `\"name != my-instance\"`.")), + mcp.WithString("orderBy", mcp.Description("Sort results. Supported values are \"name\", \"name desc\" or \"\" (unsorted).")), + mcp.WithNumber("pageSize", mcp.Description("The maximum number of items to return. If not specified, a default value of 1000 will be used by the service. Regardless of the `page_size` value, the response may include a partial list and a caller should only rely on response's `next_page_token` to determine if there are more instances left to be queried.")), + mcp.WithString("pageToken", mcp.Description("The `next_page_token` value returned from a previous List request, if any.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_instances_listHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_patch.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_patch.go new file mode 100644 index 0000000..91d41e8 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_patch.go @@ -0,0 +1,137 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "bytes" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_instances_patchHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + nameVal, ok := args["name"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: name"), nil + } + name, ok := nameVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: name"), nil + } + queryParams := make([]string, 0) + if val, ok := args["updateMask"]; ok { + queryParams = append(queryParams, fmt.Sprintf("updateMask=%v", val)) + } + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + // Create properly typed request body using the generated schema + var requestBody models.Instance + + // Optimized: Single marshal/unmarshal with JSON tags handling field mapping + if argsJSON, err := json.Marshal(args); err == nil { + if err := json.Unmarshal(argsJSON, &requestBody); err != nil { + return mcp.NewToolResultError(fmt.Sprintf("Failed to convert arguments to request type: %v", err)), nil + } + } else { + return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil + } + + bodyBytes, err := json.Marshal(requestBody) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to encode request body", err), nil + } + url := fmt.Sprintf("%s/v1/%s%s", cfg.BaseURL, name, queryString) + req, err := http.NewRequest("PATCH", url, bytes.NewBuffer(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.Operation + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_instances_patchTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("patch_v1_name", + mcp.WithDescription("Updates an existing Instance in a given project and location."), + mcp.WithString("name", mcp.Required(), mcp.Description("Required. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` Note: Memcached instances are managed and addressed at the regional level so `location_id` here refers to a Google Cloud region; however, users may choose which zones Memcached nodes should be provisioned in within an instance. Refer to zones field for more details.")), + mcp.WithString("updateMask", mcp.Description("Required. Mask of fields to update. * `displayName`")), + mcp.WithString("state", mcp.Description("Input parameter: Output only. The state of this Memcached instance.")), + mcp.WithArray("zones", mcp.Description("Input parameter: Zones in which Memcached nodes should be provisioned. Memcached nodes will be equally distributed across these zones. If not provided, the service will by default create nodes in all zones in the region for the instance.")), + mcp.WithObject("labels", mcp.Description("Input parameter: Resource labels to represent user-provided metadata. Refer to cloud documentation on labels for more details. https://cloud.google.com/compute/docs/labeling-resources")), + mcp.WithObject("nodeConfig", mcp.Description("Input parameter: Configuration for a Memcached Node.")), + mcp.WithString("createTime", mcp.Description("Input parameter: Output only. The time the instance was created.")), + mcp.WithString("updateTime", mcp.Description("Input parameter: Output only. The time the instance was updated.")), + mcp.WithString("authorizedNetwork", mcp.Description("Input parameter: The full name of the Google Compute Engine [network](/compute/docs/networks-and-firewalls#networks) to which the instance is connected. If left unspecified, the `default` network will be used.")), + mcp.WithString("discoveryEndpoint", mcp.Description("Input parameter: Output only. Endpoint for the Discovery API.")), + mcp.WithObject("maintenanceSchedule", mcp.Description("Input parameter: Upcoming maintenance schedule.")), + mcp.WithString("memcacheVersion", mcp.Description("Input parameter: The major version of Memcached software. If not provided, latest supported version will be used. Currently the latest supported major version is `MEMCACHE_1_5`. The minor version will be automatically determined by our system based on the latest supported minor version.")), + mcp.WithArray("instanceMessages", mcp.Description("Input parameter: List of messages that describe the current state of the Memcached instance.")), + mcp.WithString("displayName", mcp.Description("Input parameter: User provided name for the instance, which is only used for display purposes. Cannot be more than 80 characters.")), + mcp.WithArray("memcacheNodes", mcp.Description("Input parameter: Output only. List of Memcached nodes. Refer to Node message for more details.")), + mcp.WithNumber("nodeCount", mcp.Description("Input parameter: Required. Number of nodes in the Memcached instance.")), + mcp.WithString("name", mcp.Description("Input parameter: Required. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` Note: Memcached instances are managed and addressed at the regional level so `location_id` here refers to a Google Cloud region; however, users may choose which zones Memcached nodes should be provisioned in within an instance. Refer to zones field for more details.")), + mcp.WithObject("maintenancePolicy", mcp.Description("Input parameter: Maintenance policy per instance.")), + mcp.WithString("memcacheFullVersion", mcp.Description("Input parameter: Output only. The full version of memcached server running on this instance. System automatically determines the full memcached version for an instance based on the input MemcacheVersion. The full version format will be \"memcached-1.5.16\".")), + mcp.WithObject("parameters", mcp.Description("")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_instances_patchHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_reschedulemaintenance.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_reschedulemaintenance.go new file mode 100644 index 0000000..8bd0ee6 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_reschedulemaintenance.go @@ -0,0 +1,117 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "bytes" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_instances_reschedulemaintenanceHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + instanceVal, ok := args["instance"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: instance"), nil + } + instance, ok := instanceVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: instance"), nil + } + queryParams := make([]string, 0) + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + // Create properly typed request body using the generated schema + var requestBody models.RescheduleMaintenanceRequest + + // Optimized: Single marshal/unmarshal with JSON tags handling field mapping + if argsJSON, err := json.Marshal(args); err == nil { + if err := json.Unmarshal(argsJSON, &requestBody); err != nil { + return mcp.NewToolResultError(fmt.Sprintf("Failed to convert arguments to request type: %v", err)), nil + } + } else { + return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil + } + + bodyBytes, err := json.Marshal(requestBody) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to encode request body", err), nil + } + url := fmt.Sprintf("%s/v1/%s:rescheduleMaintenance%s", cfg.BaseURL, instance, queryString) + req, err := http.NewRequest("POST", url, bytes.NewBuffer(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.Operation + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_instances_reschedulemaintenanceTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("post_v1_instance:rescheduleMaintenance", + mcp.WithDescription("Reschedules upcoming maintenance event."), + mcp.WithString("instance", mcp.Required(), mcp.Description("Required. Memcache instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.")), + mcp.WithString("scheduleTime", mcp.Description("Input parameter: Timestamp when the maintenance shall be rescheduled to if reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for example `2012-11-15T16:19:00.094Z`.")), + mcp.WithString("rescheduleType", mcp.Description("Input parameter: Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_instances_reschedulemaintenanceHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_updateparameters.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_updateparameters.go new file mode 100644 index 0000000..c732faa --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_instances_updateparameters.go @@ -0,0 +1,117 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "bytes" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_instances_updateparametersHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + nameVal, ok := args["name"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: name"), nil + } + name, ok := nameVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: name"), nil + } + queryParams := make([]string, 0) + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + // Create properly typed request body using the generated schema + var requestBody models.UpdateParametersRequest + + // Optimized: Single marshal/unmarshal with JSON tags handling field mapping + if argsJSON, err := json.Marshal(args); err == nil { + if err := json.Unmarshal(argsJSON, &requestBody); err != nil { + return mcp.NewToolResultError(fmt.Sprintf("Failed to convert arguments to request type: %v", err)), nil + } + } else { + return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil + } + + bodyBytes, err := json.Marshal(requestBody) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to encode request body", err), nil + } + url := fmt.Sprintf("%s/v1/%s:updateParameters%s", cfg.BaseURL, name, queryString) + req, err := http.NewRequest("PATCH", url, bytes.NewBuffer(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.Operation + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_instances_updateparametersTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("patch_v1_name:updateParameters", + mcp.WithDescription("Updates the defined Memcached parameters for an existing instance. This method only stages the parameters, it must be followed by `ApplyParameters` to apply the parameters to nodes of the Memcached instance."), + mcp.WithString("name", mcp.Required(), mcp.Description("Required. Resource name of the Memcached instance for which the parameters should be updated.")), + mcp.WithObject("parameters", mcp.Description("")), + mcp.WithString("updateMask", mcp.Description("Input parameter: Required. Mask of fields to update.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_instances_updateparametersHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_list.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_list.go new file mode 100644 index 0000000..07974e4 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_list.go @@ -0,0 +1,109 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_listHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + nameVal, ok := args["name"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: name"), nil + } + name, ok := nameVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: name"), nil + } + queryParams := make([]string, 0) + if val, ok := args["filter"]; ok { + queryParams = append(queryParams, fmt.Sprintf("filter=%v", val)) + } + if val, ok := args["pageSize"]; ok { + queryParams = append(queryParams, fmt.Sprintf("pageSize=%v", val)) + } + if val, ok := args["pageToken"]; ok { + queryParams = append(queryParams, fmt.Sprintf("pageToken=%v", val)) + } + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + url := fmt.Sprintf("%s/v1/%s/locations%s", cfg.BaseURL, name, queryString) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.ListLocationsResponse + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_listTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("get_v1_name_locations", + mcp.WithDescription("Lists information about the supported locations for this service."), + mcp.WithString("name", mcp.Required(), mcp.Description("The resource that owns the locations collection, if applicable.")), + mcp.WithString("filter", mcp.Description("A filter to narrow down results to a preferred subset. The filtering language accepts strings like `\"displayName=tokyo\"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).")), + mcp.WithNumber("pageSize", mcp.Description("The maximum number of results to return. If not set, the service selects a default.")), + mcp.WithString("pageToken", mcp.Description("A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_listHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_cancel.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_cancel.go new file mode 100644 index 0000000..61bc492 --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_cancel.go @@ -0,0 +1,115 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "bytes" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_operations_cancelHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + nameVal, ok := args["name"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: name"), nil + } + name, ok := nameVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: name"), nil + } + queryParams := make([]string, 0) + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + // Create properly typed request body using the generated schema + var requestBody models.CancelOperationRequest + + // Optimized: Single marshal/unmarshal with JSON tags handling field mapping + if argsJSON, err := json.Marshal(args); err == nil { + if err := json.Unmarshal(argsJSON, &requestBody); err != nil { + return mcp.NewToolResultError(fmt.Sprintf("Failed to convert arguments to request type: %v", err)), nil + } + } else { + return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil + } + + bodyBytes, err := json.Marshal(requestBody) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to encode request body", err), nil + } + url := fmt.Sprintf("%s/v1/%s:cancel%s", cfg.BaseURL, name, queryString) + req, err := http.NewRequest("POST", url, bytes.NewBuffer(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.Empty + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_operations_cancelTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("post_v1_name:cancel", + mcp.WithDescription("Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`."), + mcp.WithString("name", mcp.Required(), mcp.Description("The name of the operation resource to be cancelled.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_operations_cancelHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_delete.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_delete.go new file mode 100644 index 0000000..e4a84cc --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_delete.go @@ -0,0 +1,97 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_operations_deleteHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + nameVal, ok := args["name"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: name"), nil + } + name, ok := nameVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: name"), nil + } + queryParams := make([]string, 0) + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + url := fmt.Sprintf("%s/v1/%s%s", cfg.BaseURL, name, queryString) + req, err := http.NewRequest("DELETE", url, nil) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.Empty + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_operations_deleteTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("delete_v1_name", + mcp.WithDescription("Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`."), + mcp.WithString("name", mcp.Required(), mcp.Description("The name of the operation resource to be deleted.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_operations_deleteHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_get.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_get.go new file mode 100644 index 0000000..5e3b78f --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_get.go @@ -0,0 +1,97 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_operations_getHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + nameVal, ok := args["name"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: name"), nil + } + name, ok := nameVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: name"), nil + } + queryParams := make([]string, 0) + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + url := fmt.Sprintf("%s/v1/%s%s", cfg.BaseURL, name, queryString) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.Operation + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_operations_getTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("get_v1_name", + mcp.WithDescription("Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service."), + mcp.WithString("name", mcp.Required(), mcp.Description("The name of the operation resource.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_operations_getHandler(cfg), + } +} diff --git a/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_list.go b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_list.go new file mode 100644 index 0000000..2761bee --- /dev/null +++ b/swagger-doc/MCP/McpServer/go/tools/projects/memcache_projects_locations_operations_list.go @@ -0,0 +1,109 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + + "github.com/cloud-memorystore-for-memcached-api/mcp-server/config" + "github.com/cloud-memorystore-for-memcached-api/mcp-server/models" + "github.com/mark3labs/mcp-go/mcp" +) + +func Memcache_projects_locations_operations_listHandler(cfg *config.APIConfig) func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + args, ok := request.Params.Arguments.(map[string]any) + if !ok { + return mcp.NewToolResultError("Invalid arguments object"), nil + } + nameVal, ok := args["name"] + if !ok { + return mcp.NewToolResultError("Missing required path parameter: name"), nil + } + name, ok := nameVal.(string) + if !ok { + return mcp.NewToolResultError("Invalid path parameter: name"), nil + } + queryParams := make([]string, 0) + if val, ok := args["filter"]; ok { + queryParams = append(queryParams, fmt.Sprintf("filter=%v", val)) + } + if val, ok := args["pageSize"]; ok { + queryParams = append(queryParams, fmt.Sprintf("pageSize=%v", val)) + } + if val, ok := args["pageToken"]; ok { + queryParams = append(queryParams, fmt.Sprintf("pageToken=%v", val)) + } + // Handle multiple authentication parameters + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("access_token=%s", cfg.BearerToken)) + } + if cfg.APIKey != "" { + queryParams = append(queryParams, fmt.Sprintf("key=%s", cfg.APIKey)) + } + if cfg.BearerToken != "" { + queryParams = append(queryParams, fmt.Sprintf("oauth_token=%s", cfg.BearerToken)) + } + queryString := "" + if len(queryParams) > 0 { + queryString = "?" + strings.Join(queryParams, "&") + } + url := fmt.Sprintf("%s/v1/%s/operations%s", cfg.BaseURL, name, queryString) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to create request", err), nil + } + // Set authentication based on auth type + // Handle multiple authentication parameters + // API key already added to query string + // API key already added to query string + // API key already added to query string + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mcp.NewToolResultErrorFromErr("Request failed", err), nil + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to read response body", err), nil + } + + if resp.StatusCode >= 400 { + return mcp.NewToolResultError(fmt.Sprintf("API error: %s", body)), nil + } + // Use properly typed response + var result models.ListOperationsResponse + if err := json.Unmarshal(body, &result); err != nil { + // Fallback to raw text if unmarshaling fails + return mcp.NewToolResultText(string(body)), nil + } + + prettyJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return mcp.NewToolResultErrorFromErr("Failed to format JSON", err), nil + } + + return mcp.NewToolResultText(string(prettyJSON)), nil + } +} + +func CreateMemcache_projects_locations_operations_listTool(cfg *config.APIConfig) models.Tool { + tool := mcp.NewTool("get_v1_name_operations", + mcp.WithDescription("Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`."), + mcp.WithString("name", mcp.Required(), mcp.Description("The name of the operation's parent resource.")), + mcp.WithString("filter", mcp.Description("The standard list filter.")), + mcp.WithNumber("pageSize", mcp.Description("The standard list page size.")), + mcp.WithString("pageToken", mcp.Description("The standard list page token.")), + ) + + return models.Tool{ + Definition: tool, + Handler: Memcache_projects_locations_operations_listHandler(cfg), + } +}