Skip to content

Commit 758f209

Browse files
committed
config git actions
1 parent 9070138 commit 758f209

File tree

3 files changed

+103
-95
lines changed

3 files changed

+103
-95
lines changed

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish Python package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.12'
19+
20+
- name: Install build tools
21+
run: pip install build twine
22+
23+
- name: Build package
24+
run: python -m build
25+
26+
- name: Publish to PyPI
27+
uses: pypa/gh-action-pypi-publish@release/v1
28+
with:
29+
user: __token__
30+
password: ${{ secrets.PYPI_API_TOKEN }}

README.md

Lines changed: 58 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
44

5-
**grit-requester-js** is a javascript library to abstract requests to microservices built using Grit.
5+
**grit-requester-python** is a python library to abstract requests to microservices built using Grit.
66

77
Features:
88

@@ -17,112 +17,80 @@ Features:
1717
## ✨ Installation
1818

1919
```bash
20-
npm install "https://github.com/not-empty/grit-requester-js/releases/download/v1.0.2/grit-requester-js-1.0.2.tgz"
20+
pip install grit_requester
2121
```
2222

2323
---
2424

2525
## 🚀 Usage Example
2626

2727
### Configure and do a request
28-
```ts
29-
import { GritRequester } from 'grit-requester-js';
30-
31-
interface IUser {
32-
id: string;
33-
name: string;
34-
email: string;
35-
}
36-
37-
// configure grit requester
38-
const ms = new GritRequester({
39-
baseUrl: 'http://localhost:8001',
40-
token: process.env.SERVICE_TOKEN || '',
41-
secret: process.env.SERVICE_SECRET || '',
42-
context: process.env.SERVICE_CONTEXT || '',
43-
});
44-
45-
// doing a request
46-
const result = await ms.request<{ id: string }>({
47-
path: '/user/add',
48-
method: 'POST',
49-
body: {
50-
name: 'example',
51-
email: 'example@example.com'
52-
}
53-
});
54-
28+
```python
29+
from grit_requester import GritService, GritConfig
30+
31+
# configure grit requester
32+
config = GritConfig(
33+
base_url=os.getenv("SERVICE_BASE_URL"),
34+
auth_url=os.getenv("SERVICE_AUTH_URL"),
35+
token=os.getenv("SERVICE_TOKEN"),
36+
secret=os.getenv("SERVICE_SECRET"),
37+
context=os.getenv("SERVICE_CONTEXT"),
38+
)
39+
40+
ms = GritService(config)
41+
42+
# doing a request
43+
resp = ms.request(
44+
"GET",
45+
"/user/list",
46+
)
5547
```
5648

5749
### Make crud requests from a domain
5850

5951
Here you can call a domain passing the type and path to access the following base routers:
6052

61-
| Path | Description |
62-
| -----------------| -------------------------------------------|
63-
| add | Create a new record |
64-
| bulk | Fetch specific records by IDs |
65-
| bulkAdd | Create up to 25 records in the same request|
66-
| deadDetail | Get a deleted record by ID |
67-
| deadList | List deleted records (paginated) |
68-
| delete | Soft-delete a record by ID |
69-
| detail | Get an active record by ID |
70-
| edit | Update specific fields |
71-
| list | List active records (paginated) |
72-
| listOne | List one record based on params |
73-
| selectRaw | Execute a predefined raw SQL query safely |
74-
75-
```ts
76-
import { GritRequester } from 'grit-requester-js';
77-
78-
interface IUser {
79-
id: string;
80-
name: string;
81-
email: string;
82-
}
83-
84-
// configure grit requester
85-
const ms = new GritRequester({
86-
baseUrl: 'http://localhost:8001',
87-
token: process.env.SERVICE_TOKEN || '',
88-
secret: process.env.SERVICE_SECRET || '',
89-
context: process.env.SERVICE_CONTEXT || '',
90-
});
91-
92-
// make a request from domain
93-
const resultFile = await ms.domain<IUser>('user').add({
94-
name: 'example',
95-
email: 'example@example.com'
96-
});
53+
| Path | Description |
54+
| ----------------- | -------------------------------------------|
55+
| add | Create a new record |
56+
| bulk | Fetch specific records by IDs |
57+
| bulk_add | Create up to 25 records in the same request|
58+
| dead_detail | Get a deleted record by ID |
59+
| dead_list | List deleted records (paginated) |
60+
| delete | Soft-delete a record by ID |
61+
| detail | Get an active record by ID |
62+
| edit | Update specific fields |
63+
| list | List active records (paginated) |
64+
| list_one | List one record based on params |
65+
| select_raw | Execute a predefined raw SQL query safely |
66+
67+
```python
68+
from grit_requester import GritService, GritConfig
69+
70+
# configure grit requester
71+
config = GritConfig(
72+
base_url=os.getenv("SERVICE_BASE_URL"),
73+
auth_url=os.getenv("SERVICE_AUTH_URL"),
74+
token=os.getenv("SERVICE_TOKEN"),
75+
secret=os.getenv("SERVICE_SECRET"),
76+
context=os.getenv("SERVICE_CONTEXT"),
77+
)
78+
79+
ms = GritService(config)
80+
81+
# make a request from domain
82+
users = ms.domain("user").list_all(
83+
filters=[{ "field": "name", "type": "eql", "value": "Admin" }]
84+
)
85+
86+
# you can save the domain context to reuse
87+
user_ms = ms.domain("user")
88+
89+
user = user_ms.detail(users[0]["id"])
9790

9891
```
9992
---
10093

101-
## 🧪 Testing
102-
103-
Run tests:
104-
105-
```bash
106-
npm run test
107-
```
108-
109-
Run test coverage
110-
```bash
111-
npm run coverage:
112-
```
113-
114-
Visualize unit coverage:
115-
116-
```bash
117-
open ./coverage/unit/lcov-report/index.html
118-
```
119-
120-
Visualize feature coverage:
121-
122-
```bash
123-
open ./coverage/feature/lcov-report/index.html
124-
```
125-
12694
## 🔧 License
12795

12896
MIT © [Not Empty](https://github.com/not-empty)

pyproject.toml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
[build-system]
2-
requires = ["setuptools"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "grit_requester"
77
version = "1.0.0"
88
description = "Grit requester client for Python"
9-
authors = [{ name = "Rainã Pepe", email = "raina.pepe@outlook.com" }]
9+
authors = [
10+
{ name="Not Empty Foundation", email="dev@not-empty.org" },
11+
]
12+
readme = "README.md"
13+
requires-python = ">=3.6.9"
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
17+
"Operating System :: OS Independent",
18+
]
1019
dependencies = ["requests"]
1120

12-
[tool.setuptools.packages.find]
13-
where = ["."]
21+
[project.urls]
22+
Homepage = "https://github.com/not-empty/grit-requester-python"
23+
Issues = "https://github.com/not-empty/grit-requester-python/issues"

0 commit comments

Comments
 (0)