Add default_fields attribute to VariableRead model and update create_variable method in VariableService
This commit is contained in:
parent
de1d5ddf00
commit
71a9051727
2 changed files with 11 additions and 1 deletions
|
|
@ -52,6 +52,7 @@ class VariableRead(SQLModel):
|
|||
id: UUID
|
||||
name: Optional[str] = Field(None, description="Name of the variable")
|
||||
type: Optional[str] = Field(None, description="Type of the variable")
|
||||
default_fields: Optional[List[str]] = Field(None, description="Default fields for the variable")
|
||||
|
||||
|
||||
class VariableUpdate(SQLModel):
|
||||
|
|
|
|||
|
|
@ -30,7 +30,14 @@ class VariableService(Service):
|
|||
if var in os.environ:
|
||||
logger.debug(f"Creating {var} variable from environment.")
|
||||
try:
|
||||
self.create_variable(user_id, var, os.environ[var], _type="Credential", session=session)
|
||||
self.create_variable(
|
||||
user_id=user_id,
|
||||
name=var,
|
||||
value=os.environ[var],
|
||||
default_fields=[],
|
||||
_type="Credential",
|
||||
session=session,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error creating {var} variable: {e}")
|
||||
|
||||
|
|
@ -91,6 +98,7 @@ class VariableService(Service):
|
|||
user_id: Union[UUID, str],
|
||||
name: str,
|
||||
value: str,
|
||||
default_fields: list[str] = [],
|
||||
_type: str = "Generic",
|
||||
session: Session = Depends(get_session),
|
||||
):
|
||||
|
|
@ -98,6 +106,7 @@ class VariableService(Service):
|
|||
name=name,
|
||||
type=_type,
|
||||
value=auth_utils.encrypt_api_key(value, settings_service=self.settings_service),
|
||||
default_fields=default_fields,
|
||||
)
|
||||
variable = Variable.model_validate(variable_base, from_attributes=True, update={"user_id": user_id})
|
||||
session.add(variable)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue