Skip to content

Commit 4519d69

Browse files
authored
docs: enhance README
Merge pull request #18 from DSD-DBS/enhance-documentation
2 parents 1aa10bd + 5c58ff3 commit 4519d69

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,42 @@ version of the client and a feature complete low level API client, which was gen
1414
Therefor the OpenAPI Specification of Polarion was used.
1515

1616
## Usage of the High Level Client
17-
tbd
18-
19-
## Updating the auto generated part
20-
To update the auto generated part of the code, execute the `open_api_client_build/build_client_source.sh` script with `path` or `url` as first
21-
arg and the path to the OpenAPI-Specification as second arg from the project root directory. For Copyright reasons, we don't publish the Specification here,
22-
but we used the Specification of Polarion version 2023.04 to generate the code published here.
17+
The high level client is an abstraction of the fine-grained, auto-generated client. It is created for a single project and currently exposes functions for Work Items, their Custom Fields, Links, Attachments and basic support for Documents.
18+
To get started, create a client and check, if the project exists. In the end, to get all Work Items of a project with an empty query, you can simply run the following code and our client will automatically take care of the paging:
2319

20+
```python
21+
import polarion_rest_api_client as polarion_api
22+
23+
client = polarion_api.OpenAPIPolarionProjectClient(
24+
project_id="PROJ",
25+
delete_polarion_work_items=False,
26+
polarion_api_endpoint="http://127.0.0.1/api",
27+
polarion_access_token="PAT123",
28+
)
29+
project_exists = client.project_exists() # Should be True
30+
work_items = client.get_all_work_items()
31+
```
32+
During the initialization of the client you can define additional settings like the page size when getting items or the maximum content size when bulk creating new items.
33+
In addition, you can define your own Work Item class with custom fields, which become available as attributes on object level instead of being part of the `additional_attributes` dictionary only.
34+
To use this feature, inherit from our Work Item class and pass your extended class to the Client on initialization:
35+
```python
36+
import polarion_rest_api_client as polarion_api
37+
38+
class CustomWorkItem(polarion_api.WorkItem):
39+
capella_uuid: str | None
40+
41+
client = polarion_api.OpenAPIPolarionProjectClient(
42+
project_id="PROJ",
43+
delete_polarion_work_items=False,
44+
polarion_api_endpoint="http://127.0.0.1/api",
45+
polarion_access_token="PAT123",
46+
batch_size=3,
47+
custom_work_item=CustomWorkItem,
48+
)
49+
50+
work_items = client.get_all_work_items() # the returned Work Items will be instances of CustomWorkItem
51+
uuid = work_items[0].capella_uuid # the value of the custom field capella_uuid can be accessed this way
52+
```
2453
## Usage of the autogenerated OpenAPI Client
2554
First, create a client:
2655

@@ -123,6 +152,11 @@ pip install -e '.[docs,test]'
123152
pre-commit install
124153
```
125154

155+
## Updating the auto generated part
156+
To update the auto generated part of the code, execute the `open_api_client_build/build_client_source.sh` script with `path` or `url` as first
157+
arg and the path to the OpenAPI-Specification as second arg from the project root directory. For Copyright reasons, we don't publish the Specification here,
158+
but we used the Specification of Polarion version 2023.04 to generate the code published here.
159+
126160
# Contributing
127161

128162
We'd love to see your bug reports and improvement suggestions! Please take a

polarion_rest_api_client/base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def get_work_item_attachments(
175175
raise NotImplementedError
176176

177177
def get_all_work_items(
178-
self, query: str, fields: dict[str, str] | None = None
178+
self, query: str = "", fields: dict[str, str] | None = None
179179
) -> list[WorkItemType]:
180180
"""Get all work items matching the given query.
181181

polarion_rest_api_client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def create_work_item_attachments(
523523

524524
def get_work_items(
525525
self,
526-
query: str,
526+
query: str = "",
527527
fields: dict[str, str] | None = None,
528528
page_size: int = 100,
529529
page_number: int = 1,

0 commit comments

Comments
 (0)