SecurityRatConnector’s documentation!

This module provides a connector to SecurityRat

class securityratconnector.SecurityRatConnector(apiEndpoint: str, verifyCertificates: bool = True, cached: bool = True)

SecurityRatConnector is a python class to access the SecurityRat API via REST. If cached is True all get requests will be cached to prevent unnecessary requests to the server. A changing request overrides the cache at the next get

Parameters
  • apiEndpoint (str) – API endpoint of SecurityRat. This is the full base URL like http://example.com/api

  • verifyCertificates (bool) – If False certificate validation is deactivated for the requests, default is True

  • cached (bool) – If enabled all get requests will be cached, default is True

addCollectionCategory(name: str, description: str, showOrder: int = 0, active: bool = False) → dict

Adds a collection category

Parameters
  • name (str) – The name of the object

  • description (str) – The description of the object

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

addCollectionInstance(name: str, description: str, collectionCategoryId: int, showOrder: int = 0, active: bool = False) → dict

Adds a new collection instance

Parameters
  • name (str) – The name of the object

  • description (str) – The description of the object

  • collectionCategoryId (int) – Id of the mapped collection category

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

addOptColumn(name: str, description: str, optColumnTypeId: int, showOrder: int = 0, active: bool = False, isVisibleByDefault: bool = True) → dict

Adds a optional column ti the server

Parameters
  • name (str) – The name of the object

  • description (str) – The description of the object

  • optColumnTypeId (int) – The mapped optional column type id

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

  • isVisibleByDefault (bool) – Sets if it is visible by default

Return dict

The requested optional column

addOptColumnContent(content: str, optColumnId: int, requirementSkeletonId: int) → dict

Add an optional column content to the server

Parameters
  • content (str) – The content of the optional column

  • optColumnId (id) – The mapped column id

  • requirementSkeletonId (id) – The mapped requirement skeleton category

Return dict

The requested optional column content

addOptColumnType(name: str, description: str) → dict

Adds a new optional column type

Parameters
  • name (str) – The name of the object

  • description (str) – The description of the object

Return dict

The answer from the server

addProjectType(name: str, description: str, statusColumnIds: List[int] = None, optColumnIds: List[int] = None, showOrder: int = 0, active: bool = False) → dict

Adds a project type to the server

Parameters
  • name (str) – The name of the object

  • description (str) – The description of the object

  • statusColumnIds (list) – A list of mapped status column Ids

  • optColumnIds (list) – A list of mapped optional column Ids

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The requested optional column content

addRequirementCategory(name: str, shortcut: str, description: str, showOrder: int = 0, active: bool = False) → dict

Adds a requirement category to the server

Parameters
  • name (str) – The name of the object

  • shortcut (str) – Short name of this category

  • description (str) – The description of the object

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

addRequirementSkeleton(shortName: str, description: str, requirementCategory: int, collectionInstances: list = None, tagInstances: list = None, projectTypes: list = None, showOrder: int = 0, active: bool = False, universalId: str = None) → dict

Adds a requirement skeleton to the server

Parameters
  • shortName (str) – A short name for this skeleton

  • description (str) – The description of the object

  • requirementCategory (int) – the mapped requirement category

  • collectionInstances (list) – A list of mapped collection instances

  • tagInstances (list) – A list of mapped tag instances

  • projectTypes (list) – A list of mapped project types

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

  • universalId (str) – A universal ID

Return dict

The answer from the server

addTagCategory(name: str, description: str, showOrder: int = 0, active: bool = False) → dict

Adds a new tag category

Parameters
  • name (str) – The name of the object

  • description (str) – The description of the object

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

addTagInstance(name: str, description: str, tagCategoryId: int, showOrder: int = 0, active: bool = False) → dict

Adds a tag instance

Parameters
  • name (str) – The name of the object

  • description (str) – The description of the object

  • tagCategoryId (int) – The tag category of this instance

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

delete(endpoint: str) → bool

Uses the DELETE call to delete data from the server

Parameters

endpoint (str) – The API endpoint which needs to be called e.g. collectionInstances

Return dict

The answer from the server

Raises

Exception – Raises an exception if the request is unsuccessfully

deleteCollectionCategory(id_: int) → bool

Deletes a specific collection category

Parameters

id (int) – The Id of the object

Return bool

The answer from the server

Raises

ValueError – Error if the Id is None

deleteCollectionInstance(id_)

Deletes a specific collection instance

Parameters

id (int) – The Id of the object

Return bool

The answer from the server

Raises

ValueError – Error if the Id is None

deleteOptColumn(id_: int) → bool

Deletes an optional column

Parameters

id (int) – The Id of the object

Return bool

The answer from the server

Raises

ValueError – Error if the Id is None

deleteOptColumnContent(id_: int) → bool

Deletes an optional column content

Parameters

id (int) – The Id of the object

Return bool

The requested optional column content

deleteOptColumnType(id_: int) → bool

Deletes an optional column type

Parameters

id (int) – The Id of the object

Return bool

The answer from the server

Raises

ValueError – Error if the Id is None

deleteProjectType(id_: int) → bool

Deletes a project type

Parameters

id (int) – The Id of the object

Return bool

The requested project type

deleteRequirementCategory(id_: int) → bool

Deletes a requirement category

Parameters

id (int) – The Id of the object

Return bool

The answer from the server

Raises

ValueError – Error if the Id is None

deleteRequirementSkeleton(id_: int) → bool

Deletes a requirement skeleton

Parameters

id (int) – The Id of the object

Return bool

The answer from the server

Raises

ValueError – Error if the Id is None

deleteTagCategory(id_: int) → bool

Deletes a tag category

Parameters

id (int) – The Id of the object

Return bool

The answer from the server

Raises

ValueError – Error if the Id is None

deleteTagInstance(id_: int) → bool

Deletes a tag instance

Parameters

id (int) – The Id of the object

Return bool

The answer from the server

Raises

ValueError – Error if the Id is None

doLogin(user: str, password: str) → bool

Does the whole login process with getting the configuration and doing the actual login.

Parameters
  • user (str) – The user name of the used account

  • password (str) – The password of the used account

Return bool

Returns True if the login was successful

findOptColumnContentsWithContent(search: str, regex: bool = False) → list

Gets a list of optional column contents with a specific string in them

Parameters
  • search (str) – The search string

  • regex (bool) – Enables a regex search (Not implemented at the moment)

Return list

list of found items

ToDo

Implement regex search

findOptColumnContentsWithOptColumnId(optColumnId: int) → list

Gets a list of optional column contents with a specific optional column id

Parameters

optColumnId (int) – the mapped optional column id

Return list

list of found items

findOptColumnContentsWithRequirementSkeletonId(requirementSkeletonId: int) → list

Gets a list of optional column contents with a specific requirement skeleton id

Parameters

requirementSkeletonId (int) – the mapped requirement skeleton id

Return list

list of found items

findRequirementSkeletonWithProjectType(projectType: Union[list, int]) → list

Returns a list of requirement skeletons which have a given project type

Parameters

projectType (list,int) – A list or a single project type

Return list

Found skeletons

get(endpoint: str) → Union[list, dict]

Uses the GET call to retrieve data from the server

Parameters

endpoint (str) – The API endpoint which needs to be called e.g. collectionInstances

Return dict

The answer from the server

Raises

Exception – Raises an exception if the request is unsuccessfully

getAlternativeInstance(id_) → dict

Returns a specific alternative instance

Parameters

id (int) – The Id of the object The Id of the object

Return dict

The requested data

Raises

ValueError – Error if the Id is None

getAlternativeInstances() → list

Returns all alternative instances

Return dict

The requested data

getAlternativeSets() → list

Returns all alternative set instances

Return dict

The requested data

getCached(cacheId: str) → Union[list, dict]

If caching is activated the cached version will be returned if it is unchanged.

Parameters

cacheId (str) – The ID of the cache (Also the API call name)

Return list,dict

Returns the API data

getCollectionCategories() → list

Returns all collection categories

Return dict

The requested data

getCollectionCategory(id_) → dict

Returns a specific collection category

Parameters

id (int) – The Id of the object The Id of the object

Return dict

The requested data

Raises

ValueError – Error if the Id is None

getCollectionInstance(id_: int) → dict

Returns a selected collection instance

Parameters

id (int) – The Id of the object

Return dict

Selected collection instance

Raises

ValueError – Error if the Id is None

getCollectionInstances() → list

Returns all collection instances

Return list

A list of all collection instances

getConfig() → None

Request to the API endpoint to retrieve some base information for the session.

Raises

Exception – Raises an exception if the request is unsuccessfully

getOptColumn(id_: int) → dict

Gets an optional column from the server

Parameters

id (int) – The Id of the object

Return dict

The requested optional column

Raises

ValueError – Error if the Id is None

getOptColumnContent(id_: int) → dict

Gets an optional column content from the server

Parameters

id (int) – The Id of the object

Return dict

The requested optional column content

Raises

ValueError – Error if the Id is None

getOptColumnContents() → list

Gets all optional column contents

Return list

all optional column contents

getOptColumnType(id_: int) → dict

Gets an optional column type from the server

Parameters

id (int) – The Id of the object

Return dict

The requested optional column type

Raises

ValueError – Error if the Id is None

getOptColumnTypes()

Gets all optional column types

Return list

all optional column types

getOptColumns() → list

Gets all optional column

Return list

all optional column

getProjectType(id_: int) → dict

Gets a project type from the server

Parameters

id (int) – The Id of the object

Return dict

The requested project type

Raises

ValueError – Error if the Id is None

getProjectTypes() → list

Gets all project types

Return list

all project types

getRawSession() → requests.sessions.session

Returns the used requests session. Might be useful if session parameters need to be changed.

Return requests.session

The used requests session

getRequirementCategories() → list

Gets all requirement categories

Return list

all requirement categories

getRequirementCategory(id_: int) → dict

Gets a requirement category from the server

Parameters

id (int) – The Id of the object

Return dict

The requested requirement category

Raises

ValueError – Error if the Id is None

getRequirementSkeleton(id_: int) → dict

Gets a requirement skeleton from the server

Parameters

id (int) – The Id of the object

Return dict

The requested requirement skeleton

Raises

ValueError – Error if the Id is None

getRequirementSkeletons() → list

Gets all requirement skeletons

Return list

all requirement skeletons

getStatusColumn(id_) → dict

Returns a specific status column instance

Parameters

id (int) – The Id of the object The Id of the object

Return dict

The requested data

Raises

ValueError – Error if the Id is None

getStatusColumnValues() → list

Returns all status column value instances

Return dict

The requested data

getStatusColumns() → list

Returns all status column instances

Return dict

The requested data

getTagCategories() → list

Gets all tag categories

Return list

all tag categories

getTagCategory(id_: int) → dict

Gets a specific tag category

Parameters

id (int) – The Id of the object

Return dict

The selected tag category

Raises

ValueError – Error if the Id is None

getTagInstance(id_: int) → dict

Gets a tag instance from the server

Parameters

id (int) – The Id of the object

Return dict

The requested tag instance

Raises

ValueError – Error if the Id is None

getTagInstances() → list

Gets all tag instances

Return list

all tag categories

login(user: str, password: str) → bool

Sends the login request to the API endpoint to retrieve a valid session.

Parameters
  • user (str) – The user name of the used account

  • password (str) – The password of the used account

Return bool

Returns True if the login was successful

Raises

Exception – Raises an exception if the login is unsuccessfully

post(endpoint: str, data: dict) → dict

Uses the POST call to add data to the server

Parameters
  • endpoint (str) – The API endpoint which needs to be called e.g. collectionInstances

  • data (dict) – The data which will be sent

Return dict

The answer from the server

Raises

Exception – Raises an exception if the request is unsuccessfully

put(endpoint: str, data: dict) → dict

Uses the PUT call to update data in the API

Parameters
  • endpoint (str) – The API endpoint which needs to be called e.g. collectionInstances

  • data (dict) – The data which will be sent

Return dict

The answer from the server

Raises

Exception – Raises an exception if the request is unsuccessfully

updateCollectionCategory(id_: int, name: str = None, description: str = None, showOrder: int = None, active: bool = None) → dict

Updates a specific collection category. A entry is unchanged if the parameter is None

Parameters
  • id (int) – The Id of the object

  • name (str) – The name of the object

  • description (str) – The description of the object

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

Raises

ValueError – Error if the Id is None

updateCollectionInstance(id_: int, name: str = None, description: str = None, collectionCategoryId: int = None, showOrder: int = None, active: bool = None) → dict

Updates an existing collection instance

Parameters
  • id (int) – The Id of the object

  • name (str) – The name of the object

  • description (str) – The description of the object

  • collectionCategoryId (int) – Id of the mapped collection category

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

updateOptColumn(id_: int, name: str = None, description: str = None, optColumnTypeId: int = None, showOrder: int = None, active: bool = None, isVisibleByDefault: bool = None) → dict

Updates an optional column

Parameters
  • id (int) – The Id of the object

  • name (str) – The name of the object

  • description (str) – The description of the object

  • optColumnTypeId (int) – The mapped optional column type id

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

  • isVisibleByDefault (bool) – Sets if it is visible by default

Return dict

The requested optional column

Raises

ValueError – Error if the Id is None

updateOptColumnContent(id_: int, content: str = None, optColumnId: int = None, requirementSkeletonId: int = None) → dict

Updates an optional column content

Parameters
  • id (int) – The Id of the object

  • content (str) – The content of the optional column

  • optColumnId (id) – The mapped column id

  • requirementSkeletonId (id) – The mapped requirement skeleton category

Return dict

The requested optional column content

Raises

ValueError – Error if the Id is None

updateOptColumnType(id_: int, name: str = None, description: str = None) → dict

Updates an optional column type

Parameters
  • id (int) – The Id of the object

  • name (str) – The name of the object

  • description (str) – The description of the object

Return dict

The answer from the server

Raises

ValueError – Error if the Id is None

updateProjectType(id_: int, name: str = None, description: str = None, statusColumnIds: List[int] = None, optColumnIds: List[int] = None, showOrder: int = None, active: bool = None) → dict

Updates a specific project type

Parameters
  • id (int) – The Id of the object

  • name (str) – The name of the object

  • description (str) – The description of the object

  • statusColumnIds (list) – A list of mapped status column Ids

  • optColumnIds (list) – A list of mapped optional column Ids

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The requested optional column content

Raises

ValueError – Error if the Id is None

updateRequirementCategory(id_: int, name: str = None, shortcut: str = None, description: str = None, showOrder: int = None, active: bool = None) → dict

Updates a requirement category

Parameters
  • id (int) – The Id of the object

  • name (str) – The name of the object

  • shortcut (str) – Short name of this category

  • description (str) – The description of the object

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

Raises

ValueError – Error if the Id is None

updateRequirementSkeleton(id_: int, shortName: str = None, description: str = None, requirementCategory: int = None, collectionInstances: list = None, tagInstances: list = None, projectTypes: list = None, showOrder: int = None, active: bool = None, universalId: str = None) → dict

Updates a requirement skeleton

Parameters
  • id (int) – The Id of the object

  • shortName (str) – A short name for this skeleton

  • description (str) – The description of the object

  • requirementCategory (int) – the mapped requirement category

  • collectionInstances (list) – A list of mapped collection instances

  • tagInstances (list) – A list of mapped tag instances

  • projectTypes (list) – A list of mapped project types

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

  • universalId (str) – A universal ID

Return dict

The answer from the server

Raises

ValueError – Error if the Id is None

updateTagCategory(id_: int, name: str = None, description: str = None, showOrder: int = None, active: bool = None) → dict

Updates a tag category

Parameters
  • id (int) – The Id of the object

  • name (str) – The name of the object

  • description (str) – The description of the object

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

Raises

ValueError – Error if the Id is None

updateTagInstance(id_: int, name: str = None, description: str = None, tagCategoryId: int = None, showOrder: int = None, active: bool = None) → dict

Updates a tag instance

Parameters
  • id (int) – The Id of the object

  • name (str) – The name of the object

  • description (str) – The description of the object

  • tagCategoryId (int) – The tag category of this instance

  • showOrder (int) – The show order of the object, default is 0

  • active (bool) – Sets if the object is active, default is False

Return dict

The answer from the server

Raises

ValueError – Error if the Id is None

class securityratconnector.SecurityRatEntryList(initlist=None)

A custom list to handle the server responses

makeDictList() → dict

Builds a dict out of a returned list

Return dict

Built dict

removeDeactivated() → collections.UserList

Removes all deactivated items from a list

Return list

cleaned list

removeDeactivatedDict(data: dict) → Optional[dict]

Recursive function for removal process

Parameters

data (dict) – Input data

Return dict

output data

removeDeactivatedList(data: list) → list

Recursive function for removal process

Parameters

data (list) – Input data

Return list

output data