foliolib.okapi.okapiClient.OkapiClient
- class foliolib.okapi.okapiClient.OkapiClient(host: str = None, port: str = None, path: str = None, ssl: bool = False)
Bases:
objectAn Okapi client
https://s3.amazonaws.com/foliodocs/api/okapi/p/okapi.html
- Parameters
host (str, optional) – IP or Hostame of the Okapi server. Defaults from foliolib.conf.
port (str, optional) – . Defaults from foliolib.conf.
Methods
add_module(module, **kwargs)Add a module
call_tenant_service(tenantId, method, path)Call a tenant service
create_tenant(tenantId[, name, description])Create a new tenant
delete_env(name)Delete an enviroment variable.
deploy_module(modId[, node])Deploy a module.
disable_all_modules(tenantId, **kwargs)Disable all modules of a tenant
disable_module(modId, tenantId, **kwargs)Disable a module for a tenant.
disable_modules(modIds, tenantId, **kwargs)Disable modules for a tenant.
enable_module(tenantId, modId[, loadSample, ...])Enable a module for a tenant
enable_modules(tenantId, modIds[, ...])Enable modules for a tenant
get_deployed_module(modId[, instanceId])Get deployed module
Get all deployed modules.
get_env()Get enviroment variables.
get_install_jobs(tenantId[, install_id])Get install jobs for a tenant
get_module(modId)Retrieve descriptor for a particular module
get_modules(**kwargs)List all or subset of modules for proxy
Get list of all nodes
get_tenant_interface(tenantId, interfaceId, ...)Get interface for a tenant.
get_tenant_interfaces(tenantId, **kwargs)Get all interfaces of a tenant
get_tenant_module(self, modId)Get a module of a tenant
get_tenant_modules(tenantId, **kwargs)Get a list of all modules of a tenant.
Get a list of all tenants
health([serviceID, instanceId])Check health of modules
install_modules(tenantModuleDescriptorList, ...)Enable, disable or upgrade one or more modules for tenant.
is_module_added(module)Is module added?
is_module_deployed(modId)Is module deployed.
is_module_enabled(modId, tenantId)Check if a module is enabled.
modify_tenant(tenantId[, name, description])Modify a tenant
remove_module(module)Remove module descriptor for a particular module, module will no longer be selectable by tenants.
remove_tenant(tenantId)Remove a tenant
request(method, path[, data, query, ...])Make a request
set_env(name, value[, description])Set an enviroment variable.
undeploy_module(modId[, instanceId])Remove registration for a given instance.
Remove registration for all instances
upgrade_modules(tenantId[, modules, ...])[summary]
version()Get the Okapi version.
- add_module(module: Union[str, foliolib.okapi.okapiModule.OkapiModule], **kwargs)
Add a module
- Parameters
module (Union[str, OkapiModule]) – Module id, Module Descriptor or instance of OkapiModule
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
check (boolean) – default = true Whether to check dependencies
preRelease (boolean) – default = true Whether to allow pre-release modules in dependency check
npmSnapshot (boolean) – default = true Whether to allow NPM module snapshots in dependency check
- Returns
Module descriptor
- Return type
dict
- call_tenant_service(tenantId: str, method: str, path: str, data: dict = None, query: dict = None, headers: dict = None, files: dict = None)
Call a tenant service
- Parameters
tenantId (str) – Tenant id
method (str) – HTML method (GET, POST, PUT, DELETE …)
path (str) – Path of the service
data (dict, optional) – Post data to call the service. Defaults to None.
query (dict, optional) – Query data to call the service. Defaults to None.
headers (dict, optional) – Headers to call the service. Defaults to None.
files (dict, optional) – Files to upload. Defaults to None.
- Returns
Return data of the service
- Return type
any
- create_tenant(tenantId: str, name: str = '', description: str = '')
Create a new tenant
- Parameters
tenantId (str) – Tenant id
name (str, optional) – Name of the tenant. Defaults to “”.
description (str, optional) – Description of the tenant. Defaults to “”.
- delete_env(name: str)
Delete an enviroment variable.
- Parameters
name (str) – Name of the enviroment variable.
- deploy_module(modId: Union[str, foliolib.okapi.okapiModule.OkapiModule], node: str = None)
Deploy a module.
- Parameters
modId (Union[str, OkapiModule]) – Module id or instance of OkapiModule.
node (str) – The node id on which module should be deployed. Default first node from nodes list.
- Returns
Deployment descriptor.
- Return type
dict
- disable_all_modules(tenantId: str, **kwargs)
Disable all modules of a tenant
- Parameters
tenantId (str) – Tenant id
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
invoke (boolean) – default = true Whether to invoke for tenant init/permissions/purge
purge (boolean) – default = false Disabled modules will also be purged.
tenantParameters (string) – Parameters for Tenant init
- disable_module(modId: str, tenantId: str, **kwargs)
Disable a module for a tenant.
- Parameters
modId (str) – Module id
tenantId (str) – Tenant id
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
ignoreErrors (boolean) – default = false Okapi 4.2.0 and later, it is possible to ignore errors during the install operation. This is done by supplying parameter ignoreErrors=true. In this case, Okapi will try to upgrade all modules in the modules list, regardless if one of them fails. However, for individual modules, if they fail, their upgrade will not be commited. This is an experimental parameter which was added to be able to inspect all problem(s) with module upgrade(s).
invoke (boolean) – default = true Whether to invoke for tenant init/permissions/purge
purge (boolean) – default = false Disabled modules will also be purged.
simulate (boolean) – default = false Whether the installation is simulated
- Returns
Dict with disabled modules
- Return type
dict
- disable_modules(modIds: str, tenantId: str, **kwargs)
Disable modules for a tenant.
- Parameters
modIds (str) –
tenantId (str) –
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
async (boolean) – default = false Whether to uninstall in the background
deploy (boolean) – default = false Whether to undeploy
ignoreErrors (boolean) – default = false Okapi 4.2.0 and later, it is possible to ignore errors during the install operation. This is done by supplying parameter ignoreErrors=true. In this case, Okapi will try to upgrade all modules in the modules list, regardless if one of them fails. However, for individual modules, if they fail, their upgrade will not be commited. This is an experimental parameter which was added to be able to inspect all problem(s) with module upgrade(s).
invoke (boolean) – default = true Whether to invoke for tenant init/permissions/purge
npmSnapshot (boolean) – default = true Whether to include NPM module snapshots (default:true).
purge (boolean) – default = false Disabled modules will also be purged.
simulate (boolean) – default = false Whether the installation is simulated
- Returns
Dict with disabled modules
- Return type
dict
- enable_module(tenantId: str, modId: str, loadSample: bool = False, loadReference: bool = False, upgrade=False, **kwargs)
Enable a module for a tenant
- Parameters
tenantId (str) – Tenant id
modId (str) – Module id
loadSample (bool, optional) – If samples should loaded. Defaults to False.
loadReference (bool, optional) – If references should loaded. Defaults to False.
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
async (boolean) – default = false Whether to install in the background
deploy (boolean) – default = false Whether to deploy
ignoreErrors (boolean) – default = false Okapi 4.2.0 and later, it is possible to ignore errors during the install operation. This is done by supplying parameter ignoreErrors=true. In this case, Okapi will try to upgrade all modules in the modules list, regardless if one of them fails. However, for individual modules, if they fail, their upgrade will not be commited. This is an experimental parameter which was added to be able to inspect all problem(s) with module upgrade(s).
invoke (boolean) – default = true Whether to invoke for tenant init/permissions/purge
npmSnapshot (boolean) – default = true Whether to include NPM module snapshots (default:true).
preRelease (boolean) – default = true Whether pre-releases should be considered for installation.
simulate (boolean) – default = false Whether the installation is simulated
- Returns
Tenant module descriptor
- Return type
dict
- enable_modules(tenantId: str, modIds: list, loadSample: bool = False, loadReference: bool = False, deploy=False, **kwargs)
Enable modules for a tenant
- Parameters
tenantId (str) – Tenant id
modIds (list) – List with Module ids
loadSample (bool, optional) – If samples should loaded. Defaults to False.
loadReference (bool, optional) – If references should loaded. Defaults to False.
deploy (boolean) – Whether to deploy. Defaults to False
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
async (boolean) – default = false Whether to install in the background
ignoreErrors (boolean) – default = false Okapi 4.2.0 and later, it is possible to ignore errors during the install operation. This is done by supplying parameter ignoreErrors=true. In this case, Okapi will try to upgrade all modules in the modules list, regardless if one of them fails. However, for individual modules, if they fail, their upgrade will not be commited. This is an experimental parameter which was added to be able to inspect all problem(s) with module upgrade(s).
invoke (boolean) – default = true Whether to invoke for tenant init/permissions/purge
npmSnapshot (boolean) – default = true Whether to include NPM module snapshots (default:true).
preRelease (boolean) – default = true Whether pre-releases should be considered for installation.
simulate (boolean) – default = false Whether the installation is simulated
- Returns
Tenant module descriptors
- Return type
dict
- get_deployed_module(modId: Union[str, foliolib.okapi.okapiModule.OkapiModule], instanceId: str = None)
Get deployed module
- Parameters
modId (Union[str, OkapiModule]) – Module id or instance of OkapiModule.
instanceId (str, optional) – Instance id. Defaults to None.
- Returns
Deployment descriptor
- Return type
dict
- get_deployed_modules()
Get all deployed modules.
- Returns
Dict with deployment descriptors.
- Return type
dict
- get_env()
Get enviroment variables.
- Returns
Enviroment variables
- Return type
dict
- get_install_jobs(tenantId: str, install_id: str = None)
Get install jobs for a tenant
- Parameters
tenantId (str) – Tenant id
install_id (str, optional) – Install id. Defaults to None.
- Returns
Dict with install jobs
- Return type
dict
- get_module(modId: str)
Retrieve descriptor for a particular module
- Parameters
modId (str) – Module id.
- Returns
Module descriptor
- Return type
dict
- get_modules(**kwargs)
List all or subset of modules for proxy
- Parameters
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
dot (boolean) – default = false If true, return Graphviz DOT content as plain text
filter (string) – Filter by module ID
full (boolean) – default = false Whether full or compact MD should be returned
latest (integer) – Limit to latest N releases (most likely 1 if given)
npmSnapshot (boolean) – default = true Whether to include NPM module snapshots
order (one of desc, asc) – Order
orderBy (string) – Order by field
preRelease (boolean) – default = true Whether to include modules with pre-release info
provide (string) – Limit to provided interface
require (string) – Limit to required interface
scope (string) – Limit to interface scope (only useful with provide and require)
- Returns
Dict with modules
- Return type
dict
- get_nodes()
Get list of all nodes
- Returns
Dict with node items.
- Return type
dict
- get_tenant_interface(tenantId: str, interfaceId: str, **kwargs)
Get interface for a tenant.
- Parameters
tenantId (str) – Tenant id
interfaceId (str) – Interface id
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
type (string) – Limit by interfaceType
- Returns
Dict with a interface of a tenant.
- Return type
dict
- get_tenant_interfaces(tenantId: str, **kwargs)
Get all interfaces of a tenant
- Parameters
tenantId (str) – Tenant id.
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
full (boolean) – default = false Whether brief or full interface list
type (string) – Limit by interfaceType
- Returns
Dict with interfaces of a tenant.
- Return type
dict
- get_tenant_module(self, modId: str)
Get a module of a tenant
- Parameters
tenantId (str) – Tenant id.
modId (str) – Module id.
- Returns
Dict with module data.
- Return type
dict
- get_tenant_modules(tenantId: str, **kwargs)
Get a list of all modules of a tenant.
- Parameters
tenantId (str) – Tenant id.
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
dot (boolean) – default: = false If true, return Graphviz DOT content as plain text
filter (string) – Filter by module ID
full – (boolean): default = false Whether full or compact MD should be returned
latest (integer) – Limit to latest N releases (most likely 1 if given)
npmSnapshot (boolean) – default = true Whether to include NPM module snapshots
order (one of desc, asc) – Order
orderBy (string) – Order by field
preRelease (boolean) – default: true Whether to include modules with pre-release info
provide (string) – Limit to provided interface
require (string) – Limit to required interface
scope (string) – Limit to interface scope (only useful with provide and require)
- Returns
Modules registered at a tenant
- Return type
dict
- get_tenants()
Get a list of all tenants
- Returns
Dict with all tenants
- Return type
dict
- health(serviceID: str = None, instanceId: str = None)
Check health of modules
- Parameters
serviceID (str, optional) – Get Health for service with serviceID. Defaults to None.
instanceId (str, optional) – Get Health for instance with instanceId. Defaults to None.
- Returns
Dict with health status.
- Return type
dict
- install_modules(tenantModuleDescriptorList: list, tenantId: str, loadSample: bool = False, loadReference: bool = False, **kwargs)
Enable, disable or upgrade one or more modules for tenant. The request body and response body is of the same type TenantModuleDescriptorList. This list includes one or more modules to be enabled, disabled or upgraded. The request is the initial desired changes and the response is the list of changes that must be fulfilled to satisfy dependencies. This service will eventually partially replace /_/proxy/tenants/{tenant}/modules . It also allows enabling multiple modules in one transaction. For simulate=true, the response, can be viewed as a recipe for what must be deployed (optionally) and enabled/disabled by the existing tenants-modules CRUD service.
- Parameters
tenantModuleDescriptorList (list) –
tenantId (str) –
loadSample (bool, optional) – If samples should loaded. Defaults to False.
loadReference (bool, optional) – If references should loaded. Defaults to False.
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
async (boolean) – default = false Whether to install in the background
deploy (boolean) – default = false Whether to deploy (or undeploy if disabling)
ignoreErrors (boolean) – default = false Okapi 4.2.0 and later, it is possible to ignore errors during the install operation. This is done by supplying parameter ignoreErrors=true. In this case, Okapi will try to upgrade all modules in the modules list, regardless if one of them fails. However, for individual modules, if they fail, their upgrade will not be commited. This is an experimental parameter which was added to be able to inspect all problem(s) with module upgrade(s).
invoke (boolean) – default = true Whether to invoke for tenant init/permissions/purge
npmSnapshot (boolean) – default = true Whether to include NPM module snapshots (default:true).
preRelease (boolean) – default = true Whether pre-releases should be considered for installation.
purge (boolean) – default = false Disabled modules will also be purged.
reinstall – (boolean - default: false) Whether to install modules even if up-to-update.
simulate (boolean) – default = false Whether the installation is simulated
- Returns
Tenant module descriptors
- Return type
dict
- is_module_added(module: Union[str, foliolib.okapi.okapiModule.OkapiModule])
Is module added?
- Parameters
module (Union[str, OkapiModule]) – Module id, Module Descriptor or instance of OkapiModule
- Returns
wether module is added.
- Return type
bool
- is_module_deployed(modId: Union[str, foliolib.okapi.okapiModule.OkapiModule])
Is module deployed.
- Parameters
modId (Union[str, OkapiModule]) – Module id or instance of OkapiModule.
- Returns
wether module is deployed.
- Return type
bool
- is_module_enabled(modId: str, tenantId: str)
Check if a module is enabled.
- Parameters
modId (str) – Modulename
tenantId (str) – Tenant id
- Returns
Wether module is enabled.
- Return type
bool
- modify_tenant(tenantId: str, name: str = '', description: str = '')
Modify a tenant
- Parameters
tenantId (str) – Tenant id
name (str, optional) – Name of the tenant. Defaults to “”.
description (str, optional) – Description of the tenant. Defaults to “”.
- remove_module(module: Union[str, foliolib.okapi.okapiModule.OkapiModule])
Remove module descriptor for a particular module, module will no longer be selectable by tenants.
- Parameters
module (Union[str, OkapiModule]) – Module id, Module Descriptor or instance of OkapiModule
- remove_tenant(tenantId: str)
Remove a tenant
- Parameters
tenantId (str) – Tenant id
- request(method: str, path: str, data: dict = None, query: dict = None, headers: dict = None, files: dict = None)
Make a request
- Parameters
method (str) – HTML method (GET, POST, PUT, DELETE …)
path (str) – Path of the service
data (dict, optional) – Post data for the request. Defaults to None.
query (dict, optional) – Query data for the request. Defaults to None.
headers (dict, optional) – Headers for the request. Defaults to None.
files (dict, optional) – Files to upload. Defaults to None.
- Raises
OkapiRequestError –
OkapiRequestUnauthorized –
OkapiRequestForbidden –
OkapiRequestNotFound –
OkapiRequestNotAcceptable –
OkapiRequestTimeout –
OkapiRequestConflict –
OkapiRequestPayloadToLarge –
OkapiRequestUnprocessableEntity –
OkapiFatalError –
OkapiException –
- Returns
return the response of the request
- Return type
any
- set_env(name: str, value: str, description: str = '')
Set an enviroment variable.
- Parameters
name (str) – Name of the enviroment variable.
value (str) – Value of the enviroment variable.
description (str) – Optional description for the enviroment variable.
- Returns
Dict of the enviroment variable.
- Return type
dict
Headers
Location - URI to the environment entry instance
- undeploy_module(modId: Union[str, foliolib.okapi.okapiModule.OkapiModule], instanceId=None)
Remove registration for a given instance.
- Parameters
modId (Union[str, OkapiModule]) – Module id or instance of OkapiModule.
instanceId (str, optional) – Instance id. Defaults to None.
- undeploy_modules()
Remove registration for all instances
- upgrade_modules(tenantId: str, modules: list = None, loadSample: bool = False, loadReference: bool = False, **kwargs)
[summary]
- Parameters
tenantId (str) – Tenant id
loadSample (bool, optional) – If samples should loaded. Defaults to False.
loadReference (bool, optional) – If references should loaded. Defaults to False.
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
async (boolean) – default = false Whether to upgrade in the background
deploy (boolean) – default = false Whether to deploy (or undeploy if disabling)
ignoreErrors (boolean) – default = false Okapi 4.2.0 and later, it is possible to ignore errors during the upgrade operation. This is done by supplying parameter ignoreErrors=true. In this case, Okapi will try to upgrade all modules in the modules list, regardless if one of them fails. However, for individual modules, if they fail, their upgrade will not be commited. This is an experimental parameter which was added to be able to inspect all problem(s) with module upgrade(s).
invoke (boolean) – default = true Whether to invoke for tenant init/permissions/purge
preRelease (boolean) – default = true Whether pre-releases should be considered for installation.
simulate (boolean) – default = false Whether the upgrade is simulated
tenantParameters (string) – Parameters for Tenant init
- Returns
Tenant module descriptors
- Return type
dict
- version()
Get the Okapi version.
- Returns
Okapi version
- Return type
str