Skip to content

Commit 10d5e42

Browse files
committed
remove comments
1 parent cbb688d commit 10d5e42

File tree

2 files changed

+0
-222
lines changed

2 files changed

+0
-222
lines changed

opa_client/base.py

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -145,142 +145,3 @@ def query_rule(
145145

146146
def ad_hoc_query(self, query: str, input_data: dict = None) -> dict:
147147
raise NotImplementedError
148-
149-
150-
# class OpaClient(BaseOpaClient):
151-
# """
152-
# Synchronous OpaClient implementation using requests.
153-
# """
154-
155-
# def __init__(self, *args, **kwargs):
156-
# super().__init__(*args, **kwargs)
157-
158-
# self._init_session()
159-
160-
# def _init_session(self):
161-
# self._session = requests.Session()
162-
# self._session.headers.update(self.headers)
163-
164-
# if self.ssl:
165-
# self._session.verify = self.cert if self.cert else True
166-
167-
# # Optionally, configure retries and other session parameters
168-
169-
# def close_connection(self):
170-
# if self._session:
171-
# self._session.close()
172-
# self._session = None
173-
174-
# def check_connection(self) -> str:
175-
# url = self._build_url('policies/')
176-
# try:
177-
# response = self._session.get(url, timeout=self.timeout)
178-
# response.raise_for_status()
179-
# return "Yes, I'm here :)"
180-
# except requests.exceptions.RequestException as e:
181-
# raise ConnectionsError('Service unreachable', 'Check config and try again') from e
182-
183-
# # Implement other synchronous methods similarly
184-
# # For example:
185-
# def get_policies_list(self) -> list:
186-
# url = self._build_url('policies/')
187-
# response = self._session.get(url, timeout=self.timeout)
188-
# response.raise_for_status()
189-
# policies = response.json().get('result', [])
190-
# return [policy.get('id') for policy in policies if policy.get('id')]
191-
192-
# # ... Rest of synchronous methods ...
193-
194-
195-
# class AsyncOpaClient(BaseOpaClient):
196-
# """
197-
# Asynchronous OpaClient implementation using aiohttp.
198-
# """
199-
200-
# async def __aenter__(self):
201-
# await self._init_session()
202-
# return self
203-
204-
# async def __aexit__(self, exc_type, exc_value, traceback):
205-
# await self.close_connection()
206-
207-
# async def _init_session(self):
208-
# ssl_context = None
209-
210-
# if self.ssl:
211-
# ssl_context = ssl.create_default_context()
212-
# if self.cert:
213-
# if isinstance(self.cert, tuple):
214-
# ssl_context.load_cert_chain(*self.cert)
215-
# else:
216-
# ssl_context.load_cert_chain(self.cert)
217-
# else:
218-
# ssl_context.load_default_certs()
219-
220-
# connector = aiohttp.TCPConnector(ssl=ssl_context)
221-
222-
# self._session = aiohttp.ClientSession(
223-
# headers=self.headers,
224-
# connector=connector,
225-
# timeout=aiohttp.ClientTimeout(total=self.timeout),
226-
# )
227-
228-
# async def close_connection(self):
229-
# if self._session and not self._session.closed:
230-
# await self._session.close()
231-
# self._session = None
232-
233-
# async def check_connection(self) -> str:
234-
# url = self._build_url('policies/')
235-
# try:
236-
# async with self._session.get(url) as response:
237-
# if response.status == 200:
238-
# return "Yes, I'm here :)"
239-
# else:
240-
# raise ConnectionsError('Service unreachable', 'Check config and try again')
241-
# except Exception as e:
242-
# raise ConnectionsError('Service unreachable', 'Check config and try again') from e
243-
244-
# # Implement other asynchronous methods similarly
245-
# # For example:
246-
# async def get_policies_list(self) -> list:
247-
# url = self._build_url('policies/')
248-
# async with self._session.get(url) as response:
249-
# response.raise_for_status()
250-
# policies = await response.json()
251-
# result = policies.get('result', [])
252-
# return [policy.get('id') for policy in result if policy.get('id')]
253-
254-
# # ... Rest of asynchronous methods ...
255-
256-
257-
# # Example usage:
258-
259-
# # Synchronous client
260-
# def sync_example():
261-
# client = OpaClient(host='localhost', port=8181)
262-
# try:
263-
# result = client.check_connection()
264-
# print(result)
265-
# policies = client.get_policies_list()
266-
# print("Policies:", policies)
267-
# finally:
268-
# client.close_connection()
269-
270-
271-
# # Asynchronous client
272-
# async def async_example():
273-
# async with AsyncOpaClient(host='localhost', port=8181) as client:
274-
# result = await client.check_connection()
275-
# print(result)
276-
# policies = await client.get_policies_list()
277-
# print("Policies:", policies)
278-
279-
280-
# if __name__ == '__main__':
281-
# # Run synchronous example
282-
# sync_example()
283-
284-
# # Run asynchronous example
285-
# import asyncio
286-
# asyncio.run(async_example())

opa_client/opa.py

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -456,89 +456,6 @@ def ad_hoc_query(self, query: str, input_data: dict = None) -> dict:
456456
response.raise_for_status()
457457
return response.json()
458458

459-
# # Property methods for read-only access to certain attributes
460-
# @property
461-
# def host(self) -> str:
462-
# return self._host
463-
464-
# @host.setter
465-
# def host(self, value: str):
466-
# self._host = value
467-
468-
# @property
469-
# def port(self) -> int:
470-
# return self._port
471-
472-
# @port.setter
473-
# def port(self, value: int):
474-
# if not isinstance(value, int):
475-
# raise TypeError('Port must be an integer')
476-
# self._port = value
477-
478-
# @property
479-
# def version(self) -> str:
480-
# return self._version
481-
482-
# @version.setter
483-
# def version(self, value: str):
484-
# self._version = value
485-
486-
# @property
487-
# def schema(self) -> str:
488-
# return self._schema
489-
490-
# @schema.setter
491-
# def schema(self, value: str):
492-
# self._schema = value
493-
494-
# @property
495-
# def root_url(self) -> str:
496-
# return self._root_url
497-
498-
# @root_url.setter
499-
# def root_url(self, value: str):
500-
# self._root_url = value
501-
502-
# @property
503-
# def ssl(self) -> bool:
504-
# return self._ssl
505-
506-
# @ssl.setter
507-
# def ssl(self, value: bool):
508-
# self._ssl = value
509-
510-
# @property
511-
# def cert(self) -> Optional[str]:
512-
# return self._cert
513-
514-
# @cert.setter
515-
# def cert(self, value: Optional[str]):
516-
# self._cert = value
517-
518-
# @property
519-
# def headers(self) -> dict:
520-
# return self._headers
521-
522-
# @headers.setter
523-
# def headers(self, value: dict):
524-
# self._headers = value
525-
526-
# @property
527-
# def retries(self) -> int:
528-
# return self._retries
529-
530-
# @retries.setter
531-
# def retries(self, value: int):
532-
# self._retries = value
533-
534-
# @property
535-
# def timeout(self) -> float:
536-
# return self._timeout
537-
538-
# @timeout.setter
539-
# def timeout(self, value: float):
540-
# self._timeout = value
541-
542459

543460
# Example usage:
544461
if __name__ == "__main__":

0 commit comments

Comments
 (0)