NomadClient.RequestBuilder (nomad_client v0.12.4)
Helper functions for building Tesla requests
Link to this section Summary
Functions
Add optional parameters to the request
Add optional parameters to the request
Handle the response for a Tesla request
Due to a bug in httpc, POST, PATCH and PUT requests will fail, if the body is empty
Specify the request method when building a request
Specify the request method when building a request
Link to this section Functions
add_optional_params(request, definitions, list)
Specs
Add optional parameters to the request
Parameters
- request (Map) - Collected request options
- definitions (Map) - Map of parameter name to parameter location.
- options (KeywordList) - The provided optional parameters
Returns
Map
add_param(request, location, key, value)
Specs
Add optional parameters to the request
Parameters
- request (Map) - Collected request options
- location (atom) - Where to put the parameter
- key (atom) - The name of the parameter
- value (any) - The value of the parameter
Returns
Map
decode(env, struct)
Specs
decode(Tesla.Env.t() | term(), false | struct() | [struct()]) :: {:ok, struct()} | {:ok, Tesla.Env.t()} | {:error, any()}
Handle the response for a Tesla request
Parameters
- arg1 (Tesla.Env.t | term) - The response object
- arg2 (:false | struct | [struct]) - The shape of the struct to deserialize into
Returns
on success {:error, term} on failure
ensure_body(request)
Specs
Due to a bug in httpc, POST, PATCH and PUT requests will fail, if the body is empty
This function will ensure, that the body param is always set
Parameters
- request (Map) - Collected request options
Returns
Map
evaluate_response(error, mapping)
method(request, m)
Specs
Specify the request method when building a request
Parameters
- request (Map) - Collected request options
- m (atom) - Request method
Returns
Map
resolve_mapping(env, mapping, default \\ nil)
url(request, u)
Specs
Specify the request method when building a request
Parameters
- request (Map) - Collected request options
- u (String) - Request URL
Returns
Map