oep
get_local_oep_data(token, block_schema, simulation_year)
async
¶
Fetches local OEP (Open Energy Platform) data based on the provided schema type and simulation year.
This function authenticates the user, validates the block schema, and reads simulation data for the requested year from local storage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
Annotated[str, Depends(oauth2_scheme)]
|
Authentication token required to access the endpoint |
required |
block_schema
|
str
|
Schema type of the data to retrieve |
required |
simulation_year
|
int
|
Year of the simulation data to fetch |
required |
Returns:
Type | Description |
---|---|
DataResponse
|
A DataResponse object containing the data items, total count, and a success flag |
Raises:
Type | Description |
---|---|
HTTPException
|
If token is invalid, if the block schema is not found, or if there are issues with the requested data |
Source code in backend/app/oep/router.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
get_local_oep_schemas(token, block_type)
async
¶
This endpoint retrieves a list of local schemas that match the provided block type. It accepts a user authentication token to ensure the request is authenticated. The schemas are filtered from a predefined list based on the specified block type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
Annotated[str, Depends(oauth2_scheme)]
|
An authentication token is required to request authorization. |
required |
block_type
|
str
|
The type of block to filter the schemas by. |
required |
Returns:
Type | Description |
---|---|
DataResponse
|
A DataResponse object containing the list of matching schemas and a success indicator. |
Raises:
Type | Description |
---|---|
HTTPException
|
Raises a 401 HTTP status code exception if the user is unauthorized or the token is invalid. |
Source code in backend/app/oep/router.py
get_oep_client()
¶
Provides a generator function to yield an instance of the OepClient class.
This function accesses environment variables to retrieve the necessary
credentials and configurations required for creating an OepClient instance.
It uses os.getenv
to get the OEP_TOKEN
and OEP_TOPIC
values for
authentication and topic management, respectively. The OepClient instance is
yielded, allowing the caller to manage resources appropriately.
Returns:
Type | Description |
---|---|
OepClient
|
OepClient: A generator that yields an instance of the OepClient class configured with a token and a default schema retrieved from the environment variables. |
Source code in backend/app/oep/router.py
get_oep_data(token, table_name, oep_cli=Depends(get_oep_client))
async
¶
Get OEP Data from a specified table.
This endpoint retrieves data from a specified table using the provided table_name
.
The OEP client instance is used to interact with the database, and token-based
authentication is required for accessing the endpoint. The data response includes
the retrieved items, their total count, and a success status indicator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
Annotated[str, Depends(oauth2_scheme)]
|
A bearer token for authentication. |
required |
table_name
|
str
|
The name of the table to retrieve data from. |
required |
oep_cli
|
OepClient
|
An instance of the OEP client to interact with the backend database. Dependency injection. |
Depends(get_oep_client)
|
Returns:
Type | Description |
---|---|
DataResponse
|
A |
Raises:
Type | Description |
---|---|
HTTPException
|
If the token is invalid or not provided. |
Source code in backend/app/oep/router.py
get_oep_metadata(token, table_name, oep_cli=Depends(get_oep_client))
async
¶
Retrieve metadata for a specific table.
This endpoint fetches metadata for the provided table name using the OEP client. It requires authentication via the provided token. If the token is invalid or not provided, an authentication error will be raised.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token
|
Annotated[str, Depends(oauth2_scheme)]
|
The authentication token obtained via the OAuth2 scheme. |
required |
table_name
|
str
|
The name of the table for which metadata is to be retrieved. |
required |
oep_cli
|
OepClient
|
Instance of the OepClient dependency for interacting with the OEP API. Dependency injection. |
Depends(get_oep_client)
|
Returns:
Type | Description |
---|---|
DataResponse
|
A DataResponse containing the retrieved metadata and its total count. |
Raises:
Type | Description |
---|---|
HTTPException
|
If the token is invalid or not provided. |