@@ -60,7 +60,7 @@ get_detector(DetectorId) ->
6060 Config :: aws_config ()) -> gd_return ().
6161get_detector (DetectorId , Config ) ->
6262 Path = " /detector/" ++ binary_to_list (DetectorId ),
63- guardduty_request (Config , get , Path , undefined ).
63+ guardduty_request (Config , get , Path ).
6464
6565
6666% %------------------------------------------------------------------------------
@@ -77,63 +77,50 @@ list_detectors() -> list_detectors(default_config()).
7777list_detectors (Config ) ->
7878 list_detectors (undefined , undefined , Config ).
7979
80- -spec list_detectors (Marker :: binary (),
81- MaxItems :: integer ()) -> gd_return ().
80+ -spec list_detectors (Marker :: undefined | binary (),
81+ MaxItems :: undefined | integer ()) -> gd_return ().
8282list_detectors (Marker , MaxItems ) ->
8383 list_detectors (Marker , MaxItems , default_config ()).
8484
85- -spec list_detectors (Marker :: binary (),
86- MaxItems :: integer (),
85+ -spec list_detectors (Marker :: undefined | binary (),
86+ MaxItems :: undefined | integer (),
8787 Config :: aws_config ()) -> gd_return ().
8888list_detectors (Marker , MaxItems , Config ) ->
8989 Path = " /detector" ,
9090 QParams = filter_undef ([{" Marker" , Marker },
9191 {" MaxItems" , MaxItems }]),
92- guardduty_request (Config , get , Path , undefined , QParams ).
92+ guardduty_request (Config , get , Path , QParams ).
9393
9494
9595% %%------------------------------------------------------------------------------
9696% %% Internal Functions
9797% %%------------------------------------------------------------------------------
9898
99- guardduty_request (Config , Method , Path , Body ) ->
100- guardduty_request (Config , Method , Path , Body , []).
99+ guardduty_request (Config , Method , Path ) ->
100+ guardduty_request (Config , Method , Path , []).
101101
102- guardduty_request (Config , Method , Path , Body , QParam ) ->
102+ guardduty_request (Config , Method , Path , QParam ) ->
103103 case erlcloud_aws :update_config (Config ) of
104104 {ok , Config1 } ->
105- guardduty_request_no_update (Config1 , Method , Path , Body , QParam );
105+ guardduty_request_no_update (Config1 , Method , Path , QParam );
106106 {error , Reason } ->
107107 {error , Reason }
108108 end .
109109
110- guardduty_request_no_update (Config , Method , Path , Body , QParam ) ->
111- Form = case encode_body (Body ) of
112- <<>> -> erlcloud_http :make_query_string (QParam );
113- Value -> Value
114- end ,
115- Headers = headers (Method , Path , Config , encode_body (Body ), QParam ),
110+ guardduty_request_no_update (Config , Method , Path , QParam ) ->
111+ Headers = headers (Method , Path , Config , QParam ),
116112 case erlcloud_aws :aws_request_form_raw (
117113 Method , Config # aws_config .guardduty_scheme , Config # aws_config .guardduty_host ,
118- Config # aws_config .guardduty_port , Path , Form , Headers , Config ) of
114+ Config # aws_config .guardduty_port , Path , <<>> , Headers , Config ) of
119115 {ok , Data } ->
120116 {ok , jsx :decode (Data )};
121117 E ->
122118 E
123119 end .
124120
125- encode_body (undefined ) ->
126- <<>>;
127- encode_body ([]) ->
128- <<" {}" >>;
129- encode_body (Body ) ->
130- jsx :encode (Body ).
131-
132- headers (Method , Uri , Config , Body , QParam ) ->
133- Headers = [{" host" , Config # aws_config .guardduty_host },
134- {" content-type" , " application/json" }],
121+ headers (Method , Uri , Config , QParam ) ->
122+ Headers = [{" host" , Config # aws_config .guardduty_host }, {" content-type" , " application/json" }],
135123 Region = erlcloud_aws :aws_region_from_host (Config # aws_config .guardduty_host ),
136- erlcloud_aws :sign_v4 (Method , Uri , Config ,
137- Headers , Body , Region , " guardduty" , QParam ).
124+ erlcloud_aws :sign_v4 (Method , Uri , Config , Headers , <<>>, Region , " guardduty" , QParam ).
138125
139126default_config () -> erlcloud_aws :default_config ().
0 commit comments