Skip to content

Conversation

@jooola
Copy link
Member

@jooola jooola commented Aug 12, 2025

Split the top level client used to gather all resource client in a single class, from the base client actually doing the requests to the API.

This allows us for example to swap or modify the base client in a resource client, that might need a different base client (session, endpoint, headers, ...).

@jooola jooola force-pushed the refactor-client-base-hetzner-api branch 3 times, most recently from b2dbe67 to 90638b1 Compare August 14, 2025 14:36
@jooola jooola changed the base branch from refator-rename-base-bound-model to main August 14, 2025 14:38
jooola added 7 commits August 14, 2025 16:39
Split the top level client used to gather all resource client in a single class, from the base client actually doing the requests to the API.

This allows us for example to swap or modify the base client in a resource client, that might need a different base client (session, endpoint, headers, ...).
@jooola jooola force-pushed the refactor-client-base-hetzner-api branch from 90638b1 to 13f7c0b Compare August 14, 2025 14:39
@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 96.33028% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.14%. Comparing base (2b4773e) to head (4ff9fbc).
⚠️ Report is 45 commits behind head on main.

Files with missing lines Patch % Lines
hcloud/actions/client.py 66.66% 2 Missing ⚠️
hcloud/_client.py 96.66% 1 Missing ⚠️
hcloud/placement_groups/client.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #534      +/-   ##
==========================================
+ Coverage   96.01%   96.14%   +0.12%     
==========================================
  Files          64       64              
  Lines        2938     2928      -10     
==========================================
- Hits         2821     2815       -6     
+ Misses        117      113       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jooola jooola marked this pull request as ready for review August 14, 2025 14:43
@jooola jooola requested a review from apricote August 14, 2025 14:56
@jooola
Copy link
Member Author

jooola commented Aug 14, 2025

Ready for a review, but still need to be tested with the Storage Box Actions implementations.

jooola added a commit that referenced this pull request Aug 15, 2025
Squashed commit of the following:

commit 4ff9fbc
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:54:47 2025 +0200

    test: timeout handling

commit 13f7c0b
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:33:26 2025 +0200

    test: fix speed optimization

commit 458631d
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:29:50 2025 +0200

    test: use parent to access other resources clients

commit f69a609
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:28:13 2025 +0200

    test: update request_mock fixture

commit d565239
Author: jo <ljonas@riseup.net>
Date:   Tue Aug 12 15:57:25 2025 +0200

    refactor: use parent to access other resources clients (2)

commit 1703985
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:25:51 2025 +0200

    refactor: use parent to access other resources clients (1)

commit adb9232
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:24:50 2025 +0200

    refactor: use type from inherited resource client property

commit 3b6c712
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:18:29 2025 +0200

    refactor: split top level client from base client

    Split the top level client used to gather all resource client in a single class, from the base client actually doing the requests to the API.

    This allows us for example to swap or modify the base client in a resource client, that might need a different base client (session, endpoint, headers, ...).
jooola added a commit that referenced this pull request Aug 15, 2025
Squashed commit of the following:

commit 4ff9fbc
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:54:47 2025 +0200

    test: timeout handling

commit 13f7c0b
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:33:26 2025 +0200

    test: fix speed optimization

commit 458631d
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:29:50 2025 +0200

    test: use parent to access other resources clients

commit f69a609
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:28:13 2025 +0200

    test: update request_mock fixture

commit d565239
Author: jo <ljonas@riseup.net>
Date:   Tue Aug 12 15:57:25 2025 +0200

    refactor: use parent to access other resources clients (2)

commit 1703985
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:25:51 2025 +0200

    refactor: use parent to access other resources clients (1)

commit adb9232
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:24:50 2025 +0200

    refactor: use type from inherited resource client property

commit 3b6c712
Author: jo <ljonas@riseup.net>
Date:   Thu Aug 14 16:18:29 2025 +0200

    refactor: split top level client from base client

    Split the top level client used to gather all resource client in a single class, from the base client actually doing the requests to the API.

    This allows us for example to swap or modify the base client in a resource client, that might need a different base client (session, endpoint, headers, ...).
jooola added a commit that referenced this pull request Aug 15, 2025
Merges #534 into the storage-boxes branch for development purposes.

Plus some required fixes after the merge.
@jooola
Copy link
Member Author

jooola commented Aug 15, 2025

I have tested this in https://github.com/hetznercloud/hcloud-python/pull/541/files#r2278661516

Seems to be working just fine.

@jooola jooola merged commit 4698975 into main Aug 15, 2025
10 checks passed
@jooola jooola deleted the refactor-client-base-hetzner-api branch August 15, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants