From 862112a26504e43077edd69e10d8b9c96a9fd0e9 Mon Sep 17 00:00:00 2001 From: Blai Peidro Date: Tue, 15 Sep 2026 02:32:04 +0200 Subject: [PATCH] feat: remove the licence pages, routes and exceptions Config carried six properties reading fields the config endpoint no longer returns: valid_key, instance_count, trial, features, and a license_type that is only ever open. is_aws_license read metadata a Tower AMI put there. None of them can answer anything but a default now, which is worse than not being there, because a caller reading is_valid_license gets False rather than an error telling it the question no longer applies. The subscriptions page posted to config/subscriptions/ and ConfigAttach posted to config/attach/. Neither route exists in ctrliq/ascender: config/subscriptions went with ctrliq/ascender#1005 and config/attach was never served at all. page.py sniffed response bodies for eleven licence phrases to decide between LicenseInvalid, LicenseExceeded and the ordinary Forbidden or BadRequest. The platform does not emit any of those phrases any more, so every response takes the else branch, and the two exception classes go with the sniffing. --- ascenderkit/api/pages/__init__.py | 1 - ascenderkit/api/pages/config.py | 31 +----------------------- ascenderkit/api/pages/page.py | 33 +------------------------- ascenderkit/api/pages/subscriptions.py | 10 -------- ascenderkit/api/resources.py | 2 -- ascenderkit/exceptions.py | 8 ------- 6 files changed, 2 insertions(+), 83 deletions(-) delete mode 100644 ascenderkit/api/pages/subscriptions.py diff --git a/ascenderkit/api/pages/__init__.py b/ascenderkit/api/pages/__init__.py index 1a2bcdb..f03ecdb 100644 --- a/ascenderkit/api/pages/__init__.py +++ b/ascenderkit/api/pages/__init__.py @@ -39,7 +39,6 @@ from .instance_groups import * # NOQA from .credential_input_sources import * # NOQA from .metrics import * # NOQA -from .subscriptions import * # NOQA from .workflow_approval_templates import * # NOQA from .host_metrics import * # NOQA from .receptor_addresses import * # NOQA diff --git a/ascenderkit/api/pages/config.py b/ascenderkit/api/pages/config.py index 7745cb3..7099391 100644 --- a/ascenderkit/api/pages/config.py +++ b/ascenderkit/api/pages/config.py @@ -4,36 +4,7 @@ class Config(base.Base): - @property - def is_aws_license(self): - return self.license_info.get('is_aws', False) or 'ami-id' in self.license_info or 'instance-id' in self.license_info - - @property - def is_valid_license(self): - return self.license_info.get('valid_key', False) and 'instance_count' in self.license_info - - @property - def is_trial_license(self): - return self.is_valid_license and self.license_info.get('trial', False) - - @property - def is_ascender_license(self): - return self.license_info.get('license_type', None) == 'open' - - @property - def is_enterprise_license(self): - return self.is_valid_license and self.license_info.get('license_type', None) == 'enterprise' - - @property - def features(self): - """returns a list of enabled license features""" - return [k for k, v in self.license_info.get('features', {}).items() if v] - - -class ConfigAttach(page.Page): - def attach(self, **kwargs): - return self.post(json=kwargs).json + pass page.register_page(resources.config, Config) -page.register_page(resources.config_attach, ConfigAttach) diff --git a/ascenderkit/api/pages/page.py b/ascenderkit/api/pages/page.py index 3aa32d8..8d8a07f 100644 --- a/ascenderkit/api/pages/page.py +++ b/ascenderkit/api/pages/page.py @@ -21,30 +21,6 @@ get_registered_page = _page_registry.get -def is_license_invalid(response): - if "Invalid license" in response.text: - return True - if "Missing 'eula_accepted' property" in response.text: - return True - if "'eula_accepted' must be True" in response.text: - return True - if "Invalid license data" in response.text: - return True - - -def is_license_exceeded(response): - if "license range of" in response.text and "instances has been exceeded" in response.text: - return True - if "License count of" in response.text and "instances has been reached" in response.text: - return True - if "License count of" in response.text and "instances has been exceeded" in response.text: - return True - if "License has expired" in response.text: - return True - if "License is missing" in response.text: - return True - - def is_duplicate_error(response): if "already exists" in response.text: return True @@ -222,16 +198,9 @@ def page_identity(self, response, request_json=None): return registered_type(self.connection, endpoint=endpoint, json=data, last_elapsed=response.elapsed, r=response, ds=ds) elif response.status_code == http.FORBIDDEN: - if is_license_invalid(response): - raise exc.LicenseInvalid(exc_str, data) - elif is_license_exceeded(response): - raise exc.LicenseExceeded(exc_str, data) - else: - raise exc.Forbidden(exc_str, data) + raise exc.Forbidden(exc_str, data) elif response.status_code == http.BAD_REQUEST: - if is_license_invalid(response): - raise exc.LicenseInvalid(exc_str, data) if is_duplicate_error(response): raise exc.Duplicate(exc_str, data) else: diff --git a/ascenderkit/api/pages/subscriptions.py b/ascenderkit/api/pages/subscriptions.py deleted file mode 100644 index e8dc5f8..0000000 --- a/ascenderkit/api/pages/subscriptions.py +++ /dev/null @@ -1,10 +0,0 @@ -from ascenderkit.api.resources import resources -from . import page - - -class Subscriptions(page.Page): - def get_possible_licenses(self, **kwargs): - return self.post(json=kwargs).json - - -page.register_page(resources.subscriptions, Subscriptions) diff --git a/ascenderkit/api/resources.py b/ascenderkit/api/resources.py index cf417e3..555c87f 100644 --- a/ascenderkit/api/resources.py +++ b/ascenderkit/api/resources.py @@ -19,7 +19,6 @@ class Resources: _bulk = 'bulk/' _bulk_job_launch = 'bulk/job_launch/' _config = 'config/' - _config_attach = 'config/attach/' _credential = r'credentials/\d+/' _credential_access_list = r'credentials/\d+/access_list/' _credential_copy = r'credentials/\d+/copy/' @@ -292,7 +291,6 @@ class Resources: _workflow_job_template_workflow_nodes = r'workflow_job_templates/\d+/workflow_nodes/' _workflow_job_templates = 'workflow_job_templates/' _workflow_job_workflow_nodes = r'workflow_jobs/\d+/workflow_nodes/' - _subscriptions = 'config/subscriptions/' _workflow_jobs = 'workflow_jobs/' api = str(config.api_base_path) common = api + r'v\d+/' diff --git a/ascenderkit/exceptions.py b/ascenderkit/exceptions.py index c33419b..beb3310 100644 --- a/ascenderkit/exceptions.py +++ b/ascenderkit/exceptions.py @@ -51,14 +51,6 @@ class BadGateway(Common): pass -class LicenseExceeded(Common): - pass - - -class LicenseInvalid(Common): - pass - - class MethodNotAllowed(Common): pass