forked from gravitational/teleport
/
presence.go
236 lines (173 loc) · 9.49 KB
/
presence.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
Copyright 2021 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package services
import (
"context"
"github.com/zmb3/teleport/api/client/proto"
"github.com/zmb3/teleport/api/types"
)
// ProxyGetter is a service that gets proxies.
type ProxyGetter interface {
// GetProxies returns a list of registered proxies.
GetProxies() ([]types.Server, error)
}
// NodesGetter is a service that gets nodes.
type NodesGetter interface {
// GetNodes returns a list of registered servers.
GetNodes(ctx context.Context, namespace string) ([]types.Server, error)
}
// Presence records and reports the presence of all components
// of the cluster - Nodes, Proxies and SSH nodes
type Presence interface {
// Semaphores is responsible for semaphore handling
types.Semaphores
// GetNode returns a node by name and namespace.
GetNode(ctx context.Context, namespace, name string) (types.Server, error)
// NodesGetter gets nodes
NodesGetter
// DeleteAllNodes deletes all nodes in a namespace.
DeleteAllNodes(ctx context.Context, namespace string) error
// DeleteNode deletes node in a namespace
DeleteNode(ctx context.Context, namespace, name string) error
// UpsertNode registers node presence, permanently if TTL is 0 or for the
// specified duration with second resolution if it's >= 1 second.
UpsertNode(ctx context.Context, server types.Server) (*types.KeepAlive, error)
// DELETE IN: 5.1.0
//
// This logic has been moved to KeepAliveServer.
//
// KeepAliveNode updates node TTL in the storage
KeepAliveNode(ctx context.Context, h types.KeepAlive) error
// GetAuthServers returns a list of registered servers
GetAuthServers() ([]types.Server, error)
// UpsertAuthServer registers auth server presence, permanently if ttl is 0 or
// for the specified duration with second resolution if it's >= 1 second
UpsertAuthServer(server types.Server) error
// DeleteAuthServer deletes auth server by name
DeleteAuthServer(name string) error
// DeleteAllAuthServers deletes all auth servers
DeleteAllAuthServers() error
// UpsertProxy registers proxy server presence, permanently if ttl is 0 or
// for the specified duration with second resolution if it's >= 1 second
UpsertProxy(server types.Server) error
// ProxyGetter gets a list of proxies
ProxyGetter
// DeleteProxy deletes proxy by name
DeleteProxy(name string) error
// DeleteAllProxies deletes all proxies
DeleteAllProxies() error
// UpsertReverseTunnel upserts reverse tunnel entry temporarily or permanently
UpsertReverseTunnel(tunnel types.ReverseTunnel) error
// GetReverseTunnel returns reverse tunnel by name
GetReverseTunnel(name string, opts ...MarshalOption) (types.ReverseTunnel, error)
// GetReverseTunnels returns a list of registered servers
GetReverseTunnels(ctx context.Context, opts ...MarshalOption) ([]types.ReverseTunnel, error)
// DeleteReverseTunnel deletes reverse tunnel by it's domain name
DeleteReverseTunnel(domainName string) error
// DeleteAllReverseTunnels deletes all reverse tunnels
DeleteAllReverseTunnels() error
// GetNamespaces returns a list of namespaces
GetNamespaces() ([]types.Namespace, error)
// GetNamespace returns namespace by name
GetNamespace(name string) (*types.Namespace, error)
// DeleteAllNamespaces deletes all namespaces
DeleteAllNamespaces() error
// UpsertNamespace upserts namespace
UpsertNamespace(types.Namespace) error
// DeleteNamespace deletes namespace by name
DeleteNamespace(name string) error
// UpsertTrustedCluster creates or updates a TrustedCluster in the backend.
UpsertTrustedCluster(ctx context.Context, tc types.TrustedCluster) (types.TrustedCluster, error)
// GetTrustedCluster returns a single TrustedCluster by name.
GetTrustedCluster(ctx context.Context, name string) (types.TrustedCluster, error)
// GetTrustedClusters returns all TrustedClusters in the backend.
GetTrustedClusters(ctx context.Context) ([]types.TrustedCluster, error)
// DeleteTrustedCluster removes a TrustedCluster from the backend by name.
DeleteTrustedCluster(ctx context.Context, name string) error
// UpsertTunnelConnection upserts tunnel connection
UpsertTunnelConnection(types.TunnelConnection) error
// GetTunnelConnections returns tunnel connections for a given cluster
GetTunnelConnections(clusterName string, opts ...MarshalOption) ([]types.TunnelConnection, error)
// GetAllTunnelConnections returns all tunnel connections
GetAllTunnelConnections(opts ...MarshalOption) ([]types.TunnelConnection, error)
// DeleteTunnelConnection deletes tunnel connection by name
DeleteTunnelConnection(clusterName string, connName string) error
// DeleteTunnelConnections deletes all tunnel connections for cluster
DeleteTunnelConnections(clusterName string) error
// DeleteAllTunnelConnections deletes all tunnel connections for cluster
DeleteAllTunnelConnections() error
// CreateRemoteCluster creates a remote cluster
CreateRemoteCluster(types.RemoteCluster) error
// UpdateRemoteCluster updates a remote cluster
UpdateRemoteCluster(ctx context.Context, rc types.RemoteCluster) error
// GetRemoteClusters returns a list of remote clusters
GetRemoteClusters(opts ...MarshalOption) ([]types.RemoteCluster, error)
// GetRemoteCluster returns a remote cluster by name
GetRemoteCluster(clusterName string) (types.RemoteCluster, error)
// DeleteRemoteCluster deletes remote cluster by name
DeleteRemoteCluster(clusterName string) error
// DeleteAllRemoteClusters deletes all remote clusters
DeleteAllRemoteClusters() error
// UpsertKubeService registers kubernetes service presence.
// DELETE in 11.0. Deprecated, use UpsertKubeServiceV2
UpsertKubeService(context.Context, types.Server) error
// UpsertKubeServiceV2 registers kubernetes service presence
UpsertKubeServiceV2(context.Context, types.Server) (*types.KeepAlive, error)
// GetApplicationServers returns all registered application servers.
GetApplicationServers(context.Context, string) ([]types.AppServer, error)
// UpsertApplicationServer registers an application server.
UpsertApplicationServer(context.Context, types.AppServer) (*types.KeepAlive, error)
// DeleteApplicationServer deletes specified application server.
DeleteApplicationServer(ctx context.Context, namespace, hostID, name string) error
// DeleteAllApplicationServers removes all registered application servers.
DeleteAllApplicationServers(context.Context, string) error
// GetDatabaseServers returns all registered database proxy servers.
GetDatabaseServers(context.Context, string, ...MarshalOption) ([]types.DatabaseServer, error)
// UpsertDatabaseServer creates or updates a new database proxy server.
UpsertDatabaseServer(context.Context, types.DatabaseServer) (*types.KeepAlive, error)
// DeleteDatabaseServer removes the specified database proxy server.
DeleteDatabaseServer(ctx context.Context, namespace, hostID, name string) error
// DeleteAllDatabaseServers removes all database proxy servers.
DeleteAllDatabaseServers(context.Context, string) error
// KeepAliveServer updates TTL of the server resource in the backend.
KeepAliveServer(ctx context.Context, h types.KeepAlive) error
// GetKubeServices returns a list of registered kubernetes services.
// DELETE IN 13.0. Deprecated, use GetKubernetesServers.
GetKubeServices(context.Context) ([]types.Server, error)
// DeleteKubeService deletes a named kubernetes service.
// DELETE IN 13.0. Deprecated, use DeleteKubernetesServer.
DeleteKubeService(ctx context.Context, name string) error
// DeleteAllKubeServices deletes all registered kubernetes services.
// DELETE IN 13.0. Deprecated, use DeleteAllKubernetesServers.
DeleteAllKubeServices(context.Context) error
// GetKubernetesServers returns a list of registered kubernetes servers.
GetKubernetesServers(context.Context) ([]types.KubeServer, error)
// DeleteKubernetesServer deletes a named kubernetes servers.
DeleteKubernetesServer(ctx context.Context, hostID, name string) error
// DeleteAllKubernetesServers deletes all registered kubernetes servers.
DeleteAllKubernetesServers(context.Context) error
// UpsertKubernetesServer registers an kubernetes server.
UpsertKubernetesServer(context.Context, types.KubeServer) (*types.KeepAlive, error)
// GetWindowsDesktopServices returns all registered Windows desktop services.
GetWindowsDesktopServices(context.Context) ([]types.WindowsDesktopService, error)
// GetWindowsDesktopService returns a Windows desktop service by name
GetWindowsDesktopService(ctx context.Context, name string) (types.WindowsDesktopService, error)
// UpsertWindowsDesktopService creates or updates a new Windows desktop service.
UpsertWindowsDesktopService(context.Context, types.WindowsDesktopService) (*types.KeepAlive, error)
// DeleteWindowsDesktopService removes the specified Windows desktop service.
DeleteWindowsDesktopService(ctx context.Context, name string) error
// DeleteAllWindowsDesktopServices removes all Windows desktop services.
DeleteAllWindowsDesktopServices(context.Context) error
// ListResoures returns a paginated list of resources.
ListResources(ctx context.Context, req proto.ListResourcesRequest) (*types.ListResourcesResponse, error)
}