66 "net/http"
77
88 "github.com/bastionzero/bastionzero-sdk-go/bastionzero/service/policies"
9+ "github.com/bastionzero/bastionzero-sdk-go/bastionzero/service/targets/dbauthconfig"
910 "github.com/bastionzero/bastionzero-sdk-go/bastionzero/types/targettype"
1011 "github.com/bastionzero/bastionzero-sdk-go/internal/client"
1112)
@@ -17,16 +18,26 @@ const (
1718
1819// CreateDatabaseTargetRequest is used to create a new Database target
1920type CreateDatabaseTargetRequest struct {
20- TargetName string `json:"targetName"`
21- ProxyTargetID string `json:"proxyTargetId"`
22- RemoteHost string `json:"remoteHost"`
23- RemotePort Port `json:"remotePort"`
24- LocalPort * Port `json:"localPort,omitempty"`
25- LocalHost string `json:"localHost,omitempty"`
26- IsSplitCert bool `json:"splitCert,omitempty"`
27- DatabaseType string `json:"databaseType,omitempty"`
28- EnvironmentID string `json:"environmentId,omitempty"`
29- EnvironmentName string `json:"environmentName,omitempty"`
21+ TargetName string `json:"targetName"`
22+ ProxyTargetID string `json:"proxyTargetId"`
23+ RemoteHost string `json:"remoteHost"`
24+ // TODO: To match REST API, change to: RemotePort *Port `json:"remotePort,omitempty"`
25+ // and update the comment below in a batched breaking changes release
26+
27+ // RemotePort is required for all databases; however, for GCP-hosted databases, the
28+ // value specified for Port.Value will be ignored when connecting to the database.
29+ RemotePort Port `json:"remotePort"`
30+ LocalPort * Port `json:"localPort,omitempty"`
31+ LocalHost string `json:"localHost,omitempty"`
32+ // Deprecated: IsSplitCert exists for historical compatibility and should not be used.
33+ // Set AuthenticationType in DatabaseAuthenticationConfig appropriately instead.
34+ IsSplitCert bool `json:"splitCert,omitempty"`
35+ // Deprecated: DatabaseType exists for historical compatibility and should not be used.
36+ // Set Database in DatabaseAuthenticationConfig appropriately instead.
37+ DatabaseType string `json:"databaseType,omitempty"`
38+ EnvironmentID string `json:"environmentId,omitempty"`
39+ EnvironmentName string `json:"environmentName,omitempty"`
40+ DatabaseAuthenticationConfig * dbauthconfig.DatabaseAuthenticationConfig `json:"databaseAuthenticationConfig,omitempty"`
3041}
3142
3243// CreateDatabaseTargetResponse is the response returned if a Database target is
@@ -43,9 +54,14 @@ type ModifyDatabaseTargetRequest struct {
4354 RemotePort * Port `json:"remotePort,omitempty"`
4455 LocalPort * Port `json:"localPort,omitempty"`
4556 LocalHost * string `json:"localHost,omitempty"`
46- IsSplitCert * bool `json:"splitCert,omitempty"`
47- DatabaseType * string `json:"databaseType,omitempty"`
48- EnvironmentID * string `json:"environmentId,omitempty"`
57+ // Deprecated: IsSplitCert exists for historical compatibility and should not be used.
58+ // Set AuthenticationType in DatabaseAuthenticationConfig appropriately instead.
59+ IsSplitCert * bool `json:"splitCert,omitempty"`
60+ // Deprecated: DatabaseType exists for historical compatibility and should not be used.
61+ // Set Database in DatabaseAuthenticationConfig appropriately instead.
62+ DatabaseType * string `json:"databaseType,omitempty"`
63+ EnvironmentID * string `json:"environmentId,omitempty"`
64+ DatabaseAuthenticationConfig * dbauthconfig.DatabaseAuthenticationConfig `json:"databaseAuthenticationConfig,omitempty"`
4965}
5066
5167// ListDatabaseTargetsOptions specifies the optional parameters when querying
@@ -81,9 +97,14 @@ type ListSplitCertDatabaseTypesResponse struct {
8197type DatabaseTarget struct {
8298 VirtualTarget
8399
84- IsSplitCert bool `json:"splitCert"`
85- DatabaseType * string `json:"databaseType"`
86- AllowedTargetUsers []policies.TargetUser `json:"allowedTargetUsers"`
100+ // Deprecated: IsSplitCert exists for historical compatibility and should not be used.
101+ // Set AuthenticationType in DatabaseAuthenticationConfig appropriately instead.
102+ IsSplitCert bool `json:"splitCert"`
103+ // Deprecated: DatabaseType exists for historical compatibility and should not be used.
104+ // Set Database in DatabaseAuthenticationConfig appropriately instead.
105+ DatabaseType * string `json:"databaseType"`
106+ AllowedTargetUsers []policies.TargetUser `json:"allowedTargetUsers"`
107+ DatabaseAuthenticationConfig dbauthconfig.DatabaseAuthenticationConfig `json:"databaseAuthenticationConfig"`
87108}
88109
89110// ListDatabaseTargets lists all Database targets.
@@ -215,6 +236,7 @@ func (s *TargetsService) ModifyDatabaseTarget(ctx context.Context, targetID stri
215236// ListSplitCertDatabaseTypes lists all Database types for which SplitCert
216237// access is supported.
217238//
239+ // Deprecated: Use ListDatabaseAuthenticationConfigs
218240// BastionZero API docs: https://cloud.bastionzero.com/api/#get-/api/v2/targets/database/supported-databases
219241func (s * TargetsService ) ListSplitCertDatabaseTypes (ctx context.Context ) (* ListSplitCertDatabaseTypesResponse , * http.Response , error ) {
220242 u := databaseBasePath + "/supported-databases"
@@ -232,6 +254,25 @@ func (s *TargetsService) ListSplitCertDatabaseTypes(ctx context.Context) (*ListS
232254 return listResp , resp , nil
233255}
234256
257+ // ListDatabaseAuthenticationConfigs lists all database authentication configurations supported by BasionZero.
258+ //
259+ // BastionZero API docs: https://cloud.bastionzero.com/api/#get-/api/v2/targets/database/supported-database-configs
260+ func (s * TargetsService ) ListDatabaseAuthenticationConfigs (ctx context.Context ) ([]dbauthconfig.DatabaseAuthenticationConfig , * http.Response , error ) {
261+ u := databaseBasePath + "/supported-database-configs"
262+ req , err := s .Client .NewRequest (ctx , http .MethodGet , u , nil )
263+ if err != nil {
264+ return nil , nil , err
265+ }
266+
267+ dbAuthConfigList := new ([]dbauthconfig.DatabaseAuthenticationConfig )
268+ resp , err := s .Client .Do (req , dbAuthConfigList )
269+ if err != nil {
270+ return nil , resp , err
271+ }
272+
273+ return * dbAuthConfigList , resp , nil
274+ }
275+
235276// Ensure DatabaseTarget implementation satisfies the expected interfaces.
236277var (
237278 // DatabaseTarget implements VirtualTargetInterface
0 commit comments