33
33
import time
34
34
35
35
from ansible .module_utils .connection import Connection
36
- from enum import Enum
37
36
38
- # class syntax
39
- class RequestType (Enum ):
40
- BEFORE_REQUEST = 1
41
- AFTER_REQUEST = 2
37
+ BEFORE_REQUEST = 1
38
+ AFTER_REQUEST = 2
42
39
43
40
checkpoint_argument_spec_for_async = dict (
44
41
wait_for_task = dict (type = 'bool' , default = True )
@@ -79,7 +76,6 @@ def get_version(module):
79
76
return res
80
77
81
78
82
-
83
79
# send the request to checkpoint
84
80
def send_request (connection , version , url , payload = None ):
85
81
code , response = connection .send_request ('/gaia_api/' + version + url , payload )
@@ -99,14 +95,14 @@ def replace_chkp_params(params, request_type):
99
95
payload = {}
100
96
old = ""
101
97
new = ""
102
- if request_type == RequestType . BEFORE_REQUEST :
98
+ if request_type == BEFORE_REQUEST :
103
99
old = "_"
104
100
new = "-"
105
101
# we used a dedicated 'msg' parametr because we can not use 'message' parameter
106
102
# as 'message' is used internally in Ansible Core engine
107
103
if "msg" in params :
108
104
params ["message" ] = params .pop ("msg" )
109
- elif request_type == RequestType . AFTER_REQUEST :
105
+ elif request_type == AFTER_REQUEST :
110
106
old = "-"
111
107
new = "_"
112
108
if "message" in params :
@@ -176,11 +172,11 @@ def wait_for_task(module, version, task_id):
176
172
177
173
# handle api call
178
174
def api_call (module , target_version , api_call_object ):
179
- payload = replace_chkp_params (module .params , RequestType . BEFORE_REQUEST )
175
+ payload = replace_chkp_params (module .params , BEFORE_REQUEST )
180
176
connection = Connection (module ._socket_path )
181
177
code , response = send_request (connection , target_version , api_call_object , payload )
182
178
183
- response = replace_chkp_params (response , RequestType . AFTER_REQUEST )
179
+ response = replace_chkp_params (response , AFTER_REQUEST )
184
180
return code , response
185
181
186
182
@@ -256,7 +252,7 @@ def chkp_api_call(module, api_call_object, has_add_api, ignore=None, show_params
256
252
[module .params .pop (key ) for key in show_params if key not in add_params ]
257
253
module .params .update (add_params )
258
254
code , res = api_call (module , target_version , api_call_object = "add-{0}" .format (api_call_object ))
259
- else : # some requests like static-route don't have add, try set instead
255
+ else : # some requests like static-route don't have add, try set instead
260
256
code , res = api_call (module , target_version , api_call_object = "set-{0}" .format (api_call_object ))
261
257
262
258
if code != 200 :
0 commit comments