@@ -26,6 +26,9 @@ type AppConfig struct {
2626
2727// AppConnection is the OAuth connection status.
2828type AppConnection struct {
29+ ID string `json:"id"`
30+ Provider string `json:"provider"`
31+ Label string `json:"label,omitempty"`
2932 Status string `json:"status"`
3033 Scopes []string `json:"scopes"`
3134 ConnectedAt string `json:"connectedAt"`
@@ -55,6 +58,36 @@ func (c *Client) GetApp(ctx context.Context, provider string) (*App, error) {
5558 return & app , nil
5659}
5760
61+ // ListConnections returns all app connections for the current project.
62+ func (c * Client ) ListConnections (ctx context.Context ) ([]AppConnection , error ) {
63+ var resp struct {
64+ Connections []AppConnection `json:"connections"`
65+ }
66+ if err := c .do (ctx , http .MethodGet , "/v1/apps/connections" , nil , & resp ); err != nil {
67+ return nil , fmt .Errorf ("listing connections: %w" , err )
68+ }
69+ return resp .Connections , nil
70+ }
71+
72+ // ListConnectionsByProvider returns app connections for a specific provider.
73+ func (c * Client ) ListConnectionsByProvider (ctx context.Context , provider string ) ([]AppConnection , error ) {
74+ var resp struct {
75+ Connections []AppConnection `json:"connections"`
76+ }
77+ if err := c .do (ctx , http .MethodGet , "/v1/apps/connections/" + provider , nil , & resp ); err != nil {
78+ return nil , fmt .Errorf ("listing connections for %s: %w" , provider , err )
79+ }
80+ return resp .Connections , nil
81+ }
82+
83+ // DisconnectApp removes an app connection by ID.
84+ func (c * Client ) DisconnectApp (ctx context.Context , connectionID string ) error {
85+ if err := c .do (ctx , http .MethodDelete , "/v1/apps/connections/" + connectionID , nil , nil ); err != nil {
86+ return fmt .Errorf ("disconnecting app: %w" , err )
87+ }
88+ return nil
89+ }
90+
5891// ConfigureApp saves BYOC credentials for a provider.
5992func (c * Client ) ConfigureApp (ctx context.Context , provider string , input ConfigAppInput ) error {
6093 var resp SuccessResponse
@@ -71,11 +104,3 @@ func (c *Client) UnconfigureApp(ctx context.Context, provider string) error {
71104 }
72105 return nil
73106}
74-
75- // DisconnectApp removes the OAuth connection for a provider.
76- func (c * Client ) DisconnectApp (ctx context.Context , provider string ) error {
77- if err := c .do (ctx , http .MethodDelete , "/v1/apps/" + provider + "/connection" , nil , nil ); err != nil {
78- return fmt .Errorf ("disconnecting app: %w" , err )
79- }
80- return nil
81- }
0 commit comments