ex_gecko v0.0.3 ExGecko.Api
API interface to communicate with geckoboard’s api
Todo: refactor code so that we can move auth part to single place
Summary
Functions
Appends data to an existing dataset. If the dataset contains a unique id field, then any fields with the same uniqueId will be updated
Add header with username and also the user agent
Builds URL based on the resource, id and parameters
Wrapper for DELETE requests
Issues a DELETE request to the given url
Issues a DELETE request to the given url, raising an exception in case of failure
Issues a GET request to the given url
Issues a GET request to the given url, raising an exception in case of failure
Issues a HEAD request to the given url
Issues a HEAD request to the given url, raising an exception in case of failure
Examples
Issues an OPTIONS request to the given url
Issues a OPTIONS request to the given url, raising an exception in case of failure
Issues a PATCH request to the given url
Issues a PATCH request to the given url, raising an exception in case of failure
Convenience function to manage datasets. Follows similar syntax as this https://developer-beta.geckoboard.com/nodejs/
Issues a POST request to the given url
Issues a POST request to the given url, raising an exception in case of failure
Wrapper for POST requests
Creating URL based on url from config and resources paths
Push API to Geckoboard, which is a POST with this data format
Monitor format expected from geckoboard
Issues a PUT request to the given url
Issues a PUT request to the given url, raising an exception in case of failure
Issues an HTTP request with the given method to the given url
Issues an HTTP request with the given method to the given url, raising an exception in case of failure
Starts HTTPoison and its dependencies
Wrapper for PUT requests
Types
Functions
Specs
append(String.t, map) :: ExGecko.response
Appends data to an existing dataset. If the dataset contains a unique id field, then any fields with the same uniqueId will be updated.
Example
Builds URL based on the resource, id and parameters
Specs
delete(String.t) :: Brighterx.response
Wrapper for DELETE requests
Examples
- ExGecko.Api.delete(“mydataset”)
Specs
Issues a DELETE request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
Issues a DELETE request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
Specs
Issues a GET request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
Issues a GET request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
Specs
Issues a HEAD request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
Issues a HEAD request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
Specs
limit_data(list) :: list
## Examples
iex> Mix.Tasks.LoadData.limit_data(Enum.to_list(1..500)) === Enum.to_list(101..500)
true
Specs
Issues an OPTIONS request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
Issues a OPTIONS request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
Specs
Issues a PATCH request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
Issues a PATCH request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
Specs
ping :: ExGecko.response
Convenience function to manage datasets. Follows similar syntax as this https://developer-beta.geckoboard.com/nodejs/
Examples
- ExGecko.Api.find_or_create - finds or creates the dataset
- ExGecko.Api.put - replaces all data in the dataset
- ExGecko.Api.delete - deletes the dataset and data therein
Specs
Issues a POST request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
Issues a POST request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
Specs
post_request(String.t, map, boolean) :: ExGecko.response
Wrapper for POST requests
Examples
Creating URL based on url from config and resources paths
Specs
push(String.t, map) :: ExGecko.response
Push API to Geckoboard, which is a POST with this data format
{ “api_key”: “222f66ab58130a8ece8ccd7be57f12e2”, “data”: {
"item": [
{ "text": "Visitors", "value": 4223 },
{ "text": "", "value": 238 }
]
} }
Monitor format expected from geckoboard
{ “status”: “Up”, “downTime”: “9 days ago”, “responseTime”: “593 ms” }
{ “status”: “Down”, “downTime”: “2 days ago”, “responseTime”: “593 ms” }
Specs
Issues a PUT request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
Issues a PUT request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
Specs
Issues an HTTP request with the given method to the given url.
This function is usually used indirectly by get/3
, post/4
, put/4
, etc
Args:
method
- HTTP method as an atom (:get
,:head
,:post
,:put
,:delete
, etc.)url
- target url as a binary string or char listbody
- request body. See more belowheaders
- HTTP headers as an orddict (e.g.,[{"Accept", "application/json"}]
)options
- Keyword list of options
Body:
- binary, char list or an iolist
{:form, [{K, V}, ...]}
- send a form url encoded{:file, "/path/to/file"}
- send a file
Options:
:timeout
- timeout to establish a connection, in milliseconds. Default is 8000:recv_timeout
- timeout used when receiving a connection. Default is 5000:stream_to
- a PID to stream the response to:proxy
- a proxy to be used for the request; it can be a regular url or a{Host, Proxy}
tuple:proxy_auth
- proxy authentication{User, Password}
tuple:ssl
- SSL options supported by thessl
erlang module:follow_redirect
- a boolean that causes redirects to be followed:max_redirect
- an integer denoting the maximum number of redirects to follow:params
- an enumerable consisting of two-item tuples that will be appended to the url as query string parameters
Timeouts can be an integer or :infinity
This function returns {:ok, response}
or {:ok, async_response}
if the
request is successful, {:error, reason}
otherwise.
Examples
request(:post, "https://my.website.com", "{\"foo\": 3}", [{"Accept", "application/json"}])
Issues an HTTP request with the given method to the given url, raising an exception in case of failure.
request!/5
works exactly like request/5
but it returns just the
response in case of a successful request, raising an exception in case the
request fails.
Specs
update(String.t, map, boolean) :: ExGecko.response
Wrapper for PUT requests
Examples