Skip to content

Commit 9194a41

Browse files
feat(specs): add secrets authentications to ingestion (#4054) (generated) [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent be40cf6 commit 9194a41

File tree

21 files changed

+206
-12
lines changed

21 files changed

+206
-12
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Models/Ingestion/AuthInput.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ public AuthInput(AuthAlgoliaInsights actualInstance)
8080
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
8181
}
8282

83+
/// <summary>
84+
/// Initializes a new instance of the AuthInput class
85+
/// with a Dictionary{string, string}
86+
/// </summary>
87+
/// <param name="actualInstance">An instance of Dictionary&lt;string, string&gt;.</param>
88+
public AuthInput(Dictionary<string, string> actualInstance)
89+
{
90+
ActualInstance = actualInstance;
91+
}
92+
8393

8494
/// <summary>
8595
/// Gets or Sets ActualInstance
@@ -146,6 +156,16 @@ public AuthAlgoliaInsights AsAuthAlgoliaInsights()
146156
return (AuthAlgoliaInsights)ActualInstance;
147157
}
148158

159+
/// <summary>
160+
/// Get the actual instance of `Dictionary{string, string}`. If the actual instance is not `Dictionary{string, string}`,
161+
/// the InvalidClassException will be thrown
162+
/// </summary>
163+
/// <returns>An instance of Dictionary&lt;string, string&gt;</returns>
164+
public Dictionary<string, string> AsDictionaryString()
165+
{
166+
return (Dictionary<string, string>)ActualInstance;
167+
}
168+
149169

150170
/// <summary>
151171
/// Check if the actual instance is of `AuthOAuth` type.
@@ -201,6 +221,15 @@ public bool IsAuthAlgoliaInsights()
201221
return ActualInstance.GetType() == typeof(AuthAlgoliaInsights);
202222
}
203223

224+
/// <summary>
225+
/// Check if the actual instance is of `Dictionary{string, string}` type.
226+
/// </summary>
227+
/// <returns>Whether or not the instance is the type</returns>
228+
public bool IsDictionaryString()
229+
{
230+
return ActualInstance.GetType() == typeof(Dictionary<string, string>);
231+
}
232+
204233
/// <summary>
205234
/// Returns the string presentation of the object
206235
/// </summary>
@@ -357,6 +386,18 @@ public override AuthInput Read(ref Utf8JsonReader reader, Type typeToConvert, Js
357386
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into AuthAlgoliaInsights: {exception}");
358387
}
359388
}
389+
if (root.ValueKind == JsonValueKind.Object)
390+
{
391+
try
392+
{
393+
return new AuthInput(jsonDocument.Deserialize<Dictionary<string, string>>(JsonConfig.Options));
394+
}
395+
catch (Exception exception)
396+
{
397+
// deserialization failed, try the next one
398+
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into Dictionary<string, string>: {exception}");
399+
}
400+
}
360401
throw new InvalidDataException($"The JSON string cannot be deserialized into any schema defined.");
361402
}
362403

clients/algoliasearch-client-csharp/algoliasearch/Models/Ingestion/AuthenticationType.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public enum AuthenticationType
5252
/// Enum AlgoliaInsights for value: algoliaInsights
5353
/// </summary>
5454
[JsonPropertyName("algoliaInsights")]
55-
AlgoliaInsights = 6
55+
AlgoliaInsights = 6,
56+
57+
/// <summary>
58+
/// Enum Secrets for value: secrets
59+
/// </summary>
60+
[JsonPropertyName("secrets")]
61+
Secrets = 7
5662
}
5763

clients/algoliasearch-client-go/algolia/ingestion/model_auth_input.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-go/algolia/ingestion/model_authentication_type.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/model/ingestion/AuthInput.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,44 @@
66
import com.algolia.exceptions.AlgoliaRuntimeException;
77
import com.fasterxml.jackson.annotation.*;
88
import com.fasterxml.jackson.core.*;
9+
import com.fasterxml.jackson.core.type.TypeReference;
910
import com.fasterxml.jackson.databind.*;
1011
import com.fasterxml.jackson.databind.annotation.*;
1112
import java.io.IOException;
13+
import java.util.Map;
1214
import java.util.logging.Logger;
1315

1416
/** AuthInput */
1517
@JsonDeserialize(using = AuthInput.Deserializer.class)
1618
public interface AuthInput {
19+
// AuthInput as Map<String, String> wrapper.
20+
static AuthInput of(Map<String, String> value) {
21+
return new MapOfStringStringWrapper(value);
22+
}
23+
24+
// AuthInput as Map<String, String> wrapper.
25+
@JsonSerialize(using = MapOfStringStringWrapper.Serializer.class)
26+
class MapOfStringStringWrapper implements AuthInput {
27+
28+
private final Map<String, String> value;
29+
30+
MapOfStringStringWrapper(Map<String, String> value) {
31+
this.value = value;
32+
}
33+
34+
public Map<String, String> getValue() {
35+
return value;
36+
}
37+
38+
static class Serializer extends JsonSerializer<MapOfStringStringWrapper> {
39+
40+
@Override
41+
public void serialize(MapOfStringStringWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException {
42+
gen.writeObject(value.getValue());
43+
}
44+
}
45+
}
46+
1747
class Deserializer extends JsonDeserializer<AuthInput> {
1848

1949
private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());
@@ -77,6 +107,16 @@ public AuthInput deserialize(JsonParser jp, DeserializationContext ctxt) throws
77107
LOGGER.finest("Failed to deserialize oneOf AuthAlgoliaInsights (error: " + e.getMessage() + ") (type: AuthAlgoliaInsights)");
78108
}
79109
}
110+
// deserialize Map<String, String>
111+
if (tree.isObject()) {
112+
try (JsonParser parser = tree.traverse(jp.getCodec())) {
113+
Map<String, String> value = parser.readValueAs(new TypeReference<Map<String, String>>() {});
114+
return new AuthInput.MapOfStringStringWrapper(value);
115+
} catch (Exception e) {
116+
// deserialization failed, continue
117+
LOGGER.finest("Failed to deserialize oneOf Map<String, String> (error: " + e.getMessage() + ") (type: Map<String, String>)");
118+
}
119+
}
80120
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
81121
}
82122

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/model/ingestion/AuthenticationType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public enum AuthenticationType {
2020

2121
ALGOLIA("algolia"),
2222

23-
ALGOLIA_INSIGHTS("algoliaInsights");
23+
ALGOLIA_INSIGHTS("algoliaInsights"),
24+
25+
SECRETS("secrets");
2426

2527
private final String value;
2628

clients/algoliasearch-client-javascript/packages/ingestion/model/authInput.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export type AuthInput =
1313
| AuthAPIKey
1414
| AuthOAuth
1515
| AuthAlgolia
16-
| AuthAlgoliaInsights;
16+
| AuthAlgoliaInsights
17+
| { [key: string]: string };

clients/algoliasearch-client-javascript/packages/ingestion/model/authenticationType.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@
33
/**
44
* Type of authentication. This determines the type of credentials required in the `input` object.
55
*/
6-
export type AuthenticationType = 'googleServiceAccount' | 'basic' | 'apiKey' | 'oauth' | 'algolia' | 'algoliaInsights';
6+
export type AuthenticationType =
7+
| 'googleServiceAccount'
8+
| 'basic'
9+
| 'apiKey'
10+
| 'oauth'
11+
| 'algolia'
12+
| 'algoliaInsights'
13+
| 'secrets';

clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthInput.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import kotlin.jvm.JvmInline
2020
* - [AuthBasic]
2121
* - [AuthGoogleServiceAccount]
2222
* - [AuthOAuth]
23+
* - [Map<kotlin.String, String>] - *[AuthInput.of]*
2324
*/
2425
@Serializable(AuthInputSerializer::class)
2526
public sealed interface AuthInput {
@@ -47,6 +48,10 @@ public sealed interface AuthInput {
4748
@JvmInline
4849
public value class AuthAlgoliaInsightsValue(public val value: AuthAlgoliaInsights) : AuthInput
4950

51+
@Serializable
52+
@JvmInline
53+
public value class MapOfkotlinStringStringValue(public val value: Map<kotlin.String, String>) : AuthInput
54+
5055
public companion object {
5156

5257
public fun of(value: AuthOAuth): AuthInput {
@@ -67,6 +72,9 @@ public sealed interface AuthInput {
6772
public fun of(value: AuthAlgoliaInsights): AuthInput {
6873
return AuthAlgoliaInsightsValue(value)
6974
}
75+
public fun of(value: Map<kotlin.String, String>): AuthInput {
76+
return MapOfkotlinStringStringValue(value)
77+
}
7078
}
7179
}
7280

@@ -79,6 +87,7 @@ internal class AuthInputSerializer : JsonContentPolymorphicSerializer<AuthInput>
7987
element is JsonObject && element.containsKey("key") -> AuthAPIKey.serializer()
8088
element is JsonObject -> AuthAlgolia.serializer()
8189
element is JsonObject -> AuthAlgoliaInsights.serializer()
90+
element is JsonObject -> AuthInput.MapOfkotlinStringStringValue.serializer()
8291
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
8392
}
8493
}

clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/ingestion/AuthenticationType.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ public enum class AuthenticationType(public val value: kotlin.String) {
2525
Algolia("algolia"),
2626

2727
@SerialName(value = "algoliaInsights")
28-
AlgoliaInsights("algoliaInsights");
28+
AlgoliaInsights("algoliaInsights"),
29+
30+
@SerialName(value = "secrets")
31+
Secrets("secrets");
2932

3033
override fun toString(): kotlin.String = value
3134
}

clients/algoliasearch-client-php/lib/Model/Ingestion/AuthenticationType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class AuthenticationType
2828

2929
public const ALGOLIA_INSIGHTS = 'algoliaInsights';
3030

31+
public const SECRETS = 'secrets';
32+
3133
/**
3234
* Gets allowable values of the enum.
3335
*
@@ -42,6 +44,7 @@ public static function getAllowableEnumValues()
4244
self::OAUTH,
4345
self::ALGOLIA,
4446
self::ALGOLIA_INSIGHTS,
47+
self::SECRETS,
4548
];
4649
}
4750
}

clients/algoliasearch-client-python/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"""

0 commit comments

Comments
 (0)