From 2c4b4deb95335a6ca43fe2e9aa8235ca973db260 Mon Sep 17 00:00:00 2001 From: "STeve (Xin) Huang" Date: Thu, 13 Jul 2023 11:48:19 -0400 Subject: [PATCH] Clarify API GetDatabases vs GetDatabaseServers (#29026) * Clarify client.GetDatabases vs client.GetDatabaseServers * address typos --- api/client/client.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/api/client/client.go b/api/client/client.go index e1dcc90e3ed..d7fee52f58c 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -1454,6 +1454,10 @@ func (c *Client) GenerateSnowflakeJWT(ctx context.Context, req types.GenerateSno } // GetDatabaseServers returns all registered database proxy servers. +// +// Note that in HA setups, a registered database may have multiple +// DatabaseServer entries. Web UI and `tsh db ls` extract databases from this +// list and remove duplicates by name. func (c *Client) GetDatabaseServers(ctx context.Context, namespace string) ([]types.DatabaseServer, error) { servers, err := GetAllResources[types.DatabaseServer](ctx, c, &proto.ListResourcesRequest{ Namespace: namespace, @@ -2631,6 +2635,14 @@ func (c *Client) UpdateApp(ctx context.Context, app types.Application) error { } // GetApp returns the specified application resource. +// +// Note that application resources here refers to "dynamically-added" +// applications such as applications created by `tctl create`, or the CreateApp +// API. Applications defined in the `app_service.apps` section of the service +// YAML configuration are not collected in this API. +// +// For a full list of registered applications that are served by an application +// service, use GetApplicationServers instead. func (c *Client) GetApp(ctx context.Context, name string) (types.Application, error) { if name == "" { return nil, trace.BadParameter("missing application name") @@ -2643,6 +2655,14 @@ func (c *Client) GetApp(ctx context.Context, name string) (types.Application, er } // GetApps returns all application resources. +// +// Note that application resources here refers to "dynamically-added" +// applications such as applications created by `tctl create`, or the CreateApp +// API. Applications defined in the `app_service.apps` section of the service +// YAML configuration are not collected in this API. +// +// For a full list of registered applications that are served by an application +// service, use GetApplicationServers instead. func (c *Client) GetApps(ctx context.Context) ([]types.Application, error) { items, err := c.grpc.GetApps(ctx, &emptypb.Empty{}) if err != nil { @@ -2745,6 +2765,16 @@ func (c *Client) UpdateDatabase(ctx context.Context, database types.Database) er } // GetDatabase returns the specified database resource. +// +// Note that database resources here refers to "dynamically-added" databases +// such as databases created by `tctl create`, the discovery service, or the +// CreateDatabase API. Databases discovered by the database agent (legacy +// discovery flow using `database_service.aws/database_service.azure`) and +// static databases defined in the `database_service.databases` section of the +// service YAML configuration are not collected in this API. +// +// For a full list of registered databases that are served by a database +// service, use GetDatabaseServers instead. func (c *Client) GetDatabase(ctx context.Context, name string) (types.Database, error) { if name == "" { return nil, trace.BadParameter("missing database name") @@ -2757,6 +2787,16 @@ func (c *Client) GetDatabase(ctx context.Context, name string) (types.Database, } // GetDatabases returns all database resources. +// +// Note that database resources here refers to "dynamically-added" databases +// such as databases created by `tctl create`, the discovery service, or the +// CreateDatabase API. Databases discovered by the database agent (legacy +// discovery flow using `database_service.aws/database_service.azure`) and +// static databases defined in the `database_service.databases` section of the +// service YAML configuration are not collected in this API. +// +// For a full list of registered databases that are served by a database +// service, use GetDatabaseServers instead. func (c *Client) GetDatabases(ctx context.Context) ([]types.Database, error) { items, err := c.grpc.GetDatabases(ctx, &emptypb.Empty{}) if err != nil {