Skip to content

Commit 047c8e2

Browse files
authored
Merge pull request #119 from opsmill/stable
stable to develop mergeback
2 parents b008784 + b5acff9 commit 047c8e2

File tree

10 files changed

+47
-20
lines changed

10 files changed

+47
-20
lines changed

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang
1111

1212
<!-- towncrier release notes start -->
1313

14+
## [1.0.0](https://github.com/opsmill/infrahub-sdk-python/tree/v1.0.0) - 2024-10-31
15+
16+
### Removed
17+
18+
- Breaking change: Removed all exports from infrahub_sdk/__init__.py except InfrahubClient, InfrahubClientSync and Config. If you previously imported other classes such as InfrahubNode from the root level these need to change to instead be an absolute path.
19+
20+
### Added
21+
22+
- Add support for specific timeout per request on InfrahubClient and InfrahubNode function calls. ([#25](https://github.com/opsmill/infrahub-sdk-python/issues/25))
23+
- Added `infrahubctl menu` command to load menu definitions into Infrahub
24+
25+
### Fixed
26+
27+
- Fix SDK playback hash generation to read the correct filename ([#64](https://github.com/opsmill/infrahub-sdk-python/issues/64))
28+
- CTL: Return friendly error on encoding violations when reading files. ([#102](https://github.com/opsmill/infrahub-sdk-python/issues/102))
29+
- Changed the default connection timeout in the SDK to 60s.
30+
- Fixes an issue where InfrahubClient was not properly URL encoding URL parameters.
31+
1432
## [0.14.1](https://github.com/opsmill/infrahub-sdk-python/tree/v0.14.1) - 2024-10-22
1533

1634
### Fixed
@@ -22,7 +40,7 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang
2240

2341
### Removed
2442

25-
- Removed depreceted methods InfrahubClient.init and InfrahubClientSync.init ([#33](https://github.com/opsmill/infrahub-sdk-python/issues/33))
43+
- Removed deprecated methods InfrahubClient.init and InfrahubClientSync.init ([#33](https://github.com/opsmill/infrahub-sdk-python/issues/33))
2644

2745
### Changed
2846

changelog/+8dff6891.removed.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/+connection-timeout.fixed.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/102.fixed.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/25.added.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/64.fixed.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

infrahub_sdk/branch.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
from typing import TYPE_CHECKING, Any, Optional, Union
4+
from urllib.parse import urlencode
45

56
from pydantic import BaseModel
67

@@ -55,14 +56,16 @@ def generate_diff_data_url(
5556
time_to: Optional[str] = None,
5657
) -> str:
5758
"""Generate the URL for the diff_data function."""
58-
url = f"{client.address}/api/diff/data?branch={branch_name}"
59-
url += f"&branch_only={str(branch_only).lower()}"
59+
url = f"{client.address}/api/diff/data"
60+
url_params = {}
61+
url_params["branch"] = branch_name
62+
url_params["branch_only"] = str(branch_only).lower()
6063
if time_from:
61-
url += f"&time_from={time_from}"
64+
url_params["time_from"] = time_from
6265
if time_to:
63-
url += f"&time_to={time_to}"
66+
url_params["time_to"] = time_to
6467

65-
return url
68+
return url + urlencode(url_params)
6669

6770

6871
class InfrahubBranchManager(InfraHubBranchManagerBase):

infrahub_sdk/client.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Union,
1919
overload,
2020
)
21+
from urllib.parse import urlencode
2122

2223
import httpx
2324
import ujson
@@ -200,7 +201,7 @@ def _graphql_url(
200201
if at:
201202
at = Timestamp(at)
202203
url_params["at"] = at.to_string()
203-
url += "?" + "&".join([f"{key}={value}" for key, value in url_params.items()])
204+
url += "?" + urlencode(url_params)
204205

205206
return url
206207

@@ -982,14 +983,19 @@ async def query_gql_query(
982983

983984
if url_params:
984985
url_params_str = []
986+
url_params_dict = {}
985987
for key, value in url_params.items():
986988
if isinstance(value, (list)):
987989
for item in value:
988-
url_params_str.append(f"{key}={item}")
990+
url_params_str.append((key, item))
989991
else:
990-
url_params_str.append(f"{key}={value}")
992+
url_params_dict[key] = value
991993

992-
url += "?" + "&".join(url_params_str)
994+
url += "?"
995+
if url_params_dict:
996+
url += urlencode(url_params_dict) + "&"
997+
if url_params_str:
998+
url += urlencode(url_params_str)
993999

9941000
payload = {}
9951001
if variables:
@@ -1988,14 +1994,19 @@ def query_gql_query(
19881994

19891995
if url_params:
19901996
url_params_str = []
1997+
url_params_dict = {}
19911998
for key, value in url_params.items():
19921999
if isinstance(value, (list)):
19932000
for item in value:
1994-
url_params_str.append(f"{key}={item}")
2001+
url_params_str.append((key, item))
19952002
else:
1996-
url_params_str.append(f"{key}={value}")
2003+
url_params_dict[key] = value
19972004

1998-
url += "?" + "&".join(url_params_str)
2005+
url += "?"
2006+
if url_params_dict:
2007+
url += urlencode(url_params_dict) + "&"
2008+
if url_params_str:
2009+
url += urlencode(url_params_str)
19992010

20002011
payload = {}
20012012
if variables:

infrahub_sdk/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class NodeStoreBase:
2424
"""Internal Store for InfrahubNode objects.
2525
2626
Often while creating a lot of new objects,
27-
we need to save them in order to reuse them laterto associate them with another node for example.
27+
we need to save them in order to reuse them later to associate them with another node for example.
2828
"""
2929

3030
def __init__(self) -> None:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "infrahub-sdk"
3-
version = "0.15.0a0"
3+
version = "1.0.0"
44
description = "Python Client to interact with Infrahub"
55
authors = ["OpsMill <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)