diff options
author | kali <kali@leap.se> | 2012-09-24 22:21:50 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2012-09-24 22:21:50 +0900 |
commit | 30570bd89c04a56b35b91a0bc1d5fc00bb6ad266 (patch) | |
tree | 10364a8c906b34474f0e453fd5a3b29c4d6fba92 /src/leap/base/specs.py | |
parent | 5c32cc7b5e00853b3cc28b5003b92ab009418dff (diff) |
add schema to JSONLeapConfig classes
and a jsonvalidate function too,
that calls to jsonchemea.validate(self, data) with self.schema
We're using the specs to both purposes now:
* providing a type casting system for our config options (work in
progress for the type casting)
* json schema validation
Diffstat (limited to 'src/leap/base/specs.py')
-rw-r--r-- | src/leap/base/specs.py | 98 |
1 files changed, 51 insertions, 47 deletions
diff --git a/src/leap/base/specs.py b/src/leap/base/specs.py index d88dc63f..e75eca70 100644 --- a/src/leap/base/specs.py +++ b/src/leap/base/specs.py @@ -1,49 +1,53 @@ leap_provider_spec = { - 'serial': { - 'type': int, - 'default': 1, - 'required': True, - }, - 'version': { - 'type': unicode, - 'default': '0.1.0' - #'required': True - }, - 'domain': { - 'type': unicode, # XXX define uri type - 'default': 'testprovider.example.org' - #'required': True, - }, - 'display_name': { - 'type': unicode, # XXX multilingual object? - 'default': 'test provider' - #'required': True - }, - 'description': { - 'default': 'test provider' - }, - 'enrollment_policy': { - 'type': unicode, # oneof ?? - 'default': 'open' - }, - 'services': { - 'type': list, # oneof ?? - 'default': ['eip'] - }, - 'api_version': { - 'type': unicode, - 'default': '0.1.0' # version regexp - }, - 'api_uri': { - 'type': unicode # uri - }, - 'public_key': { - 'type': unicode # fingerprint - }, - 'ca_cert': { - 'type': unicode - }, - 'ca_cert_uri': { - 'type': unicode - }, + 'description': 'provider definition', + 'type': 'object', + 'properties': { + 'serial': { + 'type': int, + 'default': 1, + 'required': True, + }, + 'version': { + 'type': unicode, + 'default': '0.1.0' + #'required': True + }, + 'domain': { + 'type': unicode, # XXX define uri type + 'default': 'testprovider.example.org' + #'required': True, + }, + 'display_name': { + 'type': unicode, # XXX multilingual object? + 'default': 'test provider' + #'required': True + }, + 'description': { + 'default': 'test provider' + }, + 'enrollment_policy': { + 'type': unicode, # oneof ?? + 'default': 'open' + }, + 'services': { + 'type': list, # oneof ?? + 'default': ['eip'] + }, + 'api_version': { + 'type': unicode, + 'default': '0.1.0' # version regexp + }, + 'api_uri': { + 'type': unicode # uri + }, + 'public_key': { + 'type': unicode # fingerprint + }, + 'ca_cert': { + 'type': unicode + }, + 'ca_cert_uri': { + 'type': unicode + } + } } |