@@ -176,10 +176,66 @@ class Meta:
176
176
)
177
177
178
178
179
+ class ProviderType (graphene .ObjectType ):
180
+ id = graphene .String (required = True )
181
+ name = graphene .String (required = True )
182
+ expected_credentials = graphene .List (
183
+ graphene .NonNull (graphene .String ), required = True
184
+ )
185
+ optional_credentials = graphene .List (
186
+ graphene .NonNull (graphene .String ), required = True
187
+ )
188
+ auth_scheme = graphene .String ()
189
+
190
+
191
+ class ServiceType (ObjectType ):
192
+ id = graphene .String ()
193
+ name = graphene .String ()
194
+ resource_type = graphene .String ()
195
+ provider = graphene .Field (ProviderType )
196
+
197
+
198
+ class EnvironmentSyncEventType (DjangoObjectType ):
199
+ class Meta :
200
+ model = EnvironmentSyncEvent
201
+ fields = ("id" , "env_sync" , "status" , "created_at" , "completed_at" , "meta" )
202
+
203
+
204
+ class EnvironmentSyncType (DjangoObjectType ):
205
+ service_info = graphene .Field (ServiceType )
206
+ history = graphene .List (NonNull (EnvironmentSyncEventType ), required = True )
207
+
208
+ class Meta :
209
+ model = EnvironmentSync
210
+ fields = (
211
+ "id" ,
212
+ "environment" ,
213
+ "path" ,
214
+ "service_info" ,
215
+ "options" ,
216
+ "is_active" ,
217
+ "created_at" ,
218
+ "last_sync" ,
219
+ "status" ,
220
+ "authentication" ,
221
+ "history" ,
222
+ )
223
+
224
+ def resolve_service_info (self , info ):
225
+ service_config = ServiceConfig .get_service_config (self .service .lower ())
226
+ return service_config
227
+
228
+ def resolve_history (self , info ):
229
+ return EnvironmentSyncEvent .objects .filter (env_sync = self ).order_by (
230
+ "-created_at"
231
+ )
232
+
233
+
179
234
class EnvironmentType (DjangoObjectType ):
180
235
folder_count = graphene .Int ()
181
236
secret_count = graphene .Int ()
182
- members = graphene .List (OrganisationMemberType )
237
+ members = graphene .NonNull (graphene .List (OrganisationMemberType ))
238
+ syncs = graphene .NonNull (graphene .List (EnvironmentSyncType ))
183
239
184
240
class Meta :
185
241
model = Environment
@@ -230,10 +286,14 @@ def resolve_members(self, info):
230
286
)
231
287
]
232
288
289
+ def resolve_syncs (self , info ):
290
+ return EnvironmentSync .objects .filter (environment = self )
291
+
233
292
234
293
class AppType (DjangoObjectType ):
235
294
sse_enabled = graphene .Boolean ()
236
- environments = graphene .List (EnvironmentType )
295
+ environments = graphene .NonNull (graphene .List (EnvironmentType ))
296
+ members = graphene .NonNull (graphene .List (OrganisationMemberType ))
237
297
238
298
class Meta :
239
299
model = App
@@ -269,6 +329,9 @@ def resolve_environments(self, info):
269
329
).exists ()
270
330
]
271
331
332
+ def resolve_members (self , info ):
333
+ return self .members .filter (deleted_at = None )
334
+
272
335
273
336
class EnvironmentKeyType (DjangoObjectType ):
274
337
class Meta :
@@ -312,25 +375,6 @@ class Meta:
312
375
)
313
376
314
377
315
- class ProviderType (graphene .ObjectType ):
316
- id = graphene .String (required = True )
317
- name = graphene .String (required = True )
318
- expected_credentials = graphene .List (
319
- graphene .NonNull (graphene .String ), required = True
320
- )
321
- optional_credentials = graphene .List (
322
- graphene .NonNull (graphene .String ), required = True
323
- )
324
- auth_scheme = graphene .String ()
325
-
326
-
327
- class ServiceType (ObjectType ):
328
- id = graphene .String ()
329
- name = graphene .String ()
330
- resource_type = graphene .String ()
331
- provider = graphene .Field (ProviderType )
332
-
333
-
334
378
class ProviderCredentialsType (DjangoObjectType ):
335
379
sync_count = graphene .Int ()
336
380
provider = graphene .Field (ProviderType )
@@ -359,42 +403,6 @@ def resolve_credentials(self, info):
359
403
return get_credentials (self .id )
360
404
361
405
362
- class EnvironmentSyncEventType (DjangoObjectType ):
363
- class Meta :
364
- model = EnvironmentSyncEvent
365
- fields = ("id" , "env_sync" , "status" , "created_at" , "completed_at" , "meta" )
366
-
367
-
368
- class EnvironmentSyncType (DjangoObjectType ):
369
- service_info = graphene .Field (ServiceType )
370
- history = graphene .List (NonNull (EnvironmentSyncEventType ), required = True )
371
-
372
- class Meta :
373
- model = EnvironmentSync
374
- fields = (
375
- "id" ,
376
- "environment" ,
377
- "path" ,
378
- "service_info" ,
379
- "options" ,
380
- "is_active" ,
381
- "created_at" ,
382
- "last_sync" ,
383
- "status" ,
384
- "authentication" ,
385
- "history" ,
386
- )
387
-
388
- def resolve_service_info (self , info ):
389
- service_config = ServiceConfig .get_service_config (self .service .lower ())
390
- return service_config
391
-
392
- def resolve_history (self , info ):
393
- return EnvironmentSyncEvent .objects .filter (env_sync = self ).order_by (
394
- "-created_at"
395
- )
396
-
397
-
398
406
class UserTokenType (DjangoObjectType ):
399
407
class Meta :
400
408
model = UserToken
0 commit comments