Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(link): add update endpoint for link #2175

Merged
merged 178 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 172 commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
3663b60
v2.16.8
skamril Apr 19, 2024
d9bac0e
v2.17
laurent-laporte-pro May 15, 2024
55a245b
v2.17.1
skamril Jun 10, 2024
23027df
v2.17.2
skamril Jun 19, 2024
4150708
v2.17.3
skamril Jul 18, 2024
caa9cb8
v2.17.4
skamril Jul 26, 2024
b491c80
v2.17.5
skamril Aug 2, 2024
130d76c
WIP : first commit
TheoPascoli Sep 17, 2024
2d2027b
isort and black
TheoPascoli Sep 17, 2024
5cc7cea
add versioning
TheoPascoli Sep 18, 2024
f3a9464
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 18, 2024
0cf0ff5
add versioning
TheoPascoli Sep 18, 2024
d6ecfb1
add versioning
TheoPascoli Sep 18, 2024
e3e2158
add versioning
TheoPascoli Sep 18, 2024
2c37fff
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 18, 2024
e03678a
correct typing issue
TheoPascoli Sep 19, 2024
2f17d71
correct typing issue
TheoPascoli Sep 19, 2024
22e2eda
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 19, 2024
26cdb3a
correct typing issue
TheoPascoli Sep 19, 2024
76188de
fix tests
TheoPascoli Sep 19, 2024
9dff527
fix tests
TheoPascoli Sep 19, 2024
cac1349
fix tests
TheoPascoli Sep 19, 2024
d9716e3
refactor code
TheoPascoli Sep 19, 2024
0a540b1
refactor code
TheoPascoli Sep 19, 2024
40cb85b
fix mypy
TheoPascoli Sep 20, 2024
0d17337
fix mypy
TheoPascoli Sep 20, 2024
827fef2
fix mypy
TheoPascoli Sep 20, 2024
1e7004f
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 23, 2024
3eb93dd
change ui handling
TheoPascoli Sep 23, 2024
a04fbe2
black fixing
TheoPascoli Sep 23, 2024
ca0898f
fix errors
TheoPascoli Sep 24, 2024
30cf961
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 24, 2024
6a79ad6
fix errors
TheoPascoli Sep 24, 2024
b6c0053
fix errors
TheoPascoli Sep 24, 2024
a047c30
refactor code
MartinBelthle Sep 24, 2024
60c0c52
isort and black
TheoPascoli Sep 24, 2024
d520b83
refactor classes
TheoPascoli Sep 24, 2024
40c42d0
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 25, 2024
0c002d9
add integration tests
TheoPascoli Sep 25, 2024
26d382e
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 25, 2024
c7728db
add integration tests
TheoPascoli Sep 25, 2024
779dc39
add integration tests
TheoPascoli Sep 25, 2024
6ff5520
v2.17.6
skamril Sep 25, 2024
3853e45
add integration tests
TheoPascoli Sep 26, 2024
05e4ddf
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 27, 2024
647dfbd
add integration tests
TheoPascoli Sep 27, 2024
39f81f6
WIP : add update link endpoint
TheoPascoli Sep 27, 2024
e057c4b
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 27, 2024
1355def
fix: fix tests
TheoPascoli Sep 30, 2024
c07e789
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Sep 30, 2024
8b4ad08
Merge remote-tracking branch 'origin/master' into fix/fix-endpoint-li…
TheoPascoli Sep 30, 2024
18f2d77
build(ui): fix issue with build result not working (#2163)
skamril Sep 30, 2024
b6359ff
Merge branch 'fix/fix-endpoint-links-creation' of https://github.com/…
TheoPascoli Sep 30, 2024
ede7b3e
fix: fix tests
TheoPascoli Sep 30, 2024
3a6a7c8
fix: remove optional typing in models
TheoPascoli Sep 30, 2024
fcace50
fix: remove optional typing in models
TheoPascoli Sep 30, 2024
0f4d6e0
fix: remove optional typing in models
TheoPascoli Sep 30, 2024
d81eda0
Merge remote-tracking branch 'origin/fix/fix-endpoint-links-creation'…
TheoPascoli Sep 30, 2024
ece5f0e
WIP
TheoPascoli Oct 7, 2024
a4d0cd7
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 7, 2024
4d5c8ea
conflict: merge dev
TheoPascoli Oct 7, 2024
06faa3e
Merge branch 'fix/fix-endpoint-links-creation' into feature/add-endpo…
TheoPascoli Oct 8, 2024
7bd5059
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Oct 8, 2024
5ca372c
WIP
TheoPascoli Oct 8, 2024
c4772db
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 8, 2024
833a742
add abstract class for links
TheoPascoli Oct 8, 2024
213a1b4
isort
TheoPascoli Oct 8, 2024
d4c0830
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 9, 2024
a56337c
adapt to new handling of study_versions
TheoPascoli Oct 9, 2024
fe6b602
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 9, 2024
aec9e97
Merge remote-tracking branch 'origin/fix/fix-endpoint-links-creation'…
TheoPascoli Oct 9, 2024
7a842d6
refactor series saving and to_dto method
TheoPascoli Oct 9, 2024
77f3195
refactor series saving and to_dto method
TheoPascoli Oct 9, 2024
b429307
Merge branch 'dev' into fix/fix-endpoint-links-creation
TheoPascoli Oct 10, 2024
716e8ad
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Oct 10, 2024
7ac2915
add tests
TheoPascoli Oct 10, 2024
da97885
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Oct 11, 2024
650bc59
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 11, 2024
1543472
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 14, 2024
b219b0f
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 16, 2024
a0c400d
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Oct 16, 2024
229167a
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Oct 17, 2024
2bdaa94
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 17, 2024
70de778
code review changes
TheoPascoli Oct 17, 2024
b40ccf2
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 18, 2024
506043d
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Oct 18, 2024
a7e4d21
code review changes
TheoPascoli Oct 18, 2024
d96779f
code review changes
TheoPascoli Oct 21, 2024
9e4ebfc
code review changes
TheoPascoli Oct 21, 2024
f7468cf
Refactor link creation and updating logic
TheoPascoli Oct 22, 2024
f7ef6c6
Merge branch 'dev' into fix/fix-endpoint-links-creation
TheoPascoli Oct 23, 2024
4852a43
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Oct 23, 2024
4a8ebd6
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Oct 23, 2024
3e361b3
Merge branch 'dev' into fix/fix-endpoint-links-creation
TheoPascoli Oct 23, 2024
90fcc21
Merge branch 'dev' into fix/fix-endpoint-links-creation
TheoPascoli Oct 24, 2024
419975e
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Oct 24, 2024
117887e
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Oct 24, 2024
fe34e97
Merge branch 'dev' into fix/fix-endpoint-links-creation
TheoPascoli Oct 24, 2024
a11c7c7
Merge branch 'dev' into fix/fix-endpoint-links-creation
sylvlecl Oct 25, 2024
6d0814b
Refactor to include camelcase to the return object
TheoPascoli Oct 26, 2024
eb366de
Refactor link DTOs and validation logic
TheoPascoli Oct 28, 2024
dea6710
Refactor filter values to use a constant list
TheoPascoli Oct 28, 2024
0ff40b9
Refactor filter fields to use enumerations
TheoPascoli Oct 28, 2024
b8a52e4
Add a missing newline before LinkInfoProperties820 class
TheoPascoli Oct 28, 2024
4ef3682
Merge branch 'fix/fix-endpoint-links-creation' into feature/add-endpo…
TheoPascoli Oct 28, 2024
65f1a8f
Add a missing newline before LinkInfoProperties820 class
TheoPascoli Oct 28, 2024
53bf23c
Remove unused import and update type annotations
TheoPascoli Oct 28, 2024
870dbaf
Merge branch 'fix/fix-endpoint-links-creation' into feature/add-endpo…
TheoPascoli Oct 28, 2024
78ea2ae
Refactor method names in update_link module
TheoPascoli Oct 28, 2024
a0c864d
Rename variables to reflect update context in link management
TheoPascoli Oct 28, 2024
a272fd4
Refactor `get_one_link` to `get_updated_link`
TheoPascoli Oct 28, 2024
3f4cb36
Refactor link update logic in link_management.
TheoPascoli Oct 28, 2024
99c7d63
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 29, 2024
d6a5d14
Merge branch 'fix/fix-endpoint-links-creation' into feature/add-endpo…
TheoPascoli Oct 29, 2024
13f5a60
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Oct 30, 2024
be9450e
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Oct 30, 2024
72f79e2
feat: refactor link management to use new LinkDTO class
TheoPascoli Oct 31, 2024
e611ad0
feat: simplify JSON dumping in create_link
TheoPascoli Oct 31, 2024
03570f5
Refactor link management imports and optimize validations
TheoPascoli Oct 31, 2024
482ceca
Merge branch 'fix/fix-endpoint-links-creation-refacto' into feature/a…
TheoPascoli Oct 31, 2024
c33c195
feat: refactor link update process for improved consistency
TheoPascoli Nov 4, 2024
c41b98b
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Nov 4, 2024
e7b9b72
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
TheoPascoli Nov 4, 2024
4ccf715
feat: refactor link path handling in link management.
TheoPascoli Nov 6, 2024
c96644b
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Nov 7, 2024
3f67891
Merge branch 'dev' into fix/fix-endpoint-links-creation-refacto
TheoPascoli Nov 7, 2024
38a1eb0
feat: remove unused LINK_PATH and inline its usage
TheoPascoli Nov 7, 2024
a9e64a5
Merge branch 'dev' into fix/fix-endpoint-links-creation-refacto
TheoPascoli Nov 12, 2024
5a1d565
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Nov 12, 2024
2b50f1a
Merge branch 'dev' into fix/fix-endpoint-links-creation-refacto
TheoPascoli Nov 12, 2024
42e7ca7
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Nov 12, 2024
a5d827f
feat: add header
TheoPascoli Nov 13, 2024
3bf3651
feat: add header
TheoPascoli Nov 13, 2024
e5c7bc6
feat: update return type of get_links function
TheoPascoli Nov 13, 2024
0a23a8c
Merge branch 'dev' into fix/fix-endpoint-links-creation-refacto
skamril Nov 13, 2024
c474e35
feat: update return type of get_links function
TheoPascoli Nov 13, 2024
53ec94a
Merge branch 'fix/fix-endpoint-links-creation-refacto' of https://git…
TheoPascoli Nov 13, 2024
3e73279
fix(ui-api): update links endpoints with new DTO format
skamril Nov 12, 2024
443105b
fix: fix color field validation in link model
TheoPascoli Nov 13, 2024
40e190c
fix: correct color value validation
TheoPascoli Nov 13, 2024
b790b0a
Merge branch 'fix/fix-endpoint-links-creation-refacto' into feature/a…
TheoPascoli Nov 13, 2024
7a77cb6
fix: fix test assertion message for input length validation
TheoPascoli Nov 13, 2024
8d2d34c
fix: fix test assertion message for input length validation
TheoPascoli Nov 13, 2024
f795199
refactor(link): update DTO format
TheoPascoli Nov 13, 2024
2d07e21
refactor(ui-api): update links endpoints with new DTO format
skamril Nov 12, 2024
b6f317e
fix: add copyright and license headers
TheoPascoli Nov 13, 2024
e6c3a3e
fix: add copyright and license headers
TheoPascoli Nov 13, 2024
913178e
fix: adjust color field validation limits
TheoPascoli Nov 13, 2024
78481bd
Merge branch 'dev' into feat/ANT-2312_ANT-1882_links-endpoints
TheoPascoli Nov 13, 2024
738683f
fix: refactor and simplify link validation and creation following git…
TheoPascoli Nov 14, 2024
f93ad5f
refactor(link): update DTO format
TheoPascoli Nov 13, 2024
f0717ee
refactor(ui-api): update links endpoints with new DTO format
skamril Nov 12, 2024
204d67b
fix: add copyright and license headers
TheoPascoli Nov 13, 2024
8a7a8e4
fix: add copyright and license headers
TheoPascoli Nov 13, 2024
eefd391
fix: adjust color field validation limits
TheoPascoli Nov 13, 2024
12493cd
fix: refactor and simplify link validation and creation following git…
TheoPascoli Nov 14, 2024
1fc139e
Merge branch 'feat/ANT-2312_ANT-1882_links-endpoints' of https://gith…
TheoPascoli Nov 14, 2024
0095873
feat: refactor type annotations and version parsing
TheoPascoli Nov 14, 2024
abf0bbf
feat: refactor condition handling in table_mode_management
TheoPascoli Nov 14, 2024
cf23fc1
Merge branch 'fix/fix-endpoint-links-creation-refacto' into feature/a…
TheoPascoli Nov 15, 2024
a7d46c8
fix: missing newline at end of file in model init
TheoPascoli Nov 15, 2024
92357e7
Merge branch 'feat/ANT-2312_ANT-1882_links-endpoints' into feature/ad…
TheoPascoli Nov 15, 2024
d31e7ab
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Nov 15, 2024
658d249
fix: refactor link model and update related tests
TheoPascoli Nov 15, 2024
2d3d49c
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Nov 19, 2024
c5be5ee
refactor: remove duplicate and unused imports
TheoPascoli Nov 19, 2024
38f980e
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Nov 19, 2024
0b121d4
feat: add study_version to CommandDTO in create_link
TheoPascoli Nov 19, 2024
0cd2034
Merge branch 'dev' into feature/add-endpoint-link-update
TheoPascoli Nov 19, 2024
f12c921
fix: refactor link management and update error handling
TheoPascoli Nov 20, 2024
8d669c2
Merge remote-tracking branch 'origin/dev' into feature/add-endpoint-l…
TheoPascoli Nov 20, 2024
306f85b
fix: refactor to_dto method and fix test string format
TheoPascoli Nov 21, 2024
d4b4716
fix: changes after review
TheoPascoli Nov 25, 2024
cb303b5
fix: changes after review
TheoPascoli Nov 25, 2024
729ecee
feat: fix tests
TheoPascoli Nov 27, 2024
c9077e9
feat: change the url for the update endpoint.
TheoPascoli Nov 28, 2024
841ea41
feat: change model logic for update endpoint
TheoPascoli Nov 28, 2024
43353c4
feat: change model logic for update endpoint
TheoPascoli Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions antarest/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ def __init__(self, message: str) -> None:
super().__init__(HTTPStatus.UNPROCESSABLE_ENTITY, message)


class LinkNotFound(HTTPException):
def __init__(self, message: str) -> None:
super().__init__(HTTPStatus.NOT_FOUND, message)


class VariantStudyParentNotValid(HTTPException):
def __init__(self, message: str) -> None:
super().__init__(HTTPStatus.UNPROCESSABLE_ENTITY, message)
Expand Down
47 changes: 46 additions & 1 deletion antarest/study/business/link_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@

from antares.study.version import StudyVersion

from antarest.core.exceptions import ConfigFileNotFound
from antarest.core.exceptions import ConfigFileNotFound, LinkNotFound, LinkValidationError
from antarest.core.model import JSON
from antarest.study.business.all_optional_meta import all_optional_model, camel_case_model
from antarest.study.business.model.link_model import LinkDTO, LinkInternal
from antarest.study.business.utils import execute_or_add_commands
from antarest.study.model import RawStudy, Study
from antarest.study.storage.rawstudy.model.filesystem.config.links import LinkProperties
from antarest.study.storage.rawstudy.model.filesystem.factory import FileStudy
from antarest.study.storage.storage_service import StudyStorageService
from antarest.study.storage.variantstudy.model.command.create_link import CreateLink
from antarest.study.storage.variantstudy.model.command.remove_link import RemoveLink
from antarest.study.storage.variantstudy.model.command.update_config import UpdateConfig
from antarest.study.storage.variantstudy.model.command.update_link import UpdateLink

_ALL_LINKS_PATH = "input/links"

Expand Down Expand Up @@ -76,6 +78,49 @@ def create_link(self, study: Study, link_creation_dto: LinkDTO) -> LinkDTO:

return link_creation_dto

def update_link(self, study: RawStudy, link_dto: LinkDTO) -> LinkDTO:
link = link_dto.to_internal(StudyVersion.parse(study.version))
file_study = self.storage_service.get_storage(study).get_raw(study)

self.check_link_existence(file_study, link)

command = UpdateLink(
area1=link.area1,
area2=link.area2,
parameters=link.model_dump(
include=link_dto.model_fields_set, exclude={"area1", "area2"}, exclude_none=True
MartinBelthle marked this conversation as resolved.
Show resolved Hide resolved
),
command_context=self.storage_service.variant_study_service.command_factory.command_context,
study_version=file_study.config.version,
)

execute_or_add_commands(study, file_study, [command], self.storage_service)

updated_link = self.get_internal_link(study, link)

return updated_link.to_dto()

def check_link_existence(self, file_study: FileStudy, link: LinkInternal) -> None:
area_from, area_to = sorted([link.area1, link.area2])
TheoPascoli marked this conversation as resolved.
Show resolved Hide resolved
try:
file_study.tree.get(["input", "links", area_from, "properties", area_to])
except KeyError:
raise LinkNotFound(f"The link {area_from} -> {area_to} is not present in the study")

def get_internal_link(self, study: RawStudy, link: LinkInternal) -> LinkInternal:
file_study = self.storage_service.get_storage(study).get_raw(study)

area_from, area_to = sorted([link.area1, link.area2])
TheoPascoli marked this conversation as resolved.
Show resolved Hide resolved
try:
link_properties = file_study.tree.get(["input", "links", area_from, "properties", area_to])
except KeyError:
raise LinkValidationError(f"The link {area_from} -> {area_to} is not present in the study")
TheoPascoli marked this conversation as resolved.
Show resolved Hide resolved

link_properties.update({"area1": area_from, "area2": area_to})
updated_link = LinkInternal.model_validate(link_properties)

return updated_link

def delete_link(self, study: RawStudy, area1_id: str, area2_id: str) -> None:
file_study = self.storage_service.get_storage(study).get_raw(study)
command = RemoveLink(
Expand Down
3 changes: 3 additions & 0 deletions antarest/study/business/model/link_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class Area(AntaresBaseModel):
def validate_areas(self) -> t.Self:
if self.area1 == self.area2:
raise LinkValidationError(f"Cannot create a link that goes from and to the same single area: {self.area1}")
area_from, area_to = sorted([self.area1, self.area2])
self.area1 = area_from
self.area2 = area_to
return self


Expand Down
6 changes: 5 additions & 1 deletion antarest/study/business/table_mode_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ def update_table_data(
elif table_type == TableModeType.LINK:
links_map = {tuple(key.split(" / ")): LinkOutput(**values) for key, values in data.items()}
updated_map = self._link_manager.update_links_props(study, links_map) # type: ignore
excludes = set() if int(study.version) >= STUDY_VERSION_8_2 else {"filter_synthesis", "filter_year_by_year"}
excludes = (
set()
if StudyVersion.parse(study.version) >= STUDY_VERSION_8_2
else {"filter_synthesis", "filter_year_by_year"}
)
data = {
f"{area1_id} / {area2_id}": link.model_dump(by_alias=True, exclude=excludes)
for (area1_id, area2_id), link in updated_map.items()
Expand Down
7 changes: 1 addition & 6 deletions antarest/study/business/xpansion_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from fastapi import HTTPException, UploadFile
from pydantic import Field, ValidationError, field_validator, model_validator

from antarest.core.exceptions import BadZipBinary, ChildNotFoundError
from antarest.core.exceptions import BadZipBinary, ChildNotFoundError, LinkNotFound
from antarest.core.model import JSON
from antarest.core.serialization import AntaresBaseModel
from antarest.study.business.all_optional_meta import all_optional_model
Expand Down Expand Up @@ -255,11 +255,6 @@ class XpansionCandidateDTO(AntaresBaseModel):
)


class LinkNotFound(HTTPException):
def __init__(self, message: str) -> None:
super().__init__(http.HTTPStatus.NOT_FOUND, message)


class XpansionFileNotFoundError(HTTPException):
def __init__(self, message: str) -> None:
super().__init__(http.HTTPStatus.NOT_FOUND, message)
Expand Down
19 changes: 19 additions & 0 deletions antarest/study/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,25 @@ def create_link(
)
return new_link

def update_link(
self,
uuid: str,
link_update_dto: LinkDTO,
params: RequestParameters,
) -> LinkDTO:
study = self.get_study(uuid)
assert_permission(params.user, study, StudyPermissionType.WRITE)
self._assert_study_unarchived(study)
updated_link = self.links_manager.update_link(study, link_update_dto)
self.event_bus.push(
MartinBelthle marked this conversation as resolved.
Show resolved Hide resolved
Event(
type=EventType.STUDY_DATA_EDITED,
payload=study.to_json_summary(),
permissions=PermissionInfo.from_study(study),
)
)
return updated_link

def update_area(
self,
uuid: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def _revert_create_link(base_command: CreateLink, history: t.List["ICommand"], b
)
]

@staticmethod
def _revert_update_link(base_command: CreateLink, history: t.List["ICommand"], base: FileStudy) -> t.List[ICommand]:
raise NotImplementedError("The revert function for UpdateLink is not available")

@staticmethod
def _revert_remove_link(base_command: RemoveLink, history: t.List["ICommand"], base: FileStudy) -> t.List[ICommand]:
raise NotImplementedError("The revert function for RemoveLink is not available")
Expand Down
2 changes: 2 additions & 0 deletions antarest/study/storage/variantstudy/command_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from antarest.study.storage.variantstudy.model.command.update_comments import UpdateComments
from antarest.study.storage.variantstudy.model.command.update_config import UpdateConfig
from antarest.study.storage.variantstudy.model.command.update_district import UpdateDistrict
from antarest.study.storage.variantstudy.model.command.update_link import UpdateLink
from antarest.study.storage.variantstudy.model.command.update_playlist import UpdatePlaylist
from antarest.study.storage.variantstudy.model.command.update_raw_file import UpdateRawFile
from antarest.study.storage.variantstudy.model.command.update_scenario_builder import UpdateScenarioBuilder
Expand All @@ -55,6 +56,7 @@
CommandName.CREATE_DISTRICT.value: CreateDistrict,
CommandName.REMOVE_DISTRICT.value: RemoveDistrict,
CommandName.CREATE_LINK.value: CreateLink,
CommandName.UPDATE_LINK.value: UpdateLink,
CommandName.REMOVE_LINK.value: RemoveLink,
CommandName.CREATE_BINDING_CONSTRAINT.value: CreateBindingConstraint,
CommandName.UPDATE_BINDING_CONSTRAINT.value: UpdateBindingConstraint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CommandName(Enum):
CREATE_DISTRICT = "create_district"
REMOVE_DISTRICT = "remove_district"
CREATE_LINK = "create_link"
UPDATE_LINK = "update_link"
REMOVE_LINK = "remove_link"
CREATE_BINDING_CONSTRAINT = "create_binding_constraint"
UPDATE_BINDING_CONSTRAINT = "update_binding_constraint"
Expand Down
Loading
Loading