From e82fddb162fbca8cf9be7568ad8437e82678d91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=90=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=BC=D0=BE=D0=B2?= Date: Sat, 30 Sep 2023 21:48:54 +0300 Subject: [PATCH] doc: add basic usage example and installation guide to README.md --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/README.md b/README.md index c084550..ee0846c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,59 @@ Async Yandex Tracker Client based on aiohttp and pydantic (v2) [![Code linter: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff) [![Linters](https://github.com/danfimov/ya_tracker_client/actions/workflows/code-check.yml/badge.svg)](https://github.com/danfimov/ya_tracker_client/actions/workflows/code-check.yml) +--- + +API docs: https://cloud.yandex.com/en/docs/tracker/about-api + +## Installation + +```shell +pip install ya_tracker_clint +``` + +## Usage + +```python +import os +from asyncio import run + +from dotenv import load_dotenv + +from ya_tracker_client import YaTrackerClient + + +load_dotenv() +# from registered application at Yandex OAuth - https://oauth.yandex.ru/ +API_TOKEN = os.getenv("API_TOKEN") +# from admin panel at Yandex Tracker - https://tracker.yandex.ru/admin/orgs +API_ORGANISATION_ID = os.getenv("API_ORGANISATION_ID") + + +async def main() -> None: + # init client + client = YaTrackerClient( + organisation_id=API_ORGANISATION_ID, + oauth_token=API_TOKEN, + ) + + # create issue + new_issue = await client.create_issue('New issue', 'TRACKER-QUEUE') + + # get issue + issue = await client.get_issue('KEY-1') + + # update issue (just pass kwargs) + issue = await client.edit_issue('KEY-1', description='Hello World') + + # don't forget to close tracker on app shutdown + await client.stop() + + +if __name__ == "__main__": + run(main()) +``` + + ## Explanations about naming - All `self` properties renamed to `url` cause it's incompatible with Python;