Skip to content

Commit 5a8605e

Browse files
fix(specs): add secrets payload for updates (#4061) (generated) [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 801241e commit 5a8605e

File tree

11 files changed

+166
-15
lines changed

11 files changed

+166
-15
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ public AuthInputPartial(AuthAlgoliaInsightsPartial 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 AuthInputPartial class
85+
/// with a Dictionary{string, string}
86+
/// </summary>
87+
/// <param name="actualInstance">An instance of Dictionary&lt;string, string&gt;.</param>
88+
public AuthInputPartial(Dictionary<string, string> actualInstance)
89+
{
90+
ActualInstance = actualInstance;
91+
}
92+
8393

8494
/// <summary>
8595
/// Gets or Sets ActualInstance
@@ -146,6 +156,16 @@ public AuthAlgoliaInsightsPartial AsAuthAlgoliaInsightsPartial()
146156
return (AuthAlgoliaInsightsPartial)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 `AuthGoogleServiceAccountPartial` type.
@@ -201,6 +221,15 @@ public bool IsAuthAlgoliaInsightsPartial()
201221
return ActualInstance.GetType() == typeof(AuthAlgoliaInsightsPartial);
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 AuthInputPartial Read(ref Utf8JsonReader reader, Type typeToConv
357386
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into AuthAlgoliaInsightsPartial: {exception}");
358387
}
359388
}
389+
if (root.ValueKind == JsonValueKind.Object)
390+
{
391+
try
392+
{
393+
return new AuthInputPartial(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-go/algolia/ingestion/model_auth_input_partial.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-java/algoliasearch/src/main/java/com/algolia/model/ingestion/AuthInputPartial.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
/** AuthInputPartial */
1517
@JsonDeserialize(using = AuthInputPartial.Deserializer.class)
1618
public interface AuthInputPartial {
19+
// AuthInputPartial as Map<String, String> wrapper.
20+
static AuthInputPartial of(Map<String, String> value) {
21+
return new MapOfStringStringWrapper(value);
22+
}
23+
24+
// AuthInputPartial as Map<String, String> wrapper.
25+
@JsonSerialize(using = MapOfStringStringWrapper.Serializer.class)
26+
class MapOfStringStringWrapper implements AuthInputPartial {
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<AuthInputPartial> {
1848

1949
private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());
@@ -81,6 +111,16 @@ public AuthInputPartial deserialize(JsonParser jp, DeserializationContext ctxt)
81111
);
82112
}
83113
}
114+
// deserialize Map<String, String>
115+
if (tree.isObject()) {
116+
try (JsonParser parser = tree.traverse(jp.getCodec())) {
117+
Map<String, String> value = parser.readValueAs(new TypeReference<Map<String, String>>() {});
118+
return new AuthInputPartial.MapOfStringStringWrapper(value);
119+
} catch (Exception e) {
120+
// deserialization failed, continue
121+
LOGGER.finest("Failed to deserialize oneOf Map<String, String> (error: " + e.getMessage() + ") (type: Map<String, String>)");
122+
}
123+
}
84124
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
85125
}
86126

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export type AuthInputPartial =
1313
| AuthAPIKeyPartial
1414
| AuthOAuthPartial
1515
| AuthAlgoliaPartial
16-
| AuthAlgoliaInsightsPartial;
16+
| AuthAlgoliaInsightsPartial
17+
| { [key: string]: string };

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

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

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

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

@@ -79,6 +87,7 @@ internal class AuthInputPartialSerializer : JsonContentPolymorphicSerializer<Aut
7987
element is JsonObject && element.containsKey("url") -> AuthOAuthPartial.serializer()
8088
element is JsonObject -> AuthAlgoliaPartial.serializer()
8189
element is JsonObject -> AuthAlgoliaInsightsPartial.serializer()
90+
element is JsonObject -> AuthInputPartial.MapOfkotlinStringStringValue.serializer()
8291
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
8392
}
8493
}

clients/algoliasearch-client-python/algoliasearch/ingestion/models/auth_input_partial.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

@@ -49,13 +49,16 @@ class AuthInputPartial(BaseModel):
4949

5050
oneof_schema_6_validator: Optional[AuthAlgoliaInsightsPartial] = Field(default=None)
5151

52+
oneof_schema_7_validator: Optional[Dict[str, str]] = Field(default=None)
53+
""" A key:value authentication for your transformations. """
5254
actual_instance: Union[
5355
AuthAPIKeyPartial,
5456
AuthAlgoliaInsightsPartial,
5557
AuthAlgoliaPartial,
5658
AuthBasicPartial,
5759
AuthGoogleServiceAccountPartial,
5860
AuthOAuthPartial,
61+
Dict[str, str],
5962
None,
6063
] = None
6164
one_of_schemas: Set[str] = {
@@ -65,6 +68,7 @@ class AuthInputPartial(BaseModel):
6568
"AuthBasicPartial",
6669
"AuthGoogleServiceAccountPartial",
6770
"AuthOAuthPartial",
71+
"Dict[str, str]",
6872
}
6973

7074
def __init__(self, *args, **kwargs) -> None:
@@ -91,6 +95,7 @@ def unwrap_actual_instance(
9195
AuthBasicPartial,
9296
AuthGoogleServiceAccountPartial,
9397
AuthOAuthPartial,
98+
Dict[str, str],
9499
Self,
95100
None,
96101
]:
@@ -145,12 +150,19 @@ def from_json(cls, json_str: str) -> Self:
145150
try:
146151
instance.actual_instance = AuthAlgoliaInsightsPartial.from_json(json_str)
147152

153+
return instance
154+
except (ValidationError, ValueError) as e:
155+
error_messages.append(str(e))
156+
try:
157+
instance.oneof_schema_7_validator = loads(json_str)
158+
instance.actual_instance = instance.oneof_schema_7_validator
159+
148160
return instance
149161
except (ValidationError, ValueError) as e:
150162
error_messages.append(str(e))
151163

152164
raise ValueError(
153-
"No match found when deserializing the JSON string into AuthInputPartial with oneOf schemas: AuthAPIKeyPartial, AuthAlgoliaInsightsPartial, AuthAlgoliaPartial, AuthBasicPartial, AuthGoogleServiceAccountPartial, AuthOAuthPartial. Details: "
165+
"No match found when deserializing the JSON string into AuthInputPartial with oneOf schemas: AuthAPIKeyPartial, AuthAlgoliaInsightsPartial, AuthAlgoliaPartial, AuthBasicPartial, AuthGoogleServiceAccountPartial, AuthOAuthPartial, Dict[str, str]. Details: "
154166
+ ", ".join(error_messages)
155167
)
156168

@@ -177,6 +189,7 @@ def to_dict(
177189
AuthBasicPartial,
178190
AuthGoogleServiceAccountPartial,
179191
AuthOAuthPartial,
192+
Dict[str, str],
180193
]
181194
]:
182195
"""Returns the dict representation of the actual instance"""

clients/algoliasearch-client-ruby/lib/algolia/models/ingestion/auth_input_partial.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def openapi_one_of
1515
:"AuthAlgoliaPartial",
1616
:"AuthBasicPartial",
1717
:"AuthGoogleServiceAccountPartial",
18-
:"AuthOAuthPartial"
18+
:"AuthOAuthPartial",
19+
:"Hash<String, String>"
1920
]
2021
end
2122

clients/algoliasearch-client-scala/src/main/scala/algoliasearch/ingestion/AuthInputPartial.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ sealed trait AuthInputPartial
2727

2828
trait AuthInputPartialTrait extends AuthInputPartial
2929

30-
object AuthInputPartial {}
30+
object AuthInputPartial {
31+
32+
case class MapOfStringString(value: Map[String, String]) extends AuthInputPartial
33+
34+
def apply(value: Map[String, String]): AuthInputPartial = {
35+
AuthInputPartial.MapOfStringString(value)
36+
}
37+
38+
}
3139

3240
object AuthInputPartialSerializer extends Serializer[AuthInputPartial] {
3341
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), AuthInputPartial] = {
@@ -41,6 +49,7 @@ object AuthInputPartialSerializer extends Serializer[AuthInputPartial] {
4149
case value: JObject if value.obj.exists(_._1 == "url") => Extraction.extract[AuthOAuthPartial](value)
4250
case value: JObject => Extraction.extract[AuthAlgoliaPartial](value)
4351
case value: JObject => Extraction.extract[AuthAlgoliaInsightsPartial](value)
52+
case value: JObject => AuthInputPartial.apply(Extraction.extract[Map[String, String]](value))
4453
case _ => throw new MappingException("Can't convert " + json + " to AuthInputPartial")
4554
}
4655
}

clients/algoliasearch-client-swift/Sources/Ingestion/Models/AuthInputPartial.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum AuthInputPartial: Codable, JSONEncodable, AbstractEncodable {
1313
case authOAuthPartial(AuthOAuthPartial)
1414
case authAlgoliaPartial(AuthAlgoliaPartial)
1515
case authAlgoliaInsightsPartial(AuthAlgoliaInsightsPartial)
16+
case dictionaryOfStringToString([String: String])
1617

1718
public func encode(to encoder: Encoder) throws {
1819
var container = encoder.singleValueContainer()
@@ -29,6 +30,8 @@ public enum AuthInputPartial: Codable, JSONEncodable, AbstractEncodable {
2930
try container.encode(value)
3031
case let .authAlgoliaInsightsPartial(value):
3132
try container.encode(value)
33+
case let .dictionaryOfStringToString(value):
34+
try container.encode(value)
3235
}
3336
}
3437

@@ -46,6 +49,8 @@ public enum AuthInputPartial: Codable, JSONEncodable, AbstractEncodable {
4649
self = .authAlgoliaPartial(value)
4750
} else if let value = try? container.decode(AuthAlgoliaInsightsPartial.self) {
4851
self = .authAlgoliaInsightsPartial(value)
52+
} else if let value = try? container.decode([String: String].self) {
53+
self = .dictionaryOfStringToString(value)
4954
} else {
5055
throw DecodingError.typeMismatch(
5156
Self.Type.self,
@@ -68,6 +73,8 @@ public enum AuthInputPartial: Codable, JSONEncodable, AbstractEncodable {
6873
value as AuthAlgoliaPartial
6974
case let .authAlgoliaInsightsPartial(value):
7075
value as AuthAlgoliaInsightsPartial
76+
case let .dictionaryOfStringToString(value):
77+
value as [String: String]
7178
}
7279
}
7380
}

0 commit comments

Comments
 (0)