as3ninja.schema package

Submodules

as3ninja.schema.as3schema module

AS3 Schema Class module. Represents the AS3 JSON Schema as a python class.

class as3ninja.schema.as3schema.AS3Schema(version='latest')[source]

Bases: object

Creates a AS3Schema instance of specified version. The validate() method provides AS3 Declaration validation based on the AS3 JSON Schema.

Parameters:

version (str) – AS3 Schema version (Default value = “latest”)

_SCHEMA_FILENAME_GLOB = '**/as3-schema-*.json'
_SCHEMA_LOCAL_FSPATH = PosixPath('/home/docs/.as3ninja/f5-appsvcs-extension/schema')
_SCHEMA_REF_URL_TEMPLATE = '/home/docs/.as3ninja/f5-appsvcs-extension/schema/{{version}}/as3-schema-{{version}}-*.json'
__schemalist_sort_helper(value)

Private Method: A sort helper.

Sorts based on the schema version (converted to int).

Return type:

int

__version_sort_helper(value)

Private Method: A sort helper. converts value: str to int and removes “.”

Parameters:

value (str) – str: A version str (example: “3.8.1”)

Return type:

int

_build_ref_url(version)[source]

Private Method: _build_ref_url builds the absolute filesystem url to the AS3 Schema file for specified version.

Parameters:

version (str) – The AS3 Schema version

Return type:

str

_check_version(version)[source]

Private Method: _check_version checks if the specified version exists in available schemas. In case the specified schema version is not loaded, it will load the version. It converts “latest” to the actual version.

The checked version is returned as str.

Return type:

str

_latest_version: str = ''
_load_schema(version, force=False)[source]

Private Method: load schema file from disk for specified version. force parameter can be used to force load the schema file, even if it has been read already.

Return type:

None

_ref_update(schema, _ref_url)[source]

Private Method: _ref_update performs an in-place update of relative $ref (starting with #) into absolute references by prepending _ref_url.

See: https://github.com/Julian/jsonschema/issues/570

Return type:

None

_schema_ref_update(version)[source]

Private Method: _schema_ref_update returns the AS3 Schema for specified version with updated references.

Parameters:

version (str) – The AS3 Schema version

Return type:

dict

_schemas: dict = {}
_schemas_ref_updated: dict = {}
_sort_schemas()[source]

Private Method: Sorts the schemas class attribute according to version

Return type:

None

_update_versions(versions)[source]

Private Method: Updates and sorts the versions class attribute

Return type:

None

static _validate_schema_version_format(version)[source]

Private Method: validates the format and minimum version.

Parameters:

version (str) – str: AS3 Schema version

Return type:

None

_validator(version)[source]

Creates jsonschema.Draft7Validator for specified AS3 schema version. Will check schema is valid and raise a jsonschema SchemaError otherwise. Memoizes the Draft7Validator instance for faster re-use.

Return type:

None

_validators: dict = {}
_versions: tuple = ()
property is_latest: bool

Property: returns bool(True) if this instance has the latest Schema version available. Returns False otherwise.

property latest_version: str

Property: returns the latest AS3 schema version as str.

property schema: dict

Property: returns the Schema of this AS3 Schema instance as dict.

property schema_asjson: str

Property: returns the Schema as JSON of this AS3 Schema instance as a python str.

property schemas: dict

Property: returns all known AS3 Schemas as dict.

updateschemas(githubrepo='https://github.com/F5Networks/f5-appsvcs-extension', repodir='/home/docs/.as3ninja/f5-appsvcs-extension')[source]

Method: Fetches/Updates AS3 Schemas from the GitHub Repository.

Parameters:
  • githubrepo (str) – str: Git/Github repository to fetch AS3 Schemas from (Default value = constant NINJASETTINGS.SCHEMA_GITHUB_REPO)

  • repodir (str) – str: Target directory to clone to (Default value = constant NINJASETTINGS.SCHEMA_BASE_PATH)

Return type:

None

validate(declaration, version=None)[source]

Method: Validates a declaration against the AS3 Schema. Raises a AS3ValidationError on failure.

Parameters:
  • declaration (Union[dict, str]) – Declaration to be validated against the AS3 Schema.

  • version (Optional[str]) – Allows to validate the declaration against the specified version instead of this AS3 Schema instance version. If set to “auto”, the version of the declaration is used.

Return type:

None

property version: str

Property: returns the Schema version of this AS3 Schema instance as str.

property versions: tuple

Property: returns all versions available as a sorted tuple.

as3ninja.schema.formatcheckers module

AS3 Schema Format Checker for F5 specific formats.

class as3ninja.schema.formatcheckers.AS3FormatChecker(*args, **kwargs)[source]

Bases: FormatChecker

AS3FormatChecker subclasses jsonschema.FormatChecker to provide AS3 specific format checks.

static _is_type(is_type, value)[source]

Helper function _is_type returns True when is_type(value) does not raise an exception, False otherwise

Parameters:
  • is_type (Any) – The type to check against

  • value (Any) – Value to check

Return type:

bool

static _regex_match(regex, value)[source]

Helper function _regex_match matches a regular expression against the given value. Returns True when regex matches, False otherwise.

Parameters:
  • regex (str) – The regular expression, for example: r'^[ -~]+$'

  • value (str) – Value to apply the regular expression to

Return type:

bool

property as3_schema_format_checkers: dict

Returns dict of AS3 formats: f5ip, f5ipv4, f5ipv6, f5label, f5long-id, f5remark, f5pointer, f5base64 Currently missing formats used in AS3:

  • date-time

  • uri

  • url

Module contents

AS3 Schema package.