-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustom_config.py
More file actions
434 lines (369 loc) · 15.6 KB
/
custom_config.py
File metadata and controls
434 lines (369 loc) · 15.6 KB
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
"""Cloud Registry custom config models."""
from typing import Optional
from foca.models.config import FOCABaseConfig
class ServiceConfig(FOCABaseConfig):
"""Model for configuration parameters to set up a service.
Args:
url_prefix: Service protocol at which the application is exposed.
external_host: Host at which the application is exposed.
external_port: Port at which the application is exposed.
api_path: API Path at which service resources are exposed.
Attributes:
url_prefix: Service protocol at which the application is exposed.
external_host: Host at which the application is exposed.
external_port: Port at which the application is exposed.
api_path: API Path at which service resources are exposed.
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> ServiceConfig(
... url_prefix='https',
... external_host='0.0.0.0',
... external_port=8080,
... api_path=''
... )
ServiceConfig(url_prefix='https', external_host='0.0.0.0', external_po\
rt=8080, api_path='')
"""
url_prefix: str
external_host: str
external_port: int
api_path: str
class TypeConfig(FOCABaseConfig):
"""Model for deifining the type of GA4GH Service.
Args:
group: Namespace in reverse domain name format.
artifact: Name of the API or GA4GH specification implemented.
version: Version of the API or specification.
Attributes:
group: Namespace in reverse domain name format.
artifact: Name of the API or GA4GH specification implemented.
version: Version of the API or specification.
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> TypeConfig(
... group='service.group',
... artifact='service_artifact',
... version='1.0.0'
... )
TypeConfig(group='service.group', artifact='service_artifact', version\
='1.0.0')
"""
group: str
artifact: str
version: str
class OrganizationConfig(FOCABaseConfig):
"""Model for organization providing the service.
Args:
name: Name of the organization responsible for the service.
url: URL of the website of the organization (RFC 3986 format).
Attributes:
name: Name of the organization responsible for the service.
url: URL of the website of the organization (RFC 3986 format).
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> OrganizationConfig(
... name='organization_name',
... url='organization_url'
... )
OrganizationConfig(name='organization_name', url='organization_url')
"""
name: str
url: str
class ServiceInfoConfig(FOCABaseConfig):
"""Model for service information parameters.
Args:
id: Unique identifier of this service.
name: Service name.
type: Type of GA4GH service.
description: Service description.
organization: Organization providing the service.
contactUrl: URL of the contact for the provider of the service, e.g. a
link to a contact form (RFC 3986 format), or an email (RFC 2368
format).
documentationUrl: URL of the documentation of the service (RFC 3986
format). This should help someone learn how to use your service,
including any specifics required to access data, e.g.
authentication.
createdAt: Timestamp describing when the service was first deployed and
available (RFC 3339 format).
updatedAt: Timestamp describing when the service was last updated (RFC
3339 format).
environment: Environment the service is running in. Use this to
distinguish between production, development and testing/staging
deployments. Suggested values are prod, test, dev, staging.
version: Version of the service being described. Semantic versioning
is recommended, but other identifiers, such as dates or commit
hashes, are also allowed. The version should be changed whenever
the service is updated.
Attributes:
id: Unique identifier of this service.
name: Service name.
type: Type of GA4GH service.
description: Service description.
organization: Organization providing the service.
contactUrl: URL of the contact for the provider of the service, e.g. a
link to a contact form (RFC 3986 format), or an email (RFC 2368
format).
documentationUrl: URL of the documentation of the service (RFC 3986
format). This should help someone learn how to use your service,
including any specifics required to access data, e.g.
authentication.
createdAt: Timestamp describing when the service was first deployed and
available (RFC 3339 format).
updatedAt: Timestamp describing when the service was last updated (RFC
3339 format).
environment: Environment the service is running in. Use this to
distinguish between production, development and testing/staging
deployments. Suggested values are prod, test, dev, staging.
version: Version of the service being described. Semantic versioning
is recommended, but other identifiers, such as dates or commit
hashes, are also allowed. The version should be changed whenever
the service is updated.
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> ServiceInfoConfig(
... id='service_id',
... name='service_name',
... type=TypeConfig(
... group='service.group',
... artifact='service_artifact',
... version='1.0.0'
... ),
... description='Service description.',
... organization=OrganizationConfig(
... name='organization_name',
... url='organization_url'
... ),
... contactUrl='service_contact_url',
... documentationUrl='service_document_url',
... createdAt='2020-11-04T12:58:19Z',
... updatedAt='2020-11-04T12:58:19Z',
... environment='dev',
... version='1.0.0-dev-XXXXXX'
... )
ServiceInfoConfig(id='service_id', name='service_name', type=TypeConfi\
g(group='service.group', artifact='service_artifact', version='1.0.0'), descri\
ption='Service description.', organization=OrganizationConfig(name='organizati\
on_name', url='organization_url'), contactUrl='service_contact_url', documenta\
tionUrl='service_document_url', createdAt='2020-11-04T12:58:19Z', updatedAt='2\
020-11-04T12:58:19Z', environment='dev', version='1.0.0-dev-XXXXXX')
"""
id: str
name: str
type: TypeConfig
description: str
organization: OrganizationConfig
contactUrl: str
documentationUrl: str
createdAt: Optional[str] = None
updatedAt: Optional[str] = None
environment: str
version: str
class IdConfig(FOCABaseConfig):
"""Model for defining unique identifier for services on cloud registry.
Args:
charset: A string of allowed characters or an expression evaluating to
a string of allowed characters.
length: Length of returned string.
Attributes:
charset: A string of allowed characters or an expression evaluating to
a string of allowed characters.
length: Length of returned string.
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> IdConfig(
... charset='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
... length=6
... )
IdConfig(charset='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', length=6)
"""
charset: str
length: int
class MetaVersionConfig(FOCABaseConfig):
"""Model for storing version control configurations for services onboarded
on cloud registry.
Args:
init: Initial version number for a given service.
increment: Incremental value for next version.
Attributes:
init: Initial version number for a given service.
increment: Incremental value for next versions.
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> MetaVersionConfig(
... init=1,
... increment=1
... )
MetaVersionConfig(init=1, increment=1)
"""
init: int
increment: int
class ServicesConfig(FOCABaseConfig):
"""Model for defining the service database store for cloud registry. This
defines the configurations for service identifiers stored on cloud
registry.
Args:
id: Unique identifier for a service in cloud registry.
meta_version: Version increment configuration for service upgrades.
Attributes:
id: Unique identifier for a service in cloud registry.
meta_version: Version increment configuration for service upgrades.
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> ServicesConfig(
... id=IdConfig(
... charset='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
... length=6
... ),
... meta_version=MetaVersionConfig(
... init=1,
... increment=1
... )
... )
ServicesConfig(id=IdConfig(charset='ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567\
89', length=6), meta_version=MetaVersionConfig(init=1, increment=1))
"""
id: IdConfig
meta_version: MetaVersionConfig
class EndpointsConfig(FOCABaseConfig):
"""Model for defining endpoint configuration parameters.
Args:
service: Service run parameters.
service_info: Service info parameters.
services: Cloud registry service store parameters.
Attributes:
service: Service run parameters.
service_info: Service info parameters.
services: Cloud registry service store parameters.
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> EndpointsConfig(
... service=ServiceConfig(
... url_prefix='https',
... external_host='0.0.0.0',
... external_port=8080,
... api_path=''
... ),
... service_info=ServiceInfoConfig(
... id='',
... name='service_name',
... type=TypeConfig(
... group='service.group',
... artifact='service_artifact',
... version='1.0.0'
... ),
... description='Service description.',
... organization=OrganizationConfig(
... name='organization_name',
... url='organization_url'
... ),
... contactUrl='service_contact_url',
... documentationUrl='service_document_url',
... createdAt='2020-11-04T12:58:19Z',
... updatedAt='2020-11-04T12:58:19Z',
... environment='dev',
... version='1.0.0-dev-XXXXXX'
... ),
... services=ServicesConfig(
... id=IdConfig(
... charset='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
... length=6
... ),
... meta_version=MetaVersionConfig(
... init=1,
... increment=1
... )
... )
... )
EndpointsConfig(service=ServiceConfig(url_prefix='https',external_host\
='0.0.0.0',external_port=8080,api_path=''),service_info=ServiceInfoConfig(id='\
',name='service_name',type=TypeConfig(group='service.group',artifact='service_\
artifact',version='1.0.0'),description='Service description.',organization=Org\
anizationConfig(name='organization_name',url='organization_url'),contactUrl='s\
ervice_contact_url',documentationUrl='service_document_url',createdAt='2020-11\
-04T12:58:19Z',updatedAt='2020-11-04T12:58:19Z',environment='dev',version='1.0\
.0-dev-XXXXXX'),services=ServicesConfig(id=IdConfig(charset='ABCDEFGHIJKLMNOPQ\
RSTUVWXYZ0123456789',length=6),meta_version=MetaVersionConfig(init=1,increment\
=1)))
"""
service: ServiceConfig
service_info: ServiceInfoConfig
services: ServicesConfig
class CustomConfig(FOCABaseConfig):
"""Model for defining the custom configurations for cloud registry.
Args:
endpoints: Endpoint service configurations for cloud registry.
Attributes:
endpoints: Endpoint service configurations for cloud registry.
Raises:
pydantic.ValidationError: The class was instantianted with an illegal
data type.
Example:
>>> CustomConfig(
... endpoints=EndpointsConfig(
... service=ServiceConfig(
... url_prefix='https',
... external_host='0.0.0.0',
... external_port=8080,
... api_path=''
... ),
... service_info=ServiceInfoConfig(
... id='',
... name='service_name',
... type=TypeConfig(
... group='service.group',
... artifact='service_artifact',
... version='1.0.0'
... ),
... description='Service description.',
... organization=OrganizationConfig(
... name='organization_name',
... url='organization_url'
... ),
... contactUrl='service_contact_url',
... documentationUrl='service_document_url',
... createdAt='2020-11-04T12:58:19Z',
... updatedAt='2020-11-04T12:58:19Z',
... environment='dev',
... version='1.0.0-dev-XXXXXX'
... ),
... services=ServicesConfig(
... id=IdConfig(
... charset='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
... length=6
... ),
... meta_version=MetaVersionConfig(
... init=1,
... increment=1
... )
... )
... )
... )
CustomConfig(endpoints=EndpointsConfig(service=ServiceConfig(url_prefi\
x='https',external_host='0.0.0.0',external_port=8080,api_path=''),service_info\
=ServiceInfoConfig(id='',name='service_name',type=TypeConfig(group='service.gr\
oup',artifact='service_artifact',version='1.0.0'),description='Service descrip\
tion.',organization=OrganizationConfig(name='organization_name',url='organizat\
ion_url'),contactUrl='service_contact_url',documentationUrl='service_document_\
url',createdAt='2020-11-04T12:58:19Z',updatedAt='2020-11-04T12:58:19Z',environ\
ment='dev',version='1.0.0-dev-XXXXXX'),services=ServicesConfig(id=IdConfig(cha\
rset='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',length=6),meta_version=MetaVersion\
Config(init=1,increment=1))))
"""
endpoints: EndpointsConfig