search_resource_handler#

See select_resource_handler().

aws_resource_search.handlers.search_resource_handler.creating_index_items(resource_type: str) List[InfoItem][source]#

Print a message to tell user that we are creating index.

This method is used when we need to create or recreate the index.

aws_resource_search.handlers.search_resource_handler.search_resource_and_return_items(ui: UI, searcher: T_SEARCHER, query: str, boto_kwargs: Optional[dict] = None, refresh_data: bool = False, doc_to_item_func: Callable[[T_ARS_RESOURCE_DOCUMENT], AwsResourceItem] = None, skip_ui: bool = False) List[Union[AwsResourceItem, InfoItem, FileItem]][source]#

A wrapper of the Searcher. It will return a list of UI items instead of a list of documents.

Parameters:
  • searcher – corresponding resource type searcher object.

  • query – example “my bucket”, “my role”.

  • boto_kwargs – additional boto3 kwargs.

  • refresh_data – do we need to refresh the data?

  • doc_to_item_func – a callable function that convert document object to zelfred Item object. For those resources don’t have mandatory arguments for boto3 API, it is very simple. But for those resources need a parent resource name as an argument for the boto3 API, we need special handling to convert the original doc to item. That’s the purpose of this argument.

  • skip_ui – if True, skip the UI related logic, just return the items. this argument is used for third party integration.

aws_resource_search.handlers.search_resource_handler.search_resource(ui: UI, resource_type: str, query: str, boto_kwargs: Optional[dict] = None, doc_to_item_func: Callable[[T_ARS_RESOURCE_DOCUMENT], AwsResourceItem] = None, skip_ui: bool = False) List[Union[AwsResourceItem, InfoItem, FileItem]][source]#

A wrapper around search_and_return_items(), it also handles the case that we have to create the index and the case that user wants to refresh data.

Note

this is the sub logic to handle AWS resource that doesn’t have any mandatory boto kwargs. This is the MOST common case.

Parameters:
  • ui – UI object.

  • resource_type – the resource type name

  • query – example “my bucket”, “my role”

  • doc_to_item_func – a callable function that convert document object to zelfred Item object.

  • skip_ui – if True, skip the UI related logic, just return the items. this argument is used for third party integration.

aws_resource_search.handlers.search_resource_handler.search_partitioner(ui: UI, resource_type: str, partitioner_resource_type: str, partitioner_query: str, skip_ui: bool = False) List[Union[AwsResourceItem, InfoItem, FileItem]][source]#

Search partitioner resource.

A wrapper of the BaseSearcher. It assumes that you have to search another resource before searching the real resource. For example, you have to search glue database before you can search glue table, since glue table boto3 API call requires the glue database. In this example, the glue_table is the searcher, and the glue_database is the partitioner_searcher. It returns a list of UI items instead of a list of documents.

Parameters:
  • ui – UI object.

  • resource_type – the resource type name

  • partitioner_resource_type – the partitioner (parent) resource type name

  • partitioner_query – the query to filter partitioner, example: “sfn state machine”

  • skip_ui – if True, skip the UI related logic, just return the items. this argument is used for third party integration.

aws_resource_search.handlers.search_resource_handler.search_child_resource(ui: UI, resource_type: str, partitioner_resource_type: str, resource_query: str, partitioner_query: str, boto_kwargs: Dict[str, Any], skip_ui: bool = False) List[Union[AwsResourceItem, InfoItem, FileItem]][source]#

Search child resource under the given partitioner.

A wrapper of the Searcher. But it will return a list of UI items instead of a list of documents.

Parameters:
  • ui – UI object.

  • resource_type – example: “glue-database-table”

  • partitioner_resource_type – example: “glue-database”

  • resource_query – example: “my table”

  • partitioner_query – example: “my database”

  • boto_kwargs – example: {“database_name”: “my database”}, for searching glue table under the given database

  • skip_ui – if True, skip the UI related logic, just return the items. this argument is used for third party integration.

aws_resource_search.handlers.search_resource_handler.search_resource_under_partitioner(ui: UI, resource_type: str, partitioner_resource_type: str, query: str, skip_ui: bool = False) List[Union[AwsResourceItem, InfoItem, FileItem]][source]#

IMPORTANT this is the sub logic to handle AWS resource like glue table, glue job run, that requires the parent resource name in the arguments.

Parameters:
  • resource_type – for example, "glue-table"

  • partitioner_resource_type – for example, "glue-database"

  • query – for example, if the full user query is "glue-table: my_database@my table", then this argument is "my_database@my table".

  • skip_ui – if True, skip the UI related logic, just return the items. this argument is used for third party integration.

aws_resource_search.handlers.search_resource_handler.search_resource_handler(ui: UI, resource_type: str, query: str, skip_ui: bool = False) List[Union[AwsResourceItem, InfoItem, FileItem]][source]#

IMPORTANT This handle filter resource by query.

Parameters:
  • resource_type – for example, "s3-bucket"

  • query – for example, if the full user query is "s3-bucket: my bucket", then this argument is "my bucket".

  • skip_ui – if True, skip the UI related logic, just return the items. this argument is used for third party integration.