Integrations

Loading Models

Everything within A-Ops is saved into models that can be viewed within the "Model Editor" in the UI, within integrations you can load each of the records under a given model.

Document Functions

Create a new object in the database

.new()

Create a new object in the database using bulk method

.bulkNew(bulkClass:object)

Returns a list of objects from the database

.getAsClass(fields:list=None,query:dict=None,id:str=None,limit:int=None,sort:tuple=None,skip:int=None)

Loads this object from the database

.get(id:str):

Refreshes the loaded object from the database

.refresh()

Saves the defined fields of this object to the database

.update(fields:list)

Saves the defined fields of this object to the database using bulk method

.bulkUpdate(fields:list,bulkClass:object)

Updates or creates the defined fields based on the query in the database using bulk method

.bulkUpsert(query:dict,fields:list,bulkClass:object)

Deletes objects within the database

.delete(query:dict=None)

Inserts a new record into the database

.insert_one(data:dict)

Gets an object attribute

.getAttribute(attr:str)

Set an object attribute

.setAttribute(attr:str,value:any):

Returns a list from the database

.query(fields:list=None,query:dict=None,id:str=None,limit:int=None,sort:list=None,skip:int=None)

Returns the number of objects

.count(query:dict=None,id:str=None,estimate:bool=False)

Returns distinct values of a field

.distinct(field:str=None,query:dict=None):

Returns a list from the database

.aggregate(aggregateStatement:list=None,limit:int=None):

Updates objects within the database based on a definable query

.customUpdate(setData:dict,query:dict=None):

Updates objects within the database based on a definable query using bulk method

.bulkCustomUpdate(setData:dict,query:dict=None,bulkClass:object=None)

Pushes an item into a list within the database

.push(pushData:dict,query:dict=None):

Pushes an item into a list within the database using bulk method

.bulkPush(pushData:dict,query:dict=None,bulkClass:object=None):

Pulls an item from a list within the database

.pull(pullData:dict,query:dict=None):

Pulls an item from a list within the database using bulk method

.bulkPull(pullData:dict,query:dict=None,bulkClass:object=None):

Example

from core import core
actions = core.action._action().query(query={ "name" : "some action name" })

Helper Functions

Helper functions include many of the common tasks of an action and include supporting features such as when making an API call and ensuring that the global worker proxy support is also enabled.

All helper functions exist within helpers in core

from core import core
core.helpers.<function>

Replacement Syntax

evalString

core.helpers.evalString(varString:str|list|dict,dicts:dict=None,data:dict=None,functionSafeList:dict=functionSafeList,dontTypeCast:bool=False)

evalList

core.helpers.evalList(varList:list|dict|str,dicts:dict=None,data:dict=None,functionSafeList:dict=functionSafeList,dontTypeCast:bool=False)

evalDict

core.helpers.evalDict(varDict:dict|list|str,dicts:dict=None,data:dict=None,functionSafeList:dict=functionSafeList,dontTypeCast:bool=False)

Arguments

Property Description
data A-Ops data object normally the data object that is passed into the doAction function
dontTypeCast When True the function will not attempt to convert the result of the eval statement into a class. i.e. if you run evalString on a string of "1" by default unless dontTypeCast = True the function will convert the "1" into an integer of 1

Example

from core import core

class _someAction(core.action._action):
    inputText = str()
    inputList = list()
    inputDict = dict()

        def doAction(data):
            inputText = core.helpers.evalString(self.inputText,data=data)
            inputList = core.helpers.evalList(self.inputList,data=data)
            inputDict = core.helpers.evalDict(self.inputDict,data=data)

Web Requests

Initialize

core.helpers.api(ca:str=None,proxy:dict=None,timeout:int=60)

Make Request

core.helpers.api().doRequest(url:str,method:str="GET",data:dict|list|str=None,rawResponse:bool=False,headers:dict=None,kwargs:dict=None)

Arguments

Property Description
url Target URL of the request
method HTTP method type
data HTTP body to include
rawResponse When True the python requests response object will be returned instead of the default tuple status_code and response_text
headers HTTP request headers
kwargs Additional optional kwargs to provide to the python request

Returns

Default

status_code, response_text

When rawResponse = True

response

Example

import json
from core import core
apiClass = core.helpers.api()
status_code, response_text = apiClass.doRequest("https://www.google.com")
if status_code == 200:
    jsonResponse = json.loads(response_text)

Passwords

A-Ops provides secure password storage that is only receivable by A-Ops workers and not by the web interface.

All auth functions exist within auth in core

from core import core
core.auth.<function>

Set Password

core.auth.getENCFromPassword(password,customSecure=None)

Get Password

core.auth.getPasswordFromENC(enc,customSecure=None)

Example

from core import core
password = core.auth.getPasswordFromENC("ENC j1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")