appngizer package¶
Submodules¶
appngizer.client module¶
This module contains network clients which are used to communicate with an appNGizer instance.
Currently there is only an implementation of a XMLClient.
-
class
appngizer.client.Client(url, sharedsecret)[source]¶ Bases:
objectAbstract class of an appNGizer client All further appNGizer clients will inherits from this class
-
REGEX_URL= <_sre.SRE_Pattern object at 0x332f430>¶
-
-
class
appngizer.client.ClientNetwork[source]¶ Bases:
objectappNGizer ClientNetwork class
-
class
appngizer.client.Singleton[source]¶ Bases:
typeSingleton class pattern to be used as metaclass for the
Client.
-
class
appngizer.client.XMLClient(url, sharedsecret)[source]¶ Bases:
appngizer.client.ClientappNGizer XML Client class
appngizer.elements module¶
This module contains all appNG entities which currently can managed via an appNGizer instance:
PropertySiteRepositoryApplicationPackageSubjectGroupRolePermissionDatabasePlatform(only for reload)
To do this the appngizer.elements.Element.xml attribute
helds the xml representation of the entity as an lxml.etree.Element.
CRUD methods on the entity are done via the
appngizer.client.XMLClient where the appngizer.elements.Element.xml attribute
is added to the data of the HTTP/S request if needed (usually in a PUT/POST request).
There also container elements where appNG entities of the same entity type are held. Currently they are only usable for read operations (f.e. read all available Sites) but can be the start point for further improvements like bulk operatios.
To address an appNG entity we use their appngizer.elements.Element.name attribute, the entity
type name appngizer.elements.Element.TYPE and their appngizer.elements.Element.parents attribute.
Examples:
Site entity ‘an_appng_site’:
Site('an_appng_site')
Site application property ‘a_site_app_property’:
Property('a_site_app_property', parents=[ Site('an_appng_site') , Application('an_app') ] )
-
class
appngizer.elements.Application(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage applications of an appNG instance
-
ALLOWED_FIELDS= ['displayName', 'core', 'fileBased', 'hidden', 'version']¶
-
TYPE= 'Application'¶
-
TYPE_C= 'Applications'¶
-
assign(site)[source]¶ Assigns application to a site
Parameters: site (elements.Site) – site object Returns: xml of assigned application
-
assign_by_name(site_name)[source]¶ Assigns application to a site via site_name
Parameters: site_name (elements.Site) – str Returns: xml of assigned application
-
deassign(site)[source]¶ Deassigns application from a site
Parameters: site (elements.Site) – site object Returns: xml of deassigned application
-
deassign_by_name(site_name)[source]¶ Deassigns application from a site via site_name
Parameters: site_name (elements.Site) – str Returns: xml of deassigned application
-
delete()[source]¶ Deletes an application
With additional check if application is assigned to any site before try to delete
Returns: bool (True if deleted)
-
is_assigned(site=None)[source]¶ Checks if application is already assigned to a site
Parameters: site (elements.Site) – site object Returns: bool (True if assigned, False if not assigned)
-
is_update_needed(hidden=False, core=False, fileBased=False, displayName=None)[source]¶ Checks if update of application is needed
Parameters: Returns: bool (True if needed, False if not needed), xml of current application, xml of desired application
-
read(site=None)[source]¶ Reads application from platform or if given from an assigned site
Returns: xml of application
-
-
class
appngizer.elements.Applications(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage application of an appNG instance
-
TYPE= 'Application'¶
-
TYPE_C= 'Applications'¶
-
-
class
appngizer.elements.Database(name='', parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage databases of an appNG instance
-
ALLOWED_FIELDS= ['user', 'password', 'driver', 'url']¶
-
TYPE= 'Database'¶
-
TYPE_C= 'Databases'¶
-
create()[source]¶ Creates a database
Raises: errors.ElementError – create is not avaible for database
-
is_update_needed(user, password, salt, driver, url)[source]¶ Checks if update of database is needed
Parameters: Returns: bool (True if needed, False if not needed), xml of current database, xml of desired database
-
-
class
appngizer.elements.Databases(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage databases of an appNG instance
-
TYPE= 'Database'¶
-
TYPE_C= 'Databases'¶
-
-
class
appngizer.elements.Element(name=None, parents=None, xml=None)[source]¶ Bases:
objectAbstract class of an appNGizer element All further appngizer elements will inherits from this class
-
ALLOWED_ATTRIBUTES= []¶
-
ALLOWED_CDATA_FIELDS= []¶
-
ALLOWED_CHILDS= []¶
-
ALLOWED_FIELDS= []¶
-
PRESERVED_FIELDS= ['description', 'displayName']¶
-
TYPE= 'Element'¶
-
TYPE_C= 'Elements'¶
-
XPATH_DEFAULT_NAMESPACE= {'a': 'http://www.appng.org/schema/appngizer'}¶
-
XSD_APPNGIZER_PATH= '/var/lib/jenkins/workspace/on-appngizer_release_1.14.2-XRZ3CXTNASI2QKJSRBQVSWLXVX444XPEDMNGTLZHMLBLZH6P2XHA/appngizer/appngizer.xsd'¶
-
dump(xml=None)[source]¶ Pretty print an etree as string
Parameters: xml (lxml.etree.Element) – xml to be pretty printed, if not given self.xml is used Returns: string with pretty printed xml
-
-
class
appngizer.elements.Elements(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementAbstract class of an appNGizer container element All further appngizer container elements will inherits from this class
Currently only reading is implemented.
-
class
appngizer.elements.Group(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage groups of an appNG instance.
-
ALLOWED_CHILDS= ['roles']¶
-
ALLOWED_FIELDS= ['description']¶
-
TYPE= 'Group'¶
-
TYPE_C= 'Groups'¶
-
create(description=None, roles=[])[source]¶ Creates a new group
Parameters: Returns: xml of created group
-
-
class
appngizer.elements.Groups(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage groups of an appNG instance
-
TYPE= 'Group'¶
-
TYPE_C= 'Groups'¶
-
-
class
appngizer.elements.Package(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage packages of an appNG instance
-
ALLOWED_FIELDS= ['displayName', 'version', 'timestamp', 'release', 'snapshot', 'installed', 'type']¶
-
TYPE= 'Package'¶
-
TYPE_C= 'Packages'¶
-
delete()[source]¶ Deletes a package
Raises: appngizer.errors.ElementError – delete is not avaible for packages
-
exist(version, timestamp=None)[source]¶ Checks if package exist
Parameters: Returns: bool (True if exist, False if not exist)
-
install(version, timestamp=None, type='APPLICATION')[source]¶ Installs a package
Parameters: Returns: xml of installed package
-
is_installed()[source]¶ Checks if a package is already installed
Returns: bool (True if installed, False if not installed)
-
is_update_needed(version, timestamp=None)[source]¶ Checks if update of an installed package is needed
Parameters: Returns: bool (True if needed, False if not needed), xml of current package, xml of desired package
-
-
class
appngizer.elements.Packages(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage packages of an appNG instance
-
TYPE= 'Package'¶
-
TYPE_C= 'Packages'¶
-
-
class
appngizer.elements.Permission(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage roles of an appNG instance
-
ALLOWED_FIELDS= ['description']¶
-
TYPE= 'Permission'¶
-
TYPE_C= 'Permissions'¶
-
create(description=None)[source]¶ Creates a new permission
Parameters: description (str) – short description Returns: xml of created permission
-
-
class
appngizer.elements.Permissions(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage permissions of an appNG instance
-
TYPE= 'Permission'¶
-
TYPE_C= 'Permissions'¶
-
-
class
appngizer.elements.Platform(name='', parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage the platform of an appNG instance.
-
ALLOWED_FIELDS= []¶
-
TYPE= 'Platform'¶
-
TYPE_C= 'Platform'¶
-
delete()[source]¶ Deletes a platform
Raises: errors.ElementError – delete is not avaible for platform
-
-
class
appngizer.elements.Properties(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage properties of an appNG instance
-
TYPE= 'Property'¶
-
TYPE_C= 'Properties'¶
-
-
class
appngizer.elements.Property(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage properties of an appNG instance
-
ALLOWED_ATTRIBUTES= ['clob']¶
-
ALLOWED_FIELDS= ['value', 'defaultValue', 'description']¶
-
PRESERVED_FIELDS= ['description', 'defaultValue']¶
-
TYPE= 'Property'¶
-
TYPE_C= 'Properties'¶
-
create(value, defaultValue=None, description=None, clob=False)[source]¶ Creates a new property
Parameters: Returns: xml of created property
-
-
class
appngizer.elements.Repositories(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage repositories of an appNG instance
-
TYPE= 'Repository'¶
-
TYPE_C= 'Repositories'¶
-
-
class
appngizer.elements.Repository(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage repositories of an appNG instance
-
ALLOWED_FIELDS= ['description', 'remoteName', 'uri', 'enabled', 'strict', 'published', 'mode', 'type']¶
-
TYPE= 'Repository'¶
-
TYPE_C= 'Repositories'¶
-
create(uri, type='LOCAL', remoteName=None, mode='ALL', enabled=True, strict=False, published=False, description=None)[source]¶ Creates a new repository
Parameters: - uri (str) – uri to the packages (file:// or http|s://)
- type (str) – type of repository (LOCAL = local repository, REMOTE = remote repository)
- remoteName (str) – name of remote repository
- mode (str) – mode of repository (ALL = all packages, STABLE = only stable packages, SNAPSHOT = only snapshot packages)
- enabled (bool) – enable repository
- strict (bool) – use strict mode
- published (bool) – publish repository
- description (str) – short description
Returns: xml of created repository
-
is_update_needed(uri, type='LOCAL', remoteName=None, mode='ALL', enabled=True, strict=False, published=False, description=None)[source]¶ Checks if update of repository is needed
Parameters: - uri (str) – uri to the packages (file:// or http|s://)
- type (str) – type of repository (LOCAL = local repository, REMOTE = remote repository)
- remoteName (str) – name of remote repository
- mode (str) – mode of repository (ALL = all packages, STABLE = only stable packages, SNAPSHOT = only snapshot packages)
- enabled (bool) – enable repository
- strict (bool) – use strict mode
- published (bool) – publish repository
- description (str) – short description
Returns: bool (True if needed, False if not needed), xml of current repository, xml of desired repository
-
update(uri, type='LOCAL', remoteName=None, mode='ALL', enabled=True, strict=False, published=False, description=None)[source]¶ Updates a repository
Parameters: - uri (str) – uri to the packages (file:// or http|s://)
- type (str) – type of repository (LOCAL = local repository, REMOTE = remote repository)
- remoteName (str) – name of remote repository
- mode (str) – mode of repository (ALL = all packages, STABLE = only stable packages, SNAPSHOT = only snapshot packages)
- enabled (bool) – enable repository
- strict (bool) – use strict mode
- published (bool) – publish repository
- description (str) – short description
Returns: xml of updated repository
-
-
class
appngizer.elements.Role(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage roles of an appNG instance
-
ALLOWED_CHILDS= ['permissions']¶
-
ALLOWED_FIELDS= ['application', 'description']¶
-
TYPE= 'Role'¶
-
TYPE_C= 'Roles'¶
-
create(description=None, permissions=[])[source]¶ Creates a new role
Parameters: - description (str) – short description
- permissions (list) – list of
Permissionobjects the role should be assigned to
Returns: xml of created role
-
is_update_needed(description=None, permissions=[])[source]¶ Checks if update of role is needed
Parameters: - description (str) – short description
- permissions (list) – list of
Permissionobjects the role should be assigned to
Returns: bool (True if needed, False if not needed), xml of current role, xml of desired role
-
update(description=None, permissions=[])[source]¶ Updates a role
Parameters: - description (str) – short description
- permissions (list) – list of
Permissionobjects the role should be assigned to
Returns: xml of updated role
-
-
class
appngizer.elements.Roles(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage roles of an appNG instance
-
TYPE= 'Role'¶
-
TYPE_C= 'Roles'¶
-
-
class
appngizer.elements.Site(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage a site of an appNG instance
-
ALLOWED_FIELDS= ['host', 'domain', 'description', 'active', 'createRepositoryPath']¶
-
TYPE= 'Site'¶
-
TYPE_C= 'Sites'¶
-
create(host, domain, description=None, active=True, createRepositoryPath=True)[source]¶ Creates a new site
Parameters: Returns: xml of created site
-
is_update_needed(host, domain, description=None, active=True, createRepositoryPath=True)[source]¶ Checks if update of site is needed
Parameters: Returns: bool (True if needed, False if not needed), xml of current site, xml of desired site
-
-
class
appngizer.elements.Sites(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage sites of an appNG instance
-
TYPE= 'Site'¶
-
TYPE_C= 'Sites'¶
-
-
class
appngizer.elements.Subject(name=None, parents=None, xml=None)[source]¶ Bases:
appngizer.elements.ElementClass to manage subjects of an appNG instance
-
ALLOWED_CHILDS= ['groups']¶
-
ALLOWED_FIELDS= ['realName', 'email', 'description', 'digest', 'timeZone', 'language', 'type']¶
-
TYPE= 'Subject'¶
-
TYPE_C= 'Subjects'¶
-
create(realName, digest, email, description=None, language='en', type='LOCAL_USER', timeZone='Europe/Berlin', groups=[])[source]¶ Creates a new subject
Parameters: - realName (str) – real name
- digest (str) – digest of subject (can be plaintext or bcrypt hash ($2a$13$))
- email (str) – e-mail address
- description (str) – short description
- language (str) – language setting
- type (str) – subject type (LOCAL_USER|GLOBAL_USER|GLOBAL_GROUP)
- timeZone (str) – timezone setting
- groups (list) – list of
Groupobjects the subject should be assigned to
Returns: xml of created subject
-
digest_match_hash(digest, hashed)[source]¶ Checks if digest match hash
If digest does not start with ‘$2a$’ it will handled as plaintext otherwise digest is directly matched against hashed
Parameters: Returns: bool (True if match, False if not match)
-
is_update_needed(realName, digest, email, description=None, language='en', type='LOCAL_USER', timeZone='Europe/Berlin', groups=[])[source]¶ Checks if update of subject is needed
Parameters: - realName (str) – real name
- digest (str) – digest of subject (can be plaintext or bcrypt hash ($2a$13$))
- email (str) – e-mail address
- description (str) – short description
- language (str) – language setting
- type (str) – subject type (LOCAL_USER|GLOBAL_USER|GLOBAL_GROUP)
- timeZone (str) – timezone setting
- groups (list) – list of
Groupobjects the subject should be assigned to
Returns: bool (True if needed, False if not needed), xml of current subject, xml of desired subject
-
update(realName, digest, email, description=None, language='en', type='LOCAL_USER', timeZone='Europe/Berlin', groups=[])[source]¶ Updates a subject
Parameters: - realName (str) – real name
- digest (str) – digest of subject (can be plaintext or bcrypt hash ($2a$13$))
- email (str) – e-mail address
- description (str) – short description
- language (str) – language setting
- type (str) – subject type (LOCAL_USER|GLOBAL_USER|GLOBAL_GROUP)
- timeZone (str) – timezone setting
- groups (list) – list of
Groupobjects the subject should be assigned to
Returns: xml of updated subject
-
-
class
appngizer.elements.Subjects(name='', parents=[], xml=None)[source]¶ Bases:
appngizer.elements.ElementsClass to manage subjects of an appNG instance
-
TYPE= 'Subject'¶
-
TYPE_C= 'Subjects'¶
-
appngizer.errors module¶
-
exception
appngizer.errors.CLIError[source]¶ Bases:
exceptions.Exception
-
exception
appngizer.errors.ClientError[source]¶ Bases:
appngizer.errors.Error
-
exception
appngizer.errors.ElementError[source]¶ Bases:
appngizer.errors.Error
-
exception
appngizer.errors.Error[source]¶ Bases:
exceptions.Exception
-
exception
appngizer.errors.HttpClientBadRequest[source]¶ Bases:
appngizer.errors.Error
-
exception
appngizer.errors.HttpElementConflict[source]¶ Bases:
appngizer.errors.Error
-
exception
appngizer.errors.HttpElementForbidden[source]¶ Bases:
appngizer.errors.Error
-
exception
appngizer.errors.HttpElementNotFound[source]¶ Bases:
appngizer.errors.Error
-
exception
appngizer.errors.HttpServerError[source]¶ Bases:
appngizer.errors.Error
-
exception
appngizer.errors.NotAllowedOp[source]¶ Bases:
appngizer.errors.Error
-
exception
appngizer.errors.XMLValidationError[source]¶ Bases:
appngizer.errors.Error