-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fetch Migration] Added constructs and logic for component and index …
…template migration This includes class representations of component and index template information (and their unit tests). Index_operations now also has new functions to fetch and create component/index templates - unit test coverage for this is TBD. Finally, the template migration logic has been added to metadata_migration Signed-off-by: Kartik Ganesh <gkart@amazon.com>
- Loading branch information
Showing
7 changed files
with
412 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
# | ||
|
||
|
||
# Constants | ||
from typing import Optional | ||
|
||
NAME_KEY = "name" | ||
DEFAULT_TEMPLATE_KEY = "component_template" | ||
|
||
|
||
# Class that encapsulates component template information | ||
class ComponentTemplateInfo: | ||
# Private member variables | ||
__name: str | ||
__template_def: Optional[dict] | ||
|
||
def __init__(self, template_payload: dict, template_key: str = DEFAULT_TEMPLATE_KEY): | ||
self.__name = template_payload[NAME_KEY] | ||
self.__template_def = None | ||
if template_key in template_payload: | ||
self.__template_def = template_payload[template_key] | ||
|
||
def get_name(self) -> str: | ||
return self.__name | ||
|
||
def get_template_definition(self) -> dict: | ||
return self.__template_def |
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,23 @@ | ||
# | ||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
# | ||
|
||
from component_template_info import ComponentTemplateInfo | ||
|
||
# Constants | ||
INDEX_TEMPLATE_KEY = "index_template" | ||
|
||
|
||
# Class that encapsulates index template information from a cluster. | ||
# Subclass of ComponentTemplateInfo because the structure of an index | ||
# template is identical to a component template, except that it uses | ||
# a different template key. Also, index templates can be "composed" of | ||
# one or more component templates. | ||
class IndexTemplateInfo(ComponentTemplateInfo): | ||
def __init__(self, template_payload: dict): | ||
super().__init__(template_payload, INDEX_TEMPLATE_KEY) |
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
Oops, something went wrong.