Skip to content

Commit 5a0f4dd

Browse files
authored
Merge pull request #52 from cloudblue/fix_docs
Fix and improve documentation
2 parents c893acc + 4cdb07d commit 5a0f4dd

File tree

17 files changed

+1642
-975
lines changed

17 files changed

+1642
-975
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ jobs:
5656
- name: Testing
5757
run: |
5858
poetry run pytest
59-
- name: Upload coverage
60-
uses: codecov/codecov-action@v1
61-
with:
62-
file: ./coverage.xml
63-
fail_ci_if_error: true
64-
verbose: true
6559
- name: Fix coverage.xml for Sonar
6660
run: |
6761
sed -i 's/\/home\/runner\/work\/connect-python-openapi-client\/connect-python-openapi-client\//\/github\/workspace\//g' coverage.xml

connect/client/fluent.py

Lines changed: 94 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,6 @@ def __init__(
3434
timeout=(180.0, 180.0),
3535
resourceset_append=True,
3636
):
37-
"""
38-
Create a new instance of the ConnectClient.
39-
40-
:param api_key: The API key used for authentication.
41-
:type api_key: str
42-
:param endpoint: The API endpoint, defaults to CONNECT_ENDPOINT_URL
43-
:type endpoint: str, optional
44-
:param use_specs: Use the Connect OpenAPI specification for interactive help.
45-
:type specs_location: bool, optional
46-
:param specs_location: The Connect OpenAPI specification local path or URL, defaults to
47-
CONNECT_SPECS_URL
48-
:type specs_location: str, optional
49-
:param validate_using_specs: Use the Connect OpenAPI specification to validate the call.
50-
:type validate_using_specs: bool, optional
51-
:param default_headers: Http headers to apply to each request, defaults to {}
52-
:type default_headers: dict, optional
53-
:param default_limit: Default value for pagination limit parameter.
54-
:type default_limit: int, optional
55-
:param max_retries: Max number of retries for a request before raising an error.
56-
:type max_retries: int, optional
57-
:param logger: HTTP Request logger class, defaults to None
58-
:type logger: RequestLogger, optional
59-
:param timeout: Timeout parameter to pass to the underlying http client.
60-
:type timeout: int or tuple of int, optional
61-
:param resourceset_append: Append all the page to the current resourceset.
62-
:type resourceset_append: bool, optional
63-
"""
6437
if default_headers and 'Authorization' in default_headers:
6538
raise ValueError('`default_headers` cannot contains `Authorization`')
6639

@@ -83,6 +56,11 @@ def __init__(
8356

8457
@property
8558
def response(self):
59+
"""
60+
Returns the raw
61+
[`requests`](https://requests.readthedocs.io/en/latest/api/#requests.Response)
62+
response.
63+
"""
8664
return self._response
8765

8866
@response.setter
@@ -107,12 +85,23 @@ def __call__(self, name):
10785

10886
def ns(self, name):
10987
"""
110-
Returns the namespace called ``name``.
88+
Returns a `Namespace` object identified by its name.
11189
112-
:param name: The name of the namespace to access.
113-
:type name: str
114-
:return: The namespace called ``name``.
115-
:rtype: NS
90+
Usage:
91+
92+
```python
93+
subscriptions = client.ns('subscriptions')
94+
```
95+
96+
Concise form:
97+
98+
```python
99+
subscriptions = client('subscriptions')
100+
```
101+
102+
**Parameters**
103+
104+
* **name** - The name of the namespace to access.
116105
"""
117106
if not isinstance(name, str):
118107
raise TypeError('`name` must be a string.')
@@ -124,12 +113,23 @@ def ns(self, name):
124113

125114
def collection(self, name):
126115
"""
127-
Returns the collection called ``name``.
116+
Returns a `Collection` object identified by its name.
128117
129-
:param name: The name of the collection to access.
130-
:type name: str
131-
:return: The collection called ``name``.
132-
:rtype: Collection
118+
Usage:
119+
120+
```python
121+
products = client.collection('products')
122+
```
123+
124+
Concise form:
125+
126+
```python
127+
products = client.products
128+
```
129+
130+
**Parameters**
131+
132+
* **name** - The name of the collection to access.
133133
"""
134134
if not isinstance(name, str):
135135
raise TypeError('`name` must be a string.')
@@ -179,6 +179,32 @@ def _get_api_error_details(self):
179179

180180

181181
class ConnectClient(_ConnectClientBase, threading.local, SyncClientMixin):
182+
"""
183+
Create a new instance of the ConnectClient.
184+
185+
Usage:
186+
187+
```python
188+
client = ConnectClient('ApiKey SU-000-000-000:xxxxxxxxxxxxxxxx')
189+
product = client.products['PRD-001-002-003'].get()
190+
```
191+
192+
**Parameters:**
193+
194+
* **api_key** - The API key used for authentication.
195+
* **endpoint** *(optional)* - The API endpoint, defaults to
196+
https://api.connect.cloudblue.com/public/v1.
197+
* **use_specs** *(optional)* - Use Connect OpenAPI specifications.
198+
* **specs_location** *(optional)* - The Connect OpenAPI specification local path or URL.
199+
* **validate_using_specs** *(optional)* - Use the Connect OpenAPI specification to validate
200+
the call.
201+
* **default_headers** *(optional)* - HTTP headers to apply to each request.
202+
* **default_limit** *(optional)* - Default value for pagination limit parameter.
203+
* **max_retries** *(optional)* - Max number of retries for a request before raising an error.
204+
* **logger** *(optional)* - HTTP Request logger class.
205+
* **timeout** *(optional)* - Timeout parameter to pass to the underlying HTTP client.
206+
* **resourceset_append** *(optional)* - Append all the pages to the current resourceset.
207+
"""
182208
def _get_collection_class(self):
183209
return Collection
184210

@@ -187,13 +213,44 @@ def _get_namespace_class(self):
187213

188214

189215
class AsyncConnectClient(_ConnectClientBase, AsyncClientMixin):
216+
"""
217+
Create a new instance of the AsyncConnectClient.
218+
219+
Usage:
220+
221+
```python
222+
client = AsyncConnectClient('ApiKey SU-000-000-000:xxxxxxxxxxxxxxxx')
223+
product = await client.products['PRD-001-002-003'].get()
224+
```
225+
226+
**Parameters:**
227+
228+
* **api_key** - The API key used for authentication.
229+
* **endpoint** *(optional)* - The API endpoint, defaults to
230+
https://api.connect.cloudblue.com/public/v1.
231+
* **use_specs** *(optional)* - Use Connect OpenAPI specifications.
232+
* **specs_location** *(optional)* - The Connect OpenAPI specification local path or URL.
233+
* **validate_using_specs** *(optional)* - Use the Connect OpenAPI specification to validate
234+
the call.
235+
* **default_headers** *(optional)* - HTTP headers to apply to each request.
236+
* **default_limit** *(optional)* - Default value for pagination limit parameter.
237+
* **max_retries** *(optional)* - Max number of retries for a request before raising an error.
238+
* **logger** *(optional)* - HTTP Request logger class.
239+
* **timeout** *(optional)* - Timeout parameter to pass to the underlying HTTP client.
240+
* **resourceset_append** *(optional)* - Append all the pages to the current resourceset.
241+
"""
190242

191243
def __init__(self, *args, **kwargs):
192244
super().__init__(*args, **kwargs)
193245
self._response = contextvars.ContextVar('response', default=None)
194246

195247
@property
196248
def response(self):
249+
"""
250+
Returns the raw
251+
[`httpx`](https://www.python-httpx.org/api/#response)
252+
response.
253+
"""
197254
return self._response.get()
198255

199256
@response.setter

0 commit comments

Comments
 (0)