Prepare monorepo
This commit is contained in:
parent
a1ddb43ed0
commit
938582155d
61 changed files with 5 additions and 5 deletions
0
backend/app/schemas/__init__.py
Normal file
0
backend/app/schemas/__init__.py
Normal file
21
backend/app/schemas/auth_token.py
Normal file
21
backend/app/schemas/auth_token.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas.user import Role
|
||||
|
||||
|
||||
@dataclass
|
||||
class AccessToken:
|
||||
subject: str
|
||||
role: Role
|
||||
session: str
|
||||
|
||||
class TokenRefreshRequest(BaseModel):
|
||||
refresh_token: str
|
||||
|
||||
|
||||
class TokenResponse(BaseModel):
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
not_after: datetime
|
47
backend/app/schemas/chargepoint.py
Normal file
47
backend/app/schemas/chargepoint.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas.connector import Connector
|
||||
|
||||
from ocpp.v201.enums import ResetEnumType, ResetStatusEnumType
|
||||
|
||||
class ChargePointBase(BaseModel):
|
||||
identity: str
|
||||
is_active: bool
|
||||
price: Decimal
|
||||
|
||||
class ChargePointUpdate(BaseModel):
|
||||
identity: Optional[str] = None
|
||||
is_active: Optional[bool] = None
|
||||
price: Optional[Decimal]= None
|
||||
|
||||
class ChargePointCreate(ChargePointBase):
|
||||
pass
|
||||
|
||||
class ChargePoint(ChargePointBase):
|
||||
id: UUID
|
||||
last_seen: datetime | None
|
||||
vendor_name: str | None
|
||||
model: str | None
|
||||
serial_number: str | None
|
||||
firmware_version: str | None
|
||||
connectors: list[Connector] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class ChargePointPassword(BaseModel):
|
||||
password: str
|
||||
|
||||
class ChargePointConnectionInfo(BaseModel):
|
||||
connected: bool
|
||||
|
||||
class ChargePointResetRequest(BaseModel):
|
||||
type: ResetEnumType
|
||||
evse_id: Optional[int] = None
|
||||
|
||||
class ChargePointResetResponse(BaseModel):
|
||||
status: ResetStatusEnumType
|
60
backend/app/schemas/chargepoint_variable.py
Normal file
60
backend/app/schemas/chargepoint_variable.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
import enum
|
||||
|
||||
class AttributeType(enum.Enum):
|
||||
ACTUAL = "Actual"
|
||||
TARGET = "Target"
|
||||
MIN_SET = "MinSet"
|
||||
MAX_SET = "MaxSet"
|
||||
|
||||
class MutabilityType(enum.Enum):
|
||||
READ_ONLY = "ReadOnly"
|
||||
WRITE_ONLY = "WriteOnly"
|
||||
READ_WRITE = "ReadWrite"
|
||||
|
||||
class DataType(enum.Enum):
|
||||
STRING = "string"
|
||||
DECIMAL = "decimal"
|
||||
INTEGER = "integer"
|
||||
DATETIME = "dateTime"
|
||||
BOOLEAN = "boolean"
|
||||
OPTION_LIST = "OptionList"
|
||||
SEQUENCE_LIST = "SequenceList"
|
||||
MEMBER_LIST = "MemberList"
|
||||
|
||||
class SetVariableStatusType(enum.Enum):
|
||||
ACCEPTED = "Accepted"
|
||||
REJECTED = "Rejected"
|
||||
UNKNOWN_COMPONENT = "UnknownComponent"
|
||||
NOT_SUPPORTED_ATTRIBUTE_TYPE = "NotSupportedAttributeType"
|
||||
REBOOT_REQUIRED = "RebootRequired"
|
||||
|
||||
class ChargepointVariable(BaseModel):
|
||||
id: UUID
|
||||
name: str
|
||||
type: AttributeType
|
||||
value: Optional[str] = None
|
||||
mutability: MutabilityType
|
||||
persistent: bool
|
||||
constant: bool
|
||||
unit: Optional[str] = None
|
||||
data_type: Optional[DataType] = None
|
||||
min_limit: Optional[Decimal] = None
|
||||
max_limit: Optional[Decimal] = None
|
||||
values_list: Optional[str] = None
|
||||
component_name: str
|
||||
component_instance: Optional[str] = None
|
||||
evse: Optional[int] = None
|
||||
connector_id: Optional[int] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class ChargepointVariableUpdate(BaseModel):
|
||||
value: str
|
||||
|
||||
class ChargepointVariableResponse(BaseModel):
|
||||
status: SetVariableStatusType
|
19
backend/app/schemas/connector.py
Normal file
19
backend/app/schemas/connector.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import enum
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
class ConnectorStatus(enum.Enum):
|
||||
AVAILABLE = "Available"
|
||||
OCCUPIED = "Occupied"
|
||||
RESERVED = "Reserved"
|
||||
UNAVAILABLE = "Unavailable"
|
||||
FAULTED = "Faulted"
|
||||
|
||||
class Connector(BaseModel):
|
||||
id: UUID
|
||||
evse: int
|
||||
index: int
|
||||
status: ConnectorStatus
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
33
backend/app/schemas/id_token.py
Normal file
33
backend/app/schemas/id_token.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
class IdTokenBase(BaseModel):
|
||||
friendly_name: str
|
||||
is_active: bool
|
||||
owner_id: UUID
|
||||
token: str
|
||||
|
||||
class IdTokenCreate(IdTokenBase):
|
||||
pass
|
||||
|
||||
class IdTokenUpdate(BaseModel):
|
||||
friendly_name: Optional[str] = None
|
||||
is_active: Optional[bool] = None
|
||||
owner_id: Optional[UUID] = None
|
||||
|
||||
class IdToken(IdTokenBase):
|
||||
id: UUID
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class IdTokenLearnBase(BaseModel):
|
||||
user_id: UUID
|
||||
|
||||
class IdTokenLearnRequest(IdTokenLearnBase):
|
||||
until: Optional[datetime] = None
|
||||
|
||||
class IdTokenLearnResponse(IdTokenLearnBase):
|
||||
until: datetime
|
57
backend/app/schemas/meter_value.py
Normal file
57
backend/app/schemas/meter_value.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
import enum
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
class PhaseType(enum.Enum):
|
||||
L1 = "L1"
|
||||
L2 = "L2"
|
||||
L3 = "L3"
|
||||
N = "N"
|
||||
L1_N = "L1-N"
|
||||
L2_N = "L2-N"
|
||||
L3_N = "L3-N"
|
||||
L1_L2 = "L1-L2"
|
||||
L2_L3 = "L2-L3"
|
||||
L3_L1 = "L3-L1"
|
||||
|
||||
class Measurand(enum.Enum):
|
||||
CURRENT_EXPORT = "Current.Export"
|
||||
CURRENT_IMPORT = "Current.Import"
|
||||
CURRENT_OFFERED = "Current.Offered"
|
||||
ENERGY_ACTIVE_NET = "Energy.Active.Net"
|
||||
ENERGY_ACTIVE_EXPORT_REGISTER = "Energy.Active.Export.Register"
|
||||
ENERGY_ACTIVE_IMPORT_REGISTER = "Energy.Active.Import.Register"
|
||||
ENERGY_ACTIVE_EXPORT_INTERVAL = "Energy.Active.Export.Interval"
|
||||
ENERGY_ACTIVE_IMPORT_INTERVAL = "Energy.Active.Import.Interval"
|
||||
ENERGY_REACTIVE_NET = "Energy.Reactive.Net"
|
||||
ENERGY_REACTIVE_EXPORT_REGISTER = "Energy.Reactive.Export.Register"
|
||||
ENERGY_REACTIVE_IMPORT_REGISTER = "Energy.Reactive.Import.Register"
|
||||
ENERGY_REACTIVE_EXPORT_INTERVAL = "Energy.Reactive.Export.Interval"
|
||||
ENERGY_REACTIVE_IMPORT_INTERVAL = "Energy.Reactive.Import.Interval"
|
||||
ENERGY_APPARENT_NET = "Energy.Apparent.Net"
|
||||
ENERGY_APPARENT_IMPORT = "Energy.Apparent.Import"
|
||||
ENERGY_APPARENT_EXPORT = "Energy.Apparent.Export"
|
||||
FREQUENCY = "Frequency"
|
||||
POWER_ACTIVE_EXPORT = "Power.Active.Export"
|
||||
POWER_ACTIVE_IMPORT = "Power.Active.Import"
|
||||
POWER_FACTOR = "Power.Factor"
|
||||
POWER_OFFERED = "Power.Offered"
|
||||
POWER_REACTIVE_EXPORT = "Power.Reactive.Export"
|
||||
POWER_REACTIVE_IMPORT = "Power.Reactive.Import"
|
||||
SOC = "SoC"
|
||||
VOLTAGE = "Voltage"
|
||||
|
||||
class MeterValue(BaseModel):
|
||||
id: UUID
|
||||
timestamp: datetime
|
||||
measurand: Measurand
|
||||
phase_type: Optional[PhaseType] = None
|
||||
unit: Optional[str] = None
|
||||
value: Decimal
|
||||
transaction_id: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
11
backend/app/schemas/session.py
Normal file
11
backend/app/schemas/session.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Session(BaseModel):
|
||||
id: UUID
|
||||
name: str
|
||||
last_used: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
55
backend/app/schemas/transaction.py
Normal file
55
backend/app/schemas/transaction.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
import enum
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
class TransactionStatus(enum.Enum):
|
||||
ONGOING = "ongoing"
|
||||
ENDED = "ended"
|
||||
|
||||
class TransactionEventTriggerReason(enum.Enum):
|
||||
AUTHORIZED = "Authorized"
|
||||
CABLE_PLUGGED_IN = "CablePluggedIn"
|
||||
CHARGING_RATE_CHANGED = "ChargingRateChanged"
|
||||
CHARGING_STATE_CHANGED = "ChargingStateChanged"
|
||||
DEAUTHORIZED = "Deauthorized"
|
||||
ENERGY_LIMIT_REACHED = "EnergyLimitReached"
|
||||
EV_COMMUNICATION_LOST = "EVCommunicationLost"
|
||||
EV_CONNECT_TIMEOUT = "EVConnectTimeout"
|
||||
METER_VALUE_CLOCK = "MeterValueClock"
|
||||
METER_VALUE_PERIODIC = "MeterValuePeriodic"
|
||||
TIME_LIMIT_REACHED = "TimeLimitReached"
|
||||
TRIGGER = "Trigger"
|
||||
UNLOCK_COMMAND = "UnlockCommand"
|
||||
STOP_AUTHORIZED = "StopAuthorized"
|
||||
EV_DEPARTED = "EVDeparted"
|
||||
EV_DETECTED = "EVDetected"
|
||||
REMOTE_STOP = "RemoteStop"
|
||||
REMOTE_START = "RemoteStart"
|
||||
ABNORMAL_CONDITION = "AbnormalCondition"
|
||||
SIGNED_DATA_RECEIVED = "SignedDataReceived"
|
||||
RESET_COMMAND = "ResetCommand"
|
||||
|
||||
class RemoteTransactionStartStopStatus(enum.Enum):
|
||||
ACCEPTED = "Accepted"
|
||||
REJECTED = "Rejected"
|
||||
|
||||
class Transaction(BaseModel):
|
||||
id: str
|
||||
status: TransactionStatus
|
||||
started_at: datetime
|
||||
ended_at: Optional[datetime] = None
|
||||
meter_start: Decimal
|
||||
meter_end: Optional[Decimal] = None
|
||||
end_reason: Optional[TransactionEventTriggerReason] = None
|
||||
price: Decimal
|
||||
user_id: Optional[UUID] = None
|
||||
chargepoint_id: UUID
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class RemoteTransactionStartStopResponse(BaseModel):
|
||||
status: RemoteTransactionStartStopStatus
|
39
backend/app/schemas/user.py
Normal file
39
backend/app/schemas/user.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import enum
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
|
||||
class Role(enum.StrEnum):
|
||||
MEMBER = "member"
|
||||
ADMINISTRATOR = "administrator"
|
||||
|
||||
class UserBase(BaseModel):
|
||||
email: EmailStr = Field(max_length=60)
|
||||
friendly_name: str
|
||||
is_active: bool
|
||||
|
||||
class UserUpdate(BaseModel):
|
||||
email: Optional[str] = None
|
||||
friendly_name: Optional[str] = None
|
||||
|
||||
class AdministrativeUserUpdate(UserUpdate):
|
||||
is_active: Optional[bool] = None
|
||||
|
||||
class UserCreate(UserBase):
|
||||
password: str = Field(max_length=100)
|
||||
pass
|
||||
|
||||
class User(UserBase):
|
||||
id: UUID
|
||||
role: Role
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class PasswordUpdate(BaseModel):
|
||||
old_password: str = Field(max_length=100)
|
||||
new_password: str = Field(max_length=100)
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
email: EmailStr = Field(max_length=60)
|
||||
password: str = Field(max_length=100)
|
Loading…
Add table
Add a link
Reference in a new issue