-
Notifications
You must be signed in to change notification settings - Fork 5
/
api_rest_schemas.py
2878 lines (2223 loc) · 111 KB
/
api_rest_schemas.py
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from magpie.definitions.cornice_definitions import colander, Service, CorniceSwagger, get_services
from magpie.definitions.pyramid_definitions import (
HTTPOk,
HTTPCreated,
HTTPFound,
HTTPBadRequest,
HTTPUnauthorized,
HTTPForbidden,
HTTPNotFound,
HTTPMethodNotAllowed,
HTTPNotAcceptable,
HTTPConflict,
HTTPUnprocessableEntity,
HTTPInternalServerError,
NO_PERMISSION_REQUIRED,
)
from magpie.common import JSON_TYPE
from magpie.constants import get_constant
from magpie.utils import get_magpie_url
# from magpie.security import get_provider_names
from magpie import __meta__
import six
TitleAPI = "Magpie REST API"
InfoAPI = {
"description": __meta__.__description__,
"contact": {"name": __meta__.__maintainer__, "email": __meta__.__email__, "url": __meta__.__url__}
}
# Tags
APITag = 'API'
LoginTag = 'Login'
UsersTag = 'User'
LoggedUserTag = 'Logged User'
GroupsTag = 'Group'
ResourcesTag = 'Resource'
ServicesTag = 'Service'
# Security
SecurityCookieAuthAPI = {'cookieAuth': {'type': 'apiKey', 'in': 'cookie', 'name': get_constant('MAGPIE_COOKIE_NAME')}}
SecurityDefinitionsAPI = {'securityDefinitions': SecurityCookieAuthAPI}
SecurityAdministratorAPI = [{'cookieAuth': []}]
SecurityEveryoneAPI = [{}]
def get_security(service, method):
definitions = service.definitions
args = {}
for definition in definitions:
met, view, args = definition
if met == method:
break
# automatically retrieve permission if specified within the view definition
permission = args.get('permission')
if permission == NO_PERMISSION_REQUIRED:
return SecurityEveryoneAPI
elif permission == get_constant('MAGPIE_ADMIN_PERMISSION'):
return SecurityAdministratorAPI
# return default admin permission otherwise unless specified form cornice decorator
return SecurityAdministratorAPI if 'security' not in args else args['security']
# Service Routes
def service_api_route_info(service_api):
return {'name': service_api.name, 'pattern': service_api.path}
LoggedUserBase = '/users/{}'.format(get_constant('MAGPIE_LOGGED_USER'))
SwaggerGenerator = Service(
path='/json',
name='swagger_schema_json')
SwaggerAPI = Service(
path='/api',
name='swagger_schema_ui',
description="{} documentation".format(TitleAPI))
UsersAPI = Service(
path='/users',
name='Users')
UserAPI = Service(
path='/users/{user_name}',
name='User')
UserGroupsAPI = Service(
path='/users/{user_name}/groups',
name='UserGroups')
UserGroupAPI = Service(
path='/users/{user_name}/groups/{group_name}',
name='UserGroup')
UserInheritedResourcesAPI = Service(
path='/users/{user_name}/inherited_resources',
name='UserInheritedResources')
UserResourcesAPI = Service(
path='/users/{user_name}/resources',
name='UserResources')
UserResourceInheritedPermissionsAPI = Service(
path='/users/{user_name}/resources/{resource_id}/inherited_permissions',
name='UserResourceInheritedPermissions')
UserResourcePermissionAPI = Service(
path='/users/{user_name}/resources/{resource_id}/permissions/{permission_name}',
name='UserResourcePermission')
UserResourcePermissionsAPI = Service(
path='/users/{user_name}/resources/{resource_id}/permissions',
name='UserResourcePermissions')
UserResourceTypesAPI = Service(
path='/users/{user_name}/resources/types/{resource_type}',
name='UserResourceTypes')
UserInheritedServicesAPI = Service(
path='/users/{user_name}/inherited_services',
name='UserInheritedServices')
UserServicesAPI = Service(
path='/users/{user_name}/services',
name='UserServices')
UserServiceAPI = Service(
path='/users/{user_name}/services/{service_name}',
name='UserService')
UserServiceInheritedResourcesAPI = Service(
path='/users/{user_name}/services/{service_name}/inherited_resources',
name='UserServiceInheritedResources')
UserServiceResourcesAPI = Service(
path='/users/{user_name}/services/{service_name}/resources',
name='UserServiceResources')
UserServiceInheritedPermissionsAPI = Service(
path='/users/{user_name}/services/{service_name}/inherited_permissions',
name='UserServiceInheritedPermissions')
UserServicePermissionsAPI = Service(
path='/users/{user_name}/services/{service_name}/permissions',
name='UserServicePermissions')
UserServicePermissionAPI = Service(
path='/users/{user_name}/services/{service_name}/permissions/{permission_name}',
name='UserServicePermission')
LoggedUserAPI = Service(
path=LoggedUserBase,
name='LoggedUser')
LoggedUserGroupsAPI = Service(
path=LoggedUserBase + '/groups',
name='LoggedUserGroups')
LoggedUserGroupAPI = Service(
path=LoggedUserBase + '/groups/{group_name}',
name='LoggedUserGroup')
LoggedUserInheritedResourcesAPI = Service(
path=LoggedUserBase + '/inherited_resources',
name='LoggedUserInheritedResources')
LoggedUserResourcesAPI = Service(
path=LoggedUserBase + '/resources',
name='LoggedUserResources')
LoggedUserResourceInheritedPermissionsAPI = Service(
path=LoggedUserBase + '/resources/{resource_id}/inherited_permissions',
name='LoggedUserResourceInheritedPermissions')
LoggedUserResourcePermissionAPI = Service(
path=LoggedUserBase + '/resources/{resource_id}/permissions/{permission_name}',
name='LoggedUserResourcePermission')
LoggedUserResourcePermissionsAPI = Service(
path=LoggedUserBase + '/resources/{resource_id}/permissions',
name='LoggedUserResourcePermissions')
LoggedUserResourceTypesAPI = Service(
path=LoggedUserBase + '/resources/types/{resource_type}',
name='LoggedUserResourceTypes')
LoggedUserInheritedServicesAPI = Service(
path=LoggedUserBase + '/inherited_services',
name='LoggedUserInheritedServices')
LoggedUserServicesAPI = Service(
path=LoggedUserBase + '/services',
name='LoggedUserServices')
LoggedUserServiceInheritedResourcesAPI = Service(
path=LoggedUserBase + '/services/{service_name}/inherited_resources',
name='LoggedUserServiceInheritedResources')
LoggedUserServiceResourcesAPI = Service(
path=LoggedUserBase + '/services/{service_name}/resources',
name='LoggedUserServiceResources')
LoggedUserServiceInheritedPermissionsAPI = Service(
path=LoggedUserBase + '/services/{service_name}/inherited_permissions',
name='LoggedUserServiceInheritedPermissions')
LoggedUserServicePermissionsAPI = Service(
path=LoggedUserBase + '/services/{service_name}/permissions',
name='LoggedUserServicePermissions')
LoggedUserServicePermissionAPI = Service(
path=LoggedUserBase + '/services/{service_name}/permissions/{permission_name}',
name='LoggedUserServicePermission')
GroupsAPI = Service(
path='/groups',
name='Groups')
GroupAPI = Service(
path='/groups/{group_name}',
name='Group')
GroupUsersAPI = Service(
path='/groups/{group_name}/users',
name='GroupUsers')
GroupServicesAPI = Service(
path='/groups/{group_name}/services',
name='GroupServices')
GroupServicePermissionsAPI = Service(
path='/groups/{group_name}/services/{service_name}/permissions',
name='GroupServicePermissions')
GroupServicePermissionAPI = Service(
path='/groups/{group_name}/services/{service_name}/permissions/{permission_name}',
name='GroupServicePermission')
GroupServiceResourcesAPI = Service(
path='/groups/{group_name}/services/{service_name}/resources',
name='GroupServiceResources')
GroupResourcesAPI = Service(
path='/groups/{group_name}/resources',
name='GroupResources')
GroupResourcePermissionsAPI = Service(
path='/groups/{group_name}/resources/{resource_id}/permissions',
name='GroupResourcePermissions')
GroupResourcePermissionAPI = Service(
path='/groups/{group_name}/resources/{resource_id}/permissions/{permission_name}',
name='GroupResourcePermission')
GroupResourceTypesAPI = Service(
path='/groups/{group_name}/resources/types/{resource_type}',
name='GroupResourceTypes')
ResourcesAPI = Service(
path='/resources',
name='Resources')
ResourceAPI = Service(
path='/resources/{resource_id}',
name='Resource')
ResourcePermissionsAPI = Service(
path='/resources/{resource_id}/permissions',
name='ResourcePermissions')
ServicesAPI = Service(
path='/services',
name='Services')
ServiceAPI = Service(
path='/services/{service_name}',
name='Service')
ServiceTypesAPI = Service(
path='/services/types',
name='ServiceTypes')
ServiceTypeAPI = Service(
path='/services/types/{service_type}',
name='ServiceType')
ServicePermissionsAPI = Service(
path='/services/{service_name}/permissions',
name='ServicePermissions')
ServiceResourcesAPI = Service(
path='/services/{service_name}/resources',
name='ServiceResources')
ServiceResourceAPI = Service(
path='/services/{service_name}/resources/{resource_id}',
name='ServiceResource')
ServiceTypeResourcesAPI = Service(
path='/services/types/{service_type}/resources',
name='ServiceTypeResources')
ServiceTypeResourceTypesAPI = Service(
path='/services/types/{service_type}/resources/types',
name='ServiceTypeResourceTypes')
ProvidersAPI = Service(
path='/providers',
name='Providers')
ProviderSigninAPI = Service(
path='/providers/{provider_name}/signin',
name='ProviderSignin')
SigninAPI = Service(
path='/signin',
name='signin')
SignoutAPI = Service(
path='/signout',
name='signout')
SessionAPI = Service(
path='/session',
name='Session')
VersionAPI = Service(
path='/version',
name='Version')
# Common path parameters
GroupNameParameter = colander.SchemaNode(
colander.String(),
description="Registered user group.",
example="users",)
UserNameParameter = colander.SchemaNode(
colander.String(),
description="Registered local user.",
example="toto",)
ProviderNameParameter = colander.SchemaNode(
colander.String(),
description="External identity provider.",
example="DKRZ",
# validator=colander.OneOf(get_provider_names())
)
PermissionNameParameter = colander.SchemaNode(
colander.String(),
description="Permissions applicable to the service/resource.",
example="read",)
ResourceIdParameter = colander.SchemaNode(
colander.String(),
description="Registered resource ID.",
example="123")
ServiceNameParameter = colander.SchemaNode(
colander.String(),
description="Registered service name.",
example="my-wps")
class HeaderResponseSchema(colander.MappingSchema):
content_type = colander.SchemaNode(
colander.String(),
default=JSON_TYPE,
example=JSON_TYPE,
description='Content type of the response body.',
)
content_type.name = 'Content-Type'
class HeaderRequestSchema(colander.MappingSchema):
content_type = colander.SchemaNode(
colander.String(),
default=JSON_TYPE,
example=JSON_TYPE,
missing=colander.drop,
)
content_type.name = 'Content-Type'
QueryEffectivePermissions = colander.SchemaNode(
colander.Boolean(), default=False, missing=colander.drop,
description="User groups effective permissions resolved with corresponding service inheritance functionality. "
"(Note: group inheritance is enforced regardless of any `inherit` flag).")
QueryInheritGroupsPermissions = colander.SchemaNode(
colander.Boolean(), default=False, missing=colander.drop,
description="User groups memberships inheritance to resolve service resource permissions.")
QueryCascadeResourcesPermissions = colander.SchemaNode(
colander.Boolean(), default=False, missing=colander.drop,
description="Display any service that has at least one sub-resource user permission, "
"or only services that have user permissions directly set on them.", )
class BaseResponseBodySchema(colander.MappingSchema):
__code = None
__desc = None
def __init__(self, code, description, **kw):
super(BaseResponseBodySchema, self).__init__(**kw)
assert isinstance(code, int)
assert isinstance(description, six.string_types)
self.__code = code
self.__desc = description
# update the values
child_nodes = getattr(self, 'children')
for node in child_nodes:
if node.name == 'code':
node.example = self.__code
if node.name == 'detail':
node.example = self.__desc
code = colander.SchemaNode(
colander.Integer(),
description="HTTP response code",
example=__code)
type = colander.SchemaNode(
colander.String(),
description="Response content type",
example=JSON_TYPE)
detail = colander.SchemaNode(
colander.String(),
description="Response status message",
example=__desc)
class ErrorVerifyParamBodySchema(colander.MappingSchema):
name = colander.SchemaNode(
colander.String(),
description="Name of the failing condition parameter.",
missing=colander.drop)
value = colander.SchemaNode(
colander.String(),
description="Value of the failing condition parameter.")
compare = colander.SchemaNode(
colander.String(),
description="Test comparison value of the failing condition parameter.",
missing=colander.drop)
class ErrorResponseBodySchema(BaseResponseBodySchema):
def __init__(self, code, description, **kw):
super(ErrorResponseBodySchema, self).__init__(code, description, **kw)
assert code >= 400
route_name = colander.SchemaNode(
colander.String(),
description="Route called that generated the error.",
example="/users/toto")
request_url = colander.SchemaNode(
colander.String(),
description="Request URL that generated the error.",
example="http://localhost:2001/magpie/users/toto")
method = colander.SchemaNode(
colander.String(),
description="Request method that generated the error.",
example="GET")
class InternalServerErrorResponseBodySchema(ErrorResponseBodySchema):
def __init__(self, **kw):
kw['code'] = HTTPInternalServerError.code
super(InternalServerErrorResponseBodySchema, self).__init__(**kw)
class UnauthorizedResponseBodySchema(BaseResponseBodySchema):
def __init__(self, **kw):
kw['code'] = HTTPUnauthorized.code
super(UnauthorizedResponseBodySchema, self).__init__(**kw)
route_name = colander.SchemaNode(colander.String(), description="Specified route")
request_url = colander.SchemaNode(colander.String(), description="Specified url")
class UnauthorizedResponseSchema(colander.MappingSchema):
description = "Unauthorized access to this resource. " + \
"Insufficient user privileges or missing authentication headers."
header = HeaderResponseSchema()
body = UnauthorizedResponseBodySchema(code=HTTPUnauthorized.code, description=description)
class HTTPForbiddenResponseSchema(colander.MappingSchema):
description = "Forbidden operation under this resource."
header = HeaderResponseSchema()
body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
class NotFoundResponseSchema(colander.MappingSchema):
description = "The route resource could not be found."
header = HeaderResponseSchema()
body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
class MethodNotAllowedResponseSchema(colander.MappingSchema):
description = "The method is not allowed for this resource."
header = HeaderResponseSchema()
body = ErrorResponseBodySchema(code=HTTPMethodNotAllowed.code, description=description)
class UnprocessableEntityResponseSchema(colander.MappingSchema):
description = "Invalid value specified."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPUnprocessableEntity.code, description=description)
class InternalServerErrorResponseSchema(colander.MappingSchema):
description = "Internal Server Error. Unhandled exception occurred."
header = HeaderResponseSchema()
body = ErrorResponseBodySchema(code=HTTPInternalServerError.code, description=description)
class ProvidersListSchema(colander.SequenceSchema):
provider_name = colander.SchemaNode(
colander.String(),
description="Available login providers.",
example="openid",
)
class ResourceTypesListSchema(colander.SequenceSchema):
resource_type = colander.SchemaNode(
colander.String(),
description="Available resource type under root service.",
example="file",
)
class GroupNamesListSchema(colander.SequenceSchema):
group_name = GroupNameParameter
class UserNamesListSchema(colander.SequenceSchema):
user_name = UserNameParameter
class PermissionListSchema(colander.SequenceSchema):
permission_name = colander.SchemaNode(
colander.String(),
description="Permissions applicable to the service/resource",
example="read"
)
class UserBodySchema(colander.MappingSchema):
user_name = UserNameParameter
email = colander.SchemaNode(
colander.String(),
description="Email of the user.",
example="toto@mail.com")
group_names = GroupNamesListSchema(
example=['administrators', 'users']
)
class GroupBodySchema(colander.MappingSchema):
group_name = colander.SchemaNode(
colander.String(),
description="Name of the group.",
example="Administrators")
group_id = colander.SchemaNode(
colander.Integer(),
description="ID of the group.",
example=1)
description = colander.SchemaNode(
colander.String(),
description="Description associated to the group.",
example="",
missing=colander.drop)
member_count = colander.SchemaNode(
colander.Integer(),
description="Number of users member of the group.",
example=2,
missing=colander.drop)
user_names = UserNamesListSchema(
example=['alice', 'bob'],
missing=colander.drop
)
class ServiceBodySchema(colander.MappingSchema):
resource_id = colander.SchemaNode(
colander.Integer(),
description="Resource identification number",
)
permission_names = PermissionListSchema(
example=['read', 'write']
)
service_name = colander.SchemaNode(
colander.String(),
description="Name of the service",
example="thredds"
)
service_type = colander.SchemaNode(
colander.String(),
description="Type of the service",
example="thredds"
)
service_sync_type = colander.SchemaNode(
colander.String(),
description="Type of resource synchronization implementation.",
example="thredds"
)
public_url = colander.SchemaNode(
colander.String(),
description="Proxy URL available for public access with permissions",
example="http://localhost/twitcher/ows/proxy/thredds"
)
service_url = colander.SchemaNode(
colander.String(),
description="Private URL of the service (restricted access)",
example="http://localhost:9999/thredds"
)
class ResourceBodySchema(colander.MappingSchema):
resource_id = colander.SchemaNode(
colander.Integer(),
description="Resource identification number",
)
resource_name = colander.SchemaNode(
colander.String(),
description="Name of the resource",
example="thredds"
)
resource_display_name = colander.SchemaNode(
colander.String(),
description="Display name of the resource",
example="Birdhouse Thredds Data Server"
)
resource_type = colander.SchemaNode(
colander.String(),
description="Type of the resource",
example="service"
)
parent_id = colander.SchemaNode(
colander.Integer(),
description="Parent resource identification number",
default=colander.null, # if no parent
missing=colander.drop # if not returned (basic_info = True)
)
root_service_id = colander.SchemaNode(
colander.Integer(),
description="Resource tree root service identification number",
default=colander.null, # if no parent
missing=colander.drop # if not returned (basic_info = True)
)
permission_names = PermissionListSchema(example=['read', 'write'])
permission_names.default = colander.null # if no parent
permission_names.missing = colander.drop # if not returned (basic_info = True)
# TODO: improve by making recursive resources work (?)
class Resource_ChildrenContainerWithoutChildResourceBodySchema(ResourceBodySchema):
children = colander.MappingSchema(default={})
class Resource_ChildResourceWithoutChildrenBodySchema(colander.MappingSchema):
id = Resource_ChildrenContainerWithoutChildResourceBodySchema()
id.name = '{resource_id}'
class Resource_ParentResourceWithChildrenContainerBodySchema(ResourceBodySchema):
children = Resource_ChildResourceWithoutChildrenBodySchema()
class Resource_ChildrenContainerWithChildResourceBodySchema(ResourceBodySchema):
children = Resource_ChildResourceWithoutChildrenBodySchema()
class Resource_ChildResourceWithChildrenContainerBodySchema(colander.MappingSchema):
id = Resource_ChildrenContainerWithChildResourceBodySchema()
id.name = '{resource_id}'
class Resource_ServiceWithChildrenResourcesContainerBodySchema(ServiceBodySchema):
resources = Resource_ChildResourceWithChildrenContainerBodySchema()
class Resource_ServiceType_geoserverapi_SchemaNode(colander.MappingSchema):
geoserver_api = Resource_ServiceWithChildrenResourcesContainerBodySchema()
geoserver_api.name = "geoserver-api"
class Resource_ServiceType_ncwms_SchemaNode(colander.MappingSchema):
ncwms = Resource_ServiceWithChildrenResourcesContainerBodySchema()
class Resource_ServiceType_thredds_SchemaNode(colander.MappingSchema):
thredds = Resource_ServiceWithChildrenResourcesContainerBodySchema()
class ResourcesSchemaNode(colander.MappingSchema):
geoserver_api = Resource_ServiceType_geoserverapi_SchemaNode()
geoserver_api.name = "geoserver-api"
ncwms = Resource_ServiceType_ncwms_SchemaNode()
thredds = Resource_ServiceType_thredds_SchemaNode()
class Resources_ResponseBodySchema(BaseResponseBodySchema):
resources = ResourcesSchemaNode()
class Resource_MatchDictCheck_ForbiddenResponseSchema(colander.MappingSchema):
description = "Resource query by id refused by db."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
class Resource_MatchDictCheck_NotFoundResponseSchema(colander.MappingSchema):
description = "Resource ID not found in db."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPNotFound.code, description=description)
class Resource_MatchDictCheck_NotAcceptableResponseSchema(colander.MappingSchema):
description = "Resource ID is an invalid literal for `int` type."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPNotAcceptable.code, description=description)
class Resource_GET_ResponseBodySchema(BaseResponseBodySchema):
resource = Resource_ParentResourceWithChildrenContainerBodySchema()
class Resource_GET_OkResponseSchema(colander.MappingSchema):
description = "Get resource successful."
header = HeaderResponseSchema()
body = Resource_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
class Resource_GET_InternalServerErrorResponseSchema(colander.MappingSchema):
description = "Failed building resource children json formatted tree."
header = HeaderResponseSchema()
body = InternalServerErrorResponseBodySchema(code=HTTPInternalServerError.code, description=description)
class Resource_PUT_RequestBodySchema(colander.MappingSchema):
resource_name = colander.SchemaNode(
colander.String(),
description="New name to apply to the resource to update",
)
service_push = colander.SchemaNode(
colander.Boolean(),
description="Push service resource update to Phoenix",
missing=False,
)
class Resource_PUT_RequestSchema(colander.MappingSchema):
header = HeaderRequestSchema()
body = Resource_PUT_RequestBodySchema()
resource_id = ResourceIdParameter
class Resource_PUT_ResponseBodySchema(BaseResponseBodySchema):
resource_id = colander.SchemaNode(
colander.String(),
description="Updated resource identification number."
)
resource_name = colander.SchemaNode(
colander.String(),
description="Updated resource name (from object)."
)
old_resource_name = colander.SchemaNode(
colander.String(),
description="Resource name before update."
)
new_resource_name = colander.SchemaNode(
colander.String(),
description="Resource name after update."
)
class Resource_PUT_OkResponseSchema(colander.MappingSchema):
description = "Update resource successful."
header = HeaderResponseSchema()
body = Resource_PUT_ResponseBodySchema(code=HTTPOk.code, description=description)
class Resource_PUT_ForbiddenResponseSchema(colander.MappingSchema):
description = "Failed to update resource with new name."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
class Resource_DELETE_RequestBodySchema(colander.MappingSchema):
service_push = colander.SchemaNode(
colander.Boolean(),
description="Push service update to Phoenix if applicable",
missing=colander.drop,
default=False,
)
class Resource_DELETE_RequestSchema(colander.MappingSchema):
header = HeaderRequestSchema()
body = Resource_DELETE_RequestBodySchema()
resource_id = ResourceIdParameter
class Resource_DELETE_OkResponseSchema(colander.MappingSchema):
description = "Delete resource successful."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
class Resource_DELETE_ForbiddenResponseSchema(colander.MappingSchema):
description = "Delete resource from db failed."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
class Resources_GET_OkResponseSchema(colander.MappingSchema):
description = "Get resources successful."
header = HeaderResponseSchema()
body = Resources_ResponseBodySchema(code=HTTPOk.code, description=description)
class Resources_POST_RequestBodySchema(colander.MappingSchema):
resource_name = colander.SchemaNode(
colander.String(),
description="Name of the resource to create"
)
resource_display_name = colander.SchemaNode(
colander.String(),
description="Display name of the resource to create, defaults to resource_name.",
missing=colander.drop
)
resource_type = colander.SchemaNode(
colander.String(),
description="Type of the resource to create"
)
parent_id = colander.SchemaNode(
colander.String(),
description="ID of parent resource under which the new resource should be created",
missing=colander.drop
)
class Resources_POST_RequestSchema(colander.MappingSchema):
header = HeaderRequestSchema()
body = Resources_POST_RequestBodySchema()
class Resource_POST_ResponseBodySchema(BaseResponseBodySchema):
resource = Resource_ChildResourceWithChildrenContainerBodySchema()
class Resources_POST_CreatedResponseSchema(colander.MappingSchema):
description = "Create resource successful."
header = HeaderResponseSchema()
body = Resource_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
class Resources_POST_BadRequestResponseSchema(colander.MappingSchema):
description = "Invalid [`resource_name`|`resource_type`|`parent_id`] specified for child resource creation."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPBadRequest.code, description=description)
class Resources_POST_ForbiddenResponseSchema(colander.MappingSchema):
description = "Failed to insert new resource in service tree using parent id."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
class Resources_POST_NotFoundResponseSchema(colander.MappingSchema):
description = "Could not find specified resource parent id."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPNotFound.code, description=description)
class Resources_POST_ConflictResponseSchema(colander.MappingSchema):
description = "Resource name already exists at requested tree level for creation."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPConflict.code, description=description)
class ResourcePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
permission_names = PermissionListSchema(example=['read', 'write'])
class ResourcePermissions_GET_OkResponseSchema(colander.MappingSchema):
description = "Get resource permissions successful."
header = HeaderResponseSchema()
body = ResourcePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
class ResourcePermissions_GET_NotAcceptableResponseSchema(colander.MappingSchema):
description = "Invalid resource type to extract permissions."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPNotAcceptable.code, description=description)
class ServiceResourcesBodySchema(ServiceBodySchema):
children = ResourcesSchemaNode()
class ServiceType_access_SchemaNode(colander.MappingSchema):
frontend = ServiceBodySchema(missing=colander.drop)
geoserver_web = ServiceBodySchema(missing=colander.drop)
geoserver_web.name = "geoserver-web"
magpie = ServiceBodySchema(missing=colander.drop)
class ServiceType_geoserverapi_SchemaNode(colander.MappingSchema):
geoserver_api = ServiceBodySchema(missing=colander.drop)
geoserver_api.name = "geoserver-api"
class ServiceType_geoserverwms_SchemaNode(colander.MappingSchema):
geoserverwms = ServiceBodySchema(missing=colander.drop)
class ServiceType_ncwms_SchemaNode(colander.MappingSchema):
ncwms = ServiceBodySchema(missing=colander.drop)
ncwms.name = "ncWMS2"
class ServiceType_projectapi_SchemaNode(colander.MappingSchema):
project_api = ServiceBodySchema(missing=colander.drop)
project_api.name = "project-api"
class ServiceType_thredds_SchemaNode(colander.MappingSchema):
thredds = ServiceBodySchema(missing=colander.drop)
class ServiceType_wfs_SchemaNode(colander.MappingSchema):
geoserver = ServiceBodySchema(missing=colander.drop)
class ServiceType_wps_SchemaNode(colander.MappingSchema):
lb_flyingpigeon = ServiceBodySchema(missing=colander.drop)
flyingpigeon = ServiceBodySchema(missing=colander.drop)
project = ServiceBodySchema(missing=colander.drop)
catalog = ServiceBodySchema(missing=colander.drop)
malleefowl = ServiceBodySchema(missing=colander.drop)
hummingbird = ServiceBodySchema(missing=colander.drop)
class ServiceTypesList(colander.SequenceSchema):
service_type = colander.SchemaNode(
colander.String(),
description="Available service type.",
example="api",
)
class ServiceTypes_GET_OkResponseBodySchema(BaseResponseBodySchema):
service_types = ServiceTypesList(description="List of available service types.")
class ServiceTypes_GET_OkResponseSchema(colander.MappingSchema):
description = "Get service types successful."
header = HeaderResponseSchema()
body = ServiceTypes_GET_OkResponseBodySchema(code=HTTPOk.code, description=description)
class ServicesSchemaNode(colander.MappingSchema):
access = ServiceType_access_SchemaNode()
geoserver_api = ServiceType_geoserverapi_SchemaNode(missing=colander.drop)
geoserver_api.name = "geoserver-api"
geoserverwms = ServiceType_geoserverwms_SchemaNode(missing=colander.drop)
ncwms = ServiceType_ncwms_SchemaNode()
project_api = ServiceType_projectapi_SchemaNode(missing=colander.drop)
project_api.name = "project-api"
thredds = ServiceType_thredds_SchemaNode()
wfs = ServiceType_wfs_SchemaNode(missing=colander.drop)
wps = ServiceType_wps_SchemaNode(missing=colander.drop)
class Service_FailureBodyResponseSchema(BaseResponseBodySchema):
service_name = colander.SchemaNode(
colander.String(),
description="Service name extracted from path"
)
class Service_MatchDictCheck_ForbiddenResponseSchema(colander.MappingSchema):
description = "Service query by name refused by db."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
class Service_MatchDictCheck_NotFoundResponseSchema(colander.MappingSchema):
description = "Service name not found in db."
header = HeaderResponseSchema()
body = Service_FailureBodyResponseSchema(code=HTTPNotFound.code, description=description)
class Service_GET_ResponseBodySchema(BaseResponseBodySchema):
service = ServiceBodySchema()
class Service_GET_OkResponseSchema(colander.MappingSchema):
description = "Get service successful."
header = HeaderResponseSchema()
body = Service_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
class Services_GET_ResponseBodySchema(BaseResponseBodySchema):
services = ServicesSchemaNode()
class Services_GET_OkResponseSchema(colander.MappingSchema):
description = "Get services successful."
header = HeaderResponseSchema()
body = Services_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
class Services_GET_NotAcceptableResponseBodySchema(BaseResponseBodySchema):
service_type = colander.SchemaNode(
colander.String(),
description="Name of the service type filter employed when applicable",
missing=colander.drop)
class Services_GET_NotAcceptableResponseSchema(colander.MappingSchema):
description = "Invalid `service_type` value does not correspond to any of the existing service types."
header = HeaderResponseSchema()
body = Services_GET_NotAcceptableResponseBodySchema(code=HTTPNotAcceptable.code, description=description)
class Services_POST_BodySchema(colander.MappingSchema):
service_name = colander.SchemaNode(
colander.String(),
description="Name of the service to create",
example="my_service"
)
service_type = colander.SchemaNode(
colander.String(),
description="Type of the service to create",
example="wps"
)
service_sync_type = colander.SchemaNode(
colander.String(),
description="Type of the service to create",
example="wps"
)
service_url = colander.SchemaNode(
colander.String(),
description="Private URL of the service to create",
example="http://localhost:9000/my_service"
)
class Services_POST_RequestBodySchema(colander.MappingSchema):
header = HeaderRequestSchema()
body = Services_POST_BodySchema()
class Services_POST_CreatedResponseSchema(colander.MappingSchema):
description = "Service registration to db successful."
header = HeaderResponseSchema()
body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
class Services_POST_BadRequestResponseSchema(colander.MappingSchema):
description = "Invalid `service_type` value does not correspond to any of the existing service types."