Skip to content

Commit

Permalink
fix(specs): ingestion destination reject indexPrefix (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3478

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Aug 5, 2024
1 parent 0840d88 commit 2917b58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 82 deletions.
64 changes: 0 additions & 64 deletions algoliasearch/ingestion/models/destination_index_prefix.py

This file was deleted.

22 changes: 4 additions & 18 deletions algoliasearch/ingestion/models/destination_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@
from pydantic import BaseModel, ValidationError, model_serializer

from algoliasearch.ingestion.models.destination_index_name import DestinationIndexName
from algoliasearch.ingestion.models.destination_index_prefix import (
DestinationIndexPrefix,
)


class DestinationInput(BaseModel):
"""
DestinationInput
"""

oneof_schema_1_validator: Optional[DestinationIndexPrefix] = None
oneof_schema_2_validator: Optional[DestinationIndexName] = None
actual_instance: Optional[Union[DestinationIndexName, DestinationIndexPrefix]] = (
None
)
oneof_schema_1_validator: Optional[DestinationIndexName] = None
actual_instance: Optional[Union[DestinationIndexName]] = None

def __init__(self, *args, **kwargs) -> None:
if args:
Expand All @@ -43,9 +37,7 @@ def __init__(self, *args, **kwargs) -> None:
super().__init__(**kwargs)

@model_serializer
def unwrap_actual_instance(
self,
) -> Optional[Union[DestinationIndexName, DestinationIndexPrefix]]:
def unwrap_actual_instance(self) -> Optional[Union[DestinationIndexName]]:
"""
Unwraps the `actual_instance` when calling the `to_json` method.
"""
Expand All @@ -61,12 +53,6 @@ def from_json(cls, json_str: str) -> Self:
instance = cls.model_construct()
error_messages = []

try:
instance.actual_instance = DestinationIndexPrefix.from_json(json_str)

return instance
except (ValidationError, ValueError) as e:
error_messages.append(str(e))
try:
instance.actual_instance = DestinationIndexName.from_json(json_str)

Expand All @@ -75,7 +61,7 @@ def from_json(cls, json_str: str) -> Self:
error_messages.append(str(e))

raise ValueError(
"No match found when deserializing the JSON string into DestinationInput with oneOf schemas: DestinationIndexName, DestinationIndexPrefix. Details: "
"No match found when deserializing the JSON string into DestinationInput with oneOf schemas: DestinationIndexName. Details: "
+ ", ".join(error_messages)
)

Expand Down

0 comments on commit 2917b58

Please sign in to comment.