Skip to content

Commit a39c8c0

Browse files
fix: do not require calls of _reload endpoint (#1547)
**Issue number:** ADDON-77916 ### PR Type **What kind of change does this PR introduce?** * [ ] Feature * [x] Bug Fix * [ ] Refactoring (no functional or API changes) * [ ] Documentation Update * [ ] Maintenance (dependency updates, CI, etc.) ## Summary ### Changes This change uses the exposed interface to set `need_reload` from `splunktaucclib` to False by default in order to prevent reloads of selected endpoints. ### User experience Improves the performance of the add-ons built using UCC and those that are using `splunktaucclib` to not require reloads during API calls to the endpoints. ## Checklist If an item doesn't apply to your changes, leave it unchecked. * [x] I have performed a self-review of this change according to the [development guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines) * [x] Tests have been added/modified to cover the changes [(testing doc)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test) * [ ] Changes are documented * [x] PR title and description follows the [contributing principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests) --------- Co-authored-by: kkedziak <kkedziak@splunk.com>
1 parent 0fff4dd commit a39c8c0

File tree

16 files changed

+128
-12
lines changed

16 files changed

+128
-12
lines changed

splunk_add_on_ucc_framework/commands/rest_builder/endpoint/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def generate_rh(self) -> str:
123123

124124

125125
class RestEndpointBuilder:
126-
def __init__(self, name: Optional[str], namespace: str, **kwargs: str):
126+
def __init__(self, name: Optional[str], namespace: str, **kwargs: Any):
127127
self._name = name
128128
self._namespace = namespace
129129
self._entities: List[RestEntityBuilder] = []
@@ -144,6 +144,7 @@ def __init__(self, name: Optional[str], namespace: str, **kwargs: str):
144144
self._rest_handler_name = f"{self._namespace}_rh_{self._name}"
145145
self._rest_handler_module = kwargs.get("rest_handler_module")
146146
self._rest_handler_class = kwargs.get("rest_handler_class")
147+
self._need_reload = kwargs.get("need_reload", False)
147148

148149
@property
149150
def name(self) -> str:
@@ -173,6 +174,10 @@ def rh_class(self) -> Optional[str]:
173174
def entities(self) -> List[RestEntityBuilder]:
174175
return self._entities
175176

177+
@property
178+
def need_reload(self) -> bool:
179+
return self._need_reload
180+
176181
def add_entity(self, entity: RestEntityBuilder) -> None:
177182
self._entities.append(entity)
178183

splunk_add_on_ucc_framework/commands/rest_builder/endpoint/multiple_model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class MultipleModelEndpointBuilder(RestEndpointBuilder):
5757
models=[
5858
{models}
5959
],
60+
need_reload={need_reload},
6061
)
6162
6263
@@ -81,4 +82,5 @@ def generate_rh(self) -> str:
8182
entities="\n".join(entities),
8283
models=indent(models_lines, 2),
8384
conf_name=self.conf_name,
85+
need_reload=self.need_reload,
8486
)

splunk_add_on_ucc_framework/commands/rest_builder/endpoint/single_model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class SingleModelEndpointBuilder(RestEndpointBuilder):
6262
endpoint = SingleModel(
6363
'{conf_name}',
6464
model,
65-
config_name='{config_name}'
65+
config_name='{config_name}',
66+
need_reload={need_reload},
6667
)
6768
6869
@@ -85,4 +86,5 @@ def generate_rh(self) -> str:
8586
entity=entity.generate_rh(),
8687
conf_name=self.conf_name,
8788
config_name=self._name,
89+
need_reload=self.need_reload,
8890
)

splunk_add_on_ucc_framework/commands/rest_builder/global_config_builder_schema.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ def oauth_conf_file_names(self) -> List[str]:
8484
def endpoints(self) -> List[RestEndpointBuilder]:
8585
return list(self._endpoints.values())
8686

87+
@property
88+
def need_reload(self) -> bool:
89+
return False
90+
8791
def _parse_builder_schema(self) -> None:
8892
self._builder_configs()
8993
self._builder_settings()
@@ -102,6 +106,7 @@ def _builder_configs(self) -> None:
102106
rest_handler_class=config.get(
103107
"restHandlerClass", REST_HANDLER_DEFAULT_CLASS
104108
),
109+
need_reload=self.need_reload,
105110
)
106111
self._endpoints[name] = endpoint
107112
content = self._get_oauth_enitities(config["entity"])
@@ -140,6 +145,7 @@ def _builder_settings(self) -> None:
140145
namespace=self.global_config.namespace,
141146
rest_handler_module=REST_HANDLER_DEFAULT_MODULE,
142147
rest_handler_class=REST_HANDLER_DEFAULT_CLASS,
148+
need_reload=self.need_reload,
143149
)
144150
self._endpoints["settings"] = endpoint
145151
for setting in self.global_config.settings:
@@ -173,6 +179,7 @@ def _builder_inputs(self) -> None:
173179
rest_handler_name=rest_handler_name,
174180
rest_handler_module=rest_handler_module,
175181
rest_handler_class=rest_handler_class,
182+
need_reload=self.need_reload,
176183
)
177184
self._endpoints[name] = single_model_endpoint
178185
content = self._get_oauth_enitities(input_item["entity"])

splunk_add_on_ucc_framework/install_python_libraries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
logger = logging.getLogger("ucc_gen")
2929

3030

31-
LIBS_REQUIRED_FOR_UI = {"splunktaucclib": "6.4.0"}
31+
LIBS_REQUIRED_FOR_UI = {"splunktaucclib": "6.6.0"}
3232
LIBS_REQUIRED_FOR_OAUTH = {"solnlib": "5.5.0"}
3333

3434

tests/testdata/expected_addons/expected_output_global_config_configuration/Splunk_TA_UCCExample/bin/splunk_ta_uccexample_rh_account.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@
152152
endpoint = SingleModel(
153153
'splunk_ta_uccexample_account',
154154
model,
155-
config_name='account'
155+
config_name='account',
156+
need_reload=False,
156157
)
157158

158159

tests/testdata/expected_addons/expected_output_global_config_configuration/Splunk_TA_UCCExample/bin/splunk_ta_uccexample_rh_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
model_logging,
173173
model_custom_abc
174174
],
175+
need_reload=False,
175176
)
176177

177178

tests/testdata/expected_addons/expected_output_global_config_everything/Splunk_TA_UCCExample/bin/splunk_ta_uccexample_rh_account.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@
239239
endpoint = SingleModel(
240240
'splunk_ta_uccexample_account',
241241
model,
242-
config_name='account'
242+
config_name='account',
243+
need_reload=False,
243244
)
244245

245246

tests/testdata/expected_addons/expected_output_global_config_everything/Splunk_TA_UCCExample/bin/splunk_ta_uccexample_rh_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
model_logging,
178178
model_custom_abc
179179
],
180+
need_reload=False,
180181
)
181182

182183

tests/testdata/test_addons/package_files_conflict_test/globalConfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
"meta": {
200200
"name": "test_addon",
201201
"restRoot": "test_addon",
202-
"version": "5.56.0+12f4cd8cd",
202+
"version": "5.57.0+f11804ebf",
203203
"displayName": "This is my add-on",
204204
"schemaVersion": "0.0.9"
205205
}

0 commit comments

Comments
 (0)