summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/provider/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/provider/__init__.py')
-rw-r--r--src/leap/bitmask/provider/__init__.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/leap/bitmask/provider/__init__.py b/src/leap/bitmask/provider/__init__.py
index 53587d65..89ff5d95 100644
--- a/src/leap/bitmask/provider/__init__.py
+++ b/src/leap/bitmask/provider/__init__.py
@@ -15,12 +15,20 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-Module initialization for leap.bitmask.provider
+Provider utilities.
"""
import os
+
+from pkg_resources import parse_version
+
+from leap.bitmask import __short_version__ as BITMASK_VERSION
from leap.common.check import leap_assert
+# The currently supported API versions by the client.
+SUPPORTED_APIS = ["1"]
+
+
def get_provider_path(domain):
"""
Returns relative path for provider config.
@@ -32,3 +40,26 @@ def get_provider_path(domain):
"""
leap_assert(domain is not None, "get_provider_path: We need a domain")
return os.path.join("leap", "providers", domain, "provider.json")
+
+
+def supports_api(api_version):
+ """
+ :param api_version: the version number of the api that we need to check
+ :type api_version: str
+
+ :returns: if that version is supported or not.
+ :return type: bool
+ """
+ return api_version in SUPPORTED_APIS
+
+
+def supports_client(minimum_version):
+ """
+ :param minimum_version: the version number of the client that
+ we need to check.
+ :type minimum_version: str
+
+ :returns: True if that version is supported or False otherwise.
+ :return type: bool
+ """
+ return parse_version(minimum_version) <= parse_version(BITMASK_VERSION)