Skip to content

Commit 46e8f9c

Browse files
committed
update to 4.6.25.post4 and use openapi-python-client version 0.25.1
1 parent cd79d32 commit 46e8f9c

File tree

56 files changed

+320
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+320
-375
lines changed

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project_name_override: field-manager-python-client
22
package_name_override: field_manager_python_client
3-
package_version_override: 4.6.25.post3
3+
package_version_override: 4.6.25.post4
44
post_hooks:
55
# - "bash -c 'cd field-manager-python-client && poetry install'"
Lines changed: 103 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,150 @@
11
# field-manager-python-client
22
A client library for accessing Field Manager Data API
33

4-
## Usage
5-
First, create a client:
4+
## 🚀 Quick Start
65

7-
```python
8-
from field_manager_python_client import Client
6+
### Installation
97

10-
client = Client(base_url="https://api.example.com")
8+
```bash
9+
pip install field_manager_python_client python-keycloak
1110
```
1211

13-
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
12+
### Authentication
13+
14+
The easiest way to get started is using the built-in authentication functions:
1415

1516
```python
16-
from field_manager_python_client import AuthenticatedClient
17+
from field_manager_python_client import get_prod_client
1718

18-
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
19+
# Authenticate with your Field Manager account
20+
client = get_prod_client(email="[email protected]")
1921
```
2022

21-
Now call your endpoint and use your models:
23+
### Basic Usage
2224

2325
```python
24-
from field_manager_python_client.models import MyDataModel
25-
from field_manager_python_client.api.my_tag import get_my_data_model
26-
from field_manager_python_client.types import Response
26+
from field_manager_python_client.api.projects import get_project_projects_project_id_get
2727

28-
with client as client:
29-
my_data: MyDataModel = get_my_data_model.sync(client=client)
30-
# or if you need more info (e.g. status_code)
31-
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
28+
# Use the authenticated client
29+
project_info = get_project_projects_project_id_get.sync(
30+
client=client,
31+
project_id="your-project-id"
32+
)
33+
print(f"Project: {project_info.name}")
3234
```
3335

34-
Or do the same thing with an async version:
36+
## 🔐 Authentication Options
3537

38+
### 1. Integrated Authentication (Recommended)
3639
```python
37-
from field_manager_python_client.models import MyDataModel
38-
from field_manager_python_client.api.my_tag import get_my_data_model
39-
from field_manager_python_client.types import Response
40+
from field_manager_python_client import authenticate
4041

41-
async with client as client:
42-
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
43-
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
42+
client = authenticate(environment="prod", email="[email protected]")
4443
```
4544

46-
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
47-
45+
### 2. Manual Token Setup
4846
```python
47+
from field_manager_python_client import AuthenticatedClient
48+
4949
client = AuthenticatedClient(
50-
base_url="https://internal_api.example.com",
51-
token="SuperSecretToken",
52-
verify_ssl="/path/to/certificate_bundle.pem",
50+
base_url="https://app.fieldmanager.io/api/location",
51+
token="your-access-token"
5352
)
5453
```
5554

56-
You can also disable certificate validation altogether, but beware that **this is a security risk**.
55+
### 3. Service Account (for automation)
56+
See the [main repository](https://github.com/norwegian-geotechnical-institute/field-manager-python-client) for service account setup.
57+
58+
## 📖 API Usage Patterns
5759

60+
### Synchronous Operations
5861
```python
59-
client = AuthenticatedClient(
60-
base_url="https://internal_api.example.com",
61-
token="SuperSecretToken",
62-
verify_ssl=False
63-
)
62+
from field_manager_python_client.api.organizations import get_organizations_organizations_get
63+
64+
# Simple request - returns data or None
65+
organizations = get_organizations_organizations_get.sync(client=client)
66+
67+
# Detailed request - returns Response object with status code, headers, etc.
68+
from field_manager_python_client.types import Response
69+
response: Response = get_organizations_organizations_get.sync_detailed(client=client)
70+
if response.status_code == 200:
71+
organizations = response.parsed
6472
```
6573

66-
Things to know:
67-
1. Every path/method combo becomes a Python module with four functions:
68-
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
69-
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
70-
1. `asyncio`: Like `sync` but async instead of blocking
71-
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
74+
### Asynchronous Operations
75+
```python
76+
import asyncio
77+
from field_manager_python_client.api.organizations import get_organizations_organizations_get
78+
79+
async def fetch_organizations():
80+
# Simple async request
81+
organizations = await get_organizations_organizations_get.asyncio(client=client)
82+
83+
# Detailed async request
84+
response = await get_organizations_organizations_get.asyncio_detailed(client=client)
85+
return response.parsed
86+
87+
# Run async function
88+
organizations = asyncio.run(fetch_organizations())
89+
```
7290

73-
1. All path/query params, and bodies become method arguments.
74-
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
75-
1. Any endpoint which did not have a tag will be in `field_manager_python_client.api.default`
91+
## 🛠️ Advanced Features
7692

77-
## Advanced customizations
93+
### SSL Configuration
94+
```python
95+
from field_manager_python_client import AuthenticatedClient
7896

79-
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
97+
# Custom certificate bundle
98+
client = AuthenticatedClient(
99+
base_url="https://internal.example.com/api",
100+
token="token",
101+
verify_ssl="/path/to/certificate_bundle.pem"
102+
)
80103

104+
# Disable SSL verification (not recommended for production)
105+
client = AuthenticatedClient(
106+
base_url="https://internal.example.com/api",
107+
token="token",
108+
verify_ssl=False
109+
)
110+
```
111+
112+
### Custom HTTP Configuration
81113
```python
82-
from field_manager_python_client import Client
114+
from field_manager_python_client import AuthenticatedClient
83115

84116
def log_request(request):
85-
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
117+
print(f"Request: {request.method} {request.url}")
86118

87119
def log_response(response):
88-
request = response.request
89-
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
120+
print(f"Response: {response.status_code}")
90121

91-
client = Client(
122+
client = AuthenticatedClient(
92123
base_url="https://api.example.com",
93-
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
124+
token="token",
125+
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}}
94126
)
95-
96-
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
97127
```
98128

99-
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
129+
## 📚 Learn More
100130

101-
```python
102-
import httpx
103-
from field_manager_python_client import Client
131+
For comprehensive documentation, examples, and contribution guidelines, visit the main repository:
132+
**[https://github.com/norwegian-geotechnical-institute/field-manager-python-client](https://github.com/norwegian-geotechnical-institute/field-manager-python-client)**
104133

105-
client = Client(
106-
base_url="https://api.example.com",
107-
)
108-
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
109-
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
110-
```
134+
The repository includes:
135+
- 📖 Complete authentication guide
136+
- 🔧 Advanced usage examples
137+
- 🚀 Real-world code samples
138+
- 🤝 Contributing guidelines
139+
- 📋 Issue tracking and support
140+
141+
## 🔍 API Reference
142+
143+
Every endpoint becomes a Python function with four variants:
144+
- `sync`: Blocking request returning parsed data or `None`
145+
- `sync_detailed`: Blocking request returning full `Response` object
146+
- `asyncio`: Async version of `sync`
147+
- `asyncio_detailed`: Async version of `sync_detailed`
148+
149+
All path/query parameters and request bodies become function arguments.
150+
Functions are organized by API tags in `field_manager_python_client.api.*` modules.

field-manager-python-client/field_manager_python_client/api/comments/modify_comment_projects_project_id_locations_location_id_comments_comment_id_text_put.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ def _get_kwargs(
4141
"params": params,
4242
}
4343

44-
_body = body.to_dict()
44+
_kwargs["json"] = body.to_dict()
4545

46-
_kwargs["json"] = _body
4746
headers["Content-Type"] = "application/json"
4847

4948
_kwargs["headers"] = headers

field-manager-python-client/field_manager_python_client/api/comments/submit_comment_projects_project_id_locations_location_id_comments_post.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ def _get_kwargs(
4040
"params": params,
4141
}
4242

43-
_body = body.to_dict()
43+
_kwargs["json"] = body.to_dict()
4444

45-
_kwargs["json"] = _body
4645
headers["Content-Type"] = "application/json"
4746

4847
_kwargs["headers"] = headers

field-manager-python-client/field_manager_python_client/api/cross_sections/create_cross_section_projects_project_id_cross_sections_post.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ def _get_kwargs(
2323
"url": f"/projects/{project_id}/cross_sections",
2424
}
2525

26-
_body = body.to_dict()
26+
_kwargs["json"] = body.to_dict()
2727

28-
_kwargs["json"] = _body
2928
headers["Content-Type"] = "application/json"
3029

3130
_kwargs["headers"] = headers

field-manager-python-client/field_manager_python_client/api/cross_sections/update_cross_section_projects_project_id_cross_sections_cross_section_id_put.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ def _get_kwargs(
2525
"url": f"/projects/{project_id}/cross_sections/{cross_section_id}",
2626
}
2727

28-
_body = body.to_dict()
28+
_kwargs["json"] = body.to_dict()
2929

30-
_kwargs["json"] = _body
3130
headers["Content-Type"] = "application/json"
3231

3332
_kwargs["headers"] = headers

field-manager-python-client/field_manager_python_client/api/export/export_projects_project_id_export_post.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ def _get_kwargs(
2222
"url": f"/projects/{project_id}/export",
2323
}
2424

25-
_body = body.to_dict()
25+
_kwargs["json"] = body.to_dict()
2626

27-
_kwargs["json"] = _body
2827
headers["Content-Type"] = "application/json"
2928

3029
_kwargs["headers"] = headers

field-manager-python-client/field_manager_python_client/api/files/change_file_metadata_projects_project_id_files_file_id_put.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ def _get_kwargs(
2525
"url": f"/projects/{project_id}/files/{file_id}",
2626
}
2727

28-
_body = body.to_dict()
28+
_kwargs["json"] = body.to_dict()
2929

30-
_kwargs["json"] = _body
3130
headers["Content-Type"] = "application/json"
3231

3332
_kwargs["headers"] = headers

field-manager-python-client/field_manager_python_client/api/locations/add_location_to_project_projects_project_id_locations_post.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ def _get_kwargs(
2323
"url": f"/projects/{project_id}/locations",
2424
}
2525

26-
_body = body.to_dict()
26+
_kwargs["json"] = body.to_dict()
2727

28-
_kwargs["json"] = _body
2928
headers["Content-Type"] = "application/json"
3029

3130
_kwargs["headers"] = headers

field-manager-python-client/field_manager_python_client/api/locations/delete_locations_in_project_projects_project_id_locations_delete.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ def _get_kwargs(
2222
"url": f"/projects/{project_id}/locations",
2323
}
2424

25-
_body = []
25+
_kwargs["json"] = []
2626
for body_item_data in body:
2727
body_item = str(body_item_data)
28-
_body.append(body_item)
28+
_kwargs["json"].append(body_item)
2929

30-
_kwargs["json"] = _body
3130
headers["Content-Type"] = "application/json"
3231

3332
_kwargs["headers"] = headers

0 commit comments

Comments
 (0)