From f956b881e901fb71945f4e1a9877f71afebc704b Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Thu, 11 Jul 2024 15:47:46 +0000 Subject: [PATCH] fix(specs): browse response required properties https://github.com/algolia/api-clients-automation/pull/3348 Co-authored-by: Pierre Millot --- ...utils_input.py => docker_streams_input.py} | 32 ++----- .../models/on_demand_date_utils_input.py | 83 ------------------- ...ming_utils_input.py => streaming_input.py} | 6 +- algoliasearch/ingestion/models/task_input.py | 44 +++------- .../ingestion/models/transformation.py | 5 +- .../ingestion/models/transformation_create.py | 7 +- algoliasearch/search/client.py | 3 +- 7 files changed, 30 insertions(+), 150 deletions(-) rename algoliasearch/ingestion/models/{schedule_date_utils_input.py => docker_streams_input.py} (55%) delete mode 100644 algoliasearch/ingestion/models/on_demand_date_utils_input.py rename algoliasearch/ingestion/models/{streaming_utils_input.py => streaming_input.py} (91%) diff --git a/algoliasearch/ingestion/models/schedule_date_utils_input.py b/algoliasearch/ingestion/models/docker_streams_input.py similarity index 55% rename from algoliasearch/ingestion/models/schedule_date_utils_input.py rename to algoliasearch/ingestion/models/docker_streams_input.py index 12c13d602..99b5f14d5 100644 --- a/algoliasearch/ingestion/models/schedule_date_utils_input.py +++ b/algoliasearch/ingestion/models/docker_streams_input.py @@ -7,22 +7,17 @@ from __future__ import annotations from json import loads -from typing import Annotated, Any, Dict, Optional, Self +from typing import Any, Dict, Self -from pydantic import BaseModel, ConfigDict, Field +from pydantic import BaseModel, ConfigDict -from algoliasearch.ingestion.models.mapping_input import MappingInput - -class ScheduleDateUtilsInput(BaseModel): +class DockerStreamsInput(BaseModel): """ - Input for scheduled tasks whose source is of type `bigquery` and for which extracted data spans a fixed number of days. + DockerStreamsInput """ - timeframe: Annotated[int, Field(le=30, strict=True, ge=1)] = Field( - description="Number of days in the past until the current day for which to extract Big Query data." - ) - mapping: Optional[MappingInput] = None + streams: Dict[str, Any] model_config = ConfigDict( use_enum_values=True, populate_by_name=True, validate_assignment=True @@ -33,7 +28,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Self: - """Create an instance of ScheduleDateUtilsInput from a JSON string""" + """Create an instance of DockerStreamsInput from a JSON string""" return cls.from_dict(loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -51,27 +46,16 @@ def to_dict(self) -> Dict[str, Any]: exclude={}, exclude_none=True, ) - if self.mapping: - _dict["mapping"] = self.mapping.to_dict() return _dict @classmethod def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ScheduleDateUtilsInput from a dict""" + """Create an instance of DockerStreamsInput from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate( - { - "timeframe": obj.get("timeframe"), - "mapping": ( - MappingInput.from_dict(obj.get("mapping")) - if obj.get("mapping") is not None - else None - ), - } - ) + _obj = cls.model_validate({"streams": obj.get("streams")}) return _obj diff --git a/algoliasearch/ingestion/models/on_demand_date_utils_input.py b/algoliasearch/ingestion/models/on_demand_date_utils_input.py deleted file mode 100644 index 136c076a7..000000000 --- a/algoliasearch/ingestion/models/on_demand_date_utils_input.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from typing import Any, Dict, Optional, Self - -from pydantic import BaseModel, ConfigDict, Field, StrictStr - -from algoliasearch.ingestion.models.mapping_input import MappingInput - - -class OnDemandDateUtilsInput(BaseModel): - """ - Input for a manually-triggered task whose source is of type `bigquery` and for which extracted data spans a given time range. - """ - - start_date: StrictStr = Field( - description="Earliest date in RFC 3339 format of the extracted data from Big Query.", - alias="startDate", - ) - end_date: StrictStr = Field( - description="Latest date in RFC 3339 format of the extracted data from Big Query.", - alias="endDate", - ) - mapping: Optional[MappingInput] = None - - model_config = ConfigDict( - use_enum_values=True, populate_by_name=True, validate_assignment=True - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of OnDemandDateUtilsInput from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - _dict = self.model_dump( - by_alias=True, - exclude={}, - exclude_none=True, - ) - if self.mapping: - _dict["mapping"] = self.mapping.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of OnDemandDateUtilsInput from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate( - { - "startDate": obj.get("startDate"), - "endDate": obj.get("endDate"), - "mapping": ( - MappingInput.from_dict(obj.get("mapping")) - if obj.get("mapping") is not None - else None - ), - } - ) - return _obj diff --git a/algoliasearch/ingestion/models/streaming_utils_input.py b/algoliasearch/ingestion/models/streaming_input.py similarity index 91% rename from algoliasearch/ingestion/models/streaming_utils_input.py rename to algoliasearch/ingestion/models/streaming_input.py index 60c0f72cf..2b7857ee3 100644 --- a/algoliasearch/ingestion/models/streaming_utils_input.py +++ b/algoliasearch/ingestion/models/streaming_input.py @@ -14,7 +14,7 @@ from algoliasearch.ingestion.models.mapping_input import MappingInput -class StreamingUtilsInput(BaseModel): +class StreamingInput(BaseModel): """ Input for a `streaming` task whose source is of type `ga4BigqueryExport` and for which extracted data is continuously streamed. """ @@ -30,7 +30,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Self: - """Create an instance of StreamingUtilsInput from a JSON string""" + """Create an instance of StreamingInput from a JSON string""" return cls.from_dict(loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -54,7 +54,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Dict) -> Self: - """Create an instance of StreamingUtilsInput from a dict""" + """Create an instance of StreamingInput from a dict""" if obj is None: return None diff --git a/algoliasearch/ingestion/models/task_input.py b/algoliasearch/ingestion/models/task_input.py index 5be4f358b..0d96a400f 100644 --- a/algoliasearch/ingestion/models/task_input.py +++ b/algoliasearch/ingestion/models/task_input.py @@ -11,14 +11,9 @@ from pydantic import BaseModel, ValidationError, model_serializer -from algoliasearch.ingestion.models.on_demand_date_utils_input import ( - OnDemandDateUtilsInput, -) -from algoliasearch.ingestion.models.schedule_date_utils_input import ( - ScheduleDateUtilsInput, -) +from algoliasearch.ingestion.models.docker_streams_input import DockerStreamsInput from algoliasearch.ingestion.models.shopify_input import ShopifyInput -from algoliasearch.ingestion.models.streaming_utils_input import StreamingUtilsInput +from algoliasearch.ingestion.models.streaming_input import StreamingInput class TaskInput(BaseModel): @@ -26,17 +21,11 @@ class TaskInput(BaseModel): Configuration of the task, depending on its type. """ - oneof_schema_1_validator: Optional[OnDemandDateUtilsInput] = None - oneof_schema_2_validator: Optional[ScheduleDateUtilsInput] = None - oneof_schema_3_validator: Optional[StreamingUtilsInput] = None - oneof_schema_4_validator: Optional[ShopifyInput] = None + oneof_schema_1_validator: Optional[StreamingInput] = None + oneof_schema_2_validator: Optional[DockerStreamsInput] = None + oneof_schema_3_validator: Optional[ShopifyInput] = None actual_instance: Optional[ - Union[ - OnDemandDateUtilsInput, - ScheduleDateUtilsInput, - ShopifyInput, - StreamingUtilsInput, - ] + Union[DockerStreamsInput, ShopifyInput, StreamingInput] ] = None def __init__(self, *args, **kwargs) -> None: @@ -56,14 +45,7 @@ def __init__(self, *args, **kwargs) -> None: @model_serializer def unwrap_actual_instance( self, - ) -> Optional[ - Union[ - OnDemandDateUtilsInput, - ScheduleDateUtilsInput, - ShopifyInput, - StreamingUtilsInput, - ] - ]: + ) -> Optional[Union[DockerStreamsInput, ShopifyInput, StreamingInput]]: """ Unwraps the `actual_instance` when calling the `to_json` method. """ @@ -80,19 +62,13 @@ def from_json(cls, json_str: str) -> Self: error_messages = [] try: - instance.actual_instance = OnDemandDateUtilsInput.from_json(json_str) + instance.actual_instance = StreamingInput.from_json(json_str) return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) try: - instance.actual_instance = ScheduleDateUtilsInput.from_json(json_str) - - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - try: - instance.actual_instance = StreamingUtilsInput.from_json(json_str) + instance.actual_instance = DockerStreamsInput.from_json(json_str) return instance except (ValidationError, ValueError) as e: @@ -105,7 +81,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 TaskInput with oneOf schemas: OnDemandDateUtilsInput, ScheduleDateUtilsInput, ShopifyInput, StreamingUtilsInput. Details: " + "No match found when deserializing the JSON string into TaskInput with oneOf schemas: DockerStreamsInput, ShopifyInput, StreamingInput. Details: " + ", ".join(error_messages) ) diff --git a/algoliasearch/ingestion/models/transformation.py b/algoliasearch/ingestion/models/transformation.py index a464f4a0e..15695ad9a 100644 --- a/algoliasearch/ingestion/models/transformation.py +++ b/algoliasearch/ingestion/models/transformation.py @@ -25,8 +25,9 @@ class Transformation(BaseModel): name: StrictStr = Field( description="The uniquely identified name of your transformation." ) - description: StrictStr = Field( - description="A descriptive name for your transformation of what it does." + description: Optional[StrictStr] = Field( + default=None, + description="A descriptive name for your transformation of what it does.", ) created_at: StrictStr = Field( description="Date of creation in RFC 3339 format.", alias="createdAt" diff --git a/algoliasearch/ingestion/models/transformation_create.py b/algoliasearch/ingestion/models/transformation_create.py index 3f1702473..6ba49ace3 100644 --- a/algoliasearch/ingestion/models/transformation_create.py +++ b/algoliasearch/ingestion/models/transformation_create.py @@ -7,7 +7,7 @@ from __future__ import annotations from json import loads -from typing import Any, Dict, Self +from typing import Any, Dict, Optional, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr @@ -21,8 +21,9 @@ class TransformationCreate(BaseModel): name: StrictStr = Field( description="The uniquely identified name of your transformation." ) - description: StrictStr = Field( - description="A descriptive name for your transformation of what it does." + description: Optional[StrictStr] = Field( + default=None, + description="A descriptive name for your transformation of what it does.", ) model_config = ConfigDict( diff --git a/algoliasearch/search/client.py b/algoliasearch/search/client.py index d52798c82..3babe725a 100644 --- a/algoliasearch/search/client.py +++ b/algoliasearch/search/client.py @@ -42,6 +42,7 @@ from algoliasearch.search.models.batch_response import BatchResponse from algoliasearch.search.models.batch_write_params import BatchWriteParams from algoliasearch.search.models.browse_params import BrowseParams +from algoliasearch.search.models.browse_params_object import BrowseParamsObject from algoliasearch.search.models.browse_response import BrowseResponse from algoliasearch.search.models.created_at_response import CreatedAtResponse from algoliasearch.search.models.delete_api_key_response import DeleteApiKeyResponse @@ -313,7 +314,7 @@ async def browse_objects( self, index_name: str, aggregator: Optional[Callable[[BrowseResponse], None]], - browse_params: Optional[BrowseParams] = None, + browse_params: Optional[BrowseParamsObject] = BrowseParamsObject(), request_options: Optional[Union[dict, RequestOptions]] = None, ) -> BrowseResponse: """