Skip to content

Commit 84c4b09

Browse files
feat(specs): add secrets authentications to ingestion (generated)
algolia/api-clients-automation#4054 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 38c38bd commit 84c4b09

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

algoliasearch/ingestion/models/auth_input.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from __future__ import annotations
88

9-
from json import dumps
9+
from json import dumps, loads
1010
from sys import version_info
1111
from typing import Any, Dict, Optional, Set, Union
1212

@@ -45,13 +45,16 @@ class AuthInput(BaseModel):
4545

4646
oneof_schema_6_validator: Optional[AuthAlgoliaInsights] = Field(default=None)
4747

48+
oneof_schema_7_validator: Optional[Dict[str, str]] = Field(default=None)
49+
""" A key:value authentication for your transformations. """
4850
actual_instance: Union[
4951
AuthAPIKey,
5052
AuthAlgolia,
5153
AuthAlgoliaInsights,
5254
AuthBasic,
5355
AuthGoogleServiceAccount,
5456
AuthOAuth,
57+
Dict[str, str],
5558
None,
5659
] = None
5760
one_of_schemas: Set[str] = {
@@ -61,6 +64,7 @@ class AuthInput(BaseModel):
6164
"AuthBasic",
6265
"AuthGoogleServiceAccount",
6366
"AuthOAuth",
67+
"Dict[str, str]",
6468
}
6569

6670
def __init__(self, *args, **kwargs) -> None:
@@ -87,6 +91,7 @@ def unwrap_actual_instance(
8791
AuthBasic,
8892
AuthGoogleServiceAccount,
8993
AuthOAuth,
94+
Dict[str, str],
9095
Self,
9196
None,
9297
]:
@@ -139,12 +144,19 @@ def from_json(cls, json_str: str) -> Self:
139144
try:
140145
instance.actual_instance = AuthAlgoliaInsights.from_json(json_str)
141146

147+
return instance
148+
except (ValidationError, ValueError) as e:
149+
error_messages.append(str(e))
150+
try:
151+
instance.oneof_schema_7_validator = loads(json_str)
152+
instance.actual_instance = instance.oneof_schema_7_validator
153+
142154
return instance
143155
except (ValidationError, ValueError) as e:
144156
error_messages.append(str(e))
145157

146158
raise ValueError(
147-
"No match found when deserializing the JSON string into AuthInput with oneOf schemas: AuthAPIKey, AuthAlgolia, AuthAlgoliaInsights, AuthBasic, AuthGoogleServiceAccount, AuthOAuth. Details: "
159+
"No match found when deserializing the JSON string into AuthInput with oneOf schemas: AuthAPIKey, AuthAlgolia, AuthAlgoliaInsights, AuthBasic, AuthGoogleServiceAccount, AuthOAuth, Dict[str, str]. Details: "
148160
+ ", ".join(error_messages)
149161
)
150162

@@ -171,6 +183,7 @@ def to_dict(
171183
AuthBasic,
172184
AuthGoogleServiceAccount,
173185
AuthOAuth,
186+
Dict[str, str],
174187
]
175188
]:
176189
"""Returns the dict representation of the actual instance"""

algoliasearch/ingestion/models/authentication_type.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class AuthenticationType(str, Enum):
3636

3737
ALGOLIAINSIGHTS = "algoliaInsights"
3838

39+
SECRETS = "secrets"
40+
3941
@classmethod
4042
def from_json(cls, json_str: str) -> Self:
4143
"""Create an instance of AuthenticationType from a JSON string"""

0 commit comments

Comments
 (0)