diff --git a/internal/connector/CLAUDE.md b/internal/connector/CLAUDE.md index 8efb995..252b032 100644 --- a/internal/connector/CLAUDE.md +++ b/internal/connector/CLAUDE.md @@ -5,6 +5,7 @@ The `ana connector` verb tree: `list`, `get`, `create`, `update`, `delete`, `tes ## Files - `connector.go` — `New`, `Deps`, service path prefix. +- `types.go` — shared wire shapes consumed by create + update: `createReq`, `updateReq`, `configEnvelope`, `postgresSpec`, `createResp`, `getConnectorResp`. Per-dialect spec types will land alongside (`types_snowflake.go`, etc.) as new dialects are probed. - `list.go` / `get.go` — `GetConnectors` / `GetConnector` (readonly). - `create.go` — `CreateConnector`. Postgres dialect verified; other dialects assumed from captured samples. - `update.go` — `UpdateConnector`. Pre-fetches the baseline so interleaved flags merge correctly (see commit `1433e01`). diff --git a/internal/connector/create.go b/internal/connector/create.go index f5c9bdb..c6cc54d 100644 --- a/internal/connector/create.go +++ b/internal/connector/create.go @@ -17,39 +17,6 @@ func (c *createCmd) Help() string { "Usage: ana connector create --type postgres --name --host --port

--user (--password-stdin|--password

) --database [--ssl]" } -// createReq mirrors the exact wire shape captured in the API catalog. Field -// names are protobuf camelCase; anything else is rejected server-side. -type createReq struct { - Config configEnvelope `json:"config"` -} - -// configEnvelope is also used by update; see update.go. The Postgres pointer -// so we can omit the block when no postgres flags were set (update's partial -// case). -type configEnvelope struct { - ConnectorType string `json:"connectorType,omitempty"` - Name string `json:"name,omitempty"` - Postgres *postgresSpec `json:"postgres,omitempty"` -} - -// postgresSpec matches the oneof leaf for the POSTGRES dialect. Port is an int -// per the catalog; sslMode is a boolean named `sslMode` (not `ssl`). -type postgresSpec struct { - Host string `json:"host,omitempty"` - Port int `json:"port,omitempty"` - User string `json:"user,omitempty"` - Password string `json:"password,omitempty"` - Database string `json:"database,omitempty"` - SSLMode bool `json:"sslMode,omitempty"` -} - -// createResp is the `{connectorId, name, connectorType}` captured response. -type createResp struct { - ConnectorID int `json:"connectorId"` - Name string `json:"name"` - ConnectorType string `json:"connectorType"` -} - func (c *createCmd) Run(ctx context.Context, args []string, stdio cli.IO) error { fs := cli.NewFlagSet("connector create") var typ string diff --git a/internal/connector/types.go b/internal/connector/types.go new file mode 100644 index 0000000..e886286 --- /dev/null +++ b/internal/connector/types.go @@ -0,0 +1,56 @@ +package connector + +// Shared wire types for the Connect-RPC Connector service. Field names follow +// the captured API shapes in `api-catalog/`; anything else is rejected +// server-side. Kept in one file so per-dialect files only need to add their +// own `Spec` struct and point configEnvelope at it. + +// createReq mirrors the exact wire shape captured in the API catalog. +type createReq struct { + Config configEnvelope `json:"config"` +} + +// updateReq's `connectorId` MUST sit at the top level — putting it inside +// config returns 500 "could not find connector" (captured regression). +type updateReq struct { + ConnectorID int `json:"connectorId"` + Config configEnvelope `json:"config"` +} + +// configEnvelope is shared by create + update. The Postgres pointer is a +// pointer (not a value) so update can omit the block when no postgres flags +// were set (partial-update case). +type configEnvelope struct { + ConnectorType string `json:"connectorType,omitempty"` + Name string `json:"name,omitempty"` + Postgres *postgresSpec `json:"postgres,omitempty"` +} + +// postgresSpec matches the oneof leaf for the POSTGRES dialect. Port is an int +// per the catalog; sslMode is a boolean named `sslMode` (not `ssl`). +type postgresSpec struct { + Host string `json:"host,omitempty"` + Port int `json:"port,omitempty"` + User string `json:"user,omitempty"` + Password string `json:"password,omitempty"` + Database string `json:"database,omitempty"` + SSLMode bool `json:"sslMode,omitempty"` +} + +// createResp is the `{connectorId, name, connectorType}` captured response. +type createResp struct { + ConnectorID int `json:"connectorId"` + Name string `json:"name"` + ConnectorType string `json:"connectorType"` +} + +// getConnectorResp narrows the GetConnector response to the fields the update +// flow needs to merge as a baseline. PostgresMetadata carries host/port/user/ +// database/sslMode (no password — the server keeps that secret). +type getConnectorResp struct { + Connector struct { + ConnectorType string `json:"connectorType"` + Name string `json:"name"` + PostgresMetadata postgresSpec `json:"postgresMetadata"` + } `json:"connector"` +} diff --git a/internal/connector/update.go b/internal/connector/update.go index 5749194..f2dfd9d 100644 --- a/internal/connector/update.go +++ b/internal/connector/update.go @@ -19,24 +19,6 @@ func (c *updateCmd) Help() string { "Usage: ana connector update [--type postgres] [--name ...] [--host ...] [--port ...] [--user ...] [--database ...] [--password ...|--password-stdin] [--ssl]" } -// updateReq's `connectorId` MUST sit at the top level — putting it inside -// config returns 500 "could not find connector" (captured regression). -type updateReq struct { - ConnectorID int `json:"connectorId"` - Config configEnvelope `json:"config"` -} - -// getConnectorResp narrows the GetConnector response to the fields the update -// flow needs to merge as a baseline. PostgresMetadata carries host/port/user/ -// database/sslMode (no password — the server keeps that secret). -type getConnectorResp struct { - Connector struct { - ConnectorType string `json:"connectorType"` - Name string `json:"name"` - PostgresMetadata postgresSpec `json:"postgresMetadata"` - } `json:"connector"` -} - func (c *updateCmd) Run(ctx context.Context, args []string, stdio cli.IO) error { fs := cli.NewFlagSet("connector update") typ := fs.String("type", "", "connector type (postgres)")