|
25 | 25 | from openstack import exceptions |
26 | 26 |
|
27 | 27 |
|
| 28 | +class ValidVersion(object): |
| 29 | + |
| 30 | + def __init__(self, module, path=None): |
| 31 | + """" Valid service version. |
| 32 | +
|
| 33 | + :param string module: Module associated with version. |
| 34 | + :param string path: URL path version. |
| 35 | + """ |
| 36 | + self.module = module |
| 37 | + self.path = path or module |
| 38 | + |
| 39 | + |
28 | 40 | class ServiceFilter(object): |
29 | 41 | ANY = 'any' |
30 | 42 | PUBLIC = 'public' |
31 | 43 | INTERNAL = 'internal' |
32 | 44 | ADMIN = 'admin' |
33 | 45 | VISIBILITY = [PUBLIC, INTERNAL, ADMIN] |
| 46 | + valid_versions = [] |
34 | 47 |
|
35 | 48 | def __init__(self, service_type=ANY, visibility=PUBLIC, region=None, |
36 | 49 | service_name=None, version=None): |
@@ -115,3 +128,20 @@ def set_visibility(self, visibility): |
115 | 128 | msg = "Visibility <%s> not in %s" % (visibility, self.VISIBILITY) |
116 | 129 | raise exceptions.SDKException(msg) |
117 | 130 | self.visibility = visibility |
| 131 | + |
| 132 | + def get_module(self): |
| 133 | + """Get the full module name associated with the service.""" |
| 134 | + module = self.__class__.__module__.split('.') |
| 135 | + module = ".".join(module[:-1]) |
| 136 | + # NOTE(thowe): Only support for one valid version right now. |
| 137 | + module = module + "." + self.valid_versions[0].module |
| 138 | + return module |
| 139 | + |
| 140 | + def get_service_module(self): |
| 141 | + """Get the module version of the service name. |
| 142 | +
|
| 143 | + This would often be the same as the service type except in cases like |
| 144 | + object store where the service type is `object-store` and the module |
| 145 | + is `object_store`. |
| 146 | + """ |
| 147 | + return self.__class__.__module__.split('.')[1] |
0 commit comments