lvi-api-client 0.2.9__tar.gz → 0.2.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lvi-api-client
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
4
  Summary: LogicVein API Client Library
5
5
  Requires-Python: >=3.8
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1 @@
1
+ 0.2.10
@@ -4278,6 +4278,7 @@ class LogicVeinAPIClient:
4278
4278
  sort_column: str = "policyName",
4279
4279
  descending: bool = False,
4280
4280
  page_size: int = 500,
4281
+ strict: bool = False,
4281
4282
  ) -> List[Dict[str, Any]]:
4282
4283
  """Search and list alert policies.
4283
4284
 
@@ -4297,11 +4298,17 @@ class LogicVeinAPIClient:
4297
4298
  sort_column (str): Column to sort by (default: "policyName").
4298
4299
  descending (bool): Sort descending if True (default: False).
4299
4300
  page_size (int): Records per API call (default: 500).
4301
+ strict (bool): Raise on an answer with no list of policies, such as a null result or a
4302
+ response that is not JSON-RPC, rather than stopping the listing there. Without it,
4303
+ such an answer reads as no (more) policies, so a failed read looks like an empty one.
4300
4304
 
4301
4305
  Returns:
4302
4306
  List[Dict[str, Any]]: All matching alert policies.
4307
+
4308
+ Raises:
4309
+ ValueError: If ``strict`` and an answer has no list of policies.
4303
4310
  """
4304
- return self._search_alert_policies(managed_networks, queries, sort_column, descending, page_size, strict=False)
4311
+ return self._search_alert_policies(managed_networks, queries, sort_column, descending, page_size, strict=strict)
4305
4312
 
4306
4313
  def _search_alert_policies(
4307
4314
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lvi-api-client
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
4
  Summary: LogicVein API Client Library
5
5
  Requires-Python: >=3.8
6
6
  Description-Content-Type: text/markdown
@@ -703,6 +703,22 @@ class TestAlertPolicies:
703
703
  client, _ = connect({"Collection.searchAlertPolicies": None})
704
704
  assert client.search_alert_policies() == []
705
705
 
706
+ @pytest.mark.parametrize("answer", [None, {}, {"policies": None}])
707
+ def test_a_strict_search_raises_on_an_answer_with_no_policies(self, connect, answer):
708
+ client, _ = connect({"Collection.searchAlertPolicies": answer})
709
+ with pytest.raises(ValueError):
710
+ client.search_alert_policies(strict=True)
711
+
712
+ def test_a_strict_search_raises_on_a_response_that_is_not_json_rpc(self, connect):
713
+ client, _ = connect()
714
+ with patch.object(client, "call", return_value="<html>login</html>"):
715
+ with pytest.raises(ValueError):
716
+ client.search_alert_policies(strict=True)
717
+
718
+ def test_a_strict_search_returns_what_it_reads(self, connect):
719
+ client, _ = connect({"Collection.searchAlertPolicies": {"policies": [{"policyId": 1}]}})
720
+ assert client.search_alert_policies(strict=True) == [{"policyId": 1}]
721
+
706
722
  @pytest.mark.parametrize("answer", [True, False])
707
723
  def test_a_reference_check_sends_the_id_and_returns_the_answer(self, connect, answer):
708
724
  client, server = connect({"Collection.isAlertPolicyReferenced": answer})
@@ -1 +0,0 @@
1
- 0.2.9
File without changes