Source code for kappa_sdk.wellbore.wellbore

from typing import List, Optional
from .wellbore_geometry import WellboreGeometry
from .wellbore_perforation import WellborePerforation
from .._private._tech_objects_api import TechObjectsAPI
from .._private._tech_objects_dto import WellboreQueryDto
from .._private.dto_converters._wellbore_dto_converter import WellboreDtoConverter
from datetime import datetime


[docs] class Wellbore: def __init__(self, id: str, name: str, technical_object_id: str, tech_objects_api: TechObjectsAPI, dto_converter: WellboreDtoConverter) -> None: self.__id = id self.__name = name self.__technical_object_id = technical_object_id self.__geometries: Optional[List[WellboreGeometry]] = None self.__perforations: Optional[List[WellborePerforation]] = None self.__wellbore_query_dto: Optional[WellboreQueryDto] = None self.__tech_objects_api = tech_objects_api self.__dto_converter = dto_converter def refresh_data(self) -> None: self.__wellbore_query_dto = None self.__geometries = None self.__perforations = None def __get_wellbore_query_dto(self) -> WellboreQueryDto: if self.__wellbore_query_dto is None: self.__wellbore_query_dto = self.__tech_objects_api.get_wellbore(self.__technical_object_id) return self.__wellbore_query_dto @property def id(self) -> str: """Gets the unique id of this :class:`Wellbore`.""" return self.__id @property def name(self) -> str: """Gets the name of this :class:`Wellbore`.""" return self.__name @property def technical_object_id(self) -> str: """Gets the technical object id associated with this :class:`Wellbore`.""" return self.__technical_object_id @property def geometries(self) -> List[WellboreGeometry]: """Gets the geometries of this :class:`Wellbore`.""" if self.__geometries is None: self.__geometries = self.__dto_converter.get_geometries_from_dto(self.__get_wellbore_query_dto().geometries) return self.__geometries @property def perforations(self) -> List[WellborePerforation]: """Gets the perforations of this :class:`Wellbore`.""" if self.__perforations is None: self.__perforations = self.__dto_converter.get_perforations_from_dto(self.__get_wellbore_query_dto().perforations) return self.__perforations def add_geometries(self, geometries: List[WellboreGeometry]) -> List[WellboreGeometry]: """Add a geometry to the wellbore""" geometries_command_dto = self.__dto_converter.build_geometries_command_dto_from_geometries(geometries) self.__tech_objects_api.add_wellbore_geometries(self.__technical_object_id, geometries_command_dto) self.geometries.extend(geometries) return self.geometries def delete_geometries(self, start_date: Optional[datetime], end_date: Optional[datetime]) -> None: self.__wellbore_query_dto = self.__tech_objects_api.delete_wellbore_geometries(self.__technical_object_id, start_date, end_date) self.__geometries = self.__dto_converter.get_geometries_from_dto(self.__wellbore_query_dto.geometries) def add_perforations(self, perforations: List[WellborePerforation]) -> List[WellborePerforation]: perforations_command_dto = self.__dto_converter.build_perforations_dto_from_perforations(perforations) self.__tech_objects_api.add_perforations(self.__technical_object_id, perforations_command_dto) self.perforations.extend(perforations) return self.perforations def delete_perforations(self) -> None: self.__tech_objects_api.delete_wellbore_perforations(self.technical_object_id) self.__perforations = None