class ChildEnvironmentService {

    public void detachChildEnvironment(DetachChildEnvironmentRequest request, String accountId) {
        ChildEnvironment childEnvironment = repository.findByParentAndChildEnvironmentCrns(
                request.getParentEnvironmentCrn(), request.getChildEnvironmentCrn(), accountId)
            .orElseThrow(() -> new NotFoundException(String.format("ChildEnvironment by parent environment crn [%s] and child environment crn [%s] not found",
                            request.getParentEnvironmentCrn(), request.getChildEnvironmentCrn())));
        MDCBuilder.buildMdcContext(childEnvironment.getStack());
        LOGGER.info("Detaching child env: {}", childEnvironment);
        repository.delete(childEnvironment);
    }

}