Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

Commit 5ca5c70

Browse files
authored
switch docstrings to pydoc/docusaurus format (#169)
1 parent cfa0cfc commit 5ca5c70

7 files changed

Lines changed: 73 additions & 38 deletions

File tree

pan_cortex_data_lake/adapters/adapter.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# -*- coding: utf-8 -*-
22

3-
"""Base adapter class."""
3+
"""
4+
:::info
5+
Base adapter class.
6+
:::
7+
"""
48
from __future__ import absolute_import
59

610
from abc import ABCMeta, abstractmethod
@@ -42,7 +46,9 @@ def remove_profile(self, profile=None):
4246
def write_credentials(self, credentials=None, profile=None, cache_token=None):
4347
"""Write credentials.
4448
49+
:::info
4550
Write credentials to store.
51+
:::
4652
4753
Args:
4854
cache_token (bool): If ``True``, stores ``access_token`` in token store. Defaults to ``True``.

pan_cortex_data_lake/adapters/tinydb_adapter.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# -*- coding: utf-8 -*-
22

3-
"""TinyDB storage adapter."""
3+
"""
4+
:::info
5+
TinyDB storage adapter.
6+
:::
7+
"""
48
from __future__ import absolute_import
59

610
import os
@@ -74,7 +78,9 @@ def remove_profile(self, profile=None):
7478
def write_credentials(self, credentials=None, profile=None, cache_token=None):
7579
"""Write credentials.
7680
81+
:::info
7782
Write credentials to credentials file. Performs ``upsert``.
83+
:::
7884
7985
Args:
8086
cache_token (bool): If ``True``, stores ``access_token`` in token store. Defaults to ``True``.

pan_cortex_data_lake/credentials.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# -*- coding: utf-8 -*-
22

3-
"""Access, store and refresh credentials."""
3+
"""
4+
:::info
5+
The Credentials object can be used to access, store and refresh credentials.
6+
:::
7+
8+
"""
49
from __future__ import absolute_import
510

611
import os
@@ -56,18 +61,20 @@ def __init__(
5661
token_url=None,
5762
**kwargs
5863
):
59-
"""Persist Session() and credentials attributes.
64+
"""Persist ``Session()`` and credentials attributes.
6065
66+
:::info
6167
The ``Credentials`` class is an abstraction layer for accessing,
6268
storing and refreshing credentials needed for interacting with
6369
the Application Framework.
6470
6571
``Credentials`` resolves credentials from the following locations,
6672
in the following order:
6773
68-
1) Class instance variables
69-
2) Environment variables
70-
3) Credentials store
74+
1. Class instance variables
75+
2. Environment variables
76+
3. Credentials store
77+
:::
7178
7279
Args:
7380
access_token (str): OAuth2 access token. Defaults to ``None``.
@@ -83,7 +90,7 @@ def __init__(
8390
region (str): Region. Defaults to ``None``.
8491
refresh_token (str): OAuth2 refresh token. Defaults to ``None``.
8592
scope (str): OAuth2 scope. Defaults to ``None``.
86-
storage_adapter (str): Namespace path to storage adapter module. Defaults to "pan_cortex_data_lake.adapters.tinydb_adapter.TinyDBStore".
93+
storage_adapter (str): Namespace path to storage adapter module. Defaults to "pan_cortex_data_lake.adapters.tinydb_adapter.TinyDBStore".
8794
storage_params (dict) = Storage adapter parameters. Defaults to ``None``.
8895
token_url (str): Refresh URL. Defaults to ``None``.
8996
token_revoke_url (str): Revoke URL. Defaults to ``None``.
@@ -134,7 +141,8 @@ def __repr__(self):
134141
if args[k] is not None:
135142
args[k] = "*" * 6
136143
return "{}({})".format(
137-
self.__class__.__name__, ", ".join("%s=%r" % x for x in args.items()),
144+
self.__class__.__name__,
145+
", ".join("%s=%r" % x for x in args.items()),
138146
)
139147

140148
@property
@@ -599,7 +607,9 @@ def revoke_refresh_token(self, **kwargs):
599607
def write_credentials(self):
600608
"""Write credentials.
601609
610+
:::info
602611
Write credentials to credentials store.
612+
:::
603613
604614
Returns:
605615
Return value of self.storage.write_credentials()

pan_cortex_data_lake/exceptions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# -*- coding: utf-8 -*-
22

3-
"""Exceptions raised by PAN Cloud library.
4-
3+
"""
4+
:::info
55
This module provides base classes for all errors raised by the PAN Cloud
66
library. All other exceptions are raised and maintained by Python
77
standard or nonstandard libraries.
8+
:::
89
910
"""
1011

pan_cortex_data_lake/httpclient.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
"""HTTP client wrapper for the **excellent** ``requests`` library."""
4-
53
from __future__ import absolute_import
64

75
import logging
@@ -34,28 +32,31 @@ class HTTPClient(object):
3432
"""HTTP client for the Cortex™ REST API"""
3533

3634
def __init__(self, **kwargs):
37-
"""Persist Session() attributes and implement connection-pooling.
35+
"""Persist ``Session()`` attributes and implement connection-pooling.
3836
37+
:::info
3938
Built on top of the ``Requests`` library, ``HTTPClient`` is an
4039
abstraction layer for preparing and sending HTTP `requests` to the
4140
Application Framework REST APIs and handling `responses`. All
4241
``Requests`` are prepared as ``Session`` objects, with the option
4342
to persist certain attributes such as ``cert``, ``headers``,
4443
``proxies``, etc. ``HTTPAdapter`` is implemented to enable more
4544
granular performance and reliability tuning.
45+
:::
4646
4747
Parameters:
4848
auto_refresh (bool): Perform token refresh prior to request if ``access_token`` is ``None`` or expired. Defaults to ``True``.
4949
auto_retry (bool): Retry last failed HTTP request following a token refresh. Defaults to ``True``.
50-
credentials (Credentials): :class:`~pan_cortex_data_lake.credentials.Credentials` object. Defaults to ``None``.
51-
enforce_json (bool): Require properly-formatted JSON or raise :exc:`~pan_cortex_data_lake.exceptions.CortecError`. Defaults to ``False``.
50+
credentials (Credentials): [Credentials](credentials.md#credentials) object. Defaults to ``None``.
51+
enforce_json (bool): Require properly-formatted JSON or raise [CortexError](exceptions.md#cortexerror). Defaults to ``False``.
5252
force_trace (bool): If ``True``, forces trace and forces ``x-request-id`` to be returned in the response headers. Defaults to ``False``.
5353
port (int): TCP port to append to URL. Defaults to ``443``.
54-
raise_for_status (bool): If ``True``, raises :exc:`~pan_cortex_data_lake.exceptions.HTTPError` if status_code not in 2XX. Defaults to ``False``.
55-
url (str): URL to send API requests to - gets combined with ``port`` and :meth:`~request` ``path`` parameter. Defaults to ``None``.
54+
raise_for_status (bool): If ``True``, raises [HTTPError](exceptions.md#httperror) if status_code not in 2XX. Defaults to ``False``.
55+
url (str): URL to send API requests to - gets combined with ``port`` and ``endpoint`` parameter. Defaults to ``None``.
5656
5757
Args:
58-
**kwargs: Supported :class:`~requests.Session` and :class:`~requests.adapters.HTTPAdapter` parameters.
58+
**kwargs: Supported [Session](https://github.com/psf/requests/blob/main/requests/sessions.py#L337) and
59+
[HTTPAdapter](https://github.com/psf/requests/blob/main/requests/adapters.py#L85) parameters.
5960
6061
"""
6162
self.kwargs = kwargs.copy() # used for __repr__
@@ -157,9 +158,9 @@ def _send_request(self, enforce_json, method, raise_for_status, url, **kwargs):
157158
"""Send HTTP request.
158159
159160
Args:
160-
enforce_json (bool): Require properly-formatted JSON or raise :exc:`~pan_cortex_data_lake.exceptions.CortecError`. Defaults to ``False``.
161+
enforce_json (bool): Require properly-formatted JSON or raise [CortexError](exceptions.md#cortexerror). Defaults to ``False``.
161162
method (str): HTTP method.
162-
raise_for_status (bool): If ``True``, raises :exc:`~pan_cortex_data_lake.exceptions.HTTPError` if status_code not in 2XX. Defaults to ``False``.
163+
raise_for_status (bool): If ``True``, raises [HTTPError](exceptions.md#httperror) if status_code not in 2XX. Defaults to ``False``.
163164
url (str): Request URL.
164165
**kwargs (dict): Re-packed key-word arguments.
165166
@@ -182,18 +183,21 @@ def _send_request(self, enforce_json, method, raise_for_status, url, **kwargs):
182183
def request(self, **kwargs):
183184
"""Generate HTTP request using given parameters.
184185
186+
:::info
185187
The request method prepares HTTP requests using class or
186188
method-level attributes/variables. Class-level attributes may be
187189
overridden by method-level variables offering greater
188190
flexibility and efficiency.
191+
:::
189192
190193
Parameters:
191-
enforce_json (bool): Require properly-formatted JSON or raise :exc:`~pan_cortex_data_lake.exceptions.HTTPError`. Defaults to ``False``.
194+
enforce_json (bool): Require properly-formatted JSON or raise [HTTPError](exceptions.md#httperror). Defaults to ``False``.
192195
path (str): URI path to append to URL. Defaults to ``empty``.
193-
raise_for_status (bool): If ``True``, raises :exc:`~pan_cortex_data_lake.exceptions.HTTPError` if status_code not in 2XX. Defaults to ``False``.
196+
raise_for_status (bool): If ``True``, raises [HTTPError](exceptions.md#httperror) if status_code not in 2XX. Defaults to ``False``.
194197
195198
Args:
196-
**kwargs: Supported :class:`~requests.Session` and :class:`~requests.adapters.HTTPAdapter` parameters.
199+
**kwargs: Supported [Session](https://github.com/psf/requests/blob/main/requests/sessions.py#L337) and
200+
[HTTPAdapter](https://github.com/psf/requests/blob/main/requests/adapters.py#L85) parameters.
197201
198202
Returns:
199203
requests.Response: Requests Response() object

pan_cortex_data_lake/query.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# -*- coding: utf-8 -*-
22

3-
"""Interact with the Cortex Query Service API.
4-
3+
"""
4+
:::info
55
The Query Service is a Palo Alto Networks cloud service which allows
66
for the storage and retrieval of data stored in the Cortex Data Lake.
77
Any type of textual data can be stored in the Cortex Data Lake. Palo
88
Alto Networks firewalls and software can write data to this service, as
99
can the software and services created by Palo Alto Network's various
1010
partners.
11+
:::
1112
1213
Examples:
13-
Refer to the examples provided with this library.
14+
Refer to the [examples provided with this library](https://github.com/PaloAltoNetworks/pan-cortex-data-lake-python/tree/master/examples).
1415
1516
"""
1617

@@ -30,11 +31,11 @@ def __init__(self, **kwargs):
3031
"""
3132
3233
Parameters:
33-
session (HTTPClient): :class:`~cortex.httpclient.HTTPClient` object. Defaults to ``None``.
34-
url (str): URL to send API requests to. Later combined with ``port`` and :meth:`~request` ``endpoint`` parameter.
34+
session (HTTPClient): [HTTPClient](httpclient.md#httpclient) object. Defaults to ``None``.
35+
url (str): URL to send API requests to. Later combined with ``port`` and ``endpoint`` parameter.
3536
3637
Args:
37-
**kwargs: Supported :class:`~cortex.httpclient.HTTPClient` parameters.
38+
**kwargs: Supported [HTTPClient](httpclient.md#httpclient) parameters.
3839
3940
"""
4041
self.kwargs = kwargs.copy() # used for __repr__
@@ -77,7 +78,7 @@ def cancel_job(self, job_id=None, **kwargs):
7778
7879
Args:
7980
job_id (str): Specifies the ID of the query job.
80-
**kwargs: Supported :meth:`~pan_cortex_data_lake.httpclient.HTTPClient.request` parameters.
81+
**kwargs: Supported [HTTPClient.request()](httpclient.md#request) parameters.
8182
8283
Returns:
8384
requests.Response: Requests Response() object.
@@ -93,14 +94,16 @@ def cancel_job(self, job_id=None, **kwargs):
9394
def create_query(self, job_id=None, query_params=None, **kwargs):
9495
"""Create a search request.
9596
96-
When submission is successful, http status code of 201 (Created)
97+
:::info
98+
When submission is successful, http status code of ``201`` (Created)
9799
is returned with a 'jobId' in response. Specifying a 'jobId' is
98100
optional.
101+
:::
99102
100103
Args:
101104
job_id (str): Specifies the ID of the query job. (optional)
102105
query_params (dict): Query parameters.
103-
**kwargs: Supported :meth:`~pan_cortex_data_lake.httpclient.HTTPClient.request` parameters.
106+
**kwargs: Supported [HTTPClient.request()](httpclient.md#request) parameters.
104107
105108
Returns:
106109
requests.Response: Requests Response() object.
@@ -129,7 +132,7 @@ def get_job(self, job_id=None, **kwargs):
129132
Args:
130133
job_id (str): Specifies the ID of the query job.
131134
params (dict): Payload/request dictionary.
132-
**kwargs: Supported :meth:`~pan_cortex_data_lake.httpclient.HTTPClient.request` parameters.
135+
**kwargs: Supported [HTTPClient.request()](httpclient.md#request) parameters.
133136
134137
Returns:
135138
requests.Response: Requests Response() object.
@@ -163,7 +166,7 @@ def get_job_results(
163166
page_number (int): Return the nth page from the result set as specified by this parameter.
164167
page_size (int): If specified, limits the size of a batch of results to the specified value. If un-specified, backend picks a size that may provide best performance.
165168
result_format (str): valuesArray or valuesJson.
166-
**kwargs: Supported :meth:`~pan_cortex_data_lake.httpclient.HTTPClient.request` parameters.
169+
**kwargs: Supported [HTTPClient.request()](httpclient.md#request) parameters.
167170
168171
Returns:
169172
requests.Response: Requests Response() object.
@@ -213,7 +216,7 @@ def iter_job_results(
213216
page_number (int): Return the nth page from the result set as specified by this parameter.
214217
page_size (int): If specified, limits the size of a batch of results to the specified value. If un-specified, backend picks a size that may provide best performance.
215218
result_format (str): valuesArray or valuesJson.
216-
**kwargs: Supported :meth:`~pan_cortex_data_lake.httpclient.HTTPClient.request` parameters.
219+
**kwargs: Supported [HTTPClient.request()](httpclient.md#request) parameters.
217220
218221
Yields:
219222
requests.Response: Requests Response() object.
@@ -271,7 +274,7 @@ def list_jobs(
271274
state (str): Job state, e.g. 'RUNNING', 'PENDING', 'FAILED', 'DONE'.
272275
job_type (str): Query type hint.
273276
tenant_id (str): Tenant ID.
274-
**kwargs: Supported :meth:`~pan_cortex_data_lake.httpclient.HTTPClient.request` parameters.
277+
**kwargs: Supported [HTTPClient.request()](httpclient.md#request) parameters.
275278
276279
Returns:
277280
requests.Response: Requests Response() object.

pan_cortex_data_lake/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# -*- coding: utf-8 -*-
22

3-
"""PAN Cloud Python SDK utilities."""
3+
"""
4+
:::info
5+
PAN Cloud Python SDK utilities.
6+
:::
7+
8+
"""
49

510
from __future__ import absolute_import
611

0 commit comments

Comments
 (0)