in src/sagemaker_core/tools/resources_codegen.py [0:0]
def generate_import_method(self, resource_name: str) -> str:
"""
Auto-generate the IMPORT method for a resource.
Args:
resource_name (str): The resource name.
Returns:
str: The formatted Import Method template.
"""
# Get the operation and shape for the 'import' method
operation_name = "Import" + resource_name
operation_metadata = self.operations[operation_name]
operation_input_shape_name = operation_metadata["input"]["shape"]
# Generate the arguments for the 'import' method
import_args = self._generate_method_args(operation_input_shape_name)
operation_input_args = self._generate_operation_input_args(
operation_metadata, is_class_method=True
)
# Convert the resource name to snake case
resource_lower = convert_to_snake_case(resource_name)
# Convert the operation name to snake case
operation = convert_to_snake_case(operation_name)
get_args = self._generate_get_args(resource_name, operation_input_shape_name)
docstring = self._generate_docstring(
title=f"Import a {resource_name} resource",
operation_name=operation_name,
resource_name=resource_name,
operation_input_shape_name=operation_input_shape_name,
include_session_region=True,
include_return_resource_docstring=True,
)
# Format the method using the IMPORT_METHOD_TEMPLATE
formatted_method = IMPORT_METHOD_TEMPLATE.format(
docstring=docstring,
resource_name=resource_name,
import_args=import_args,
resource_lower=resource_lower,
# TODO: change service name based on the service - runtime, sagemaker, etc.
service_name="sagemaker",
operation_input_args=operation_input_args,
operation=operation,
get_args=get_args,
)
# Return the formatted method
return formatted_method