Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ascenderkit/api/pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 1 addition & 30 deletions ascenderkit/api/pages/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
33 changes: 1 addition & 32 deletions ascenderkit/api/pages/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions ascenderkit/api/pages/subscriptions.py

This file was deleted.

2 changes: 0 additions & 2 deletions ascenderkit/api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Expand Down Expand Up @@ -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+/'
Expand Down
8 changes: 0 additions & 8 deletions ascenderkit/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ class BadGateway(Common):
pass


class LicenseExceeded(Common):
pass


class LicenseInvalid(Common):
pass


class MethodNotAllowed(Common):
pass

Expand Down