Skip to content

Commit

Permalink
feat(specs): add authentications to ingestion transformations (genera…
Browse files Browse the repository at this point in the history
…ted)

algolia/api-clients-automation#3494

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Aug 8, 2024
1 parent 51155fa commit d0a8175
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 6 deletions.
83 changes: 81 additions & 2 deletions algoliasearch/ingestion/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4082,7 +4082,7 @@ async def try_transformation_with_http_info(
request_options: Optional[Union[dict, RequestOptions]] = None,
) -> ApiResponse[str]:
"""
Try a transformation.
Try a transformation before creating it.
Required API Key ACLs:
- addObject
Expand Down Expand Up @@ -4120,7 +4120,7 @@ async def try_transformation(
request_options: Optional[Union[dict, RequestOptions]] = None,
) -> TransformationTryResponse:
"""
Try a transformation.
Try a transformation before creating it.
Required API Key ACLs:
- addObject
Expand All @@ -4138,6 +4138,85 @@ async def try_transformation(
)
).deserialize(TransformationTryResponse)

async def try_transformation_before_update_with_http_info(
self,
transformation_id: Annotated[
StrictStr, Field(description="Unique identifier of a transformation.")
],
transformation_try: TransformationTry,
request_options: Optional[Union[dict, RequestOptions]] = None,
) -> ApiResponse[str]:
"""
Try a transformation before updating it.
Required API Key ACLs:
- addObject
- deleteIndex
- editSettings
:param transformation_id: Unique identifier of a transformation. (required)
:type transformation_id: str
:param transformation_try: (required)
:type transformation_try: TransformationTry
:param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
:return: Returns the raw algoliasearch 'APIResponse' object.
"""

if transformation_id is None:
raise ValueError(
"Parameter `transformation_id` is required when calling `try_transformation_before_update`."
)

if transformation_try is None:
raise ValueError(
"Parameter `transformation_try` is required when calling `try_transformation_before_update`."
)

_data = {}
if transformation_try is not None:
_data = transformation_try

return await self._transporter.request(
verb=Verb.POST,
path="/1/transformations/{transformationID}/try".replace(
"{transformationID}", quote(str(transformation_id), safe="")
),
request_options=self._request_options.merge(
data=dumps(bodySerializer(_data)),
user_request_options=request_options,
),
use_read_transporter=False,
)

async def try_transformation_before_update(
self,
transformation_id: Annotated[
StrictStr, Field(description="Unique identifier of a transformation.")
],
transformation_try: TransformationTry,
request_options: Optional[Union[dict, RequestOptions]] = None,
) -> TransformationTryResponse:
"""
Try a transformation before updating it.
Required API Key ACLs:
- addObject
- deleteIndex
- editSettings
:param transformation_id: Unique identifier of a transformation. (required)
:type transformation_id: str
:param transformation_try: (required)
:type transformation_try: TransformationTry
:param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
:return: Returns the deserialized response in a 'TransformationTryResponse' result object.
"""
return (
await self.try_transformation_before_update_with_http_info(
transformation_id, transformation_try, request_options
)
).deserialize(TransformationTryResponse)

async def update_authentication_with_http_info(
self,
authentication_id: Annotated[
Expand Down
8 changes: 7 additions & 1 deletion algoliasearch/ingestion/models/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from json import loads
from typing import Any, Dict, Optional, Self
from typing import Any, Dict, List, Optional, Self

from pydantic import BaseModel, ConfigDict, Field, StrictStr

Expand All @@ -21,6 +21,11 @@ class Transformation(BaseModel):
description="Universally unique identifier (UUID) of a transformation.",
alias="transformationID",
)
authentication_ids: Optional[List[StrictStr]] = Field(
default=None,
description="The authentications associated for the current transformation.",
alias="authenticationIDs",
)
code: StrictStr = Field(description="The source code of the transformation.")
name: StrictStr = Field(
description="The uniquely identified name of your transformation."
Expand Down Expand Up @@ -79,6 +84,7 @@ def from_dict(cls, obj: Dict) -> Self:
_obj = cls.model_validate(
{
"transformationID": obj.get("transformationID"),
"authenticationIDs": obj.get("authenticationIDs"),
"code": obj.get("code"),
"name": obj.get("name"),
"description": obj.get("description"),
Expand Down
8 changes: 7 additions & 1 deletion algoliasearch/ingestion/models/transformation_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from json import loads
from typing import Any, Dict, Optional, Self
from typing import Any, Dict, List, Optional, Self

from pydantic import BaseModel, ConfigDict, Field, StrictStr

Expand All @@ -25,6 +25,11 @@ class TransformationCreate(BaseModel):
default=None,
description="A descriptive name for your transformation of what it does.",
)
authentication_ids: Optional[List[StrictStr]] = Field(
default=None,
description="The authentications associated for the current transformation.",
alias="authenticationIDs",
)

model_config = ConfigDict(
use_enum_values=True, populate_by_name=True, validate_assignment=True
Expand Down Expand Up @@ -69,6 +74,7 @@ def from_dict(cls, obj: Dict) -> Self:
"code": obj.get("code"),
"name": obj.get("name"),
"description": obj.get("description"),
"authenticationIDs": obj.get("authenticationIDs"),
}
)
return _obj
24 changes: 22 additions & 2 deletions algoliasearch/ingestion/models/transformation_try.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
from __future__ import annotations

from json import loads
from typing import Any, Dict, Self
from typing import Any, Dict, List, Optional, Self

from pydantic import BaseModel, ConfigDict, Field, StrictStr

from algoliasearch.ingestion.models.authentication_create import AuthenticationCreate


class TransformationTry(BaseModel):
"""
Expand All @@ -21,6 +23,7 @@ class TransformationTry(BaseModel):
sample_record: Dict[str, Any] = Field(
description="The record to apply the given code to.", alias="sampleRecord"
)
authentications: Optional[List[AuthenticationCreate]] = None

model_config = ConfigDict(
use_enum_values=True, populate_by_name=True, validate_assignment=True
Expand Down Expand Up @@ -49,6 +52,12 @@ def to_dict(self) -> Dict[str, Any]:
exclude={},
exclude_none=True,
)
_items = []
if self.authentications:
for _item in self.authentications:
if _item:
_items.append(_item.to_dict())
_dict["authentications"] = _items
return _dict

@classmethod
Expand All @@ -61,6 +70,17 @@ def from_dict(cls, obj: Dict) -> Self:
return cls.model_validate(obj)

_obj = cls.model_validate(
{"code": obj.get("code"), "sampleRecord": obj.get("sampleRecord")}
{
"code": obj.get("code"),
"sampleRecord": obj.get("sampleRecord"),
"authentications": (
[
AuthenticationCreate.from_dict(_item)
for _item in obj.get("authentications")
]
if obj.get("authentications") is not None
else None
),
}
)
return _obj

0 comments on commit d0a8175

Please sign in to comment.