@@ -56,6 +56,8 @@ client = OpaClient() # default host='localhost', port=8181, version='v1'
5656
5757client.check_connection() # response is Yes I'm here :)
5858
59+ # Ensure the connection is closed correctly by deleting the client
60+ del client
5961```
6062
6163
@@ -76,6 +78,7 @@ client = OpaClient(
7678
7779client.check_connection() # response is Yes I'm here :)
7880
81+ del client
7982```
8083
8184
@@ -92,6 +95,7 @@ client.update_opa_policy_fromfile("/your/path/filename.rego", endpoint="fromfile
9295
9396client.get_policies_list() # response is ["fromfile"]
9497
98+ del client
9599```
96100
97101
@@ -108,6 +112,7 @@ client.update_opa_policy_fromurl("http://opapolicyurlexample.test/example.rego",
108112
109113client.get_policies_list() # response is ["fromfile","fromurl"]
110114
115+ del client
111116```
112117
113118
@@ -125,6 +130,7 @@ client.delete_opa_policy("fromfile") # response is True
125130
126131client.get_policies_list() # response is [fromurl"]
127132
133+ del client
128134```
129135
130136### Get raw data from OPA service ###
@@ -139,6 +145,7 @@ client = OpaClient() # default host='localhost', port=8181, version='v1'
139145
140146print (client.get_opa_raw_data(" testapi/testdata" )) # response is {'result': ['world', 'hello']}
141147
148+ del client
142149```
143150
144151### Save policy to file from OPA service ###
@@ -153,7 +160,7 @@ client = OpaClient() # default host='localhost', port=8181, version='v1'
153160
154161client.opa_policy_to_file(policy_name = " fromurl" ,path = " /your/path" ,filename = " example.rego" ) # response is True
155162
156-
163+ del client
157164```
158165
159166### Delete data from OPA service ###
@@ -168,7 +175,7 @@ client = OpaClient() # default host='localhost', port=8181, version='v1'
168175
169176client.delete_opa_data(" testapi" ) # response is True
170177
171-
178+ del client
172179```
173180
174181
@@ -186,6 +193,7 @@ client.get_policies_info()
186193
187194# response is {'testpolicy': {'path': ['http://your-opa-service/v1/data/play'], 'rules': ['http://your-opa-service/v1/data/play/hello']}
188195
196+ del client
189197```
190198
191199
@@ -204,6 +212,7 @@ client.check_permission(input_data=permission_you_want_check, policy_name="testp
204212
205213# response is {'result': True}
206214
215+ del client
207216```
208217
209218
0 commit comments