Skip to content

Commit 4a3b2f0

Browse files
authored
Merge pull request #7 from OnePoint-Team/master
merge branches
2 parents bdc6b9c + f339649 commit 4a3b2f0

File tree

4 files changed

+182
-186
lines changed

4 files changed

+182
-186
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Python Open Policy Agent (OPA) Client
22

3-
4-
3+
[![Downloads](https://pepy.tech/badge/opa-python-client)](https://pepy.tech/project/opa-python-client)
54

65
See offical documentation page [Open Policy Agent](https://www.openpolicyagent.org/docs/latest/)
76

@@ -57,6 +56,8 @@ client = OpaClient() # default host='localhost', port=8181, version='v1'
5756

5857
client.check_connection() # response is Yes I'm here :)
5958

59+
# Ensure the connection is closed correctly by deleting the client
60+
del client
6061
```
6162

6263

@@ -77,6 +78,7 @@ client = OpaClient(
7778

7879
client.check_connection() # response is Yes I'm here :)
7980

81+
del client
8082
```
8183

8284

@@ -93,6 +95,7 @@ client.update_opa_policy_fromfile("/your/path/filename.rego", endpoint="fromfile
9395

9496
client.get_policies_list() # response is ["fromfile"]
9597

98+
del client
9699
```
97100

98101

@@ -109,6 +112,7 @@ client.update_opa_policy_fromurl("http://opapolicyurlexample.test/example.rego",
109112

110113
client.get_policies_list() # response is ["fromfile","fromurl"]
111114

115+
del client
112116
```
113117

114118

@@ -126,6 +130,7 @@ client.delete_opa_policy("fromfile") # response is True
126130

127131
client.get_policies_list() # response is [fromurl"]
128132

133+
del client
129134
```
130135

131136
### Get raw data from OPA service ###
@@ -140,6 +145,7 @@ client = OpaClient() # default host='localhost', port=8181, version='v1'
140145

141146
print(client.get_opa_raw_data("testapi/testdata")) # response is {'result': ['world', 'hello']}
142147

148+
del client
143149
```
144150

145151
### Save policy to file from OPA service ###
@@ -154,7 +160,7 @@ client = OpaClient() # default host='localhost', port=8181, version='v1'
154160

155161
client.opa_policy_to_file(policy_name="fromurl",path="/your/path",filename="example.rego") # response is True
156162

157-
163+
del client
158164
```
159165

160166
### Delete data from OPA service ###
@@ -169,7 +175,7 @@ client = OpaClient() # default host='localhost', port=8181, version='v1'
169175

170176
client.delete_opa_data("testapi") # response is True
171177

172-
178+
del client
173179
```
174180

175181

@@ -187,6 +193,7 @@ client.get_policies_info()
187193

188194
# response is {'testpolicy': {'path': ['http://your-opa-service/v1/data/play'], 'rules': ['http://your-opa-service/v1/data/play/hello']}
189195

196+
del client
190197
```
191198

192199

@@ -205,6 +212,7 @@ client.check_permission(input_data=permission_you_want_check, policy_name="testp
205212

206213
# response is {'result': True}
207214

215+
del client
208216
```
209217

210218

0 commit comments

Comments
 (0)