3232``` python
3333from crowdsec_tracker_api import (
3434 Cves,
35- Server,
3635 ApiKeyAuth,
3736)
37+ from httpx import HTTPStatusError
3838auth = ApiKeyAuth(api_key = ' your_api_key' )
39- client = Cves(base_url = Server.production_server.value, auth = auth)
40- response = client.get_cves(
41- query = None ,
42- page = 1 ,
43- size = 50 ,
44- )
45- print (response)
39+ client = Cves(auth = auth)
40+ try :
41+ response = client.get_cves(
42+ query = None ,
43+ page = 1 ,
44+ size = 50 ,
45+ )
46+ print (response)
47+ except HTTPStatusError as e:
48+ print (f " An error occurred: { e.response.status_code} - { e.response.text} " )
4649```
4750
4851
@@ -67,15 +70,18 @@ print(response)
6770``` python
6871from crowdsec_tracker_api import (
6972 Cves,
70- Server,
7173 ApiKeyAuth,
7274)
75+ from httpx import HTTPStatusError
7376auth = ApiKeyAuth(api_key = ' your_api_key' )
74- client = Cves(base_url = Server.production_server.value, auth = auth)
75- response = client.get_cve(
76- cve_id = ' cve_id' ,
77- )
78- print (response)
77+ client = Cves(auth = auth)
78+ try :
79+ response = client.get_cve(
80+ cve_id = ' cve_id' ,
81+ )
82+ print (response)
83+ except HTTPStatusError as e:
84+ print (f " An error occurred: { e.response.status_code} - { e.response.text} " )
7985```
8086
8187
@@ -103,18 +109,21 @@ print(response)
103109``` python
104110from crowdsec_tracker_api import (
105111 Cves,
106- Server,
107112 ApiKeyAuth,
108113)
114+ from httpx import HTTPStatusError
109115auth = ApiKeyAuth(api_key = ' your_api_key' )
110- client = Cves(base_url = Server.production_server.value, auth = auth)
111- response = client.get_cve_ips(
112- cve_id = ' cve_id' ,
113- since = None ,
114- page = 1 ,
115- size = 50 ,
116- )
117- print (response)
116+ client = Cves(auth = auth)
117+ try :
118+ response = client.get_cve_ips(
119+ cve_id = ' cve_id' ,
120+ since = None ,
121+ page = 1 ,
122+ size = 50 ,
123+ )
124+ print (response)
125+ except HTTPStatusError as e:
126+ print (f " An error occurred: { e.response.status_code} - { e.response.text} " )
118127```
119128
120129
@@ -141,17 +150,20 @@ print(response)
141150``` python
142151from crowdsec_tracker_api import (
143152 Cves,
144- Server,
145153 ApiKeyAuth,
146154)
155+ from httpx import HTTPStatusError
147156auth = ApiKeyAuth(api_key = ' your_api_key' )
148- client = Cves(base_url = Server.production_server.value, auth = auth)
149- response = client.get_cve_subscribed_integrations(
150- cve_id = ' cve_id' ,
151- page = 1 ,
152- size = 50 ,
153- )
154- print (response)
157+ client = Cves(auth = auth)
158+ try :
159+ response = client.get_cve_subscribed_integrations(
160+ cve_id = ' cve_id' ,
161+ page = 1 ,
162+ size = 50 ,
163+ )
164+ print (response)
165+ except HTTPStatusError as e:
166+ print (f " An error occurred: { e.response.status_code} - { e.response.text} " )
155167```
156168
157169
@@ -176,20 +188,23 @@ print(response)
176188``` python
177189from crowdsec_tracker_api import (
178190 Cves,
179- Server,
180191 ApiKeyAuth,
181192 SubscribeCVEIntegrationRequest,
182193)
194+ from httpx import HTTPStatusError
183195auth = ApiKeyAuth(api_key = ' your_api_key' )
184- client = Cves(base_url = Server.production_server.value, auth = auth)
196+ client = Cves(auth = auth)
185197request = SubscribeCVEIntegrationRequest(
186198 name = None ,
187199)
188- response = client.subscribe_integration_to_cve(
189- request = request,
190- cve_id = ' cve_id' ,
191- )
192- print (response)
200+ try :
201+ response = client.subscribe_integration_to_cve(
202+ request = request,
203+ cve_id = ' cve_id' ,
204+ )
205+ print (response)
206+ except HTTPStatusError as e:
207+ print (f " An error occurred: { e.response.status_code} - { e.response.text} " )
193208```
194209
195210
@@ -214,15 +229,18 @@ print(response)
214229``` python
215230from crowdsec_tracker_api import (
216231 Cves,
217- Server,
218232 ApiKeyAuth,
219233)
234+ from httpx import HTTPStatusError
220235auth = ApiKeyAuth(api_key = ' your_api_key' )
221- client = Cves(base_url = Server.production_server.value, auth = auth)
222- response = client.unsubscribe_integration_from_cve(
223- cve_id = ' cve_id' ,
224- integration_name = ' integration_name' ,
225- )
226- print (response)
236+ client = Cves(auth = auth)
237+ try :
238+ response = client.unsubscribe_integration_from_cve(
239+ cve_id = ' cve_id' ,
240+ integration_name = ' integration_name' ,
241+ )
242+ print (response)
243+ except HTTPStatusError as e:
244+ print (f " An error occurred: { e.response.status_code} - { e.response.text} " )
227245```
228246
0 commit comments