Source code for idem_vra.exec.vra.abx.actionruns

from idem_vra.client.vra_abx_lib.api import ActionRunsApi
from idem_vra.helpers.mapper import remap_response
from idem_vra.helpers.models import ExecReturn


[docs]async def cancel_action_run_using_patch(hub, ctx, p_id, **kwargs): """Cancel an action run Cancels an action run which is currently being executed Performs PATCH /abx/api/resources/action-runs/{id}/cancel :param string p_id: (required in path) ID of the action run :param string actionId: (optional in body) ID of the action :param string actionType: (optional in body) Type of the action :param string actionVersionId: (optional in body) ID of the action version used for the execution :param string actionVersionName: (optional in body) Name of the action version used for the execution :param object configuration: (optional in body) Configuration of the action run for specific providers :param integer createdMillis: (optional in body) Creation time in millis :param integer endTimeMillis: (optional in body) Completion time in millis :param string errorMessage: (optional in body) Error message in case the run completed with an error :param string id: (optional in body) ID of the resource :param object inputs: (optional in body) Input parameters of the action :param string logs: (optional in body) Action run logs :param string name: (optional in body) Name of the resource :param string orgId: (optional in body) Org ID of the resource :param object outputs: (optional in body) Output parameters generated by the action :param string projectId: (optional in body) Project Id of the action (required for non-system actions) :param string provider: (optional in body) Provider used for code execution :param string runProjectId: (optional in body) Project Id where the project will be executed (required for non-system actions) :param string runState: (optional in body) State of the action run :param string runtime: (optional in body) Runtime of the action run (python, nodejs, etc...) :param boolean scalable: (optional in body) :param string source: (optional in body) Source used for the execution :param integer startTimeMillis: (optional in body) Start time in millis :param boolean system: (optional in body) :param integer timeoutSeconds: (optional in body) Timeout in seconds for execution :param string triggeredBy: (optional in body) The user who triggered the action run """ hub.log.debug("PATCH /abx/api/resources/action-runs/{id}/cancel") api = ActionRunsApi(hub.clients["idem_vra.client.vra_abx_lib.api"]) body = {} if "actionId" in kwargs: hub.log.debug(f"Got kwarg 'actionId' = {kwargs['actionId']}") body["actionId"] = kwargs.get("actionId") del kwargs["actionId"] if "actionType" in kwargs: hub.log.debug(f"Got kwarg 'actionType' = {kwargs['actionType']}") body["actionType"] = kwargs.get("actionType") del kwargs["actionType"] if "actionVersionId" in kwargs: hub.log.debug(f"Got kwarg 'actionVersionId' = {kwargs['actionVersionId']}") body["actionVersionId"] = kwargs.get("actionVersionId") del kwargs["actionVersionId"] if "actionVersionName" in kwargs: hub.log.debug(f"Got kwarg 'actionVersionName' = {kwargs['actionVersionName']}") body["actionVersionName"] = kwargs.get("actionVersionName") del kwargs["actionVersionName"] if "configuration" in kwargs: hub.log.debug(f"Got kwarg 'configuration' = {kwargs['configuration']}") body["configuration"] = kwargs.get("configuration") del kwargs["configuration"] if "createdMillis" in kwargs: hub.log.debug(f"Got kwarg 'createdMillis' = {kwargs['createdMillis']}") body["createdMillis"] = kwargs.get("createdMillis") del kwargs["createdMillis"] if "endTimeMillis" in kwargs: hub.log.debug(f"Got kwarg 'endTimeMillis' = {kwargs['endTimeMillis']}") body["endTimeMillis"] = kwargs.get("endTimeMillis") del kwargs["endTimeMillis"] if "errorMessage" in kwargs: hub.log.debug(f"Got kwarg 'errorMessage' = {kwargs['errorMessage']}") body["errorMessage"] = kwargs.get("errorMessage") del kwargs["errorMessage"] if "id" in kwargs: hub.log.debug(f"Got kwarg 'id' = {kwargs['id']}") body["id"] = kwargs.get("id") del kwargs["id"] if "inputs" in kwargs: hub.log.debug(f"Got kwarg 'inputs' = {kwargs['inputs']}") body["inputs"] = kwargs.get("inputs") del kwargs["inputs"] if "logs" in kwargs: hub.log.debug(f"Got kwarg 'logs' = {kwargs['logs']}") body["logs"] = kwargs.get("logs") del kwargs["logs"] if "name" in kwargs: hub.log.debug(f"Got kwarg 'name' = {kwargs['name']}") body["name"] = kwargs.get("name") del kwargs["name"] if "orgId" in kwargs: hub.log.debug(f"Got kwarg 'orgId' = {kwargs['orgId']}") body["orgId"] = kwargs.get("orgId") del kwargs["orgId"] if "outputs" in kwargs: hub.log.debug(f"Got kwarg 'outputs' = {kwargs['outputs']}") body["outputs"] = kwargs.get("outputs") del kwargs["outputs"] if "projectId" in kwargs: hub.log.debug(f"Got kwarg 'projectId' = {kwargs['projectId']}") body["projectId"] = kwargs.get("projectId") del kwargs["projectId"] if "provider" in kwargs: hub.log.debug(f"Got kwarg 'provider' = {kwargs['provider']}") body["provider"] = kwargs.get("provider") del kwargs["provider"] if "runProjectId" in kwargs: hub.log.debug(f"Got kwarg 'runProjectId' = {kwargs['runProjectId']}") body["runProjectId"] = kwargs.get("runProjectId") del kwargs["runProjectId"] if "runState" in kwargs: hub.log.debug(f"Got kwarg 'runState' = {kwargs['runState']}") body["runState"] = kwargs.get("runState") del kwargs["runState"] if "runtime" in kwargs: hub.log.debug(f"Got kwarg 'runtime' = {kwargs['runtime']}") body["runtime"] = kwargs.get("runtime") del kwargs["runtime"] if "scalable" in kwargs: hub.log.debug(f"Got kwarg 'scalable' = {kwargs['scalable']}") body["scalable"] = kwargs.get("scalable") del kwargs["scalable"] if "source" in kwargs: hub.log.debug(f"Got kwarg 'source' = {kwargs['source']}") body["source"] = kwargs.get("source") del kwargs["source"] if "startTimeMillis" in kwargs: hub.log.debug(f"Got kwarg 'startTimeMillis' = {kwargs['startTimeMillis']}") body["startTimeMillis"] = kwargs.get("startTimeMillis") del kwargs["startTimeMillis"] if "system" in kwargs: hub.log.debug(f"Got kwarg 'system' = {kwargs['system']}") body["system"] = kwargs.get("system") del kwargs["system"] if "timeoutSeconds" in kwargs: hub.log.debug(f"Got kwarg 'timeoutSeconds' = {kwargs['timeoutSeconds']}") body["timeoutSeconds"] = kwargs.get("timeoutSeconds") del kwargs["timeoutSeconds"] if "triggeredBy" in kwargs: hub.log.debug(f"Got kwarg 'triggeredBy' = {kwargs['triggeredBy']}") body["triggeredBy"] = kwargs.get("triggeredBy") del kwargs["triggeredBy"] ret = api.cancel_action_run_using_patch(body, id=p_id, **kwargs) # hub.log.debug(ret) return ExecReturn(result=True, ret=remap_response(ret))
[docs]async def delete_using_delete2(hub, ctx, **kwargs): """Delete multiple action runs Deletes multiple action runs with their specific ID Performs DELETE /abx/api/resources/action-runs""" hub.log.debug("DELETE /abx/api/resources/action-runs") api = ActionRunsApi(hub.clients["idem_vra.client.vra_abx_lib.api"]) ret = api.delete_using_delete2(**kwargs) # hub.log.debug(ret) return ExecReturn(result=True, ret=remap_response(ret))
[docs]async def delete_using_delete3(hub, ctx, p_id, **kwargs): """Delete an action run Deletes an action run with a specific ID Performs DELETE /abx/api/resources/action-runs/{id} :param string p_id: (required in path) ID of the action run """ hub.log.debug("DELETE /abx/api/resources/action-runs/{id}") api = ActionRunsApi(hub.clients["idem_vra.client.vra_abx_lib.api"]) ret = api.delete_using_delete3(id=p_id, **kwargs) # hub.log.debug(ret) return ExecReturn(result=True, ret=remap_response(ret))
[docs]async def get_action_runs_by_action_id_using_get(hub, ctx, p_id, **kwargs): """Fetch all action runs of an action Retrieves all action runs of an action Performs GET /abx/api/resources/actions/{id}/action-runs :param string p_id: (required in path) ID of the action :param string page: (optional in query) Page to fetch (starting from 0) :param string size: (optional in query) Amount of entities per page """ hub.log.debug("GET /abx/api/resources/actions/{id}/action-runs") api = ActionRunsApi(hub.clients["idem_vra.client.vra_abx_lib.api"]) ret = api.get_action_runs_by_action_id_using_get(id=p_id, **kwargs) # hub.log.debug(ret) return ExecReturn(result=True, ret=remap_response(ret))
[docs]async def get_all_using_get1(hub, ctx, **kwargs): """Fetch all action runs Retrieves all action run entities Performs GET /abx/api/resources/action-runs :param string page: (optional in query) Page to fetch (starting from 0) :param string size: (optional in query) Amount of entities per page :param string id: (optional in query) :param boolean localAddress.address.MCGlobal: (optional in query) :param boolean localAddress.address.MCLinkLocal: (optional in query) :param boolean localAddress.address.MCNodeLocal: (optional in query) :param boolean localAddress.address.MCOrgLocal: (optional in query) :param boolean localAddress.address.MCSiteLocal: (optional in query) :param string localAddress.address.address: (optional in query) :param boolean localAddress.address.anyLocalAddress: (optional in query) :param string localAddress.address.canonicalHostName: (optional in query) :param string localAddress.address.hostAddress: (optional in query) :param string localAddress.address.hostName: (optional in query) :param boolean localAddress.address.linkLocalAddress: (optional in query) :param boolean localAddress.address.loopbackAddress: (optional in query) :param boolean localAddress.address.multicastAddress: (optional in query) :param boolean localAddress.address.siteLocalAddress: (optional in query) :param string localAddress.hostName: (optional in query) :param string localAddress.hostString: (optional in query) :param integer localAddress.port: (optional in query) :param boolean localAddress.unresolved: (optional in query) :param boolean remoteAddress.address.MCGlobal: (optional in query) :param boolean remoteAddress.address.MCLinkLocal: (optional in query) :param boolean remoteAddress.address.MCNodeLocal: (optional in query) :param boolean remoteAddress.address.MCOrgLocal: (optional in query) :param boolean remoteAddress.address.MCSiteLocal: (optional in query) :param string remoteAddress.address.address: (optional in query) :param boolean remoteAddress.address.anyLocalAddress: (optional in query) :param string remoteAddress.address.canonicalHostName: (optional in query) :param string remoteAddress.address.hostAddress: (optional in query) :param string remoteAddress.address.hostName: (optional in query) :param boolean remoteAddress.address.linkLocalAddress: (optional in query) :param boolean remoteAddress.address.loopbackAddress: (optional in query) :param boolean remoteAddress.address.multicastAddress: (optional in query) :param boolean remoteAddress.address.siteLocalAddress: (optional in query) :param string remoteAddress.hostName: (optional in query) :param string remoteAddress.hostString: (optional in query) :param integer remoteAddress.port: (optional in query) :param boolean remoteAddress.unresolved: (optional in query) :param string sslInfo.peerCertificates[0].TBSCertificate: (optional in query) :param integer sslInfo.peerCertificates[0].basicConstraints: (optional in query) :param string sslInfo.peerCertificates[0].encoded: (optional in query) :param array sslInfo.peerCertificates[0].extendedKeyUsage: (optional in query) :param string sslInfo.peerCertificates[0].issuerDN.name: (optional in query) :param array sslInfo.peerCertificates[0].issuerUniqueID: (optional in query) :param string sslInfo.peerCertificates[0].issuerX500Principal.encoded: (optional in query) :param string sslInfo.peerCertificates[0].issuerX500Principal.name: (optional in query) :param array sslInfo.peerCertificates[0].keyUsage: (optional in query) :param string sslInfo.peerCertificates[0].notAfter: (optional in query) :param string sslInfo.peerCertificates[0].notBefore: (optional in query) :param integer sslInfo.peerCertificates[0].serialNumber: (optional in query) :param string sslInfo.peerCertificates[0].sigAlgName: (optional in query) :param string sslInfo.peerCertificates[0].sigAlgOID: (optional in query) :param string sslInfo.peerCertificates[0].sigAlgParams: (optional in query) :param string sslInfo.peerCertificates[0].signature: (optional in query) :param string sslInfo.peerCertificates[0].subjectDN.name: (optional in query) :param array sslInfo.peerCertificates[0].subjectUniqueID: (optional in query) :param string sslInfo.peerCertificates[0].subjectX500Principal.encoded: (optional in query) :param string sslInfo.peerCertificates[0].subjectX500Principal.name: (optional in query) :param string sslInfo.peerCertificates[0].type: (optional in query) :param integer sslInfo.peerCertificates[0].version: (optional in query) :param string sslInfo.sessionId: (optional in query) """ hub.log.debug("GET /abx/api/resources/action-runs") api = ActionRunsApi(hub.clients["idem_vra.client.vra_abx_lib.api"]) ret = api.get_all_using_get1(**kwargs) # hub.log.debug(ret) return ExecReturn(result=True, ret=remap_response(ret))
[docs]async def get_by_id_using_get1(hub, ctx, p_id, **kwargs): """Fetch an action run by its ID Retrieves an action run entity with a specific ID Performs GET /abx/api/resources/action-runs/{id} :param string p_id: (required in path) ID of the action run """ hub.log.debug("GET /abx/api/resources/action-runs/{id}") api = ActionRunsApi(hub.clients["idem_vra.client.vra_abx_lib.api"]) ret = api.get_by_id_using_get1(id=p_id, **kwargs) # hub.log.debug(ret) return ExecReturn(result=True, ret=remap_response(ret))
[docs]async def run_using_post(hub, ctx, p_id, **kwargs): """Trigger an action run Runs the specified action taking into consideration the supplied configuration Performs POST /abx/api/resources/actions/{id}/action-runs :param string p_id: (required in path) ID of the action :param string actionId: (optional in body) ID of the action :param string actionType: (optional in body) Type of the action :param string actionVersionId: (optional in body) ID of the action version used for the execution :param string actionVersionName: (optional in body) Name of the action version used for the execution :param object configuration: (optional in body) Configuration of the action run for specific providers :param integer createdMillis: (optional in body) Creation time in millis :param integer endTimeMillis: (optional in body) Completion time in millis :param string errorMessage: (optional in body) Error message in case the run completed with an error :param string id: (optional in body) ID of the resource :param object inputs: (optional in body) Input parameters of the action :param string logs: (optional in body) Action run logs :param string name: (optional in body) Name of the resource :param string orgId: (optional in body) Org ID of the resource :param object outputs: (optional in body) Output parameters generated by the action :param string projectId: (optional in body) Project Id of the action (required for non-system actions) :param string provider: (optional in body) Provider used for code execution :param string runProjectId: (optional in body) Project Id where the project will be executed (required for non-system actions) :param string runState: (optional in body) State of the action run :param string runtime: (optional in body) Runtime of the action run (python, nodejs, etc...) :param boolean scalable: (optional in body) :param string source: (optional in body) Source used for the execution :param integer startTimeMillis: (optional in body) Start time in millis :param boolean system: (optional in body) :param integer timeoutSeconds: (optional in body) Timeout in seconds for execution :param string triggeredBy: (optional in body) The user who triggered the action run """ hub.log.debug("POST /abx/api/resources/actions/{id}/action-runs") api = ActionRunsApi(hub.clients["idem_vra.client.vra_abx_lib.api"]) body = {} if "actionId" in kwargs: hub.log.debug(f"Got kwarg 'actionId' = {kwargs['actionId']}") body["actionId"] = kwargs.get("actionId") del kwargs["actionId"] if "actionType" in kwargs: hub.log.debug(f"Got kwarg 'actionType' = {kwargs['actionType']}") body["actionType"] = kwargs.get("actionType") del kwargs["actionType"] if "actionVersionId" in kwargs: hub.log.debug(f"Got kwarg 'actionVersionId' = {kwargs['actionVersionId']}") body["actionVersionId"] = kwargs.get("actionVersionId") del kwargs["actionVersionId"] if "actionVersionName" in kwargs: hub.log.debug(f"Got kwarg 'actionVersionName' = {kwargs['actionVersionName']}") body["actionVersionName"] = kwargs.get("actionVersionName") del kwargs["actionVersionName"] if "configuration" in kwargs: hub.log.debug(f"Got kwarg 'configuration' = {kwargs['configuration']}") body["configuration"] = kwargs.get("configuration") del kwargs["configuration"] if "createdMillis" in kwargs: hub.log.debug(f"Got kwarg 'createdMillis' = {kwargs['createdMillis']}") body["createdMillis"] = kwargs.get("createdMillis") del kwargs["createdMillis"] if "endTimeMillis" in kwargs: hub.log.debug(f"Got kwarg 'endTimeMillis' = {kwargs['endTimeMillis']}") body["endTimeMillis"] = kwargs.get("endTimeMillis") del kwargs["endTimeMillis"] if "errorMessage" in kwargs: hub.log.debug(f"Got kwarg 'errorMessage' = {kwargs['errorMessage']}") body["errorMessage"] = kwargs.get("errorMessage") del kwargs["errorMessage"] if "id" in kwargs: hub.log.debug(f"Got kwarg 'id' = {kwargs['id']}") body["id"] = kwargs.get("id") del kwargs["id"] if "inputs" in kwargs: hub.log.debug(f"Got kwarg 'inputs' = {kwargs['inputs']}") body["inputs"] = kwargs.get("inputs") del kwargs["inputs"] if "logs" in kwargs: hub.log.debug(f"Got kwarg 'logs' = {kwargs['logs']}") body["logs"] = kwargs.get("logs") del kwargs["logs"] if "name" in kwargs: hub.log.debug(f"Got kwarg 'name' = {kwargs['name']}") body["name"] = kwargs.get("name") del kwargs["name"] if "orgId" in kwargs: hub.log.debug(f"Got kwarg 'orgId' = {kwargs['orgId']}") body["orgId"] = kwargs.get("orgId") del kwargs["orgId"] if "outputs" in kwargs: hub.log.debug(f"Got kwarg 'outputs' = {kwargs['outputs']}") body["outputs"] = kwargs.get("outputs") del kwargs["outputs"] if "projectId" in kwargs: hub.log.debug(f"Got kwarg 'projectId' = {kwargs['projectId']}") body["projectId"] = kwargs.get("projectId") del kwargs["projectId"] if "provider" in kwargs: hub.log.debug(f"Got kwarg 'provider' = {kwargs['provider']}") body["provider"] = kwargs.get("provider") del kwargs["provider"] if "runProjectId" in kwargs: hub.log.debug(f"Got kwarg 'runProjectId' = {kwargs['runProjectId']}") body["runProjectId"] = kwargs.get("runProjectId") del kwargs["runProjectId"] if "runState" in kwargs: hub.log.debug(f"Got kwarg 'runState' = {kwargs['runState']}") body["runState"] = kwargs.get("runState") del kwargs["runState"] if "runtime" in kwargs: hub.log.debug(f"Got kwarg 'runtime' = {kwargs['runtime']}") body["runtime"] = kwargs.get("runtime") del kwargs["runtime"] if "scalable" in kwargs: hub.log.debug(f"Got kwarg 'scalable' = {kwargs['scalable']}") body["scalable"] = kwargs.get("scalable") del kwargs["scalable"] if "source" in kwargs: hub.log.debug(f"Got kwarg 'source' = {kwargs['source']}") body["source"] = kwargs.get("source") del kwargs["source"] if "startTimeMillis" in kwargs: hub.log.debug(f"Got kwarg 'startTimeMillis' = {kwargs['startTimeMillis']}") body["startTimeMillis"] = kwargs.get("startTimeMillis") del kwargs["startTimeMillis"] if "system" in kwargs: hub.log.debug(f"Got kwarg 'system' = {kwargs['system']}") body["system"] = kwargs.get("system") del kwargs["system"] if "timeoutSeconds" in kwargs: hub.log.debug(f"Got kwarg 'timeoutSeconds' = {kwargs['timeoutSeconds']}") body["timeoutSeconds"] = kwargs.get("timeoutSeconds") del kwargs["timeoutSeconds"] if "triggeredBy" in kwargs: hub.log.debug(f"Got kwarg 'triggeredBy' = {kwargs['triggeredBy']}") body["triggeredBy"] = kwargs.get("triggeredBy") del kwargs["triggeredBy"] ret = api.run_using_post(body, id=p_id, **kwargs) # hub.log.debug(ret) return ExecReturn(result=True, ret=remap_response(ret))