-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(generate): generation of XML files
- Loading branch information
1 parent
6fef598
commit fd0e8b1
Showing
11 changed files
with
426 additions
and
142 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 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
30 changes: 30 additions & 0 deletions
30
splunk_add_on_ucc_framework/generators/xml_files/__init__.py
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,30 @@ | ||
# | ||
# Copyright 2024 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from .xml_generator import XMLGenerator | ||
from .create_default_xml import DefaultXml | ||
from .create_configuration_xml import ConfigurationXml | ||
from .create_dashboard_xml import DashboardXml | ||
from .create_inputs_xml import InputsXml | ||
from .create_redirect_xml import RedirectXml | ||
|
||
__all__ = [ | ||
"XMLGenerator", | ||
"DefaultXml", | ||
"ConfigurationXml", | ||
"DashboardXml", | ||
"InputsXml", | ||
"RedirectXml", | ||
] |
50 changes: 50 additions & 0 deletions
50
splunk_add_on_ucc_framework/generators/xml_files/create_configuration_xml.py
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,50 @@ | ||
# | ||
# Copyright 2024 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from splunk_add_on_ucc_framework.generators.xml_files import XMLGenerator | ||
from splunk_add_on_ucc_framework.global_config import GlobalConfig | ||
from typing import Any, Dict | ||
from splunk_add_on_ucc_framework import data_ui_generator | ||
|
||
|
||
class ConfigurationXml(XMLGenerator): | ||
__description__ = " Generates configuration.xml file in `default/data/ui/views/` folder if globalConfig is present." | ||
|
||
def __init__( | ||
self, | ||
global_config: GlobalConfig, | ||
input_dir: str, | ||
output_dir: str, | ||
**kwargs: Any, | ||
) -> None: | ||
super().__init__(global_config, input_dir, output_dir, **kwargs) | ||
|
||
def _set_attributes(self, **kwargs: Any) -> None: | ||
self.configuration_xml_content = ( | ||
data_ui_generator.generate_views_configuration_xml( | ||
kwargs["addon_name"], | ||
) | ||
) | ||
|
||
def generate_xml(self) -> Dict[str, str]: | ||
file_path = self.get_file_output_path( | ||
["default", "data", "ui", "views", "configuration.xml"] | ||
) | ||
self.writer( | ||
file_name="configuration.xml", | ||
file_path=file_path, | ||
content=self.configuration_xml_content, | ||
) | ||
return {"configuration.xml": file_path} |
54 changes: 54 additions & 0 deletions
54
splunk_add_on_ucc_framework/generators/xml_files/create_dashboard_xml.py
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,54 @@ | ||
# | ||
# Copyright 2024 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from splunk_add_on_ucc_framework.generators.xml_files import XMLGenerator | ||
from splunk_add_on_ucc_framework.global_config import GlobalConfig | ||
from typing import Any, Dict | ||
from splunk_add_on_ucc_framework import data_ui_generator | ||
|
||
|
||
class DashboardXml(XMLGenerator): | ||
__description__ = ( | ||
" Generates dashboard.xml file based on dashboard configuration present in globalConfig" | ||
" in `default/data/ui/views` folder." | ||
) | ||
|
||
def __init__( | ||
self, | ||
global_config: GlobalConfig, | ||
input_dir: str, | ||
output_dir: str, | ||
**kwargs: Any, | ||
) -> None: | ||
super().__init__(global_config, input_dir, output_dir, **kwargs) | ||
|
||
def _set_attributes(self, **kwargs: Any) -> None: | ||
if self._global_config and self._global_config.has_dashboard(): | ||
self.dashboard_xml_content = data_ui_generator.generate_views_dashboard_xml( | ||
kwargs["addon_name"] | ||
) | ||
|
||
def generate_xml(self) -> Dict[str, str]: | ||
if self._global_config and not self._global_config.has_dashboard(): | ||
return super().generate_xml() | ||
file_path = self.get_file_output_path( | ||
["default", "data", "ui", "views", "dashboard.xml"] | ||
) | ||
self.writer( | ||
file_name="dashboard.xml", | ||
file_path=file_path, | ||
content=self.dashboard_xml_content, | ||
) | ||
return {"dashboard.xml": file_path} |
Oops, something went wrong.