def get_policy_events_duration(self, duration_sec, sampling=None, aggregations=None, scope_filter=None, event_filter=None):

epoch = datetime.datetime.utcfromtimestamp(<NUM_LIT:0>)<EOL>to_ts = (datetime.datetime.utcnow() - epoch).total_seconds() * <NUM_LIT:1000> * <NUM_LIT:1000><EOL>from_ts = to_ts - (int(duration_sec) * <NUM_LIT:1000> * <NUM_LIT:1000>)<EOL>options = {"<STR_LIT:to>": to_ts,<EOL>"<STR_LIT>": from_ts,<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:1000>,<EOL>"<STR_LIT>": sampling,<EOL>"<STR_LIT>": aggregations,<EOL>"<STR_LIT>": scope_filter,<EOL>"<STR_LIT>": event_filter}<EOL>ctx = {k: v for k, v in options.items() if v is not None}<EOL>return self._get_policy_events_int(ctx)<EOL>

**Description**
            Fetch all policy events that occurred in the last duration_sec seconds. This method is used in conjunction with
            :func:`~sdcclient.SdSecureClient.get_more_policy_events` to provide paginated access to policy events.

        **Arguments**
            - duration_sec: Fetch all policy events that have occurred in the last *duration_sec* seconds.
            - sampling: Sample all policy events using *sampling* interval.
            - aggregations: When present it specifies how to aggregate events (sampling does not need to be specified, because when it's present it automatically means events will be aggregated). This field can either be a list of scope metrics or a list of policyEvents fields but (currently) not a mix of the two. When policy events fields are specified, only these can be used= severity, agentId, containerId, policyId, ruleType.
            - scope_filter: this is a SysdigMonitor-like filter (e.g 'container.image=ubuntu'). When provided, events are filtered by their scope, so only a subset will be returned (e.g. 'container.image=ubuntu' will provide only events that have happened on an ubuntu container).
            - event_filter: this is a SysdigMonitor-like filter (e.g. policyEvent.policyId=3). When provided, events are filtered by some of their properties. Currently the supported set of filters is policyEvent.all(which can be used just with matches, policyEvent.policyId, policyEvent.id, policyEvent.severity, policyEvent.ruleTye, policyEvent.ruleSubtype.

        **Success Return Value**
            An array containing:
              - A context object that should be passed to later calls to get_more_policy_events.
              - An array of policy events, in JSON format. See :func:`~sdcclient.SdSecureClient.get_more_policy_events`
                for details on the contents of policy events.

        **Example**
            `examples/get_secure_policy_events.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_secure_policy_events.py>`_


def get_policy_events_id_range(self, id, from_sec, to_sec, sampling=None, aggregations=None, scope_filter=None, event_filter=None):

options = {"<STR_LIT:id>": id,<EOL>"<STR_LIT>": int(from_sec) * <NUM_LIT>,<EOL>"<STR_LIT:to>": int(to_sec) * <NUM_LIT>,<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:1000>,<EOL>"<STR_LIT>": sampling,<EOL>"<STR_LIT>": aggregations,<EOL>"<STR_LIT>": scope_filter,<EOL>"<STR_LIT>": event_filter}<EOL>ctx = {k: v for k, v in options.items() if v is not None}<EOL>return self._get_policy_events_int(ctx)<EOL>

**Description**
            Fetch all policy events with id that occurred in the time range [from_sec:to_sec]. This method is used in conjunction
            with :func:`~sdcclient.SdSecureClient.get_more_policy_events` to provide paginated access to policy events.

        **Arguments**
            - id: the id of the policy events to fetch.
            - from_sec: the start of the timerange for which to get events
            - end_sec: the end of the timerange for which to get events
            - sampling: sample all policy events using *sampling* interval.
            - scope_filter: this is a SysdigMonitor-like filter (e.g 'container.image=ubuntu'). When provided, events are filtered by their scope, so only a subset will be returned (e.g. 'container.image=ubuntu' will provide only events that have happened on an ubuntu container).
            - event_filter: this is a SysdigMonitor-like filter (e.g. policyEvent.policyId=3). When provided, events are filtered by some of their properties. Currently the supported set of filters is policyEvent.all(which can be used just with matches, policyEvent.policyId, policyEvent.id, policyEvent.severity, policyEvent.ruleTye, policyEvent.ruleSubtype.
            - aggregations: When present it specifies how to aggregate events (sampling does not need to be specified, because when it's present it automatically means events will be aggregated). This field can either be a list of scope metrics or a list of policyEvents fields but (currently) not a mix of the two. When policy events fields are specified, only these can be used= severity, agentId, containerId, policyId, ruleType.

        **Success Return Value**
            An array containing:
              - A context object that should be passed to later calls to get_more_policy_events.
              - An array of policy events, in JSON format. See :func:`~sdcclient.SdSecureClient.get_more_policy_events`
                for details on the contents of policy events.

        **Example**
            `examples/get_secure_policy_events.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_secure_policy_events.py>`_


def get_policy_events_id_duration(self, id, duration_sec, sampling=None, aggregations=None, scope_filter=None, event_filter=None):

epoch = datetime.datetime.utcfromtimestamp(<NUM_LIT:0>)<EOL>to_ts = (datetime.datetime.utcnow() - epoch).total_seconds() * <NUM_LIT:1000> * <NUM_LIT:1000><EOL>from_ts = to_ts - (int(duration_sec) * <NUM_LIT:1000> * <NUM_LIT:1000>)<EOL>ctx = {"<STR_LIT:id>": id,<EOL>"<STR_LIT:to>": to_ts,<EOL>"<STR_LIT>": from_ts,<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:1000>,<EOL>"<STR_LIT>": sampling,<EOL>"<STR_LIT>": aggregations,<EOL>"<STR_LIT>": scope_filter,<EOL>"<STR_LIT>": event_filter}<EOL>ctx = {k: v for k, v in options.items() if v is not None}<EOL>return self._get_policy_events_int(ctx)<EOL>

**Description**
            Fetch all policy events with id that occurred in the last duration_sec seconds. This method is used in conjunction with
            :func:`~sdcclient.SdSecureClient.get_more_policy_events` to provide paginated access to policy events.

        **Arguments**
            - id: the id of the policy events to fetch.
            - duration_sec: Fetch all policy events that have occurred in the last *duration_sec* seconds.
            - sampling: Sample all policy events using *sampling* interval.
            - aggregations: When present it specifies how to aggregate events (sampling does not need to be specified, because when it's present it automatically means events will be aggregated). This field can either be a list of scope metrics or a list of policyEvents fields but (currently) not a mix of the two. When policy events fields are specified, only these can be used= severity, agentId, containerId, policyId, ruleType.
            - scope_filter: this is a SysdigMonitor-like filter (e.g 'container.image=ubuntu'). When provided, events are filtered by their scope, so only a subset will be returned (e.g. 'container.image=ubuntu' will provide only events that have happened on an ubuntu container).
            - event_filter: this is a SysdigMonitor-like filter (e.g. policyEvent.policyId=3). When provided, events are filtered by some of their properties. Currently the supported set of filters is policyEvent.all(which can be used just with matches, policyEvent.policyId, policyEvent.id, policyEvent.severity, policyEvent.ruleTye, policyEvent.ruleSubtype.

        **Success Return Value**
            An array containing:
              - A context object that should be passed to later calls to get_more_policy_events.
              - An array of policy events, in JSON format. See :func:`~sdcclient.SdSecureClient.get_more_policy_events`
                for details on the contents of policy events.

        **Example**
            `examples/get_secure_policy_events.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_secure_policy_events.py>`_


return self._get_policy_events_int(ctx)<EOL>

**Description**
            Fetch additional policy events after an initial call to :func:`~sdcclient.SdSecureClient.get_policy_events_range` /
            :func:`~sdcclient.SdSecureClient.get_policy_events_duration` or a prior call to get_more_policy_events.

        **Arguments**
            - ctx: a context object returned from an initial call to :func:`~sdcclient.SdSecureClient.get_policy_events_range` /
              :func:`~sdcclient.SdSecureClient.get_policy_events_duration` or a prior call to get_more_policy_events.

        **Success Return Value**
            An array containing:
              - A context object that should be passed to later calls to get_more_policy_events()
              - An array of policy events, in JSON format. Each policy event contains the following:
                 - hostMac: the mac address of the machine where the event occurred
                 - severity: a severity level from 1-7
                 - timestamp: when the event occurred (ns since the epoch)
                 - version: a version number for this message (currently 1)
                 - policyId: a reference to the policy that generated this policy event
                 - output: A string describing the event that occurred
                 - id: a unique identifier for this policy event
                 - isAggregated: if true, this is a combination of multiple policy events
                 - containerId: the container in which the policy event occurred

            When the number of policy events returned is 0, there are no remaining events and you can stop calling get_more_policy_events().

        **Example**
            `examples/get_secure_policy_events.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_secure_policy_events.py>`_


res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Create a set of default policies using the current system falco rules file as a reference. For every falco rule in the system
            falco rules file, one policy will be created. The policy will take the name and description from the name and description of
            the corresponding falco rule. If a policy already exists with the same name, no policy is added or modified. Existing
            policies will be unchanged.

        **Arguments**
            - None

        **Success Return Value**
            JSON containing details on any new policies that were added.

        **Example**
            `examples/create_default_policies.py <https://github.com/draios/python-sdc-client/blob/master/examples/create_default_policies.py>`_


res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, "<STR_LIT>"]<EOL>

**Description**
            Delete all existing policies. The falco rules file is unchanged.

        **Arguments**
            - None

        **Success Return Value**
            The string "Policies Deleted"

        **Example**
            `examples/delete_all_policies.py <https://github.com/draios/python-sdc-client/blob/master/examples/delete_all_policies.py>`_


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            List the current set of policies.

        **Arguments**
            - None

        **Success Return Value**
            A JSON object containing the number and details of each policy.

        **Example**
            `examples/list_policies.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_policies.py>`_


**Description**
            Get a list of policy ids in the order they will be evaluated.

        **Arguments**
            - None

        **Success Return Value**
            A JSON object representing the list of policy ids.

        **Example**
            `examples/list_policies.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_policies.py>`_


try:<EOL><INDENT>json.loads(priorities_json)<EOL><DEDENT>except Exception as e:<EOL><INDENT>return [False, "<STR_LIT>".format(str(e))]<EOL><DEDENT>res = requests.put(self.url + '<STR_LIT>', headers=self.hdrs, data=priorities_json, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Change the policy evaluation order

        **Arguments**
            - priorities_json: a description of the new policy order.

        **Success Return Value**
            A JSON object representing the updated list of policy ids.

        **Example**
            `examples/set_policy_order.py <https://github.com/draios/python-sdc-client/blob/master/examples/set_policy_order.py>`_


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>policies = res.json()["<STR_LIT>"]<EOL>for policy in policies:<EOL><INDENT>if policy["<STR_LIT:name>"] == name:<EOL><INDENT>return [True, policy]<EOL><DEDENT><DEDENT>return [False, "<STR_LIT>".format(name)]<EOL>

**Description**
            Find the policy with name <name> and return its json description.

        **Arguments**
            - name: the name of the policy to fetch

        **Success Return Value**
            A JSON object containing the description of the policy. If there is no policy with
            the given name, returns False.

        **Example**
            `examples/get_policy.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_policy.py>`_


try:<EOL><INDENT>policy_obj = json.loads(policy_json)<EOL><DEDENT>except Exception as e:<EOL><INDENT>return [False, "<STR_LIT>".format(str(e))]<EOL><DEDENT>body = {"<STR_LIT>": policy_obj}<EOL>res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, data=json.dumps(body), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Add a new policy using the provided json.

        **Arguments**
            - policy_json: a description of the new policy

        **Success Return Value**
            The string "OK"

        **Example**
            `examples/add_policy.py <https://github.com/draios/python-sdc-client/blob/master/examples/add_policy.py>`_


try:<EOL><INDENT>policy_obj = json.loads(policy_json)<EOL><DEDENT>except Exception as e:<EOL><INDENT>return [False, "<STR_LIT>".format(str(e))]<EOL><DEDENT>if "<STR_LIT:id>" not in policy_obj:<EOL><INDENT>return [False, "<STR_LIT>"]<EOL><DEDENT>body = {"<STR_LIT>": policy_obj}<EOL>res = requests.put(self.url + '<STR_LIT>'.format(policy_obj["<STR_LIT:id>"]), headers=self.hdrs, data=json.dumps(body), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Update an existing policy using the provided json. The 'id' field from the policy is
            used to determine which policy to update.

        **Arguments**
            - policy_json: a description of the new policy

        **Success Return Value**
            The string "OK"

        **Example**
            `examples/update_policy.py <https://github.com/draios/python-sdc-client/blob/master/examples/update_policy.py>`_


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>for policy in res.json()["<STR_LIT>"]:<EOL><INDENT>if policy["<STR_LIT:name>"] == name:<EOL><INDENT>return self.delete_policy_id(policy["<STR_LIT:id>"])<EOL><DEDENT><DEDENT>return [False, "<STR_LIT>".format(name)]<EOL>

**Description**
            Delete the policy with the given name.

        **Arguments**
            - name: the name of the policy to delete

        **Success Return Value**
            The JSON object representing the now-deleted policy.

        **Example**
            `examples/delete_policy.py <https://github.com/draios/python-sdc-client/blob/master/examples/delete_policy.py>`_


res = requests.delete(self.url + '<STR_LIT>'.format(id), headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Delete the policy with the given id

        **Arguments**
            - id: the id of the policy to delete

        **Success Return Value**
            The JSON object representing the now-deleted policy.

        **Example**
            `examples/delete_policy.py <https://github.com/draios/python-sdc-client/blob/master/examples/delete_policy.py>`_


def add_compliance_task(self, name, module_name='<STR_LIT>', schedule='<STR_LIT>', scope=None, enabled=True):

task = {<EOL>"<STR_LIT:id>": None,<EOL>"<STR_LIT:name>": name,<EOL>"<STR_LIT>": module_name,<EOL>"<STR_LIT>": enabled,<EOL>"<STR_LIT>": scope,<EOL>"<STR_LIT>": schedule<EOL>}<EOL>res = requests.post(self.url + '<STR_LIT>', data=json.dumps(task), headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Add a new compliance task.

        **Arguments**
            - name: The name of the task e.g. 'Check Docker Compliance'.
            - module_name: The name of the module that implements this task. Separate from task name in case you want to use the same module to run separate tasks with different scopes or schedules. [ 'docker-bench-security', 'kube-bench' ]
            - schedule: The frequency at which this task should run. Expressed as an `ISO 8601 Duration <https://en.wikipedia.org/wiki/ISO_8601#Durations>`_
            - scope: The agent will only run the task on hosts matching this scope or on hosts where containers match this scope.
            - enabled: Whether this task should actually run as defined by its schedule.

        **Success Return Value**
            A JSON representation of the compliance task.


**Description**
            Get the list of all compliance tasks.

        **Arguments**
            - None

        **Success Return Value**
            A JSON list with the representation of each compliance task.


res = requests.get(self.url + '<STR_LIT>'.format(id), headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Get a compliance task.

        **Arguments**
            - id: the id of the compliance task to get.

        **Success Return Value**
            A JSON representation of the compliance task.


def update_compliance_task(self, id, name=None, module_name=None, schedule=None, scope=None, enabled=None):

ok, res = self.get_compliance_task(id)<EOL>if not ok:<EOL><INDENT>return ok, res<EOL><DEDENT>task = res<EOL>options = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': module_name,<EOL>'<STR_LIT>': schedule,<EOL>'<STR_LIT>': scope,<EOL>'<STR_LIT>': enabled<EOL>}<EOL>task.update({k: v for k, v in options.items() if v is not None})<EOL>res = requests.put(self.url + '<STR_LIT>'.format(id), data=json.dumps(task), headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Update an existing compliance task.

        **Arguments**
            - id: the id of the compliance task to be updated.
            - name: The name of the task e.g. 'Check Docker Compliance'.
            - module_name: The name of the module that implements this task. Separate from task name in case you want to use the same module to run separate tasks with different scopes or schedules. [ 'docker-bench-security', 'kube-bench' ]
            - schedule: The frequency at which this task should run. Expressed as an `ISO 8601 Duration <https://en.wikipedia.org/wiki/ISO_8601#Durations>`_
            - scope: The agent will only run the task on hosts matching this scope or on hosts where containers match this scope.
            - enabled: Whether this task should actually run as defined by its schedule.

        **Success Return Value**
            A JSON representation of the compliance task.


res = requests.delete(self.url + '<STR_LIT>'.format(id), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return False, self.lasterr<EOL><DEDENT>return True, None<EOL>

**Description**
            Delete the compliance task with the given id

        **Arguments**
            - id: the id of the compliance task to delete


def list_compliance_results(self, limit=<NUM_LIT:50>, direction=None, cursor=None, filter="<STR_LIT>"):

url = "<STR_LIT>".format(<EOL>url=self.url,<EOL>limit=limit,<EOL>direction="<STR_LIT>" % direction if direction else "<STR_LIT>",<EOL>cursor="<STR_LIT>" % cursor if cursor is not None else "<STR_LIT>",<EOL>filter=filter)<EOL>res = requests.get(url, headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Get the list of all compliance tasks runs.

        **Arguments**
            - limit: Maximum number of alerts in the response.
            - direction: the direction (PREV or NEXT) that determines which results to return in relation to cursor.
            - cursor: An opaque string representing the current position in the list of alerts. It's provided in the 'responseMetadata' of the list_alerts response.
            - filter: an optional case insensitive filter used to match against the completed task name and return matching results.

        **Success Return Value**
            A JSON list with the representation of each compliance task run.


**Description**
            Retrieve the details for a specific compliance task run result.

        **Arguments**
            - id: the id of the compliance task run to get.

        **Success Return Value**
            A JSON representation of the compliance task run result.


res = requests.get(self.url + '<STR_LIT>'.format(id), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return False, self.lasterr<EOL><DEDENT>return True, res.text<EOL>

**Description**
            Retrieve the details for a specific compliance task run result in csv.

        **Arguments**
            - id: the id of the compliance task run to get.

        **Success Return Value**
            A CSV representation of the compliance task run result.


def list_commands_audit(self, from_sec=None, to_sec=None, scope_filter=None, command_filter=None, limit=<NUM_LIT:100>, offset=<NUM_LIT:0>, metrics=[]):

if to_sec is None:<EOL><INDENT>to_sec = time.time()<EOL><DEDENT>if from_sec is None:<EOL><INDENT>from_sec = to_sec - (<NUM_LIT> * <NUM_LIT> * <NUM_LIT>)  <EOL><DEDENT>url = "<STR_LIT>".format(<EOL>url=self.url,<EOL>offset=offset,<EOL>limit=limit,<EOL>frm=int(from_sec * <NUM_LIT:10>**<NUM_LIT:6>),<EOL>to=int(to_sec * <NUM_LIT:10>**<NUM_LIT:6>),<EOL>scope="<STR_LIT>" + scope_filter if scope_filter else "<STR_LIT>",<EOL>commandFilter="<STR_LIT>" + command_filter if command_filter else "<STR_LIT>",<EOL>metrics="<STR_LIT>" + json.dumps(metrics) if metrics else "<STR_LIT>")<EOL>res = requests.get(url, headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            List the commands audit.

        **Arguments**
            - from_sec: the start of the timerange for which to get commands audit.
            - end_sec: the end of the timerange for which to get commands audit.
            - scope_filter: this is a SysdigMonitor-like filter (e.g 'container.image=ubuntu'). When provided, commands are filtered by their scope, so only a subset will be returned (e.g. 'container.image=ubuntu' will provide only commands that have happened on an ubuntu container).
            - command_filter: this is a SysdigMonitor-like filter (e.g. command.comm="touch"). When provided, commands are filtered by some of their properties. Currently the supported set of filters is command.comm, command.cwd, command.pid, command.ppid, command.uid, command.loginshell.id, command.loginshell.distance
            - limit: Maximum number of commands in the response.
            - metrics: A list of metric values to include in the return.

        **Success Return Value**
            A JSON representation of the commands audit.


def get_command_audit(self, id, metrics=[]):

url = "<STR_LIT>".format(<EOL>url=self.url,<EOL>id=id,<EOL>to=int(time.time() * <NUM_LIT:10>**<NUM_LIT:6>),<EOL>metrics="<STR_LIT>" + json.dumps(metrics) if metrics else "<STR_LIT>")<EOL>res = requests.get(url, headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Get a command audit.

        **Arguments**
            - id: the id of the command audit to get.

        **Success Return Value**
            A JSON representation of the command audit.


**Description**
            Get details about the current user.

        **Success Return Value**
            A dictionary containing information about the user, for example its email and the maximum number of agents it can install.

        **Example**
            `examples/print_user_info.py <https://github.com/draios/python-sdc-client/blob/master/examples/print_user_info.py>`_


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>tkinfo = res.json()<EOL>return [True, tkinfo['<STR_LIT>']['<STR_LIT:key>']]<EOL>

**Description**
            Return the API token of the current user.

        **Success Return Value**
            A string containing the user token.


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>data = res.json()<EOL>return [True, data['<STR_LIT>']]<EOL>

**Description**
            Return the agents currently connected to Sysdig Monitor for the current user.

        **Success Return Value**
            A list of the agents with all their attributes.


**Description**
            Return the number of agents currently connected to Sysdig Monitor for the current user.

        **Success Return Value**
            An integer number.


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            List all configured Notification Channels

        **Arguments**
            none

        **Success Return Value**
            A JSON representation of all the notification channels


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return False, self.lasterr<EOL><DEDENT>ids = []<EOL>if channels is None:<EOL><INDENT>for ch in res.json()["<STR_LIT>"]:<EOL><INDENT>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT>return [True, ids]<EOL><DEDENT>for c in channels:<EOL><INDENT>found = False<EOL>for ch in res.json()["<STR_LIT>"]:<EOL><INDENT>if c['<STR_LIT:type>'] == ch['<STR_LIT:type>']:<EOL><INDENT>if c['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>opt = ch['<STR_LIT>']<EOL>if set(opt['<STR_LIT>']) == set(c['<STR_LIT>']):<EOL><INDENT>found = True<EOL>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT><DEDENT>elif c['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>opt = ch['<STR_LIT>']<EOL>if '<STR_LIT>' in c:<EOL><INDENT>if set(c['<STR_LIT>']) == set(opt['<STR_LIT>']):<EOL><INDENT>found = True<EOL>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT><DEDENT>elif '<STR_LIT:name>' in c:<EOL><INDENT>if c['<STR_LIT:name>'] == ch.get('<STR_LIT:name>'):<EOL><INDENT>found = True<EOL>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT><DEDENT><DEDENT>elif c['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>opt = ch['<STR_LIT>']<EOL>if opt['<STR_LIT>'] == c['<STR_LIT>'] and opt['<STR_LIT>'] == c['<STR_LIT>']:<EOL><INDENT>found = True<EOL>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT><DEDENT>elif c['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>opt = ch['<STR_LIT>']<EOL>if '<STR_LIT>' in opt and opt['<STR_LIT>'] == c['<STR_LIT>']:<EOL><INDENT>found = True<EOL>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT><DEDENT>elif c['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT:name>' in c:<EOL><INDENT>if c['<STR_LIT:name>'] == ch.get('<STR_LIT:name>'):<EOL><INDENT>found = True<EOL>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT><DEDENT><DEDENT>elif c['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT:name>' in c:<EOL><INDENT>if c['<STR_LIT:name>'] == ch.get('<STR_LIT:name>'):<EOL><INDENT>found = True<EOL>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT><DEDENT><DEDENT>elif c['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT:name>' in c:<EOL><INDENT>if c['<STR_LIT:name>'] == ch.get('<STR_LIT:name>'):<EOL><INDENT>found = True<EOL>ids.append(ch['<STR_LIT:id>'])<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if not found:<EOL><INDENT>return False, "<STR_LIT>" + str(c)<EOL><DEDENT><DEDENT>return True, ids<EOL>

**Description**
            Get an array of all configured Notification Channel IDs, or a filtered subset of them.

        **Arguments**
            - **channels**: an optional array of dictionaries to limit the set of Notification Channel IDs returned. If not specified, IDs for all configured Notification Channels are returned. Each dictionary contains a ``type`` field that can be one of the available types of Notification Channel (``EMAIL``, ``SNS``, ``PAGER_DUTY``, ``SLACK``, ``OPSGENIE``, ``VICTOROPS``, ``WEBHOOK``) as well as additional elements specific to each channel type.

        **Success Return Value**
            An array of Notification Channel IDs (integers).

        **Examples**
            - `examples/create_alert.py <https://github.com/draios/python-sdc-client/blob/master/examples/create_alert.py>`_
            - `examples/restore_alerts.py <https://github.com/draios/python-sdc-client/blob/master/examples/restore_alerts.py>`_


**Description**
            Return the list of data retention intervals, with beginning and end UTC time for each of them. Sysdig Monitor performs rollups of the data it stores. This means that data is stored at different time granularities depending on how far back in time it is. This call can be used to know what precision you can expect before you make a call to :func:`~SdcClient.get_data`.

        **Success Return Value**
            A dictionary containing the list of available sampling intervals.

        **Example**
            `examples/print_data_retention_info.py <https://github.com/draios/python-sdc-client/blob/master/examples/print_data_retention_info.py>`_


def post_event(self, name, description=None, severity=None, event_filter=None, tags=None):

options = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT:description>': description,<EOL>'<STR_LIT>': severity,<EOL>'<STR_LIT>': event_filter,<EOL>'<STR_LIT>': tags<EOL>}<EOL>edata = {<EOL>'<STR_LIT>': {k: v for k, v in options.items() if v is not None}<EOL>}<EOL>res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, data=json.dumps(edata), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Send an event to Sysdig Monitor. The events you post are available in the Events tab in the Sysdig Monitor UI and can be overlied to charts.

        **Arguments**
            - **name**: the name of the new event.
            - **description**: a longer description offering detailed information about the event.
            - **severity**: syslog style from 0 (high) to 7 (low).
            - **event_filter**: metadata, in Sysdig Monitor format, of nodes to associate with the event, e.g. ``host.hostName = 'ip-10-1-1-1' and container.name = 'foo'``.
            - **tags**: a list of key-value dictionaries that can be used to tag the event. Can be used for filtering/segmenting purposes in Sysdig Monitor.

        **Success Return Value**
            A dictionary describing the new event.

        **Examples**
            - `examples/post_event_simple.py <https://github.com/draios/python-sdc-client/blob/master/examples/post_event_simple.py>`_
            - `examples/post_event.py <https://github.com/draios/python-sdc-client/blob/master/examples/post_event.py>`_


def get_events(self, name=None, from_ts=None, to_ts=None, tags=None):

options = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': from_ts,<EOL>'<STR_LIT:to>': to_ts,<EOL>'<STR_LIT>': tags<EOL>}<EOL>params = {k: v for k, v in options.items() if v is not None}<EOL>res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, params=params, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Returns the list of Sysdig Monitor events.

        **Arguments**
            - **name**: filter events by name.
            - **from_ts**: filter events by start time. Timestamp format is in UTC (seconds).
            - **to_ts**: filter events by end time. Timestamp format is in UTC (seconds).
            - **tags**: filter events by tags. Can be, for example ``tag1 = 'value1'``.

        **Success Return Value**
            A dictionary containing the list of events.

        **Example**
            `examples/list_events.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_events.py>`_


if '<STR_LIT:id>' not in event:<EOL><INDENT>return [False, "<STR_LIT>"]<EOL><DEDENT>res = requests.delete(self.url + '<STR_LIT>' + str(event['<STR_LIT:id>']), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, None]<EOL>

**Description**
            Deletes an event.

        **Arguments**
            - **event**: the event object as returned by :func:`~SdcClient.get_events`.

        **Success Return Value**
            `None`.

        **Example**
            `examples/delete_event.py <https://github.com/draios/python-sdc-client/blob/master/examples/delete_event.py>`_


def get_data(self, metrics, start_ts, end_ts=<NUM_LIT:0>, sampling_s=<NUM_LIT:0>,<EOL>filter='<STR_LIT>', datasource_type='<STR_LIT:host>', paging=None):

reqbody = {<EOL>'<STR_LIT>': metrics,<EOL>'<STR_LIT>': datasource_type,<EOL>}<EOL>if start_ts < <NUM_LIT:0>:<EOL><INDENT>reqbody['<STR_LIT>'] = -start_ts<EOL><DEDENT>elif start_ts == <NUM_LIT:0>:<EOL><INDENT>return [False, "<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>reqbody['<STR_LIT:start>'] = start_ts<EOL>reqbody['<STR_LIT:end>'] = end_ts<EOL><DEDENT>if filter != '<STR_LIT>':<EOL><INDENT>reqbody['<STR_LIT>'] = filter<EOL><DEDENT>if paging is not None:<EOL><INDENT>reqbody['<STR_LIT>'] = paging<EOL><DEDENT>if sampling_s != <NUM_LIT:0>:<EOL><INDENT>reqbody['<STR_LIT>'] = sampling_s<EOL><DEDENT>res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, data=json.dumps(reqbody), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Export metric data (both time-series and table-based).

        **Arguments**
            - **metrics**: a list of dictionaries, specifying the metrics and grouping keys that the query will return. A metric is any of the entries that can be found in the *Metrics* section of the Explore page in Sysdig Monitor. Metric entries require an *aggregations* section specifying how to aggregate the metric across time and containers/hosts. A grouping key is any of the entries that can be found in the *Show* or *Segment By* sections of the Explore page in Sysdig Monitor. These entries are used to apply single or hierarchical segmentation to the returned data and don't require the aggregations section. Refer to the Example link below for ready-to-use code snippets.
            - **start_ts**: the UTC time (in seconds) of the beginning of the data window. A negative value can be optionally used to indicate a relative time in the past from now. For example, -3600 means "one hour ago".
            - **end_ts**: the UTC time (in seconds) of the end of the data window, or 0 to indicate "now". A negative value can also be optionally used to indicate a relative time in the past from now. For example, -3600 means "one hour ago".
            - **sampling_s**: the duration of the samples that will be returned. 0 means that the whole data will be returned as a single sample.
            - **filter**: a boolean expression combining Sysdig Monitor segmentation criteria that defines what the query will be applied to. For example: *kubernetes.namespace.name='production' and container.image='nginx'*.
            - **datasource_type**: specify the metric source for the request, can be ``container`` or ``host``. Most metrics, for example ``cpu.used.percent`` or ``memory.bytes.used``, are reported by both hosts and containers. By default, host metrics are used, but if the request contains a container-specific grouping key in the metric list/filter (e.g. ``container.name``), then the container source is used. In cases where grouping keys are missing or apply to both hosts and containers (e.g. ``tag.Name``), *datasource_type* can be explicitly set to avoid any ambiguity and allow the user to select precisely what kind of data should be used for the request. `examples/get_data_datasource.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_data_datasource.py>`_ contains a few examples that should clarify the use of this argument.
            - **paging**: if segmentation of the query generates values for several different entities (e.g. containers/hosts), this parameter specifies which to include in the returned result. It's specified as a dictionary of inclusive values for ``from`` and ``to`` with the default being ``{ "from": 0, "to": 9 }``, which will return values for the "top 10" entities. The meaning of "top" is query-dependent, based on points having been sorted via the specified group aggregation, with the results sorted in ascending order if the group aggregation is ``min`` or ``none``, and descending order otherwise.

        **Success Return Value**
            A dictionary with the requested data. Data is organized in a list of time samples, each of which includes a UTC timestamp and a list of values, whose content and order reflect what was specified in the *metrics* argument.

        **Examples**
            - `examples/get_data_simple.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_data_simple.py>`_
            - `examples/get_data_advanced.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_data_advanced.py>`_
            - `examples/list_hosts.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_hosts.py>`_
            - `examples/get_data_datasource.py <https://github.com/draios/python-sdc-client/blob/master/examples/get_data_datasource.py>`_


def get_sysdig_captures(self, from_sec=None, to_sec=None, scope_filter=None):

url = '<STR_LIT>'.format(<EOL>url=self.url,<EOL>source=self.product,<EOL>frm="<STR_LIT>" % (from_sec * <NUM_LIT:10>**<NUM_LIT:6>) if from_sec else "<STR_LIT>",<EOL>to="<STR_LIT>" % (to_sec * <NUM_LIT:10>**<NUM_LIT:6>) if to_sec else "<STR_LIT>",<EOL>scopeFilter="<STR_LIT>" % scope_filter if scope_filter else "<STR_LIT>")<EOL>res = requests.get(url, headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Returns the list of sysdig captures for the user.

        **Arguments**
            - from_sec: the start of the timerange for which to get the captures
            - end_sec: the end of the timerange for which to get the captures
            - scope_filter: this is a SysdigMonitor-like filter (e.g 'container.image=ubuntu'). When provided, events are filtered by their scope, so only a subset will be returned (e.g. 'container.image=ubuntu' will provide only events that have happened on an ubuntu container).

        **Success Return Value**
            A dictionary containing the list of captures.

        **Example**
            `examples/list_sysdig_captures.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_sysdig_captures.py>`_


if '<STR_LIT:id>' not in capture:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>url = '<STR_LIT>'.format(<EOL>url=self.url, id=capture['<STR_LIT:id>'], source=self.product)<EOL>res = requests.get(url, headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Fetch the updated state of a sysdig capture. Can be used to poll the status of a capture that has been previously created and started with :func:`~SdcClient.create_sysdig_capture`.

        **Arguments**
            - **capture**: the capture object as returned by :func:`~SdcClient.get_sysdig_captures` or :func:`~SdcClient.create_sysdig_capture`.

        **Success Return Value**
            A dictionary showing the updated details of the capture. Use the ``status`` field to check the progress of a capture.

        **Example**
            `examples/create_sysdig_capture.py <https://github.com/draios/python-sdc-client/blob/master/examples/create_sysdig_capture.py>`_


def create_sysdig_capture(self, hostname, capture_name, duration, capture_filter='<STR_LIT>', folder='<STR_LIT:/>'):

res = self.get_connected_agents()<EOL>if not res[<NUM_LIT:0>]:<EOL><INDENT>return res<EOL><DEDENT>capture_agent = None<EOL>for agent in res[<NUM_LIT:1>]:<EOL><INDENT>if hostname == agent['<STR_LIT>']:<EOL><INDENT>capture_agent = agent<EOL>break<EOL><DEDENT><DEDENT>if capture_agent is None:<EOL><INDENT>return [False, hostname + '<STR_LIT>']<EOL><DEDENT>data = {<EOL>'<STR_LIT>': capture_agent,<EOL>'<STR_LIT:name>': capture_name,<EOL>'<STR_LIT>': duration,<EOL>'<STR_LIT>': folder,<EOL>'<STR_LIT>': capture_filter,<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT:source>': self.product<EOL>}<EOL>res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, data=json.dumps(data), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Create a new sysdig capture. The capture will be immediately started.

        **Arguments**
            - **hostname**: the hostname of the instrumented host where the capture will be taken.
            - **capture_name**: the name of the capture.
            - **duration**: the duration of the capture, in seconds.
            - **capture_filter**: a sysdig filter expression.
            - **folder**: directory in the S3 bucket where the capture will be saved.

        **Success Return Value**
            A dictionary showing the details of the new capture.

        **Example**
            `examples/create_sysdig_capture.py <https://github.com/draios/python-sdc-client/blob/master/examples/create_sysdig_capture.py>`_


url = '<STR_LIT>'.format(<EOL>url=self.url, id=capture_id, product=self.product)<EOL>res = requests.get(url, headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return False, self.lasterr<EOL><DEDENT>return True, res.content<EOL>

**Description**
            Download a sysdig capture by id.

        **Arguments**
            - **capture_id**: the capture id to download.

        **Success Return Value**
            The bytes of the scap


def create_user_invite(self, user_email, first_name=None, last_name=None, system_role=None):

<EOL>res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>data = res.json()<EOL>for user in data['<STR_LIT>']:<EOL><INDENT>if user['<STR_LIT:username>'] == user_email:<EOL><INDENT>return [False, '<STR_LIT>' + user_email + '<STR_LIT>']<EOL><DEDENT><DEDENT>options = {'<STR_LIT:username>': user_email,<EOL>'<STR_LIT>': first_name,<EOL>'<STR_LIT>': last_name,<EOL>'<STR_LIT>': system_role}<EOL>user_json = {k: v for k, v in options.items() if v is not None}<EOL>res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, data=json.dumps(user_json), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Invites a new user to use Sysdig Monitor. This should result in an email notification to the specified address.

        **Arguments**
            - **user_email**: the email address of the user that will be invited to use Sysdig Monitor
            - **first_name**: the first name of the user being invited
            - **last_name**: the last name of the user being invited
            - **system_role**: system-wide privilege level for this user regardless of team. specify 'ROLE_CUSTOMER' to create an Admin. if not specified, default is a non-Admin ('ROLE_USER').

        **Success Return Value**
            The newly created user.

        **Examples**
            - `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_
            - `examples/user_team_mgmt_extended.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt_extended.py>`_


res = self.get_user_ids([user_email])<EOL>if res[<NUM_LIT:0>] == False:<EOL><INDENT>return res<EOL><DEDENT>userid = res[<NUM_LIT:1>][<NUM_LIT:0>]<EOL>res = requests.delete(self.url + '<STR_LIT>' + str(userid), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, None]<EOL>

**Description**
            Deletes a user from Sysdig Monitor.

        **Arguments**
            - **user_email**: the email address of the user that will be deleted from Sysdig Monitor

        **Example**
            `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, res.json()['<STR_LIT>']]<EOL>

**Description**
            Return a list containing details about all users in the Sysdig Monitor environment. The API token must have Admin rights for this to succeed.

        **Success Return Value**
            A list user objects


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>ret = [t for t in res.json()['<STR_LIT>'] if team_filter in t['<STR_LIT:name>']]<EOL>return [True, ret]<EOL>

**Description**
            Return the set of teams that match the filter specified. The *team_filter* should be a substring of the names of the teams to be returned.

        **Arguments**
            - **team_filter**: the team filter to match when returning the list of teams

        **Success Return Value**
            The teams that match the filter.


res = self.get_teams(name)<EOL>if res[<NUM_LIT:0>] == False:<EOL><INDENT>return res<EOL><DEDENT>for t in res[<NUM_LIT:1>]:<EOL><INDENT>if t['<STR_LIT:name>'] == name:<EOL><INDENT>return [True, t]<EOL><DEDENT><DEDENT>return [False, '<STR_LIT>']<EOL>

**Description**
            Return the team with the specified team name, if it is present.

        **Arguments**
            - **name**: the name of the team to return

        **Success Return Value**
            The requested team.

        **Example**
            `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_


def create_team(self, name, memberships=None, filter='<STR_LIT>', description='<STR_LIT>', show='<STR_LIT:host>', theme='<STR_LIT>',<EOL>perm_capture=False, perm_custom_events=False, perm_aws_data=False):

reqbody = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT:description>': description,<EOL>'<STR_LIT>': theme,<EOL>'<STR_LIT>': show,<EOL>'<STR_LIT>': perm_capture,<EOL>'<STR_LIT>': perm_custom_events,<EOL>'<STR_LIT>': perm_aws_data,<EOL>}<EOL>if memberships != None and len(memberships) != <NUM_LIT:0>:<EOL><INDENT>res = self._get_user_id_dict(list(memberships.keys()))<EOL>if res[<NUM_LIT:0>] == False:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>reqbody['<STR_LIT>'] = [<EOL>{<EOL>'<STR_LIT>': user_id,<EOL>'<STR_LIT>': memberships[user_name]<EOL>}<EOL>for (user_name, user_id) in res[<NUM_LIT:1>].items()<EOL>]<EOL><DEDENT>else:<EOL><INDENT>reqbody['<STR_LIT>'] = []<EOL><DEDENT>if filter != '<STR_LIT>':<EOL><INDENT>reqbody['<STR_LIT>'] = filter<EOL><DEDENT>res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, data=json.dumps(reqbody), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
    Creates a new team

**Arguments**
    - **name**: the name of the team to create.
    - **memberships**: dictionary of (user-name, team-role) pairs that should describe new memberships of the team.
    - **filter**: the scope that this team is able to access within Sysdig Monitor.
    - **description**: describes the team that will be created.
    - **show**: possible values are *host*, *container*.
    - **theme**: the color theme that Sysdig Monitor will use when displaying the team.
    - **perm_capture**: if True, this team will be allowed to take sysdig captures.
    - **perm_custom_events**: if True, this team will be allowed to view all custom events from every user and agent.
    - **perm_aws_data**: if True, this team will have access to all AWS metrics and tags, regardless of the team's scope.

**Success Return Value**
    The newly created team.

**Example**
    `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_


def edit_team(self, name, memberships=None, filter=None, description=None, show=None, theme=None,<EOL>perm_capture=None, perm_custom_events=None, perm_aws_data=None):

res = self.get_team(name)<EOL>if res[<NUM_LIT:0>] == False:<EOL><INDENT>return res<EOL><DEDENT>t = res[<NUM_LIT:1>]<EOL>reqbody = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': theme if theme else t['<STR_LIT>'],<EOL>'<STR_LIT>': show if show else t['<STR_LIT>'],<EOL>'<STR_LIT>': perm_capture if perm_capture else t['<STR_LIT>'],<EOL>'<STR_LIT>': perm_custom_events if perm_custom_events else t['<STR_LIT>'],<EOL>'<STR_LIT>': perm_aws_data if perm_aws_data else t['<STR_LIT>'],<EOL>'<STR_LIT:id>': t['<STR_LIT:id>'],<EOL>'<STR_LIT:version>': t['<STR_LIT:version>']<EOL>}<EOL>if description is not None:<EOL><INDENT>reqbody['<STR_LIT:description>'] = description<EOL><DEDENT>elif '<STR_LIT:description>' in list(t.keys()):<EOL><INDENT>reqbody['<STR_LIT:description>'] = t['<STR_LIT:description>']<EOL><DEDENT>if memberships != None:<EOL><INDENT>res = self._get_user_id_dict(list(memberships.keys()))<EOL>if res[<NUM_LIT:0>] == False:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>reqbody['<STR_LIT>'] = [<EOL>{<EOL>'<STR_LIT>': user_id,<EOL>'<STR_LIT>': memberships[user_name]<EOL>}<EOL>for (user_name, user_id) in res[<NUM_LIT:1>].items()<EOL>]<EOL><DEDENT>elif '<STR_LIT>' in list(t.keys()):<EOL><INDENT>reqbody['<STR_LIT>'] = t['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>reqbody['<STR_LIT>'] = []<EOL><DEDENT>if filter != None:<EOL><INDENT>reqbody['<STR_LIT>'] = filter<EOL><DEDENT>elif '<STR_LIT>' in list(t.keys()):<EOL><INDENT>reqbody['<STR_LIT>'] = t['<STR_LIT>']<EOL><DEDENT>res = requests.put(self.url + '<STR_LIT>' + str(t['<STR_LIT:id>']), headers=self.hdrs, data=json.dumps(reqbody), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
   Edits an existing team. All arguments are optional. Team settings for any arguments unspecified will remain at their current settings.

**Arguments**
    - **name**: the name of the team to edit.
    - **memberships**: dictionary of (user-name, team-role) pairs that should describe new memberships of the team.
    - **filter**: the scope that this team is able to access within Sysdig Monitor.
    - **description**: describes the team that will be created.
    - **show**: possible values are *host*, *container*.
    - **theme**: the color theme that Sysdig Monitor will use when displaying the team.
    - **perm_capture**: if True, this team will be allowed to take sysdig captures.
    - **perm_custom_events**: if True, this team will be allowed to view all custom events from every user and agent.
    - **perm_aws_data**: if True, this team will have access to all AWS metrics and tags, regardless of the team's scope.

**Success Return Value**
    The edited team.

**Example**
    `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_


res = self.get_team(name)<EOL>if res[<NUM_LIT:0>] == False:<EOL><INDENT>return res<EOL><DEDENT>t = res[<NUM_LIT:1>]<EOL>res = requests.delete(self.url + '<STR_LIT>' + str(t['<STR_LIT:id>']), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, None]<EOL>

**Description**
            Deletes a team from Sysdig Monitor.

        **Arguments**
            - **name**: the name of the team that will be deleted from Sysdig Monitor

        **Example**
            `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_


res = self.get_team(team)<EOL>if res[<NUM_LIT:0>] == False:<EOL><INDENT>return res<EOL><DEDENT>raw_memberships = res[<NUM_LIT:1>]['<STR_LIT>']<EOL>user_ids = [m['<STR_LIT>'] for m in raw_memberships]<EOL>res = self._get_id_user_dict(user_ids)<EOL>if res[<NUM_LIT:0>] == False:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>id_user_dict = res[<NUM_LIT:1>]<EOL><DEDENT>return [True, dict([(id_user_dict[m['<STR_LIT>']], m['<STR_LIT>']) for m in raw_memberships])]<EOL>

**Description**
    List all memberships for specified team.

**Arguments**
    - **team**: the name of the team for which we want to see memberships

**Result**
    Dictionary of (user-name, team-role) pairs that should describe memberships of the team.

**Example**
    `examples/user_team_mgmt_extended.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt_extended.py>`_


def save_memberships(self, team, memberships):

res = self.list_memberships(team)<EOL>if res[<NUM_LIT:0>] is False:<EOL><INDENT>return res<EOL><DEDENT>full_memberships = res[<NUM_LIT:1>]<EOL>full_memberships.update(memberships)<EOL>res = self.edit_team(team, full_memberships)<EOL>if res[<NUM_LIT:0>] is False:<EOL><INDENT>return res<EOL><DEDENT>else:<EOL><INDENT>return [True, None]<EOL><DEDENT>

**Description**
    Create new user team memberships or update existing ones.

**Arguments**
    - **team**: the name of the team for which we are creating new memberships
    - **memberships**: dictionary of (user-name, team-role) pairs that should describe new memberships

**Example**
    `examples/user_team_mgmt_extended.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt_extended.py>`_


def remove_memberships(self, team, users):

res = self.list_memberships(team)<EOL>if res[<NUM_LIT:0>] is False:<EOL><INDENT>return res<EOL><DEDENT>old_memberships = res[<NUM_LIT:1>]<EOL>new_memberships = {k: v for k, v in old_memberships.items() if k not in users}<EOL>res = self.edit_team(team, new_memberships)<EOL>if res[<NUM_LIT:0>] is False:<EOL><INDENT>return res<EOL><DEDENT>else:<EOL><INDENT>return [True, None]<EOL><DEDENT>

**Description**
    Remove user memberships from specified team.

**Arguments**
    - **team**: the name of the team from which user memberships are removed
    - **users**: list of usernames which should be removed from team

**Example**
    `examples/user_team_mgmt_extended.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt_extended.py>`_


dashboard_configuration = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': <NUM_LIT:2>,<EOL>'<STR_LIT>': []<EOL>}<EOL>res = requests.post(self.url + self._dashboards_api_endpoint, headers=self.hdrs, data=json.dumps({'<STR_LIT>': dashboard_configuration}),<EOL>verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
    Creates an empty dashboard. You can then add panels by using ``add_dashboard_panel``.

**Arguments**
    - **name**: the name of the dashboard that will be created.

**Success Return Value**
    A dictionary showing the details of the new dashboard.

**Example**
    `examples/dashboard.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard.py>`_


def add_dashboard_panel(self, dashboard, name, panel_type, metrics, scope=None, sort_by=None, limit=None, layout=None):

panel_configuration = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': <NUM_LIT:1>,<EOL>'<STR_LIT>': <NUM_LIT:1>,<EOL>'<STR_LIT>': <NUM_LIT:12>,<EOL>'<STR_LIT>': <NUM_LIT:6><EOL>}<EOL>}<EOL>if panel_type == '<STR_LIT>':<EOL><INDENT>metrics = copy.copy(metrics)<EOL>metrics.insert(<NUM_LIT:0>, {'<STR_LIT:id>': '<STR_LIT>'})<EOL><DEDENT>property_names = {}<EOL>k_count = <NUM_LIT:0><EOL>v_count = <NUM_LIT:0><EOL>for i, metric in enumerate(metrics):<EOL><INDENT>property_name = '<STR_LIT:v>' if '<STR_LIT>' in metric else '<STR_LIT:k>'<EOL>if property_name == '<STR_LIT:k>':<EOL><INDENT>i = k_count<EOL>k_count += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>i = v_count<EOL>v_count += <NUM_LIT:1><EOL><DEDENT>property_names[metric['<STR_LIT:id>']] = property_name + str(i)<EOL>panel_configuration['<STR_LIT>'].append({<EOL>'<STR_LIT>': metric['<STR_LIT:id>'],<EOL>'<STR_LIT>': metric['<STR_LIT>']['<STR_LIT:time>'] if '<STR_LIT>' in metric else None,<EOL>'<STR_LIT>': metric['<STR_LIT>']['<STR_LIT>'] if '<STR_LIT>' in metric else None,<EOL>'<STR_LIT>': property_name + str(i)<EOL>})<EOL><DEDENT>panel_configuration['<STR_LIT>'] = scope<EOL>panel_configuration['<STR_LIT>'] = ('<STR_LIT>' in dashboard and dashboard['<STR_LIT>'] != scope) or ('<STR_LIT>' not in dashboard and scope != None)<EOL>if panel_type == '<STR_LIT>':<EOL><INDENT>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL>if limit != None:<EOL><INDENT>panel_configuration['<STR_LIT>'] = {<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT:to>': limit - <NUM_LIT:1><EOL>}<EOL><DEDENT><DEDENT>elif panel_type == '<STR_LIT>':<EOL><INDENT>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>elif panel_type == '<STR_LIT>':<EOL><INDENT>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL>if sort_by is None:<EOL><INDENT>panel_configuration['<STR_LIT>'] = [{<EOL>'<STR_LIT:id>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}]<EOL><DEDENT>else:<EOL><INDENT>panel_configuration['<STR_LIT>'] = [{<EOL>'<STR_LIT:id>': property_names[sort_by['<STR_LIT>']],<EOL>'<STR_LIT>': sort_by['<STR_LIT>']<EOL>}]<EOL><DEDENT>if limit is None:<EOL><INDENT>panel_configuration['<STR_LIT>'] = {<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT:to>': <NUM_LIT:10><EOL>}<EOL><DEDENT>else:<EOL><INDENT>panel_configuration['<STR_LIT>'] = {<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT:to>': limit - <NUM_LIT:1><EOL>}<EOL><DEDENT><DEDENT>if layout != None:<EOL><INDENT>panel_configuration['<STR_LIT>'] = layout<EOL><DEDENT>dashboard_configuration = copy.deepcopy(dashboard)<EOL>dashboard_configuration['<STR_LIT:id>'] = None<EOL>dashboard_configuration['<STR_LIT>'].append(panel_configuration)<EOL>res = requests.put(self.url + self._dashboards_api_endpoint + '<STR_LIT:/>' + str(dashboard['<STR_LIT:id>']), headers=self.hdrs, data=json.dumps({'<STR_LIT>': dashboard_configuration}),<EOL>verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Adds a panel to the dashboard. A panel can be a time series, or a top chart (i.e. bar chart), or a number panel.

        **Arguments**
            - **dashboard**: dashboard to edit
            - **name**: name of the new panel
            - **panel_type**: type of the new panel. Valid values are: ``timeSeries``, ``top``, ``number``
            - **metrics**:  a list of dictionaries, specifying the metrics to show in the panel, and optionally, if there is only one metric, a grouping key to segment that metric by. A metric is any of the entries that can be found in the *Metrics* section of the Explore page in Sysdig Monitor. Metric entries require an *aggregations* section specifying how to aggregate the metric across time and groups of containers/hosts. A grouping key is any of the entries that can be found in the *Show* or *Segment By* sections of the Explore page in Sysdig Monitor. Refer to the examples section below for ready to use code snippets. Note, certain panels allow certain combinations of metrics and grouping keys:
                - ``timeSeries``: 1 or more metrics OR 1 metric + 1 grouping key
                - ``top``: 1 or more metrics OR 1 metric + 1 grouping key
                - ``number``: 1 metric only
            - **scope**: filter to apply to the panel; must be based on metadata available in Sysdig Monitor; Example: *kubernetes.namespace.name='production' and container.image='nginx'*.
            - **sort_by**: Data sorting; The parameter is optional and it's a dictionary of ``metric`` and ``mode`` (it can be ``desc`` or ``asc``)
            - **limit**: This parameter sets the limit on the number of lines/bars shown in a ``timeSeries`` or ``top`` panel. In the case of more entities being available than the limit, the top entities according to the sort will be shown. The default value is 10 for ``top`` panels (for ``timeSeries`` the default is defined by Sysdig Monitor itself). Note that increasing the limit above 10 is not officially supported and may cause performance and rendering issues
            - **layout**: Size and position of the panel. The dashboard layout is defined by a grid of 12 columns, each row height is equal to the column height. For example, say you want to show 2 panels at the top: one panel might be 6 x 3 (half the width, 3 rows height) located in row 1 and column 1 (top-left corner of the viewport), the second panel might be 6 x 3 located in row 1 and position 7. The location is specified by a dictionary of ``row`` (row position), ``col`` (column position), ``size_x`` (width), ``size_y`` (height).

        **Success Return Value**
            A dictionary showing the details of the edited dashboard.

        **Example**
            `examples/dashboard.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard.py>`_


def remove_dashboard_panel(self, dashboard, panel_name):

<EOL>dashboard_configuration = copy.deepcopy(dashboard)<EOL>dashboard_configuration['<STR_LIT:id>'] = None<EOL>def filter_fn(panel):<EOL><INDENT>return panel['<STR_LIT:name>'] == panel_name<EOL><DEDENT>panels = list(filter(filter_fn, dashboard_configuration['<STR_LIT>']))<EOL>if len(panels) > <NUM_LIT:0>:<EOL><INDENT>for panel in panels:<EOL><INDENT>dashboard_configuration['<STR_LIT>'].remove(panel)<EOL><DEDENT>res = requests.put(self.url + self._dashboards_api_endpoint + '<STR_LIT:/>' + str(dashboard['<STR_LIT:id>']), headers=self.hdrs, data=json.dumps({'<STR_LIT>': dashboard_configuration}),<EOL>verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL><DEDENT>else:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>

**Description**
            Removes a panel from the dashboard. The panel to remove is identified by the specified ``name``.

        **Arguments**
            - **name**: name of the panel to find and remove

        **Success Return Value**
            A dictionary showing the details of the edited dashboard.

        **Example**
            `examples/dashboard.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard.py>`_


<EOL>return {}<EOL>

**Description**
            Internal function to return dashboard converters from one version to another one.


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Retrieve the list of alerts configured by the user.

        **Success Return Value**
            An array of alert dictionaries, with the format described at `this link <https://app.sysdigcloud.com/apidocs/#!/Alerts/get_api_alerts>`__

        **Example**
            `examples/list_alerts.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_alerts.py>`_


def get_notifications(self, from_ts, to_ts, state=None, resolved=None):

params = {}<EOL>if from_ts is not None:<EOL><INDENT>params['<STR_LIT>'] = from_ts * <NUM_LIT><EOL><DEDENT>if to_ts is not None:<EOL><INDENT>params['<STR_LIT:to>'] = to_ts * <NUM_LIT><EOL><DEDENT>if state is not None:<EOL><INDENT>params['<STR_LIT:state>'] = state<EOL><DEDENT>if resolved is not None:<EOL><INDENT>params['<STR_LIT>'] = resolved<EOL><DEDENT>res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, params=params, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, res.json()]<EOL>

**Description**
            Returns the list of Sysdig Monitor alert notifications.

        **Arguments**
            - **from_ts**: filter events by start time. Timestamp format is in UTC (seconds).
            - **to_ts**: filter events by start time. Timestamp format is in UTC (seconds).
            - **state**: filter events by alert state. Supported values are ``OK`` and ``ACTIVE``.
            - **resolved**: filter events by resolution status. Supported values are ``True`` and ``False``.

        **Success Return Value**
            A dictionary containing the list of notifications.

        **Example**
            `examples/list_alert_notifications.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_alert_notifications.py>`_


def update_notification_resolution(self, notification, resolved):

if '<STR_LIT:id>' not in notification:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>notification['<STR_LIT>'] = resolved<EOL>data = {'<STR_LIT>': notification}<EOL>res = requests.put(self.url + '<STR_LIT>' + str(notification['<STR_LIT:id>']), headers=self.hdrs, data=json.dumps(data), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Updates the resolution status of an alert notification.

        **Arguments**
            - **notification**: notification object as returned by :func:`~SdcClient.get_notifications`.
            - **resolved**: new resolution status. Supported values are ``True`` and ``False``.

        **Success Return Value**
            The updated notification.

        **Example**
            `examples/resolve_alert_notifications.py <https://github.com/draios/python-sdc-client/blob/master/examples/resolve_alert_notifications.py>`_


def create_alert(self, name=None, description=None, severity=None, for_atleast_s=None, condition=None,<EOL>segmentby=[], segment_condition='<STR_LIT>', user_filter='<STR_LIT>', notify=None, enabled=True,<EOL>annotations={}, alert_obj=None):

<EOL>res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>res.json()<EOL>if alert_obj is None:<EOL><INDENT>if None in (name, description, severity, for_atleast_s, condition):<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>alert_json = {<EOL>'<STR_LIT>': {<EOL>'<STR_LIT:type>': '<STR_LIT>',<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT:description>': description,<EOL>'<STR_LIT>': enabled,<EOL>'<STR_LIT>': severity,<EOL>'<STR_LIT>': for_atleast_s * <NUM_LIT>,<EOL>'<STR_LIT>': condition,<EOL>'<STR_LIT>': user_filter<EOL>}<EOL>}<EOL>if segmentby != None and segmentby != []:<EOL><INDENT>alert_json['<STR_LIT>']['<STR_LIT>'] = segmentby<EOL>alert_json['<STR_LIT>']['<STR_LIT>'] = {'<STR_LIT:type>': segment_condition}<EOL><DEDENT>if annotations != None and annotations != {}:<EOL><INDENT>alert_json['<STR_LIT>']['<STR_LIT>'] = annotations<EOL><DEDENT>if notify != None:<EOL><INDENT>alert_json['<STR_LIT>']['<STR_LIT>'] = notify<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>alert_obj.pop('<STR_LIT:id>', None)<EOL>alert_obj.pop('<STR_LIT:version>', None)<EOL>alert_json = {<EOL>'<STR_LIT>': alert_obj<EOL>}<EOL><DEDENT>res = requests.post(self.url + '<STR_LIT>', headers=self.hdrs, data=json.dumps(alert_json), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Create a threshold-based alert.

        **Arguments**
            - **name**: the alert name. This will appear in the Sysdig Monitor UI and in notification emails.
            - **description**: the alert description. This will appear in the Sysdig Monitor UI and in notification emails.
            - **severity**: syslog-encoded alert severity. This is a number from 0 to 7 where 0 means 'emergency' and 7 is 'debug'.
            - **for_atleast_s**: the number of consecutive seconds the condition must be satisfied for the alert to fire.
            - **condition**: the alert condition, as described here https://app.sysdigcloud.com/apidocs/#!/Alerts/post_api_alerts
            - **segmentby**: a list of Sysdig Monitor segmentation criteria that can be used to apply the alert to multiple entities. For example, segmenting a CPU alert by ['host.mac', 'proc.name'] allows to apply it to any process in any machine.
            - **segment_condition**: When *segmentby* is specified (and therefore the alert will cover multiple entities) this field is used to determine when it will fire. In particular, you have two options for *segment_condition*: **ANY** (the alert will fire when at least one of the monitored entities satisfies the condition) and **ALL** (the alert will fire when all of the monitored entities satisfy the condition).
            - **user_filter**: a boolean expression combining Sysdig Monitor segmentation criteria that makes it possible to reduce the scope of the alert. For example: *kubernetes.namespace.name='production' and container.image='nginx'*.
            - **notify**: the type of notification you want this alert to generate. Options are *EMAIL*, *SNS*, *PAGER_DUTY*, *SYSDIG_DUMP*.
            - **enabled**: if True, the alert will be enabled when created.
            - **annotations**: an optional dictionary of custom properties that you can associate to this alert for automation or management reasons
            - **alert_obj**: an optional fully-formed Alert object of the format returned in an "alerts" list by :func:`~SdcClient.get_alerts` This is an alternative to creating the Alert using the individual parameters listed above.

        **Success Return Value**
            A dictionary describing the just created alert, with the format described at `this link <https://app.sysdigcloud.com/apidocs/#!/Alerts/post_api_alerts>`__

        **Example**
            `examples/create_alert.py <https://github.com/draios/python-sdc-client/blob/master/examples/create_alert.py>`_


if '<STR_LIT:id>' not in alert:<EOL><INDENT>return [False, "<STR_LIT>"]<EOL><DEDENT>res = requests.put(self.url + '<STR_LIT>' + str(alert['<STR_LIT:id>']), headers=self.hdrs, data=json.dumps({"<STR_LIT>": alert}), verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Update a modified threshold-based alert.

        **Arguments**
            - **alert**: one modified alert object of the same format as those in the list returned by :func:`~SdcClient.get_alerts`.

        **Success Return Value**
            The updated alert.

        **Example**
            `examples/update_alert.py <https://github.com/draios/python-sdc-client/blob/master/examples/update_alert.py>`_


if '<STR_LIT:id>' not in alert:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>res = requests.delete(self.url + '<STR_LIT>' + str(alert['<STR_LIT:id>']), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, None]<EOL>

**Description**
            Deletes an alert.

        **Arguments**
            - **alert**: the alert dictionary as returned by :func:`~SdcClient.get_alerts`.

        **Success Return Value**
            ``None``.

        **Example**
            `examples/delete_alert.py <https://github.com/draios/python-sdc-client/blob/master/examples/delete_alert.py>`_


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>data = res.json()<EOL>if '<STR_LIT>' not in data:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>gconfs = data['<STR_LIT>']<EOL>for gconf in gconfs:<EOL><INDENT>if gconf['<STR_LIT:id>'] == '<STR_LIT>':<EOL><INDENT>res = []<EOL>items = gconf['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT>']<EOL>for item in items:<EOL><INDENT>res.append(item['<STR_LIT>'])<EOL><DEDENT>return [True, res]<EOL><DEDENT><DEDENT>return [False, '<STR_LIT>']<EOL>

**Description**
            Return the user's current grouping hierarchy as visible in the Explore tab of Sysdig Monitor.

        **Success Return Value**
            A list containing the list of the user's Explore grouping criteria.

        **Example**
            `examples/print_explore_grouping.py <https://github.com/draios/python-sdc-client/blob/master/examples/print_explore_grouping.py>`_


body = {<EOL>'<STR_LIT:id>': '<STR_LIT>',<EOL>'<STR_LIT>': [{'<STR_LIT>': []}]<EOL>}<EOL>for item in new_hierarchy:<EOL><INDENT>body['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT>'].append({'<STR_LIT>': item})<EOL><DEDENT>res = requests.put(self.url + '<STR_LIT>', headers=self.hdrs,<EOL>data=json.dumps(body), verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>else:<EOL><INDENT>return [True, None]<EOL><DEDENT>

**Description**
            Changes the grouping hierarchy in the Explore panel of the current user.

        **Arguments**
            - **new_hierarchy**: a list of sysdig segmentation metrics indicating the new grouping hierarchy.


res = requests.get(self.url + self._dashboards_api_endpoint, headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Return the list of dashboards available under the given user account. This includes the dashboards created by the user and the ones shared with her by other users.

        **Success Return Value**
            A dictionary containing the list of available sampling intervals.

        **Example**
            `examples/list_dashboards.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_dashboards.py>`_


res = self.get_dashboards()<EOL>if res[<NUM_LIT:0>] is False:<EOL><INDENT>return res<EOL><DEDENT>else:<EOL><INDENT>def filter_fn(configuration):<EOL><INDENT>return configuration['<STR_LIT:name>'] == name<EOL><DEDENT>def create_item(configuration):<EOL><INDENT>return {'<STR_LIT>': configuration}<EOL><DEDENT>dashboards = list(map(create_item, list(filter(filter_fn, res[<NUM_LIT:1>]['<STR_LIT>']))))<EOL>return [True, dashboards]<EOL><DEDENT>

**Description**
            Finds dashboards with the specified name. You can then delete the dashboard (with :func:`~SdcClient.delete_dashboard`) or edit panels (with :func:`~SdcClient.add_dashboard_panel` and :func:`~SdcClient.remove_dashboard_panel`)

        **Arguments**
            - **name**: the name of the dashboards to find.

        **Success Return Value**
            A list of dictionaries of dashboards matching the specified name.

        **Example**
            `examples/dashboard.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard.py>`_


dashboard_configuration = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': <NUM_LIT:2>,<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>}<EOL>res = requests.post(self.url + self._dashboards_api_endpoint, headers=self.hdrs, data=json.dumps({'<STR_LIT>': dashboard_configuration}),<EOL>verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>


def add_dashboard_panel(self, dashboard, name, panel_type, metrics, scope=None, sort_direction='<STR_LIT>', limit=None, layout=None):

panel_configuration = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': <NUM_LIT:1>,<EOL>'<STR_LIT>': <NUM_LIT:1>,<EOL>'<STR_LIT>': <NUM_LIT:12>,<EOL>'<STR_LIT>': <NUM_LIT:6><EOL>},<EOL>'<STR_LIT>': {}<EOL>}<EOL>if panel_type == '<STR_LIT>':<EOL><INDENT>metrics = copy.copy(metrics)<EOL>metrics.insert(<NUM_LIT:0>, {'<STR_LIT:id>': '<STR_LIT>'})<EOL><DEDENT>property_names = {}<EOL>k_count = <NUM_LIT:0><EOL>v_count = <NUM_LIT:0><EOL>for i, metric in enumerate(metrics):<EOL><INDENT>property_name = '<STR_LIT:v>' if '<STR_LIT>' in metric else '<STR_LIT:k>'<EOL>if property_name == '<STR_LIT:k>':<EOL><INDENT>i = k_count<EOL>k_count += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>i = v_count<EOL>v_count += <NUM_LIT:1><EOL><DEDENT>property_names[metric['<STR_LIT:id>']] = property_name + str(i)<EOL>panel_configuration['<STR_LIT>'].append({<EOL>'<STR_LIT:id>': metric['<STR_LIT:id>'],<EOL>'<STR_LIT>': metric['<STR_LIT>']['<STR_LIT:time>'] if '<STR_LIT>' in metric else None,<EOL>'<STR_LIT>': metric['<STR_LIT>']['<STR_LIT>'] if '<STR_LIT>' in metric else None,<EOL>'<STR_LIT>': property_name + str(i)<EOL>})<EOL><DEDENT>panel_configuration['<STR_LIT>'] = scope<EOL>panel_configuration['<STR_LIT>'] = ('<STR_LIT>' in dashboard and dashboard['<STR_LIT>'] != scope) or ('<STR_LIT>' not in dashboard and scope != None)<EOL>if '<STR_LIT>' not in panel_configuration:<EOL><INDENT>panel_configuration['<STR_LIT>'] = {<EOL>'<STR_LIT>': {<EOL>'<STR_LIT:count>': <NUM_LIT:10>,<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>},<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': <NUM_LIT:10><EOL>},<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT:to>': None<EOL>},<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT:to>': None<EOL>},<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT:to>': None<EOL>}<EOL>}<EOL><DEDENT>if panel_type == '<STR_LIT>':<EOL><INDENT>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL>if limit != None:<EOL><INDENT>panel_configuration['<STR_LIT>']['<STR_LIT>'] = {<EOL>'<STR_LIT:count>': limit,<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL><DEDENT><DEDENT>elif panel_type == '<STR_LIT>':<EOL><INDENT>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>elif panel_type == '<STR_LIT>':<EOL><INDENT>panel_configuration['<STR_LIT>'] = '<STR_LIT>'<EOL>if limit != None:<EOL><INDENT>panel_configuration['<STR_LIT>']['<STR_LIT>'] = {<EOL>'<STR_LIT:count>': limit,<EOL>'<STR_LIT>': sort_direction<EOL>}<EOL><DEDENT><DEDENT>if layout != None:<EOL><INDENT>panel_configuration['<STR_LIT>'] = layout<EOL><DEDENT>dashboard_configuration = copy.deepcopy(dashboard)<EOL>dashboard_configuration['<STR_LIT>'].append(panel_configuration)<EOL>res = requests.put(self.url + self._dashboards_api_endpoint + '<STR_LIT:/>' + str(dashboard['<STR_LIT:id>']), headers=self.hdrs, data=json.dumps({'<STR_LIT>': dashboard_configuration}),<EOL>verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Adds a panel to the dashboard. A panel can be a time series, or a top chart (i.e. bar chart), or a number panel.

        **Arguments**
            - **dashboard**: dashboard to edit
            - **name**: name of the new panel
            - **panel_type**: type of the new panel. Valid values are: ``timeSeries``, ``top``, ``number``
            - **metrics**:  a list of dictionaries, specifying the metrics to show in the panel, and optionally, if there is only one metric, a grouping key to segment that metric by. A metric is any of the entries that can be found in the *Metrics* section of the Explore page in Sysdig Monitor. Metric entries require an *aggregations* section specifying how to aggregate the metric across time and groups of containers/hosts. A grouping key is any of the entries that can be found in the *Show* or *Segment By* sections of the Explore page in Sysdig Monitor. Refer to the examples section below for ready to use code snippets. Note, certain panels allow certain combinations of metrics and grouping keys:
                - ``timeSeries``: 1 or more metrics OR 1 metric + 1 grouping key
                - ``top``: 1 or more metrics OR 1 metric + 1 grouping key
                - ``number``: 1 metric only
            - **scope**: filter to apply to the panel; must be based on metadata available in Sysdig Monitor; Example: *kubernetes.namespace.name='production' and container.image='nginx'*.
            - **sort_direction**: Data sorting; The parameter is optional and it's a string identifying the sorting direction (it can be ``desc`` or ``asc``)
            - **limit**: This parameter sets the limit on the number of lines/bars shown in a ``timeSeries`` or ``top`` panel. In the case of more entities being available than the limit, the top entities according to the sort will be shown. The default value is 10 for ``top`` panels (for ``timeSeries`` the default is defined by Sysdig Monitor itself). Note that increasing the limit above 10 is not officially supported and may cause performance and rendering issues
            - **layout**: Size and position of the panel. The dashboard layout is defined by a grid of 12 columns, each row height is equal to the column height. For example, say you want to show 2 panels at the top: one panel might be 6 x 3 (half the width, 3 rows height) located in row 1 and column 1 (top-left corner of the viewport), the second panel might be 6 x 3 located in row 1 and position 7. The location is specified by a dictionary of ``row`` (row position), ``col`` (column position), ``size_x`` (width), ``size_y`` (height).

        **Success Return Value**
            A dictionary showing the details of the edited dashboard.

        **Example**
            `examples/dashboard.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard.py>`_


<EOL>dashboard_configuration = copy.deepcopy(dashboard)<EOL>def filter_fn(panel):<EOL><INDENT>return panel['<STR_LIT:name>'] == panel_name<EOL><DEDENT>panels = list(filter(filter_fn, dashboard_configuration['<STR_LIT>']))<EOL>if len(panels) > <NUM_LIT:0>:<EOL><INDENT>for panel in panels:<EOL><INDENT>dashboard_configuration['<STR_LIT>'].remove(panel)<EOL><DEDENT>res = requests.put(self.url + self._dashboards_api_endpoint + '<STR_LIT:/>' + str(dashboard['<STR_LIT:id>']), headers=self.hdrs, data=json.dumps({'<STR_LIT>': dashboard_configuration}),<EOL>verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL><DEDENT>else:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>


def create_dashboard_from_view(self, newdashname, viewname, filter, shared=False, public=False):

<EOL>gvres = self.get_view(viewname)<EOL>if gvres[<NUM_LIT:0>] is False:<EOL><INDENT>return gvres<EOL><DEDENT>view = gvres[<NUM_LIT:1>]['<STR_LIT>']<EOL>view['<STR_LIT>'] = {'<STR_LIT>': <NUM_LIT:1>}<EOL>view['<STR_LIT:time>'] = {'<STR_LIT>': <NUM_LIT:2> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT>, '<STR_LIT>': <NUM_LIT:2> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT>}<EOL>return self.create_dashboard_from_template(newdashname, view, filter, shared, public)<EOL>

**Description**
            Create a new dasboard using one of the Sysdig Monitor views as a template. You will be able to define the scope of the new dashboard.

        **Arguments**
            - **newdashname**: the name of the dashboard that will be created.
            - **viewname**: the name of the view to use as the template for the new dashboard. This corresponds to the name that the view has in the Explore page.
            - **filter**: a boolean expression combining Sysdig Monitor segmentation criteria that defines what the new dasboard will be applied to. For example: *kubernetes.namespace.name='production' and container.image='nginx'*.
            - **shared**: if set to True, the new dashboard will be a shared one.
            - **public**: if set to True, the new dashboard will be shared with public token.

        **Success Return Value**
            A dictionary showing the details of the new dashboard.

        **Example**
            `examples/create_dashboard.py <https://github.com/draios/python-sdc-client/blob/master/examples/create_dashboard.py>`_


def create_dashboard_from_dashboard(self, newdashname, templatename, filter, shared=False, public=False):

<EOL>res = requests.get(self.url + self._dashboards_api_endpoint, headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>j = res.json()<EOL>dboard = None<EOL>for db in j['<STR_LIT>']:<EOL><INDENT>if db['<STR_LIT:name>'] == templatename:<EOL><INDENT>dboard = db<EOL>break<EOL><DEDENT><DEDENT>if dboard is None:<EOL><INDENT>self.lasterr = '<STR_LIT>' + templatename + '<STR_LIT>'<EOL>return [False, self.lasterr]<EOL><DEDENT>return self.create_dashboard_from_template(newdashname, dboard, filter, shared, public)<EOL>

**Description**
            Create a new dasboard using one of the existing dashboards as a template. You will be able to define the scope of the new dasboard.

        **Arguments**
            - **newdashname**: the name of the dashboard that will be created.
            - **viewname**: the name of the dasboard to use as the template, as it appears in the Sysdig Monitor dashboard page.
            - **filter**: a boolean expression combining Sysdig Monitor segmentation criteria defines what the new dasboard will be applied to. For example: *kubernetes.namespace.name='production' and container.image='nginx'*.
            - **shared**: if set to True, the new dashboard will be a shared one.
            - **public**: if set to True, the new dashboard will be shared with public token.

        **Success Return Value**
            A dictionary showing the details of the new dashboard.

        **Example**
            `examples/create_dashboard.py <https://github.com/draios/python-sdc-client/blob/master/examples/create_dashboard.py>`_


def create_dashboard_from_file(self, dashboard_name, filename, filter, shared=False, public=False):

<EOL>with open(filename) as data_file:<EOL><INDENT>loaded_object = json.load(data_file)<EOL><DEDENT>if '<STR_LIT>' not in loaded_object:<EOL><INDENT>loaded_object = {<EOL>'<STR_LIT:version>': '<STR_LIT>',<EOL>'<STR_LIT>': loaded_object<EOL>}<EOL><DEDENT>dashboard = loaded_object['<STR_LIT>']<EOL>if loaded_object['<STR_LIT:version>'] != self._dashboards_api_version:<EOL><INDENT>conversion_result, dashboard = self._convert_dashboard_to_current_version(dashboard, loaded_object['<STR_LIT:version>'])<EOL>if conversion_result == False:<EOL><INDENT>return conversion_result, dashboard<EOL><DEDENT><DEDENT>return self.create_dashboard_from_template(dashboard_name, dashboard, filter, shared, public)<EOL>

**Description**
    Create a new dasboard using a dashboard template saved to disk. See :func:`~SdcClient.save_dashboard_to_file` to use the file to create a dashboard (usefl to create and restore backups).

    The file can contain the following JSON formats:
    1. dashboard object in the format of an array element returned by :func:`~SdcClient.get_dashboards`
    2. JSON object with the following properties:
        * version: dashboards API version (e.g. 'v2')
        * dashboard: dashboard object in the format of an array element returned by :func:`~SdcClient.get_dashboards`

**Arguments**
    - **dashboard_name**: the name of the dashboard that will be created.
    - **filename**: name of a file containing a JSON object
    - **filter**: a boolean expression combining Sysdig Monitor segmentation criteria defines what the new dasboard will be applied to. For example: *kubernetes.namespace.name='production' and container.image='nginx'*.
    - **shared**: if set to True, the new dashboard will be a shared one.
    - **public**: if set to True, the new dashboard will be shared with public token.

**Success Return Value**
    A dictionary showing the details of the new dashboard.

**Example**
    `examples/dashboard_save_load.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard_save_load.py>`_


def save_dashboard_to_file(self, dashboard, filename):

with open(filename, '<STR_LIT:w>') as outf:<EOL><INDENT>json.dump({<EOL>'<STR_LIT:version>': self._dashboards_api_version,<EOL>'<STR_LIT>': dashboard<EOL>}, outf)<EOL><DEDENT>

**Description**
    Save a dashboard to disk. See :func:`~SdcClient.create_dashboard_from_file` to use the file to create a dashboard (usefl to create and restore backups).

    The file will contain a JSON object with the following properties:
    * version: dashboards API version (e.g. 'v2')
    * dashboard: dashboard object in the format of an array element returned by :func:`~SdcClient.get_dashboards`

**Arguments**
    - **dashboard**: dashboard object in the format of an array element returned by :func:`~SdcClient.get_dashboards`
    - **filename**: name of a file that will contain a JSON object

**Example**
    `examples/dashboard_save_load.py <https://github.com/draios/python-sdc-client/blob/master/examples/dashboard_save_load.py>`_


if '<STR_LIT:id>' not in dashboard:<EOL><INDENT>return [False, "<STR_LIT>"]<EOL><DEDENT>res = requests.delete(self.url + self._dashboards_api_endpoint + '<STR_LIT:/>' + str(dashboard['<STR_LIT:id>']), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, None]<EOL>

**Description**
            Deletes a dashboard.

        **Arguments**
            - **dashboard**: the dashboard object as returned by :func:`~SdcClient.get_dashboards`.

        **Success Return Value**
            `None`.

        **Example**
            `examples/delete_dashboard.py <https://github.com/draios/python-sdc-client/blob/master/examples/delete_dashboard.py>`_


res = requests.get(self.url + '<STR_LIT>', headers=self.hdrs, verify=self.ssl_verify)<EOL>return self._request_result(res)<EOL>

**Description**
            Return the metric list that can be used for data requests/alerts/dashboards.

        **Success Return Value**
            A dictionary containing the list of available metrics.

        **Example**
            `examples/list_metrics.py <https://github.com/draios/python-sdc-client/blob/master/examples/list_metrics.py>`_


<EOL>if scope is None or not scope:<EOL><INDENT>return [True, []]<EOL><DEDENT>expressions = []<EOL>string_expressions = scope.strip('<STR_LIT>').split('<STR_LIT>')<EOL>expression_re = re.compile('<STR_LIT>')<EOL>for string_expression in string_expressions:<EOL><INDENT>matches = expression_re.match(string_expression)<EOL>if matches is None:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>is_not_operator = matches.group('<STR_LIT>') is not None<EOL>if matches.group('<STR_LIT>') == '<STR_LIT>':<EOL><INDENT>list_value = matches.group('<STR_LIT:value>').strip('<STR_LIT>')<EOL>value_matches = re.findall('<STR_LIT>', list_value)<EOL>if len(value_matches) == <NUM_LIT:0>:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>value_matches = map(lambda v: v[<NUM_LIT:0>] if v[<NUM_LIT:0>] else v[<NUM_LIT:1>], value_matches)<EOL>values = map(lambda v: v.strip('<STR_LIT>'), value_matches)<EOL><DEDENT>else:<EOL><INDENT>values = [matches.group('<STR_LIT:value>').strip('<STR_LIT>')]<EOL><DEDENT>operator_parse_dict = {<EOL>'<STR_LIT>': '<STR_LIT>' if not is_not_operator else '<STR_LIT>',<EOL>'<STR_LIT:=>': '<STR_LIT>' if not is_not_operator else '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>' if not is_not_operator else '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>' if not is_not_operator else '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>operator = operator_parse_dict.get(matches.group('<STR_LIT>'), None)<EOL>if operator is None:<EOL><INDENT>return [False, '<STR_LIT>']<EOL><DEDENT>expressions.append({<EOL>'<STR_LIT>': matches.group('<STR_LIT>'),<EOL>'<STR_LIT>': operator,<EOL>'<STR_LIT:value>': values<EOL>})<EOL><DEDENT>return [True, expressions]<EOL>

**Description**
            Internal function to convert a filter string to a filter object to be used with dashboards.


def add_image(self, image, force=False, dockerfile=None, annotations={}, autosubscribe=True):

itype = self._discover_inputimage_format(image)<EOL>if itype != '<STR_LIT>':<EOL><INDENT>return [False, "<STR_LIT>"]<EOL><DEDENT>payload = {}<EOL>if dockerfile:<EOL><INDENT>payload['<STR_LIT>'] = base64.b64encode(dockerfile.encode()).decode("<STR_LIT:utf-8>")<EOL><DEDENT>payload['<STR_LIT>'] = image<EOL>if annotations:<EOL><INDENT>payload['<STR_LIT>'] = annotations<EOL><DEDENT>url = "<STR_LIT>".format(<EOL>base_url=self.url,<EOL>autosubscribe=str(autosubscribe),<EOL>force="<STR_LIT>" if force else "<STR_LIT>")<EOL>res = requests.post(url, data=json.dumps(payload), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, res.json()]<EOL>

**Description**
            Add an image to the scanner

        **Arguments**
            - image: Input image can be in the following formats: registry/repo:tag
            - dockerfile: The contents of the dockerfile as a str.
            - annotations: A dictionary of annotations {str: str}.
            - autosubscribe: Should active the subscription to this image?

        **Success Return Value**
            A JSON object representing the image that was added.


url = self.url + "<STR_LIT>"<EOL>res = requests.post(url, data=json.dumps(image_data), headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, res.json()]<EOL>

**Description**
            Import an image from the scanner export

        **Arguments**
            - image_data: A JSON with the image information.

        **Success Return Value**
            A JSON object representing the image that was imported.


def get_image(self, image, show_history=False):

itype = self._discover_inputimage_format(image)<EOL>if itype not in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>return [False, "<STR_LIT>"]<EOL><DEDENT>params = {}<EOL>params['<STR_LIT>'] = str(show_history and itype not in ['<STR_LIT>', '<STR_LIT>']).lower()<EOL>if itype == '<STR_LIT>':<EOL><INDENT>params['<STR_LIT>'] = image<EOL><DEDENT>url = self.url + "<STR_LIT>"<EOL>url += {<EOL>'<STR_LIT>': '<STR_LIT>'.format(image),<EOL>'<STR_LIT>': '<STR_LIT>'.format(image)<EOL>}.get(itype, '<STR_LIT>')<EOL>res = requests.get(url, params=params, headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, res.json()]<EOL>

**Description**
            Find the image with the tag <image> and return its json description

        **Arguments**
            - image: Input image can be in the following formats: registry/repo:tag

        **Success Return Value**
            A JSON object representing the image.


url = self.url + "<STR_LIT>"<EOL>res = requests.get(url, headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, res.json()]<EOL>

**Description**
            List the current set of images in the scanner.

        **Arguments**
            - None

        **Success Return Value**
            A JSON object containing all the images.


def query_image_content(self, image, content_type="<STR_LIT>"):

return self._query_image(image, query_group='<STR_LIT:content>', query_type=content_type)<EOL>

**Description**
            Find the image with the tag <image> and return its content.

        **Arguments**
            - image: Input image can be in the following formats: registry/repo:tag
            - content_type: The content type can be one of the following types:
                - os: Operating System Packages
                - npm: Node.JS NPM Module
                - gem: Ruby GEM
                - files: Files

        **Success Return Value**
            A JSON object representing the image content.


def query_image_metadata(self, image, metadata_type="<STR_LIT>"):

return self._query_image(image, query_group='<STR_LIT>', query_type=metadata_type)<EOL>

**Description**
            Find the image with the tag <image> and return its metadata.

        **Arguments**
            - image: Input image can be in the following formats: registry/repo:tag
            - metadata_type: The metadata type can be one of the types returned by running without a type specified

        **Success Return Value**
            A JSON object representing the image metadata.


def query_image_vuln(self, image, vuln_type="<STR_LIT>", vendor_only=True):

return self._query_image(image, query_group='<STR_LIT>', query_type=vuln_type, vendor_only=vendor_only)<EOL>

**Description**
            Find the image with the tag <image> and return its vulnerabilities.

        **Arguments**
            - image: Input image can be in the following formats: registry/repo:tag
            - vuln_type: Vulnerability type can be one of the following types:
                - os: CVE/distro vulnerabilities against operating system packages

        **Success Return Value**
            A JSON object representing the image vulnerabilities.


def delete_image(self, image, force=False):

_, _, image_digest = self._discover_inputimage(image)<EOL>if not image_digest:<EOL><INDENT>return [False, "<STR_LIT>"]<EOL><DEDENT>url = self.url + "<STR_LIT>" + image_digest<EOL>res = requests.delete(url, headers=self.hdrs, verify=self.ssl_verify)<EOL>if not self._checkResponse(res):<EOL><INDENT>return [False, self.lasterr]<EOL><DEDENT>return [True, res.json()]<EOL>

**Description**
            Delete image from the scanner.

        **Arguments**
            - None