-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Unify various API endpoints related to config
More details in the linked issue. Closes #1960
- Loading branch information
Showing
24 changed files
with
216 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from capellacollab.core import pydantic as core_pydantic | ||
from capellacollab.settings.configuration import models as config_models | ||
|
||
|
||
class Metadata(core_pydantic.BaseModel): | ||
version: str | ||
privacy_policy_url: str | None | ||
imprint_url: str | None | ||
provider: str | None | ||
authentication_provider: str | None | ||
environment: str | None | ||
|
||
host: str | None | ||
port: str | None | ||
protocol: str | None | ||
|
||
|
||
class UnifiedConfig(core_pydantic.BaseModel): | ||
metadata: Metadata | ||
feedback: config_models.FeedbackConfiguration | ||
navbar: config_models.NavbarConfiguration | ||
beta: config_models.BetaConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import capellacollab | ||
from capellacollab.config import config | ||
from capellacollab.settings.configuration import models as config_models | ||
from capellacollab.unifiedconfig import models | ||
|
||
|
||
def get_metadata( | ||
global_config: config_models.GlobalConfiguration, | ||
) -> models.Metadata: | ||
return models.Metadata.model_validate( | ||
global_config.metadata.model_dump() | ||
| { | ||
"version": capellacollab.__version__, | ||
"host": config.general.host, | ||
"port": str(config.general.port), | ||
"protocol": config.general.scheme, | ||
} | ||
) | ||
|
||
|
||
def get_feedback( | ||
global_config: config_models.GlobalConfiguration, | ||
) -> config_models.FeedbackConfiguration: | ||
feedback = global_config.feedback | ||
if not (config.smtp and config.smtp.enabled): | ||
feedback.enabled = False | ||
feedback.after_session = False | ||
feedback.on_footer = False | ||
feedback.on_session_card = False | ||
feedback.interval.enabled = False | ||
|
||
return feedback | ||
|
||
|
||
def get_navbar( | ||
global_config: config_models.GlobalConfiguration, | ||
) -> config_models.NavbarConfiguration: | ||
return global_config.navbar | ||
|
||
|
||
def get_beta( | ||
global_config: config_models.GlobalConfiguration, | ||
) -> config_models.BetaConfiguration: | ||
return global_config.beta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.