|
1 | 1 | defmodule Console.GraphQl.Kubernetes do |
2 | 2 | use Console.GraphQl.Schema.Base |
3 | 3 | alias Console.GraphQl.Resolvers.Kubernetes |
4 | | - alias Console.Middleware.{Authenticated, AdminRequired, Rbac} |
| 4 | + alias Console.GraphQl.Resolvers.VPN |
| 5 | + alias Console.Middleware.{Authenticated, AdminRequired, Rbac, Feature} |
5 | 6 |
|
6 | 7 | object :metadata do |
7 | 8 | field :labels, list_of(:label_pair), resolve: fn %{labels: labels}, _, _ -> {:ok, make_labels(labels)} end |
@@ -63,6 +64,7 @@ defmodule Console.GraphQl.Kubernetes do |
63 | 64 | import_types Console.GraphQl.Kubernetes.ConfigurationOverlay |
64 | 65 | import_types Console.GraphQl.Kubernetes.VerticalPodAutoscaler |
65 | 66 | import_types Console.GraphQl.Kubernetes.Namespace |
| 67 | + import_types Console.GraphQl.Kubernetes.VPN |
66 | 68 |
|
67 | 69 | delta :application |
68 | 70 |
|
@@ -164,6 +166,26 @@ defmodule Console.GraphQl.Kubernetes do |
164 | 166 | safe_resolve &Kubernetes.list_all_pods/2 |
165 | 167 | end |
166 | 168 |
|
| 169 | + field :wireguard_peers, list_of(:wireguard_peer) do |
| 170 | + middleware Authenticated |
| 171 | + middleware AdminRequired |
| 172 | + |
| 173 | + safe_resolve &VPN.list_peers/2 |
| 174 | + end |
| 175 | + |
| 176 | + field :my_wireguard_peers, list_of(:wireguard_peer) do |
| 177 | + middleware Authenticated |
| 178 | + |
| 179 | + safe_resolve &VPN.list_my_peers/2 |
| 180 | + end |
| 181 | + |
| 182 | + field :wireguard_peer, :wireguard_peer do |
| 183 | + middleware Authenticated |
| 184 | + arg :name, non_null(:string) |
| 185 | + |
| 186 | + safe_resolve &VPN.get_peer/2 |
| 187 | + end |
| 188 | + |
167 | 189 | field :cached_pods, list_of(:pod) do |
168 | 190 | middleware Authenticated |
169 | 191 | arg :namespaces, list_of(:string) |
@@ -241,6 +263,26 @@ defmodule Console.GraphQl.Kubernetes do |
241 | 263 |
|
242 | 264 | safe_resolve &Kubernetes.execute_overlay/2 |
243 | 265 | end |
| 266 | + |
| 267 | + field :create_peer, :wireguard_peer do |
| 268 | + middleware Authenticated |
| 269 | + middleware AdminRequired |
| 270 | + middleware Feature, :vpn |
| 271 | + arg :user_id, :id |
| 272 | + arg :email, :string |
| 273 | + arg :name, non_null(:string) |
| 274 | + |
| 275 | + safe_resolve &VPN.create_peer/2 |
| 276 | + end |
| 277 | + |
| 278 | + field :delete_peer, :wireguard_peer do |
| 279 | + middleware Authenticated |
| 280 | + middleware AdminRequired |
| 281 | + middleware Feature, :vpn |
| 282 | + arg :name, non_null(:string) |
| 283 | + |
| 284 | + safe_resolve &VPN.delete_peer/2 |
| 285 | + end |
244 | 286 | end |
245 | 287 |
|
246 | 288 | object :kubernetes_subscriptions do |
|
0 commit comments