"""enables standard access to of runZero custom integrations, limited to read operations."""importbase64importuuidfromtypingimportAny,List,Optionalfromrunzero.clientimportClientfromrunzero.typesimportCustomIntegration
[docs]classCustomIntegrations:"""Read access to custom integrations. This is a subset of operations available in runzero.admin.custom_integrations.CustomIntegrationsAdmin which allows 'write' operations for custom integrations. :param client: A handle to the :class:`runzero.Client` which manages interactions with the runZero server. """_ENDPOINT="api/v1.0/org/custom-integrations"def__init__(self,client:Client):"""Constructor method"""self._client=client
[docs]defget_all(self,org_id:uuid.UUID)->List[CustomIntegration]:""" Lists all custom integrations available to your account. :param org_id: The ID of the organization to operate against :returns: List of custom integrations :raises: AuthError, ClientError, ServerError """params={"_oid":org_id}res=self._client.execute("GET",self._ENDPOINT,params=params)result:List[CustomIntegration]=[]forsrcinres.json_obj:result.append(_resp_to_source(src))returnresult
[docs]defget(self,org_id:uuid.UUID,name:Optional[str]=None,custom_integration_id:Optional[uuid.UUID]=None)->Optional[CustomIntegration]:""" Retrieves runZero custom integrations with either the matching ID or Name. :param org_id: The ID of the organization to operate against :param name: Optional, name of the organization you want the UUID for :param custom_integration_id: Optional, the id of the source to retrieve :raises: AuthError, ClientError, ServerError ValueError if neither custom_integration_id nor name are provided. :returns: The matching CustomIntegration or None """params={"_oid":org_id}ifnameisNoneandcustom_integration_idisNone:raiseValueError("must provide custom_integration_id or source name")ifcustom_integration_idisnotNone:res=self._client.execute("GET",f"{self._ENDPOINT}/{custom_integration_id}",params=params)return_resp_to_source(res.json_obj)# nameforsrcinself.get_all(org_id):ifsrc.name==name:returnsrcreturnNone