pybgpkit 0.4.1__tar.gz → 0.4.3__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.1
2
2
  Name: pybgpkit
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: BGPKIT tools Python bindings
5
5
  Home-page: https://github.com/bgpkit/pybgpkit
6
6
  Author: Mingwei Zhang
@@ -1,6 +1,7 @@
1
1
  from dataclasses import dataclass
2
2
 
3
3
  import requests as requests
4
+ import urllib3
4
5
 
5
6
 
6
7
  def check_type(value: any, ty: type) -> bool:
@@ -24,9 +25,13 @@ class BrokerItem:
24
25
 
25
26
  class Broker:
26
27
 
27
- def __init__(self, api_url: str = "https://api.broker.bgpkit.com/v2", page_size: int = 100):
28
+ def __init__(self, api_url: str = "https://api.broker.bgpkit.com/v2", page_size: int = 100, verify=True):
28
29
  self.base_url = api_url.strip()
29
30
  self.page_size = int(page_size)
31
+ self.verify = verify
32
+ if not verify:
33
+ # if a user disable SSL verification on-purpose, do not warn the user
34
+ urllib3.disable_warnings()
30
35
 
31
36
  def query(self,
32
37
  ts_start: str = None,
@@ -58,7 +63,7 @@ class Broker:
58
63
  data_items = []
59
64
  if print_url:
60
65
  print(api_url)
61
- res = requests.get(api_url).json()
66
+ res = requests.get(api_url, verify=self.verify).json()
62
67
  while res:
63
68
  if res["count"] > 0:
64
69
  data_items.extend([BrokerItem(**i) for i in res["data"]])
@@ -70,7 +75,7 @@ class Broker:
70
75
  query_url = f"{api_url}&page={page}"
71
76
  if print_url:
72
77
  print(query_url)
73
- res = requests.get(query_url).json()
78
+ res = requests.get(query_url, verify=self.verify).json()
74
79
  else:
75
80
  break
76
81
 
@@ -31,6 +31,14 @@ class TestIntegration(unittest.TestCase):
31
31
  print(len(items))
32
32
  assert len(items) == 7
33
33
 
34
+ def test_broker_no_verify(self):
35
+ broker = bgpkit.Broker(verify=False)
36
+ items = broker.query(ts_start="1643760000", ts_end="2022-02-02T00:20:00", collector_id="rrc00")
37
+ for item in items:
38
+ print(json.dumps(item.__dict__))
39
+ print(len(items))
40
+ assert len(items) == 7
41
+
34
42
  def test_roas(self):
35
43
  roas = bgpkit.Roas()
36
44
  data = roas.query(debug=True, asn=3333, date="2018-01-01")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybgpkit
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: BGPKIT tools Python bindings
5
5
  Home-page: https://github.com/bgpkit/pybgpkit
6
6
  Author: Mingwei Zhang
@@ -1,3 +1,3 @@
1
1
  dataclasses_json
2
- pybgpkit-parser==0.4.1
2
+ pybgpkit-parser==0.4.2
3
3
  requests
@@ -7,7 +7,7 @@ long_description = (this_directory / "README.md").read_text()
7
7
 
8
8
  setuptools.setup(
9
9
  name='pybgpkit',
10
- version='0.4.1',
10
+ version='0.4.3',
11
11
  description='BGPKIT tools Python bindings',
12
12
  url='https://github.com/bgpkit/pybgpkit',
13
13
  author='Mingwei Zhang',
@@ -19,7 +19,7 @@ setuptools.setup(
19
19
  install_requires=[
20
20
  # available on pip
21
21
  'dataclasses_json',
22
- 'pybgpkit-parser==0.4.1',
22
+ 'pybgpkit-parser==0.4.2',
23
23
  'requests',
24
24
  ]
25
25
  )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes