@@ -28,21 +28,13 @@ class OpenSearchContainer(DockerContainer):
28
28
... search_result = client.search(index="test", body={"query": {"match_all": {}}})
29
29
"""
30
30
31
- def __init__ (
32
- self ,
33
- image = "opensearchproject/opensearch:2.4.0" ,
34
- port_to_expose = 9200 ,
35
- security_enabled = False ,
36
- ** kwargs ,
37
- ):
31
+ def __init__ (self , image : str = "opensearchproject/opensearch:2.4.0" ,
32
+ port_to_expose : int = 9200 , security_enabled : bool = False , ** kwargs ) -> None :
38
33
"""
39
34
Args:
40
- image (str, optional): The Docker image to use for the container.
41
- Defaults to "opensearchproject/opensearch:2.4.0".
42
- port_to_expose (int, optional): The port to expose on the container.
43
- Defaults to 9200.
44
- security_enabled (bool, optional): `False` disables the security plugin in OpenSearch.
45
- Defaults to False.
35
+ image: Docker image to use for the container.
36
+ port_to_expose: Port to expose on the container.
37
+ security_enabled: :code:`False` disables the security plugin in OpenSearch.
46
38
"""
47
39
super (OpenSearchContainer , self ).__init__ (image , ** kwargs )
48
40
self .port_to_expose = port_to_expose
@@ -54,7 +46,7 @@ def __init__(
54
46
if security_enabled :
55
47
self .with_env ("plugins.security.allow_default_init_securityindex" , "true" )
56
48
57
- def get_config (self ):
49
+ def get_config (self ) -> dict :
58
50
"""This method returns the configuration of the OpenSearch container,
59
51
including the host, port, user, and password.
60
52
@@ -91,13 +83,13 @@ def get_client(self, verify_certs: bool = False, **kwargs) -> OpenSearch:
91
83
)
92
84
93
85
@wait_container_is_ready (ConnectionError , TransportError )
94
- def _healthcheck (self ):
86
+ def _healthcheck (self ) -> None :
95
87
"""This is an internal method used to check if the OpenSearch container
96
88
is healthy and ready to receive requests."""
97
89
client : OpenSearchContainer = self .get_client ()
98
90
client .cluster .health (wait_for_status = "green" )
99
91
100
- def start (self ):
92
+ def start (self ) -> "OpenSearchContainer" :
101
93
"""This method starts the OpenSearch container and runs the healthcheck
102
94
to verify that the container is ready to use."""
103
95
super ().start ()
0 commit comments