ex_victor_ops v0.4.1 ExVictorOps.Api
Provides a basic HTTP client for the VictorOps API by wrapping HTTPotion
.
Examples
Requests are made by calling the method for the request passing in the path to the API resource:
ExVictorOps.Api.get(“team/support/oncall/schedule”) %HTTPotion.Response({…})
Summary
Functions
A shortcut for request(:delete, url, options)
A shortcut for request!(:delete, url, options)
A shortcut for request(:get, url, options)
A shortcut for request!(:get, url, options)
A shortcut for request(:head, url, options)
A shortcut for request!(:head, url, options)
A shortcut for request(:options, url, options)
A shortcut for request!(:options, url, options)
A shortcut for request(:patch, url, options)
A shortcut for request!(:patch, url, options)
A shortcut for request(:post, url, options)
A shortcut for request!(:post, url, options)
Adds the VictorOps headers to a request
Set the URL to perform HTTP request against
A shortcut for request(:put, url, options)
A shortcut for request!(:put, url, options)
Sends an HTTP request
Deprecated form of request
; body and headers are now options, see request/3
Like request
, but raises HTTPotion.HTTPError
if failed
Deprecated form of request
with the direct
option; body and headers are now options, see request/3
Starts a linked worker process for use with the direct
option
Starts a worker process for use with the direct
option
Ensures that HTTPotion and its dependencies are started
Stops a worker process started with spawn_worker_process/2
or spawn_link_worker_process/2
Functions
Adds the VictorOps headers to a request.
Examples
iex> ExVictorOps.Api.process_request_headers %{}
%{"User-Agent": "ex-victor-ops",
"X-VO-Api-Id": "foobar",
"X-VO-Api-Key": "helloworld"}
Set the URL to perform HTTP request against.
Examples
iex> ExVictorOps.Api.process_url "on-call"
"https://api.victorops.com/api-public/v1/on-call"
request(atom, String.t, [{atom, any}]) :: %HTTPotion.Response{body: term, headers: term, status_code: term} | %HTTPotion.AsyncResponse{id: term} | %HTTPotion.ErrorResponse{message: term}
Sends an HTTP request.
Args:
method
- HTTP method, atom (:get, :head, :post, :put, :delete, etc.)url
- URL, binary string or char listoptions
- orddict of options
Options:
body
- request body, binary string or char listheaders
- HTTP headers, orddict (eg.["Accept": "application/json"]
)timeout
- timeout in ms, integerbasic_auth
- basic auth credentials (eg.{"user", "password"}
)stream_to
- if you want to make an async request, the pid of the processdirect
- if you want to use ibrowse’s direct feature, the pid ofthe worker spawned by [`spawn_worker_process/2`](#spawn_worker_process/2) or [`spawn_link_worker_process/2`](#spawn_link_worker_process/2)
follow_redirects
- if true and a response is a redirect, header[:Location] is taken for the next request
Returns HTTPotion.Response
or HTTPotion.AsyncResponse
if successful.
Returns HTTPotion.ErrorResponse
if failed.
Deprecated form of request
; body and headers are now options, see request/3
.
request!(atom, String.t, [{atom, any}]) :: %HTTPotion.Response{body: term, headers: term, status_code: term} | %HTTPotion.AsyncResponse{id: term}
Like request
, but raises HTTPotion.HTTPError
if failed.
Deprecated form of request
with the direct
option; body and headers are now options, see request/3
.
Starts a linked worker process for use with the direct
option.
Stops a worker process started with spawn_worker_process/2
or spawn_link_worker_process/2
.